henrypinkard / Pygellan

[DEPREACATED] Python interface for data-driven microscopy with Micro-manager/Micro-Magellan
BSD 3-Clause "New" or "Revised" License
14 stars 3 forks source link

mmcore works! Mostly... #6

Closed BIDCatUCSF closed 5 years ago

BIDCatUCSF commented 5 years ago

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

henrypinkard commented 5 years ago

Almost the entire core is available. The way this works is that when the Python client starts up it sends a request to the Java side to list all usable methods. The Java side then goes through every method and checks whether its return type and all of its arguments are classes that it knows how to serialize and python knows how to deserialize (so it can be passed from one language to the other). This includes most, but not all, functions of the core at the moment. The nice aspect of this system is that it's future-proof: since the API is discovered at runtime, if something changes in the core API it will automatically be usable without having to change pygellan (provided the function meets the criteria described above).

The error you have there means that those functions are among the set that do not meet the criteria (Because of their Java return type, I think). If you're using ipython, you should be able to type core. and then have it autocomplete the available methods. If you don't see the method on there then it's one of the ones that's not usable at present.

I could update to include their return types, but I think you probably want to be using core.getTaggedImage() instead. I made a more detailed example showing this.

BIDCatUCSF commented 5 years ago

Thanks for the detailed explanation. Using ipython yesterday the core. autocomplete did indicate that getImage() and getLastImage() were not available. I actually tried core.getTaggedImage(), but it crashed my micro-manager instance at the time.

Today I followed your new more detailed example and everything worked. May I suggest rounding out the example by including;

import matplotlib.pyplot as plt plt.imshow(pixels,cmap='gray') plt.show()

Thanks, Kyle

henrypinkard commented 5 years ago

Maybe something went wrong in the c++ layer because you hadn't snapped first? In any case, glad it works

Added your suggestion. Feel to submit pull requests if you have future ideas for improving examples!