Stream mode acquisition and metadata

Hello!

Some time ago one of my problem got solved by using the core streaming mode to acquire images. However, my former colleagues only had use for it recently and realised that the metadata are mostly empty (or non-populated), compared to the acqManager.runAcquisitionWithSettings type of acquisition.

The reason is that (beyond me forgetting to plug in the metadata at first), I built the metadata as follows:

core.startSequenceAcquisition(frames, interval, true);
Metadata.Builder metadata = studio.data().getMetadataBuilder();
[...]
TaggedImage tagged = core.popNextTaggedImage();
Image image = studio.data().convertTaggedImage(tagged, coord.build(), metadata.build());
store.putImage(image);

Now, the only ways I figured out how to get a metadata.txt closer to what I would get using runAcquisitionWithSettings is by doing this very hacky and not pretty thing:

TaggedImage tagged = core.popNextTaggedImage();

// create image without metadata
Image imageNoMetadata = studio.data().convertTaggedImage(tagged, coord.build(), null)

// generate metadata using the acquisition manager
Metadata metadata = acqManager.generateMetadata(imageNoMetadata, true);

// convert again the tagged image, this time with metadata
Image image = studio.data().convertTaggedImage(tagged, coord.build(), metadata);
store.putImage(image);

or simply building the metadata from scratch (example here adapted from acqManager.generateMetadata).

Is there a more elegant way that I missed?

Thanks in advance!

You could do:

TaggedImage tagged = core.popNextTaggedImage();
Image image = studio.data().convertTaggedImage(tagged);
store.putImage(image.copyAtCoords(coord.build());

Ah very nice, thanks! Funnily, this places all the devices properties in “User Data” with a type (String, Integer…), which is different from the MDA and the other “dirtier” approach (Key:Value at the higher JSON level).

Another question, I now realised that the SummaryMetada (DefaultSummaryMetada) does not contain entries such as “Frames” or “Slices” unless the intended dimensions are defined. Are those added by the clojure acquisition engine? I did not find anything in the Java code (but I might be blind).

And the same question as before, if I want to have these entries in the metadata, do I need to manually build them?

Right now, the only thing I can think of is something along those lines:
EDIT:

SummaryMetadata defaultSM = studio.acquisitions().generateSummaryMetadata();
SummaryMetadata.Builder b = defaultSM.copyBuilder();
Coords c = defaultSM.getIntendedDimensions();
b.intendedDimensions(c.copyBuilder().t(n).c(1).p(1).z(1).build());
store.setSummaryMetadata(b.build());

but again very hacky…

Thanks!