Micro-Manager Multi-D Metadata extraction from pymmcore: how to achieve same formatting as running Micro-Manager 1.4 default GUI

Hi all,

I am currently writing a program to automate an imaging process using pymmcore on Python 3.8.5. I would like to retain the same JSON formatting metadata.txt file that Micro-Manager 1.4 generates when using Multi-Dimensional Acquisition.

Using md = pymmcore.Metadata() and md.Dump(), I am able to generate metadata in the following format:

11s : Binning
_
11

s : Camera
_
1Camera

s : ElapsedTime-ms
_
113.01

s : Height
_
1512

s : ImageNumber
_
10

s : PixelType
_
1GRAY16

s : ROI-X-start
_
10

s : ROI-Y-start
_
10

s : StartTime-ms
_
1672972781391.99

s : TimeReceivedByCore
_
12021-04-29 00:53:01.406006

s : Width
_
1512

There seems to be a “1” amended before each of the values, and does not follow the same JSON format that is usually seen inside the Pos0 folder metadata.txt of a multi-d acquisition. Is there any way to get the same type of output as the standard Micro-Manager GUI with pymmcore?

Any suggestions will be appreciated. Thank you!

Best,
Joe

Not sure what is causing the issue here, but if you call the core through pycro-manager, it will indirectly use the Java bindings (exposed thorugh python), which should give you the metadata format you’re looking for

The Dump() method does not produce JSON, but an internal format used to transport the metadata between modules in Micro-Manager. The 1s you see are part of the encoding of this format.

There is no built-in JSON generation in pymmcore, so the only option is to generate it yourself from the property values, which can be obtained by calling GetKeys() and then GetSingleTag() on each key. The latter returns a ‘tag’ object with methods like GetName() and GetValue().

As Henry says, it might be easier to use pycro-manager if you want JSON and if that is an option in your situation.

Thank you Henry! Currently we are trying to stick with MM 1.4. I believe Pycro-Manager requires MM 2.0. I will try out Pycro-Manager separately to see if it will serve our purposes better. Is there any way to have Pycro-Manager interact with MM 1.4?

Hi Mark, thank you for the insight! I attempted this, and by printing GetSingleTag() with a specific tag for example GetSingleTag(‘Camera’), I am getting this:

<Swig Object of type ‘MetadataSingleTag *’ at 0x000001B827E8CCB0>

How should I extract the value or string from this Swig Object? I do apologize, I am not very familiar with SWIG in general.

Thank you!

Unfortunately there isn’t. Best of luck!

Do [quote=“marktsuchida, post:3, topic:52125”]
GetName() and GetValue()
[/quote] nor work on this object?

Since 2.0 is now almost final, and 1.4 is no longer maintained, now would be a good time to speak up what is missing or not right in 2.0. That will at least give the developers a chance to consider and understand your requirements. It would be a pity to continue building workflows on top of a no longer maintained platform.