henrypinkard / pygellan Goto Github PK
View Code? Open in Web Editor NEW[DEPREACATED] Python interface for data-driven microscopy with Micro-manager/Micro-Magellan
License: BSD 3-Clause "New" or "Revised" License
[DEPREACATED] Python interface for data-driven microscopy with Micro-manager/Micro-Magellan
License: BSD 3-Clause "New" or "Revised" License
It seems necessary for ensuring you're working with a fresh slate.
Thanks
Hi Henry,
Thanks for the GUI access. It seems very straightforward.
I'd like to be able to create Magellan grids using predefined positions. For example, new_grid_1 = create_magellan_grid(xPos, yPos, nRows, nColumns)
This will be essential for the randomized ROI acquisition interface I'm making.
Thanks for the help!
Kyle
Create a python generator function that produces acquisition events according some syntax (e.g. {'z_pos': 123.45, 'time_index': 0}) which then drive acquisition on Java side and hardware sequenced where applicable. This would enable a lot of flexibility in driving acquisitions.
Maybe could do this push/pull ZMQ sockets
There's a memory leak related to the magellan image windows. The image windows and associated objects never get garbage collected, and as a result, leak a few MB of memory with each acquisition. Since the Magellan window is one big hack on top of micro-manager which is itself on top of imageJ, I have no idea how to fix this.
Hi Henry,
I can elaborate more on this issue next week, but wanted you to be aware that there is some weird channel acquisition bug on the latest nightly build of Magellan. The channels don't stay consistent as far as the ordering goes; ch1, ch2, ch3 becomes ch2, ch3, ch1, or something. I wasn't able to find a pattern as I was trying to run an expt. Will get you more details soon.
I'll see you in person for the fix?
Kyle
This would require:
Move ZMQServer
to micro-manager so that it is on a master ClassLoader
that can access plugins. (org.micromanager.internal.zmq
)
Add server startup to "tools--options"and start ZMQServer from appropriate place in micro-manager if enabled @nicost
Add mechanism exposing Plugin classes as MMJavaClasses
. Maybe do this by exposing everything, maybe do this by passing in an argument of the full javaclasspath as a string argument to MagellanBridge
(e.g bridge = MagellanBridge('org.micromanager.plugins.MM2Python')
). Check to see if any performance issues passing all available plugins
Make sure Java objects can be passed backed into Java functions by their hashes
Add convenience flag to not translate function names from camelCase to snake_case
Add to documentation/examples for how to access plugin
Latest master on both micromanager (nico's branch) and pygellan.
Running
from pygellan.acquire import MagellanBridge
import os
#establish communication with Magellan
bridge = MagellanBridge()
#get object representing micro-magellan API
magellan = bridge.get_magellan()
acquistions = magellan.get_acquisitions()
#grab the first acquisition in the list
acq = acquistions[0]
acq_settings = acq.get_acquisition_settings()
#channel settings
acq_settings.set_channel_group('Channel')
Hi Henry,
I'd like to be able to build grids from Python and assign them to Magellan for the acquisition.
I will need to set stepsize, z start, and z end for each grid.
Thanks,
Kyle
Hello,
I was recently pointed towards Pygellan as some way to control acquisitions with Micro Manager externally by Python.
After installing Pygellan and starting Micro Manager (2.0y nightly), I first tried some simple things as outlined in the examples - setting some acquisition parameters, etc., which worked fine.
However, when I try to use the Micro-magellan acquisitions, something goes wrong.
Using magellan = bridge.get_magellan()
after
from pygellan.acquire import PygellanBridge
bridge = PygellanBridge()
will result in an error:
Exception: Couldnt find class with nameorg.micromanager.magellan.api.MagellanAPI
What's strange is, I could have sworn it worked the first time I tried one of the example scripts, but hung itself up at the command acq.start()
Since then, I always get the above error message.
I have since tried reinstalling pygellan and Micro-Manager, but the error persists...
Am I missing something?
I was able to follow the example code using Anaconda > Spyder > Ipython no problem with the demo.cfg. Which is awesome.
I was playing around with the core commands and found a lot to be working, but a few were missing. core.getImage() results in AttributeError: 'MMJavaClass' object has no attribute 'getImage' . Same with core.getLastImage().
This is after using core.snapImage().
Is the whole cmmcore available, or is it still a work in progress?
Thanks,
Kyle
Hi Henry,
I'd like to be able to control the time tab in Magellan through Python. Will need to be able to set whether the grids are run sequentially or not.
Thanks,
Kyle
For example, would like to be able to call both core.set_exposure(10)
and `core.set_exposure('CameraName', 10), which right now isn't possible
Want to be able to pass in "acquisiton hooks", i.e. python functions that are automatically executed in different parts of the acquisition sequence (e.g. before hardware move, after hardware move, before image saving). This would enable the ability to adjust hardware based on data during the acquisition cycle (with a simple example being autofocus)
The "+" button on the acquisitions tab does not add another line for multiple acquisitions.
Can we also get an example of how to add an acquisition in python? something like?
acquisitions = magellan.get_acquisitions()
acq = acquisitions[0]
acq_settings = acq.get_acquisition_settings()
acq1 = acq
acquisitions.append(acq1)
There's some bad bug where the incorrect acquisition gets finished when running two in close succession
In many situations, would be good to be able to apply some arbitrary transformation to images in using Python libraries and then send them back into the regualar Java image processing queue. Basicially the same idea as this, but implemented in pure Python
Maybe could do this with a ZMQ client server architecture where the client runs as micromanager processor plugin, and the server runs in python and returns image or none?
Demo dataset acquired with MM2.0gamma nightly 10/14/2019 includes 4 channel, 3 timepoints, 11 z, on a 2x2 grid.
Cannot access magellan.summary_metadata['ChNames']
without crashing.
KeyError: 'ChNames'
Code worked for dataset acquired with MM 1.4 Magellan.
your code in magellan_data.py
if 'ChNames' in self.summary_metadata:
#Legacy magellan files--load channel names here
self._channel_names = {i: ch for i, ch in enumerate(self.summary_metadata['ChNames'])}
else:
self._channel_names = {} #read them from image metadata
how should we access channel names in the new version?
Thanks!
Kyle
A few questions regarding re-use of parts of the µMagellan code in a separate µManager plugin. I appreciate some pointers to get me going in the right direction.
Viewer: I understand µMagellan has its own viewer code. To what extent is the µMagellan viewer separate and usable from the outside the µMagellan plugin? Less importantly, in 2.0 gamma there is ClearVolume; have you considered it as a viewer?
File format: Are there important differences between Magellan's multi-resolution format and BDV's format? I know BDV can open Magellan files but it seems better yet if they used the identical format. I would love to see multi-resolution become a first-class file saving option within µManager and that raises the question of the format specifics.
1.4 vs. 2.0: Has anything significant changed with µMagellan when porting to 2.0 besides updating the calls to µManager API? I understand current development has migrated to 2.0, but I'm initially interested in using parts of µMagellan in 1.4.
@henrypinkard @nicost
Furthering the disucssion from #25
I still hold that the "core" behavior that we have should be separated from the magellan acquisition engine for precisely these reasons:
In order to enable the functionality described in the issues, I will need to add different types of socket architectures (i.e. not Java server python client). These may be fairly tightly coupled to the magellan acquisition engine. Hard to say for me right now which layer they would belong in, because there is still a lot to figure out.
The problem with this approach is that it means future development potentially breaks existing behavior. If you can guarantee it will not, then that's actually an argument that this "core" functionality is ready to be isolated.
In other words, i'm saying that the goal of this module is to provide a general service that others can build upon for their applications. Specific elaborations should build on top as a separate layer, but mostly pipe into API provided by this "core". If you think certain fundamental changes need to be made (multi sockets maybe?), then let's think about that right now.
Hi Henry,
Tried to run a simple script with the new Pygellan and last night's MicroManager build. In my VS code editor the simple script caused an endless output of the errors seen in the screen shot (had to screen shot as killing the terminal clears the errors and they were flying by too fast to read).
If I run the code in my Spyder editor, it runs fine. The main issue for me personally is that I had to switch from Spyder to VS code due to different error happening specifically in Spyder. Running out of editors...
Anyways, let me know if it's fixable, or I'll hunt for another editor.
Kyle
When trying to read information pertinent to packing an .hdf5 file, how would you pull information from the Magellan dataset? x, y, z, t resolution are most interesting. I can access the micromanager metadata but z and t resolution aren't in there I believe.
Thanks,
Kyle
Using the demo config for acquisitions and explore, no XML metadata file is produced.
Hi Henry,
I'd like to be able to assign and control channel exposure from Python to send to Magellan for multiple grid acquisitions.
Thanks,
Kyle
Once acquisition stuff is implemented, implement headless mode so that no Java based viewer pops up and everything can be done from your language of choice
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.