[ome-devel] OME-TIFF merge

Melissa Linkert melissa at glencoesoftware.com
Sun Sep 16 18:24:19 BST 2012


Hi Heinrich,

> Now I also want to copy metadata to the newly created merge. I am able to get the metadata via
> 
> //--
> 
> // get the metadata from the Imp
> String OmeXml = "";
> OmeXml = Imp.getOriginalFileInfo().description;
> // create bio-formats metadata object out of the omexml
> IMetadata Meta = MetadataTools.createOMEXMLMetadata(OmeXml);
> 
> --//
> 
> However, I only know how to get and set single metadata entries, like
> 
> //
> DyeList[i] = Meta.getChannelFluor(0,i);
> //
> 
> Is it possible to get all metadata concerning one channel, concerning the instrument, or the pixels entries with one command only?

Not using the IMetadata API.  If you are only working with IMetadata
objects that are created from an OME-XML string, then 'Meta' will be an
instance of loci.formats.ome.OMEXMLMetadata.  This means that all of the
metadata storage and retrieval takes place in the ome.xml.model.*
classes, so you could work with those classes directly to do the copying.

An example is here:

https://github.com/openmicroscopy/bioformats/blob/develop/components/bio-formats/src/loci/formats/in/CellWorxReader.java#L372

(through line 385).  That takes an existing IMetadata created from an
OME-XML string and copies the first Instrument and all of the Images to
a new IMetadata.

> Because otherwise, I would need to go through all entries that might be set in the metadata, right?

If you choose not to use the ome.xml.model.* classes, then yes, you will
need to go through all of the methods for Channel (or Instrument, etc.).

Regards,
-Melissa

On Thu, Sep 13, 2012 at 04:05:56PM +0000, Grabmayr, Heinrich wrote:
> Hi Melissa,
> 
> thanks a lot  for that input. I used your snipped and it worked fine. Now I also want to copy metadata to the newly created merge. I am able to get the metadata via
> 
> //--
> 
> // get the metadata from the Imp
> String OmeXml = "";
> OmeXml = Imp.getOriginalFileInfo().description;
> // create bio-formats metadata object out of the omexml
> IMetadata Meta = MetadataTools.createOMEXMLMetadata(OmeXml);
> 
> --//
> 
> However, I only know how to get and set single metadata entries, like
> 
> //
> DyeList[i] = Meta.getChannelFluor(0,i);
> //
> 
> Is it possible to get all metadata concerning one channel, concerning the instrument, or the pixels entries with one command only?
> Because otherwise, I would need to go through all entries that might be set in the metadata, right?
> 
> 
> Best, Heinrich
> 
> -----Ursprüngliche Nachricht-----
> Von: Melissa Linkert [mailto:melissa.linkert at gmail.com] Im Auftrag von Melissa Linkert
> Gesendet: Donnerstag, 13. September 2012 02:46
> An: Grabmayr, Heinrich
> Cc: ome-devel at lists.openmicroscopy.org.uk
> Betreff: Re: [ome-devel] OME-TIFF merge
> 
> Hi Heinrich,
> 
> > I have a similar question to the one below which I found on the ome-users list.
> > 
> > My data is ome-tif, and I have different images with several channels. I would like to merge one or more of each to a resulting ome-tif, also copying the according metadata. Is there a plugin out there that does this?
> 
> Not to my knowledge, no.
> 
> > The route I found was to use LOCI channel splitter, convert to a hyperstack, and then merge in there. That does not keep the metadata, though, I fear.
> > 
> > For writing a plugin myself, my questions would be
> > 
> > -    Can IMetadata give me the complete "channel" metadata? Or should I cut it out of the xml string?
> 
> Yes, IMetadata can give you anything that would be in the OME-XML string.
> 
> > -    Is there a more intelligent way of copying a whole channel than to go through all frames and z-positions and do it pixelwise via stack.setVoxel? (I did find the ImageProcessor.getPixels() but did not understand how to use its return value)
> 
> You could do something like this instead:
> 
> // --
> ImagePlus originalStack = BF.openImagePlus(file)[0]; int[] dimensions = originalStack.getDimensions(); int channel = 0; ImageStack singleChannel = new ImageStack();
> 
> for (int z=0; z<dimensions[3]; z++) {
>   for (int t=0; t<dimensions[4]; t++) {
>     originalStack.setPositionWithoutUpdate(channel + 1, z + 1, t + 1);
>     singleChannel.addSlice(originalStack.getProcessor());
>   }
> }
> 
> ImagePlus newStack = new ImagePlus("the first channel", singleChannel); // --
> 
> > And more generally, I sometimes feel that I fail to know basic methods and utils within the loci / bio-formats framework. Are there collections of ome-tiff plugins around (more than those in ImageJ->plugins->Loci and components/loci-plugins/utils)? Also, is there a guide/introduction on how to do things? I often write things that work but at the same time guessing there might be a useful class I don't know of that would make it more elegant...
> 
> Have you read through all of the documentation here:
> 
> http://trac.openmicroscopy.org.uk/ome/wiki/BioFormats
> 
> and here:
> 
> http://loci.wisc.edu/bio-formats/bio-formats-java-library
> 
> in particular these examples:
> 
> https://github.com/openmicroscopy/bioformats/tree/develop/components/bio-formats/utils
> 
> (which are not ImageJ-related, but do show you some possibly useful things about using Bio-Formats).
> 
> That's about as close as we have to a guide at the moment; otherwise, the best thing to do really is to familiarize yourself with the Javadoc documentation (linked from both of the above) and ask questions here.
> 
> Regards,
> -Melissa
> 
> On Wed, Sep 12, 2012 at 06:37:10PM +0000, Grabmayr, Heinrich wrote:
> > Hi,
> > 
> > 
> > 
> > I have a similar question to the one below which I found on the ome-users list.
> > 
> > My data is ome-tif, and I have different images with several channels. I would like to merge one or more of each to a resulting ome-tif, also copying the according metadata. Is there a plugin out there that does this?
> > 
> > The route I found was to use LOCI channel splitter, convert to a hyperstack, and then merge in there. That does not keep the metadata, though, I fear.
> > 
> > For writing a plugin myself, my questions would be
> > 
> > -    Can IMetadata give me the complete "channel" metadata? Or should I cut it out of the xml string?
> > 
> > -    Is there a more intelligent way of copying a whole channel than to go through all frames and z-positions and do it pixelwise via stack.setVoxel? (I did find the ImageProcessor.getPixels() but did not understand how to use its return value)
> > 
> > 
> > 
> > And more generally, I sometimes feel that I fail to know basic methods and utils within the loci / bio-formats framework. Are there collections of ome-tiff plugins around (more than those in ImageJ->plugins->Loci and components/loci-plugins/utils)? Also, is there a guide/introduction on how to do things? I often write things that work but at the same time guessing there might be a useful class I don't know of that would make it more elegant...
> > 
> > 
> > 
> > Best
> > 
> >    Heinrich
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > Melissa Linkert melissa at glencoesoftware.com 
> > <mailto:ome-users%40lists.openmicroscopy.org.uk?Subject=Re%3A%20%5Bome
> > -users%5D%20Combine%20two%20tif%20to%20a%20multilayer%20tif&In-Reply-T
> > o=%3C20120514180726.GC31887%40medusa%3E>
> > Mon May 14 19:07:26 BST 2012
> > 
> >   *   Previous message: [ome-users] Combine two tif to a multilayer tif <http://lists.openmicroscopy.org.uk/pipermail/ome-users/2012-May/003057.html>
> >   *   Next message: [ome-users] Importing .dv File via BioFormats <http://lists.openmicroscopy.org.uk/pipermail/ome-users/2012-May/003059.html>
> >   *   Messages sorted by: [ date ]<http://lists.openmicroscopy.org.uk/pipermail/ome-users/2012-May/date.html#3058> [ thread ]<http://lists.openmicroscopy.org.uk/pipermail/ome-users/2012-May/thread.html#3058> [ subject ]<http://lists.openmicroscopy.org.uk/pipermail/ome-users/2012-May/subject.html#3058> [ author ]<http://lists.openmicroscopy.org.uk/pipermail/ome-users/2012-May/author.html#3058>
> > 
> > 
> > 
> > 
> > 
> > Hi Jürgen,
> > 
> > 
> > 
> > > I have some image data in MetaMorph format. The Image format is not
> > 
> > > supported by Omero and I have to create an OME-XML header prior to
> > 
> > > importing the data.
> > 
> > 
> > 
> > MetaMorph data is definitely supposed to be supported.  Could you 
> > please
> > 
> > tell us what goes wrong when you try to import it into OMERO (as the
> > 
> > simplest solution is almost always to just import the original data)?
> > 
> > 
> > 
> > > Each channel (I have two, DAPI and GFP) is saved in a single separate image.
> > 
> > >
> > 
> > > For further processing I would like to combine the two channel
> > 
> > > images into a multi-layer tif file with a single header.
> > 
> > >
> > 
> > > I can do using convert from the imagemagick pckage:
> > 
> > >
> > 
> > > convert file1.tif file2.tif output.tif
> > 
> > >
> > 
> > > But that literally just concatenates the two files, resulting in a
> > 
> > > multi-layer file but also in two headers, so I have
> > 
> > >
> > 
> > > Exif.Image.Description
> > 
> > >
> > 
> > > as well as:
> > 
> > >
> > 
> > > Exif.Image2.Description
> > 
> > >
> > 
> > > Does anyone know of a tool to properly combine the two tiff files
> > 
> > > resulting in a new multi-layer tif file with a single header?
> > 
> > 
> > 
> > I believe this:
> > 
> > 
> > 
> > http://www.imagemagick.org/Usage/color_basics/#combine
> > 
> > 
> > 
> > and this:
> > 
> > 
> > 
> > http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=13534
> > 
> > 
> > 
> > explain how to do what you want in ImageMagick.
> > 
> > 
> > 
> > Regards,
> > 
> > -Melissa
> > 
> > 
> > 
> > On Mon, May 14, 2012 at 06:15:24PM +0200, Dr. Juergen helmers wrote:
> > 
> > > Hi!
> > 
> > >
> > 
> > > I have some image data in MetaMorph format. The Image format is not
> > 
> > > supported by Omero and I have to create an OME-XML header prior to
> > 
> > > importing the data.
> > 
> > >
> > 
> > > Each channel (I have two, DAPI and GFP) is saved in a single separate image.
> > 
> > >
> > 
> > > For further processing I would like to combine the two channel
> > 
> > > images into a multi-layer tif file with a single header.
> > 
> > >
> > 
> > > I can do using convert from the imagemagick pckage:
> > 
> > >
> > 
> > > convert file1.tif file2.tif output.tif
> > 
> > >
> > 
> > > But that literally just concatenates the two files, resulting in a
> > 
> > > multi-layer file but also in two headers, so I have
> > 
> > >
> > 
> > > Exif.Image.Description
> > 
> > >
> > 
> > > as well as:
> > 
> > >
> > 
> > > Exif.Image2.Description
> > 
> > >
> > 
> > > Does anyone know of a tool to properly combine the two tiff files
> > 
> > > resulting in a new multi-layer tif file with a single header?
> > 
> > >
> > 
> > > Thanks Juergen
> > 
> > >
> > 
> > > --
> > 
> > > *Dr. Jürgen Helmers*
> > 
> > > /Chief Developer/ | webnow | http://www.web-now.de
> > 
> > > *email:*juergen.helmers at 
> > > gmail.com<http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-us
> > > ers> | *tel:*+49 30 37301306 | *skype:*
> > 
> > > helmerj
> > 
> > 
> > 
> > > _______________________________________________
> > 
> > > ome-users mailing list
> > 
> > > ome-users at 
> > > lists.openmicroscopy.org.uk<http://lists.openmicroscopy.org.uk/mailm
> > > an/listinfo/ome-users>
> > 
> > > http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-users
> > 
> 
> > _______________________________________________
> > ome-devel mailing list
> > ome-devel at lists.openmicroscopy.org.uk
> > http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel
> 


More information about the ome-devel mailing list