I am trying to use autofocus to focus in the z direction for an MDA acquisition (multiple timepoints, channels, slices). Looking at the code for OughtaFocus, it appears that the top z slice +/- the user-given search range is used. Then, based on the sharpest image, the z position is changed. However, for the next acquisition, that new z value is not used for the top, middle, or bottom of the stack. The z position in the metadata is the same set of values for top/bottom/step for all time points. It seems that after autofocus, the z moves back to the top of the stack for the next acquisition. In the Acquisition engine, lines 232-243 (linked below), autofocus is run and there is a hook to return to the top of the z range for the next timepoint.
Main question: Why is the z position found from autofocus not used to adjust the z range in an MDA acquisition, and how can this be done?
I can change the code for the oughtafocus plugin-- I have changed the search range from top z +/- half the search range to middle z +/- half the search range, and what I want to do is use the newly focused z as the middle of the z stack at the next time point, and use that as the middle of the search range for the next round of autofocus. This seems intuitive to me, and I want to implement it without interfering with the acquisition.