-
Notifications
You must be signed in to change notification settings - Fork 10
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
Unify algorithms for on-the-fly analysis and hardware control in a repo to facilitate smart microscopy
#168
Comments
I'm all for reusing the infra whenever possible so we don't do the packaging job again if we don't have to. One problem I can think of is dependency management when accumulating scientific/CV python libraries (especially those with compiled extensions like CuPy and OpenCV). This can be mitigated with cautious planning and optional dependencies though. |
I am also supportive of this idea. It will be helpful for everyone to have these algorithms in a common repo with a common structure, such that they can be easily reused. I think we'll need to define which algorithms belong here and which don't. I think we should strive for these algorithms to be independent of the underlying microscope acquisition engine and control software. For example, autofocus algorithms which take a series of images and return the correct focal plane would be a good fit here. This algorithm will be independent of how the images are acquired and will not be responsible for moving the z stage to the correct focal plane - this will be done by the microscope control software based on the output of the autofocus algorithm. Let's explicitly list out algorithms that may fit here, with their input and output, such that we can as a group decide what belongs and what doesn't. Based on the discussion so far:
Algorithms I'm less confident that they belong here:
Anything other algorithms you think may or may not belong here? We're looking for your input. If we house these algorithms in |
I am also in support of this idea, and agree with what Ivan has listed above. Sample position interpolation I think would be applicable here. Centroid finding is just a helper function for autotracking. We have a few helper functions written that are different methods of performing the tracking. I'm not familiar with the opencv version, @ieivanov do you know if it can do 3D? Or only 2D? |
I really like the idea. I think packing these algorithms into a library, and a single conda package that includes our other libraries (e.g. iohub) would be very useful because installing python packages is very complicated, especially on Windows. IMO, the functions should have a somewhat standardized API and they could be implemented such that it works both with cupy and numpy without depending on cupy. How often is opencv used? |
Thank you all for your input here and in offline conversations. I like that there is a general agreement on such collection of algorithm implementations. Here, I would like to summarize the main points everyone seems to agree on so far (if not, please comment below):
I am curious about how often OpenCV is used, too. I have similar experience to @JoOkuma 's experience. |
It's exciting that we all agree on this. I mentioned OpenCV as an example of standard image analysis pipeline which some of the algorithms here may depend on. I'll let @talonchandler @edyoshikun and @rachel-banks say what dependencies the algorithms they've written may bring along to |
I'm in favor! I think it's a good decision to make these No major dependencies on my end beyond |
I used OpenCV as an example not because I am in favor of including it, but because I know it will cause problems and should be avoided if possible among other potentially problematic dependencies. |
We use opencv only with the template matching method for autotracking, because it is much faster than the skimage version. If someone, (@JoOkuma maybe?) has a suggestion for another alternative, I'm happy to avoid it.
|
@rachel-banks I don't know any alternatives. From a quick search, it seems they use the same algorithm (depending on what mode you're using on OpenCV). |
This is exciting! I think the algorithms summarized above cover a lot of "decisions" that need to be made during high throughput imaging, imaging developing embryos, and maintaining focus over long time series. Another set of algorithms we could unify here is registration algorithms. The methods to compute registration (e.g., phase correlation, template matching) are currently used across microscopes and can benefit from collaborative algorithmic/numerical optimizations. I think that our near term needs are:
|
smart microscopy
smart microscopy
I strongly vote to make a separate repo/module to collect generic analysis algorithms. We should NOT mix generic analysis stuff with hardware control, unless a particular part of the hardware control code requires some very specific analysis. |
@rafa-gomez-s and I were talking about this github issue. I agree with his vote that a small analysis library will be easier to build, manage, and reuse across different acquisition repos. |
@royerloic @JoOkuma Loic and I discussed a lean library that enables online analysis (PSF estimation and other tasks discussed above) that acquisition engines of different microscopes can reuse. In this thread, we discussed whether such algorithms fit as a module within coPylot. At that time, the consensus was that coPylot should focus on hardware device adapters. Two ideas for what to do:
At the operational level, I've observed that chunking related code in a single repo promotes code reuse and regular review of code by peers. So, I naturally lean towards chunking. But, I think the number of methods in an online analysis repo is large enough that splitting also makes sense. @ieivanov , @edyoshikun, @talonchandler , @JoOkuma, @royerloic your thoughts and vote? |
I vote for creating a new repo dedicated to the analysis code - splitting. It's definitely a lot cleaner and makes the code more modular and reusable in different scenarios. |
I'm in favor of splitting, but some thought should be put into this. For example, a lot of image processing functionality already exists in What are the good practices we should follow? Especially regarding the API, so |
I think both chunking and splitting can be used for the same purpose. For the chunking, similar to napari one could do I lean towards the idea of splitting as @JoOkuma mentions based on the dependencies. I can also see us using optional dependencies depending on what sort of analysis we are doing and the packages required (i.e Viscy(torch), Cellpose (torch), Stardist(tensoflow), etc) I mention these because these are the 'bigger' imports and the ones that can cause the most issues in my experience. As for the API, I can see us making at least these kinds of functions:
|
@JoOkuma I agree that good ergonomics is a key to the reuse of the library and circular dependencies are to be avoided! I like how @edyoshikun structured different types of methods. It is intuitive to me that algorithms are all part of @ieivanov @talonchandler your thoughts and votes? |
I see a lot of value in an It might be useful to decide together which GPU library |
@talonchandler, yes, being a torch first is a concern for us. We extensively use I think with additional functionality, we could reduce the overhead of managing However, it will require some extra care when implementing additional functionalities. In an ideal world, |
One important thing we should consider is how much time should be put into this. Having different compatible libraries without trying to have a single library for each purpose can be an alternative. |
Currently, the different teams at Biohub have created multiple tools and image-based hardware tunning to do the same task. This creates code duplication and inefficient project development as there is no need to completely reinvent the wheel. One suggestion that we proposed during our last copylot meeting was to find a repo/place where we can unify these pieces of code that can be easily discovered (i.e autofocus, autotracking, autoexposure, centroid detection, plate map position generator, etc).
These algorithms should be simple, perform a single task or functionality, and break down complex and repetitive tasks such that we can integrate these easily into other projects. For example, one algorithm is finding the focused slice given a 3D volume. and dragonfly's plate interpolation here which can take a 3D array and return a suggestion or take a list of positions and return a plane estimate respectively. In compmicro, we would like to use algorithms like autoexposure and autofocus by integrating this through the pycromanger hook functions, which basically allow on-the-fly processing and tunning of the microscope hardware.
A proposed solution:
copylot/algorithms
) used among most groups in the Biohub. This will hopefully surface these pieces of code that are unknown to other groups and reduce code duplication. Additionally, keeping them in one repo facilitates access, code-review and adds momentum for other people to contribute.This should also be discussed on the SIGs to see where do we see the best fit.
What are your thoughts?
@i-jey @talonchandler @ieivanov @rachel-banks @ziw-liu @AhmetCanSolak @YangLiujames @keithchev @JoOkuma @gregcourville
Please tag anyone else who might find this suggestion useful.
The text was updated successfully, but these errors were encountered: