Autofocus + Multiposition
Request from @SJShep.
What would it take for us to create a feature sequence where we perform an autofocus measurement for every position in the multi-position table? We would...
- move to the first position in the multi-position table (e.g., pos_0)
- move to z[0]
- measure the autofocus
- set the
F_Startposition - move to z[-1],
- measure the autofocus,
- set the
F_Endposition. - Image the full z-stack.
- move to the second position in the multi-position table (e.g., pos_0)
- ...
To make it even better, we could evaluate if the tissue is present or not before running the autofocus routine...
- move to the first position in the multi-position table (e.g., pos_0)
- move to z[0]
- evaluate if tissue is present.
- if tissue is present
- measure the autofocus
- set the
F_Startposition - move to z[-1],
- evaluate if tissue is present.
- if tissue is present
- measure the autofocus,
- set the
F_Endposition.
- if tissue is not present
- pass ( no need to run autofocus or set focus position )
- Image the full z-stack
- move to the second position in the multi-position table (e.g., pos_0)
- ...
@dpshepherd @SJShep
According to @annie-xd-wang, this feature sequence will get you most of the way there. It does not check for the presence of tissue, but does everything else.
[{"name": PrepareNextChannel,},({"name": MoveToNextPositionInMultiPositionTable,"args": (None,None,None,),},{"name": CalculateFocusRange,},{"name": ZStackAcquisition,"args": (True,True,"z-stack",),},{"name": WaitToContinue,},{"name": LoopByCount,"args": ("experiment.MicroscopeState.multiposition_count",),},),]
This one ties it all together. The first popup window shows the overall logic, but does not include what happens within the DetectTissueAndReturn feature.
If you click on
DetectTissueAndReturn, it will show the logic within it. Here, it is set to look at 2 planes, which is the same as the first and last z-positions. You can add your own function to do the segmentation. If it is None it is just an Otsu, but this is done on a per-image basis without knowledge of brightness history. It is thus not the best thing possible.
For Percentage, 1 = 100%. This is the threshold amount of the image that needs to be occupied by tissue in order to return True. If True, it then runs the CalculateFocusRange, acquires a ZStackAcquisition, and then WaitToContinue which enables large stage movements without camera timeouts.
Thank you @annie-xd-wang @AdvancedImagingUTSW, I will try implementing on our end and let you know how it goes.
@SJShep & @dpshepherd - Any luck?
Pending update, used as an opportunity to place the example in the documentation here. If anything is not exactly correct, we will have to update it accordingly.