Page 1 of 1

Adding Modulo annotation to metadata

PostPosted: Thu May 15, 2014 2:49 pm
by yuriy_alexandrov
Hi All,

We work with Bioformats and Matlab, and want to create OME-tiffs with Modulo specifications.

Modulo is the OME XML annotation specifying additional XY-plane indexing attribute (e.g. the lifetime in FLIM, agreed to be ModuloAlongT).

Bioformats provides mechanism for adding ModuloAlong to metadata, and I now want to use it, as it should result in desired effect in corresponding OME.tiff files and Omero-imports made of them.
To pass metadata to the writer, I copy the code from "bfsave" function:

Code: Select all
OMEXMLService = loci.formats.services.OMEXMLServiceImpl();
metadata = OMEXMLService.createOMEXMLMetadata();
...
writer = loci.formats.ImageWriter();
...
writer.setMetadataRetrieve(metadata);
...

"OMEXMLService" object there contains "addModuloAlong" functions, "getModuloAlongZ"(C,T), and likely this is the place where one can add Modulo annotation to metadata.

Will be grateful for any hint.

Best,
Y.

Re: Adding Modulo annotation to metadata

PostPosted: Fri May 16, 2014 11:41 am
by mlinkert
Something like this should work:

Code: Select all
OMEXMLService = loci.formats.services.OMEXMLServiceImpl();
metadata = OMEXMLService.createOMEXMLMetadata();

% set all of the other metadata fields

% define the Modulo annotations

coreMetadata = loci.formats.CoreMetadata();

% see the loci.formats.Modulo javadoc for details of what fields can be set
% this will be turned into a Modulo XML annotation later
coreMetadata.moduloC.step = 3;
coreMetadata.moduloC.end = 12;
coreMetadata.moduloC.type = loci.formats.FormatTools.LIFETIME;
coreMetadata.moduloC.unit = 'ns';

% moduloZ and moduloT in coreMetadata can be set in the same way if desired

% adds each of the Modulo annotations defined by coreMetadata to the OME-XML
% the '0' argument specifies the Image to which the annotations should be attached;
% for multi-Image datasets (multi-series in Bio-Formats terms) you will need to call this method
% in a loop over the number of Images
OMEXMLService.addModuloAlong(metadata, coreMetadata, 0);

writer = loci.formats.ImageWriter();
writer.setMetadataRetrieve(metadata);

Re: Adding Modulo annotation to metadata

PostPosted: Fri May 16, 2014 3:11 pm
by yuriy_alexandrov
...
Many thanks Melissa,

It looks really good, almost everything is working.

The only thing that remains, - I should use "public String[] labels" field in Modulo, and wasn't able to adjust the assignment syntax.

I tried this (and similar) constructions but all result in errors

Code: Select all
for i=1:length(delays)
   modlo.moduloT.labels(i)= java.lang.String(num2str(delays(i)));
end

Just wonder how to get this puzzle solved.. :)

Best wishes, thanks again,
Y.

Re: Adding Modulo annotation to metadata

PostPosted: Fri May 16, 2014 3:54 pm
by yuriy_alexandrov
...
Actually I found that pre-allocating helps in this case.
The following code is working:

Code: Select all
modlo.moduloT.labels = javaArray('java.lang.String',length(delays));                                 
for i=1:length(delays)
   modlo.moduloT.labels(i)= java.lang.String(num2str(delays(i)));
end

now need to fix my other stuff to make it practical..

Thanks All,
Y.