Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic tissue surface detection #166

Open
campagnola opened this issue Sep 27, 2023 · 16 comments · Fixed by #188
Open

Automatic tissue surface detection #166

campagnola opened this issue Sep 27, 2023 · 16 comments · Fixed by #188

Comments

@campagnola
Copy link
Contributor

campagnola commented Sep 27, 2023

Automatically determine z-location of tissue surface

@outofculture
Copy link
Collaborator

New button on the Camera window, "Find Surface" (right under the "Set Surface" button). This will scan ±200µm from the currently-set surface and find the most in-focus frame to be the new surface. Let me know if it works at all, @jessicatrnh - my mock hardware was not a very good test bed for this feature.

@outofculture
Copy link
Collaborator

This should be testable now, with the z-stack code falling back to the slower behavior, though it won't be very fast.

@jessicatrnh
Copy link
Contributor

To test, I preset the surface ~130um below where I would normally set it by eye.

When hitting "Find Surface" the function does not work initially--the video stops acquiring and produces this error

Image

Hitting the button again immediately starts the acquisition, but the objective overshoots the surface so that the start of the scanning range is ~70um above the actual surface. Consequently, this means that I have to preset the surface at least 200um below the actual surface to have this function work properly, otherwise the objective continues to move away from the slice indefinitely.

I tested this again by setting my surface ~300 um below the actual surface and the objective scanned way beyond the range of 200um with an indefinite upper range, and did not detect the clearest frame.

@jessicatrnh
Copy link
Contributor

image with traceback included

Image

@outofculture
Copy link
Collaborator

@jessicatrnh the bug in fast-z-stacks prevented this from being testable. with that fixed, you can try again.

@jessicatrnh
Copy link
Contributor

@outofculture When I try to "Find Surface" the objective moves all the way up out of the solution, then comes down to start scanning at a range about 200um above the previously set surface marker.

@outofculture
Copy link
Collaborator

maybe with the focus speed fixed, this will behave? it's worth a test. if it's still doing the extraneous movement, I'll need to dig into MP0.

@jessicatrnh
Copy link
Contributor

Find surface still starts well above previous surface marker (~200um) and scans upward very slowly. The objective does not scan in the +/-200um range from the previous surface marker.

@campagnola
Copy link
Contributor Author

We also noticed:

  • Focus doesn't stop moving after clicking find surface. It ended up about 800 μm above the surface before we stopped it by esc.
  • Focus moves very slowly. The camera was running at 20 fps and we probably only need about 5 μm accuracy here, so it should only scan about 4 seconds.

@jessicatrnh
Copy link
Contributor

The "Find Surface" function now scans the depth from +200 to -200 um with reference to the previously set surface, but does not indicate if the surface has been found; it just stops at -200 below previous surface.

@outofculture
Copy link
Collaborator

I just added a final "focus to the new surface depth" step to the button behavior. If it doesn't find a new surface, it will stay at the bottom of the scan, as before. I tested the rest of the algorithm, and it found the surface on the few test files I have, but if you run it on a slice and it doesn't find a surface, please save a ±200µm, top-down z-stack for me to test against.

@jessicatrnh
Copy link
Contributor

Scans the depth range but does not return anything for surface detection. Stack is saved in autopatch_test\2024.03.12_000\Surface_Finder_Stack

@outofculture
Copy link
Collaborator

okay, it should do more than just scan this time.

@jessicatrnh
Copy link
Contributor

jessicatrnh commented Mar 19, 2024

@outofculture So it does. The feature scans from +200 to -200 microns from the previously set surface. However, the correct surface is not detected and the surface marker is now reset to the bottom of the range.

See autopatch_test\2024.03.19_000\Surface_Finding stack for the latest stack

@outofculture
Copy link
Collaborator

and again!

@jessicatrnh
Copy link
Contributor

@outofculture This works now! behavior: scans the 400um range and resets and focuses on surface depth. Might be about -25um from where I would consider the surface to be but this is working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants