MTF50 through-focus

  • 29 June 2020
  • 4 replies
  • 344 views

There is a 'Through-focus MTF feature'. Is there a way to extract MTF50 through focus instead of modulation at a certain frequency through focus?


4 replies

Userlevel 6
Badge +2

Hi Anton,


The Through-Focus MTF plots do not provide a way to search for the spatial frequency which provides MTF50. Although, you could write a ZPL to do that search for you. For example, you could ask a ZPL to perform the following actions:



  1. Set the field and wavelength of interest

  2. Create a loop to cycle through multiple spatial frequencies

  3. Store the tangential and sagittal response to an array

  4. Use an IF statement to check for MTF50. If found, store the spatial frequency and focus shift data to a different array


I have set up a ZPL macro that will perform actions 1-3 for you. This macro will cycle through spatial frequency 0 to 70 and output the tangential and sagittal response for fiel = 1, wavelength = 1. You can add an IF statement before line 47 to run a check for MTF50. Here is what I have so far:


 


! Set up the location of the configuration file

lensFile$ = $FILEPATH()

fileNameLength = SLEN(lensFile$)

fileName$ = $LEFTSTRING(lensFile$, fileNameLength - 3)

cfgfile$ = fileName$ + 'CFG'



! Set up the Through Focus Analysis



field = 1        # Declare the field of interest

wave = 1        # Declare the wavelength of interest



MODIFYSETTINGS cfgfile$, TFM_FIELD, field        # Change the settings to use the field of interest

MODIFYSETTINGS cfgfile$, TFM_WAVE, wave            # Change the settings to use the wavelength of interest



numDataPoints = 201            # Each field will have 201 data points in the output

DECLARE tangent, double, 1, numDataPoints    # Setup array to hold Tangential data

DECLARE sagit, double, 1, numDataPoints        # Setup array to hold Sagittal data



! Extract data and write it to the arrays

! Cycle through multiple spatial frequency values



FOR freq, 0, 70, 5



    PRINT 'Spatial Frequency: ', freq

    MODIFYSETTINGS cfgfile$, TFM_FREQ, freq        # Set new spatial frequency



    A$ = $TEMPFILENAME()

    GETTEXTFILE A$, Tfm            # Extract Through Focus data

    OPEN A$                        # Open Through Focus data file and skip to numeric data

    FOR i, 1, 14, 1

        READSTRING B$

    NEXT

    

    FOR i, 1, numDataPoints, 1                # Write the data to the arrays

        READNEXT shift, tanVal, sagVal

        tangent(i) = tanVal

        sagit(i) = sagVal

        FORMAT 1.6

        PRINT tangent(i), ' ', sagit(i)        # Print the data for comparison

    NEXT

    

    DELETEFILE A$

    CLOSE

    

    PRINT

    

NEXT

 


Each of the keywords I used are described in the Help System file 'The Programming Tab > About the ZPL > KEYWORDS (about the zpl).' Will this work for you? Let me know if you have any questions!


Best,


Allie

Hi Allie,


 


Thank you for the prompt response!


I think this is all I need. I will give it a try and post here if I have more questions. 


Thank you


Anton

Hi Allie,


I am trying to run your code without modifications ans I am getting this error:


'ERROR in MODIFYSETTINGS: Cannot open settings file.

MODIFYSETTINGS CFGFILE$ , HFT_FIELD , FIELD'


Any chance you know how to fix this?


Thank you 


Anton

Userlevel 6
Badge +2

Hi Anton,


This usually crops up when the wrong configuration file is provided. In the code I attached, the configuration file I used was .cfg where  will match the title of your ZMX file. This file may not exist for you. In that case, you should use this line instead:


data$ = $DATAPATH()

cfgfile$ = data$ + '\Configs\TFM.CFG'


I have provided some guidance on identifying and using configuration files here:



Let me know if you have any other questions!


Best,


Allie

Reply