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

multiprocessing model for mantis #27

Open
mattersoflight opened this issue Apr 26, 2023 · 2 comments
Open

multiprocessing model for mantis #27

mattersoflight opened this issue Apr 26, 2023 · 2 comments
Labels
analysis Software development needed for data analysis meta question Further information is requested

Comments

@mattersoflight
Copy link
Collaborator

mattersoflight commented Apr 26, 2023

We need a few acquisition (label-free and light-sheet) and analysis (viewer) processes to run in parallel.
In the future, it may be useful to have other features (FOV scoring, auto-alignment) run in their separate threads.

We would want a multiprocessing library that provides an intuitive Pythonic implementation of synchronization primitives (semaphores and mutex) to facilitate concurrent execution when we need it.

@ieivanov What is the current multiprocessing model for mantis and should the model be revised? You mentioned that pycro-manager spins up a process for every hook function - what library does pycro-manager use?

Qt has support for semaphores and mutex.

@ziw-liu can you point to an example or two of how recOrder uses qt threads for synchronization?

@mattersoflight mattersoflight added question Further information is requested analysis Software development needed for data analysis meta labels Apr 26, 2023
@ziw-liu
Copy link
Contributor

ziw-liu commented Apr 26, 2023

@ziw-liu can you point to an example or two of how recOrder uses qt threads for synchronization?

When recOrder performs calibration, the real-time progress from the calibration worker thread is emitted to a Qt signal slot in the main thread (napari event loop):

https://github.com/mehta-lab/recOrder/blob/802cc62cac537749ab5dce5535d7c0a18137f819/recOrder/plugin/main_widget.py#L1852-L1853

@ieivanov
Copy link
Collaborator

I actually don't think there is a large outstanding need for multiprocessing in the mantis acquisition engine.

Multiprocessing is most useful when the individual processes perform independent tasks in parallel. Inter-process communication is possible, but I think not very straightforward.

The LS and LF acquisitions already run in parallel on separate processes by virtue of running on two separate MM instances.

FOV scoring and autofocus would need to run on the same thread as the acquisition engine - the acquisition would need to wait until these are finished, so I think there is no need to spin up another process. If autofocus needs to perform heaving math before returning, we could consider putting it on another process while the acquisition moves on to the next position, but that would complicate the acquisition flow quite a bit.

A napari viewer is a good example of where multiprocessing is helpful. The acq engine can keep on acquiring data while it is being viewed in another process. I am planning to implement that using the subprocess module. That is still to be worked out and tested.

This was referenced May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analysis Software development needed for data analysis meta question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants