1

I'm trying to set up a microscope control script using Pycro-Manager, which is a Python wrapper for Micro-Manager:

from pycromanager import Acquisition, multi_d_acquisition_events

with Acquisition(directory=r'C:\Users\joanna\Desktop', name='z-stack') as acq:
    # Generate the events for a single z-stack
    events = multi_d_acquisition_events(z_start=0, z_end=10, z_step=0.5)
    acq.acquire(events)

For some reason, the cell doesn't execute until I terminate the kernel. What is the problem here?

I first thought that adding VAR.__exit__() at the end (as suggested here) would solve the issue, but it does not. This seems to be a problem specific to Jupyter/IPython as the same code runs fine directly from the Python interpreter, i.e. an acquisition window is opened and an image stack is acquired from the camera.

  • so you tried `acq.__exit__()` ? – Jean-François Fabre Apr 28 '21 at 07:34
  • Hi, yes, I first had `Acquisition.__exit__()` and changed it to `acq.__exit__()`, but Jupyter won't run unless I kill the kernel. Which effectively renders the package unusable (in this case) with Jupyter, since killing the kernel will unload all notebook cells. And doing everything from the Python console is really not so productive, especially if you want to plug the acquisition output directly into some data analysis scripts, generate plots etc. – joannajanssen Apr 30 '21 at 11:27
  • From the Python interpreter, the acquisition does start with or without the additional exit statement, so there seems to be some issue with either Jupyter or with how Jupyter and Pycro-Manager communicate – joannajanssen Apr 30 '21 at 11:28

0 Answers0