[ome-devel] MATLAB Class for fast and simple writing of OME-TIFFs

Sebastien Besson s.besson at dundee.ac.uk
Tue Nov 4 11:07:59 GMT 2014


Hi Gary,

On 3 Nov 2014, at 21:00, Yellen, Gary <gary_yellen at hms.harvard.edu<mailto:gary_yellen at hms.harvard.edu>> wrote:

Hi Sebastian,
I’m happy to share the code.  My thought was that the OMETiffWriter_gy class (only has my initials because OMETiffWriter is such a general name) should actually be generally usable code, even though the other m file is more specific.  I’m sure it would only cover a subset of applications, of course.

We will be opening a Pull Request to add a link to this thread and the code in the Bio-Formats documentation.

 I like your idea of providing a more simple interface through the helper methods.

Improving this aspect of Bio-Formats is certainly something under investigation. The most likely placeholder
for such additions will be a priori a Java service like the OMEXMLService interface.

The reason I implemented my methods as part of a class object is because it can retain persistent state information about (e.g.) the next available annotation IDs in specific types.

That makes sense, the index of the next available annotation is also readable using the getxxxAnnotationCount() getter methods. See
for instance https://downloads.openmicroscopy.org/bio-formats/5.0.5/api/ome/xml/meta/OMEXMLMetadataImpl.html#getTagAnnotationCount()
While using them, please note these methods can throw a null pointer exception e.g. if no annotation has been added.

I find it useful to have the annotation IDs specify the type (e.g. Annotation:C0, Annotation:D3), as this makes de-referencing them much easier when the file is read back.

All noted. If we implement helper methods, this could likely be supported via a prefix argument.

I also meant to ask: some of the setXxxxAnnotationRef methods require an annotation index as well as the ID, but I’m not sure why this is necessary, as the ID seems to be a unique identifier.

Taking https://downloads.openmicroscopy.org/bio-formats/5.0.5/api/ome/xml/meta/OMEXMLMetadataImpl.html#setImageAnnotationRef(java.lang.String,%20int,%20int)
as an example.
- String annotation corresponds to the ID of the annotation to be referenced in the Image, e.g. `Annotation:0`
- annotationRefIndex is the index of the annotation reference for the image. This index is a priori independent of the index of the referenced
  annotation. This is the same index that is used while retrieving a given annotation reference for an image with e.g.
  https://downloads.openmicroscopy.org/bio-formats/5.0.5/api/ome/xml/meta/MetadataRetrieve.html#getImageAnnotationRef(int,%20int)

 I am happy with my current hybrid solution – it seems to work quite efficiently.  I have also created an OMETiffReader_gy class for reading back the series efficiently into MATLAB objects (and also reading back the metadata into a MATLAB structure).  I have also subclassed both the reader and the writer objects to provide functions more specific to my own application (such as combining read metadata and image data back into a data object).  I think that the general superclass and specific subclass might be a good approach for MATLAB users who want to read and write OME-TIFFs from their own applications.

I’m sure you will still want to investigate the Bio-Formats performance, but there is no rush for my own purposes.

All noted and understood. We will keep you posted on performance issues.

Best,
Sebastien


Best regards,
Gary




From: Sebastien Besson [mailto:s.besson at dundee.ac.uk]
Sent: Monday, November 03, 2014 10:15 AM
To: Yellen, Gary
Cc: OME-devel OME; Copeland, Jay Arnold Jesse
Subject: Re: [ome-devel] MATLAB Class for fast and simple writing of OME-TIFFs

Hi Gary,

thank you very much for your email.
Regarding the code itself, I had a quick glance at it and did not see any obvious issue so far. Obviously part of it is
quite specific to your application but there are many methods useful for the community and it is really nice to see
concrete examples of usage.

A couple of immediate thoughts:
- are you happy with your current hybrid solution? The performance issue arising with Bio-Formats only calls is
  certainly something we want to investigate but this will require a bit of time. Having access to the code allows us
  to schedule this in our agenda thought.

- I am considering porting back some of this code back to the open-source code. In particular the mechanisms
  for creating and linking annotations to images could likely be simplified for others by adding helper methods, e.g.
  something like:

>> tagID = createTagAnnotation(metadata, value);
>> linkImageAnnotation(metadata, imageIndex, tagID);

Would that be acceptable for you and if so do you have any comments/suggestions?

Thanks again for sharing your code,
Sebastien

On 31 Oct 2014, at 21:09, Yellen, Gary <gary_yellen at hms.harvard.edu<mailto:gary_yellen at hms.harvard.edu>> wrote:


Hi all –
Here is some code for exporting OME-TIFFs from MATLAB data, using a combination of Bio-Formats calls for the metadata and MATLAB Tiff calls for the actual file writing.  I have found the speed to be significantly faster than using all Bio-Formats calls.

I’ve also included tools (hopefully general!) for adding all different types of annotations to the images, without wrestling with the many Java calls necessary to do this.

The main code is the OMETiffWriter_gy class, in a single file.  There’s documentation of the workflow at the top of the code.  I’ve also included example code in the dF_saveAsOMETiff.m file, which is just for your perusal since it requires object classes that are peculiar to our lab.

Please let me know if you find bugs in the OMETiffWriter_gy code, or if you make improvements.

Best,
Gary


Gary Yellen, PhD  ::   Professor of Neurobiology
Harvard Medical School :: 220 Longwood Ave [WAB 328] :: Boston, MA 02115
617-432-0137 ::  gary_yellen at hms.harvard.edu<mailto:gary_yellen at hms.harvard.edu>


<OMETiffWriter_gy.m><dF_saveAsOMETiff.m>

Dr Sébastien Besson
Open Microscopy Environment / Harvard Medical School
Wellcome Trust Centre for Gene Regulation and Expression,
College of Life Sciences, University of Dundee, Dow Street,
Dundee DD1 5EH Scotland UK   Tel: (01382) 386364


The University of Dundee is a registered Scottish Charity, No: SC015096

Dr Sébastien Besson
Open Microscopy Environment / Harvard Medical School
Wellcome Trust Centre for Gene Regulation and Expression,
College of Life Sciences, University of Dundee, Dow Street,
Dundee DD1 5EH Scotland UK   Tel: (01382) 386364


The University of Dundee is a registered Scottish Charity, No: SC015096
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20141104/76dadad1/attachment-0001.html>


More information about the ome-devel mailing list