[ome-devel] CZI support
Melissa Linkert
melissa at glencoesoftware.com
Tue May 13 19:14:31 BST 2014
Hi all,
> Looking more closely at the ZeissCZIReader, I was wrong about how those
> fields are stored - I thought they were coming from OME-XML, but it's
> actually stored in a nested class that is not exposed via the API.
>
> So, off-hand, it looks like if you want to get the Zeiss-specific
> metadata, you should look through r.getGlobalMetadata() for keys containing
> Rotations, Phases, Illuminations, etc... as it seems the values are stored
> there<https://github.com/openmicroscopy/bioformats/blob/v5.0.0/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java#L2115>
> .
>
> I am also forwarding this to the OME-devel list, as there is probably a
> better way to get this metadata.
No, as mentioned in a private reply, the correct way to do this is to
use the getModuloC(), getModuloT(), and getModuloZ() methods in
IFormatReader. Those each return a loci.formats.Modulo object, whose
length() method will give the number of illuminations, phases, and
rotations, respectively (for Zeiss .czi files specifically; other
formats may store different dimensions).
Please see the Javadoc for Modulo for additional information:
http://ci.openmicroscopy.org/view/Bio-Formats/job/BIOFORMATS-5.0-merge-daily/javadoc/loci/formats/Modulo.html
Regards,
-Melissa
On Tue, May 13, 2014 at 12:55:02PM -0500, Mark Hiner wrote:
> Hi Steffi,
>
> I cannot import the ZeissCZIReader, do I need some new jar or version maybe?
> >
>
> ZeissCZI is a proprietary format, so it lives in the formats-gpl component
> which I believe is not imported by default by pom-fiji. You just need to
> add the dependency:
>
> <dependency>
> <groupId>ome</groupId>
> <artifactId>formats-gpl</artifactId>
> <version>${bio-formats.version}</version>
> </dependency>
>
> to your pom. This will also allow you to import the ZeissCZIReader directly
> if it becomes necessary.
>
> Looking more closely at the ZeissCZIReader, I was wrong about how those
> fields are stored - I thought they were coming from OME-XML, but it's
> actually stored in a nested class that is not exposed via the API.
>
> So, off-hand, it looks like if you want to get the Zeiss-specific
> metadata, you should look through r.getGlobalMetadata() for keys containing
> Rotations, Phases, Illuminations, etc... as it seems the values are stored
> there<https://github.com/openmicroscopy/bioformats/blob/v5.0.0/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java#L2115>
> .
>
> I am also forwarding this to the OME-devel list, as there is probably a
> better way to get this metadata.
>
> Good luck!
> Mark
>
>
>
>
>
>
> On Tue, May 13, 2014 at 12:11 PM, Stephan Preibisch <
> preibischs at janelia.hhmi.org> wrote:
>
> > Hi Mark,
> >
> > that sounds great, I will give it a shot. I was just not really sure where
> > to start. It seems everything is already in place, that is fantastic.
> >
> > I have some problems actually being able to implement it. I cannot import
> > the ZeissCZIReader, do I need some new jar or version maybe? (I work on
> > this branch directly
> > https://github.com/fiji/spimreconstruction/tree/newspimreconstruction,
> > using this pom.xml
> > https://github.com/fiji/spimreconstruction/blob/newspimreconstruction/pom.xml
> > ).
> >
> > Here is how I started, it is based on what Curtis implemented for me quite
> > some time back and which is still the code I for example use to open
> > standard LSMs using Bioformats:
> >
> > // should I use the ZeissCZIReader here directly?
> > *final* IFormatReader r = *new* ChannelSeparator();
> >
> > // is that still necessary (code is below)?
> > *if* ( !createOMEXMLMetadata( r ) )
> > {
> > *try* { r.close(); } *catch* (IOException e) { e.printStackTrace(); }
> > *return* *null*;
> > }
> >
> >
> > *try*
> > {
> > r.setId( firstFile.getAbsolutePath() );
> >
> > // now I should be able to query all the details, right? But how do I get
> > illuminations and angles?
> > *final* *boolean* isLittleEndian = r.isLittleEndian();
> > * final* *int* width = r.getSizeX();
> > *final* *int* height = r.getSizeY();
> > *final* *int* depth = r.getSizeZ();
> > *int* timepoints = r.getSizeT();
> > *int* channels = r.getSizeC();
> > *final* *int* pixelType = r.getPixelType();
> > *final* *int* bytesPerPixel = FormatTools.getBytesPerPixel( pixelType );
> > *final* String pixelTypeString = FormatTools.getPixelTypeString(
> > pixelType );
> >
> >
> > *final* MetadataRetrieve retrieve =
> > (MetadataRetrieve)r.getMetadataStore();
> >
> >
> > *float* cal = retrieve.getPixelsPhysicalSizeX( 0
> > ).getValue().floatValue();
> > *if* ( cal == 0 )
> > {
> > cal = 1;
> > IOFunctions.println( "StackListLOCI: Warning, calibration for dimension
> > X seems corrupted, setting to 1." );
> > }
> > *final* *double* calX = cal;
> >
> > ...
> >
> > // and later on open the requested data
> >
> > } *catch* ( Exception e ) { e.printStackTrace(); }
> >
> > ...
> >
> > *public* *static* *boolean* createOMEXMLMetadata( *final* IFormatReader r
> > )
> > {
> > *try*
> > {
> > *final* ServiceFactory serviceFactory = *new* ServiceFactory();
> > *final* OMEXMLService service = serviceFactory.getInstance(
> > OMEXMLService.*class* );
> > *final* IMetadata omexmlMeta = service.createOMEXMLMetadata();
> > r.setMetadataStore(omexmlMeta);
> > }
> > *catch* (*final* ServiceException e)
> > {
> > e.printStackTrace();
> > *return* *false*;
> > }
> > *catch* (*final* DependencyException e)
> > {
> > e.printStackTrace();
> > *return* *false*;
> > }
> >
> >
> > *return* *true*;
> > }
> >
> > Thank you so much for your fast reply!!!
> > Steffi
> >
> > On May 13, 2014, at 12:25 , Mark Hiner wrote:
> >
> > Hi Steffi,
> >
> >
> > a) Read all the metadata
> >> - how many timepoints
> >> - how many channels
> >> - how many angles
> >> - how many illumination directions
> >> - calibration x,y,z (um/px)
> >>
> >
> > Looking at the latest Bio-Formats CZI reader<https://github.com/openmicroscopy/bioformats/blob/develop/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java>,
> > it looks like there is support for this metadata already. Looking at the
> > calculateDimensions<https://github.com/openmicroscopy/bioformats/blob/develop/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java#L834>method you can see that the illuminations, phases, rotations, etc... are
> > all recorded, and if I understand correctly (Melissa can clarify if needed
> > here) they are compressed to ZCT dimensions here<https://github.com/openmicroscopy/bioformats/blob/develop/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java#L516>
> > .
> >
> > Given that Bio-Formats already supports these fields, can you clarify a
> > bit what functionality is missing that you'd like to see? It seems to me
> > like you don't need to implement a completely new reader, but could just
> > use the existing API.
> >
> > b) Be able to read individual 3d-stacks: Image = get( Timepoint t, Angle
> >> a, Illumination i, Channel c )
> >>
> >
> > If I am understanding correctly, what you really want to do is understand
> > how these parameters are being converted to ZCT dimensions and thus plane
> > ranges, and then use openBytes<https://github.com/openmicroscopy/bioformats/blob/develop/components/formats-gpl/src/loci/formats/in/ZeissCZIReader.java#L276>on the correct plane numbers using the Bio-Formats ImageReader API.
> >
> > Looking at calculateDimensions again, it looks like the metadata is stored
> > under the plane elements in the XML, I believe. So to do what you'd want,
> > you could write a little plugin that:
> >
> > 1) Calls setId using Bio-Formats
> > 2) Checks the XML planes for the angle, illumination, etc.. parameters
> > you're interested in. If they're not there, return as unsupported data.
> > 3) Prompts for an input based on the ranges of these parameters
> > 4) Converts the received input to image/plane numbers for Bio-Formats
> > 5) Calls openBytes as necessary to build the requested 3D image.
> >
> > I'm envisioning it as an ImageJ plugin but you could adapt as needed.
> >
> > Does that make sense..? I don't think anything needs to change in the CZI
> > Reader, or additional reader layers on top..
> >
> > Again, Melissa please correct me if I got anything wrong.
> >
> > Steffi, let me know if you'd like clarification on anything, or if I
> > misunderstood what you're trying to do.
> >
> > Thanks!
> > Mark
> >
> >
> > On Tue, May 13, 2014 at 10:25 AM, Stephan Preibisch <
> > preibischs at janelia.hhmi.org> wrote:
> >
> >> Hi Melissa, Mark, Curtis,
> >>
> >> if you have a second, I would have a question about Bioformats, Scifio
> >> and LOCI. The guys at Zeiss told me that you recently added support for the
> >> multi-view, multi-channel, multi-timepoint CZI files as they are saved by
> >> their Lightsheet Z.1 microscope. Is that correct?
> >>
> >> If so, I want to implement a specialized reader for those files. What I
> >> want to achieve is the following:
> >>
> >> a) Read all the metadata
> >> - how many timepoints
> >> - how many channels
> >> - how many angles
> >> - how many illumination directions
> >> - calibration x,y,z (um/px)
> >>
> >> b) Be able to read individual 3d-stacks: Image = get( Timepoint t, Angle
> >> a, Illumination i, Channel c )
> >>
> >> This data can be in one gigantic file or distributed over many different
> >> files. So I am not sure how to start. Do you abstract that already, or
> >> should I do that?
> >>
> >> Should I use Scifio? And if so, where should I start reading, and which
> >> version do I need? Is that compatible with the current version that is in
> >> Fiji?
> >>
> >> Thank you so much for your help!
> >>
> >> Cheers,
> >> Steffi
> >
> >
> >
> >
More information about the ome-devel
mailing list