We're Hiring!

Adding Modulo annotation to metadata

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

Adding Modulo annotation to metadata

Postby yuriy_alexandrov » Thu May 15, 2014 2:49 pm

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.
yuriy_alexandrov
 
Posts: 126
Joined: Thu Oct 25, 2012 2:06 pm

Re: Adding Modulo annotation to metadata

Postby mlinkert » Fri May 16, 2014 11:41 am

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);
User avatar
mlinkert
Team Member
 
Posts: 353
Joined: Fri May 29, 2009 2:12 pm
Location: Southwest Wisconsin

Re: Adding Modulo annotation to metadata

Postby yuriy_alexandrov » Fri May 16, 2014 3:11 pm

...
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.
Last edited by yuriy_alexandrov on Fri May 16, 2014 3:55 pm, edited 1 time in total.
yuriy_alexandrov
 
Posts: 126
Joined: Thu Oct 25, 2012 2:06 pm

Re: Adding Modulo annotation to metadata

Postby yuriy_alexandrov » Fri May 16, 2014 3:54 pm

...
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.
yuriy_alexandrov
 
Posts: 126
Joined: Thu Oct 25, 2012 2:06 pm


Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 1 guest