SWC-Advanced-Microscopy / measurePSF

Measure PSF FWHM along different axes
GNU Lesser General Public License v3.0
24 stars 5 forks source link

Create variable input prompts in record.PSF #68

Closed iwhiteley closed 4 months ago

iwhiteley commented 4 months ago

Bring to the same format at the uniform_slide and lens_paper functions

raacampbell commented 4 months ago

Current situation

The functions mpsf.record.uniform_slide and mpsf.record.lens_paper have two modes with which they can be called. The first is using input arguments at the command line to specify laser power at the sample in mW and laser wavelength in nm. These two values can be supplied in either order. This means the user does not have to memorise the order, but calling functions this way is highly unusual. e.g. the following will both have the correct effect:

>> mpsf.record.lens_paper(10,920)
>> mpsf.record.lens_paper(920,10)

If the user supplies no input arguments, they are instead prompted to enter the values interactively. For both functions this process is handled by mpsf.record.parsePowerAndWavelength.

mpsf.record.PSF has two required input arguments (depth to image and step size, both in microns) and two optional ones ( wavelength in nm and power in mW). If the optional input arguments are supplied, the information is added to the file name. Otherwise it is silently not added to the file name.

General problem

Two positional input arguments are easy enough for users to learn, but four is a bit much unless the code is run very often. Therefore something should be done to make mpsf.record.PSF more user friendly.

Potential solutions

We can not simply have four interactive prompts for mpsf.record.PSF because this is really annoying to run repeatedly: it's 3 key presses for no interactive prompts vs up to 13 with interactive prompts. We must also retain a reasonable option that allows the user to specify everything as input arguments. Potential solutions:

1. Last two input arguments handled like mpsf.record.lens_paper

>>> mpsf.record.PSF(20, 0.25, 920, 10)
>>> mpsf.record.PSF(20, 0.25, 10, 920)

or

>>> mpsf.record.PSF(20, 0.25)
Please enter laser wavelength (nm): 920
Please enter laser power at the sample (mW): 10 

The above is the quick to implement and it's reasonable for the user to learn two positional input arguments, but it remains unusual.

2. Replace everything with parameter value pairs plus interactive

Examples

>>> mpsf.record.PSF('depth', 20, 'stepsize', 0.25)
Please enter laser wavelength (nm): 920
Please enter laser power at the sample (mW): 10 
>>> mpsf.record.PSF
Please enter depth to image in microns: 20
Please enter step size in microns: 0.25
Please enter laser wavelength (nm): 920
Please enter laser power at the sample (mW): 10 
>>> mpsf.record.PSF('wavelength', 920, 'power', 10)
Please enter depth to image in microns: 20
Please enter step size in microns: 0.25

The above is the most flexible, although we ought to also then modify all the record functions. The commands become longer because of the need to enter the parameters, although parameters can be shortened. e.g. the following two do the same thing:

>>> mpsf.record.PSF('depth', 20, 'stepsize', 0.25, 'wavelength', 920, 'power', 10)
>>> mpsf.record.PSF('depth', 20, 'step', 0.25, 'wav', 920, 'pow', 10)

The step step size argument in particular can set to a default value unless over-ridden. This is currently the case: the default is 0.25 microns.

  1. Leave as is but add interactive option if command is run without input args For example
    >>> mpsf.record.PSF(20, 0.25, 10, 920)
>>> mpsf.record.PSF
Please enter depth to image in microns: 20
Please enter step size in microns: 0.25
Please enter laser wavelength (nm): 920
Please enter laser power at the sample (mW): 10 

This does not solve the fundamental problem, though, and the user still needs to learn the argument order if they want top avoid entering lots of text each time the command is run.

Currently I favour option 2, I think, as It makes everything more idiomatic.

raacampbell commented 4 months ago

Done: f626f013ad46e326a2272ab2dd31cd5e424868ce