Standard Autofocus Software


I have a sample with significant topography that I am scanning using the OFM software. I have been trying to modify the autofocus extension to be better at autofocussing on such a sample but I am having trouble. As I understand, in the standard autofocus initially the focus moves up (or down?) a certain amount then the z axis is moved in increments of 10/30/100 steps depending whether coarse/medium/fine is chosen. I am trying to find a way to modify the amount of steps the initial movement is & subsequently how many steps (as in increments) the autofocus performs back down before deciding which image is sharpest. I have looked at the extension code but can’t figure out how to alter these parameters. Any help would be appreciated!

Hi @Ryan the step size and range are set when you call the autofocus method; if you’re using the web interface, the parameters are baked in to the code that calls “coarse/medium/fine”. Currently the only way to customise what happens when you click the button would be to modify the web app, but it’s easier to customise if you are using e.g the python client. How would you like to do it?

If you direct me to the section of code that determines the step size and range in the web app I should be able to play around with the parameters. I think having it baked into the code is easier as I perform numerous scans per day.


Sure - I am guessing you want to change the autofocus parameters used in the scan, rather than just when you click the autofocus buttons? If so, the relevant file is openflexure_microscope/api/static/src/components/tabContentComponents/captureComponents/paneCapture.vue line 379, that defines the step size for autofocus. Note that “fast” autofocus is a special case, it defines the total range instead, as it doesn’t move in discrete steps.

If you want to play with the parameters without having to modify the web app every time, open a web browser and enter your microscope’s address with port 5000 and /api/v2/docs/swagger-ui, i.e.


If you locate the “autofocus” action, it should let you “try it out” with different parameters until you find something that works nicely for you.

The readme should be up to date with how to compile and run the web app, but do shout if it doesn’t work for you!