I’m having an issue trying to get the Stack and Scan to work as I expect it to.
I’m trying to make some z-stacked images, but whenever I click “capture” the Z stage will move off to some position instead of staying where I placed it - even having “autofocus” disabled.
I would expect the scan to start from the position I am in when I click “capture”, and then move the required steps in the Z direction. Am I missing something? Is there a reason this isn’t how it behaves?
Instead, it seems the Z stage moves up automatically at the begining of the scan for some reason - maybe to the maximum range it calculates? But the point is that it doesn’t end up where I need it.
EDIT: My current theory: At each Z stack, the stage first moves to the “end” of the stack, and then works it’s way back - so if I set 20 steps of size 50, it will first move 1000 steps up, and then work it’s way down during the capture (instead of starting at 0 and then moving up). Is this correct?
If you are taking multiple z-positions then the stack indeed does not start in the middle. I thought it started at the bottom and moved up rather than the other way round, but I have not looked at that detail. Starting in the middle would mean moving in both directions during the stack, and with backlash in the motion that might mean that the steps are not equal around the central step and even could be in the wrong height order. Moving in one direction, then even if the is a problem in backlash correction the images are all in sequence of height and step sizes are the problem at the beginning of the stack. @JohemianKnapsody has done a lot of work on an update to the stack and scan recently, he might be able to help with what the height does without autofocus.
I understand that starting from the center is not an option - what I expected was that it would start from the current position, and then step in the required direction for each capture - instead it seems to move to the end of the desired travel, and work it’s way back to the start position.
If I start from 0, tell it to move 3 steps of 100, my expectation was that it will capture images at 0, 100, 200, and then return to 0 - instead, it seems to be doing 200, 100, 0 - which makes sense, spares you the trip back.
It’s not really a problem, but it was unexpected and it’s not explained in the use guide for the stack and scan that this is how the Z motion happens - it might be worth mentioning, if it’s the case
The stack and scan was driven by medical projects with high resolution oil immersion objectives. Autofocus is essential in that case and so what happens without autofocus is not at the front of the mind. I would have thought that starting from 0 one would want -100, 0, 100?
I’ve gone through the software, and z stacking tries to centre at your current position. So if you move to z = 0, and select 3 steps of 100 steps, it moves to -100, then captures at -100, 0, +100 (this is the same as if you autofocus first, but @r.w.bowman we could add something to the default scanning code that undershoots the peak by half the stack height? Saves a small amount of time, reduces backlash and would be much better if someone has negative dz)
If you’re using a higher power objective and small step sizes, I can believe this would misalign your stack quite badly, especially if you’re trying to start from the lowest point. In the short term, are you comfortable using Python to control your microscope, or have you tried out OpenFlexure Blockly to do a custom stack? If you’re happy with either of those, I can share some code to do the z-stack as you’d expect.
Long term, maybe this is another scan option we could add to the software
Hope this makes sense, thanks for flagging it with us
Yes, I’d definitely be comfortable using Python to control the scope as well as using Blockly (I had never heard about Blockly before, but it seems pretty user friendly!), so I’d appreciate if you could share the code with me.
It should be fairly straight forward to set up according to the README, I’ve not got a microscope with me today, but after setting everything up and moving to the area you’re interested in, the two functions you’ll want are microscope.capture_image_to_disk() microscope.move_rel([0,0,z_distance])
capture_image_to_disk takes a few options, for example if you wanted to rename the images, make them higher resolution, etc. You can also skip using Connect to download the images to your computer (if that’s what you’re doing), with microscope.download_from_id
Hope this makes sense, if not please give us a shout
Ah, Python control makes it so much easier to use.
Now I can finally capture the stacks as I need.
For future reference: To capture high-res images using python use the parameter {“use_video_port”: False} (i.e. microscope.capture_image_to_disk({"use_video_port": False})