[ome-devel] CZI support
Stephan Preibisch
preibischs at janelia.hhmi.org
Tue May 13 19:23:11 BST 2014
Thanks a lot Melissa, Mark, Curtis,
I am having initial success getting all the metadata from the files, so it should hopefully work from now on. That's awesome.
Adding the dependency that Mark suggested to the pom.xml did the job of being able to import the CZI reader:
<dependency>
<groupId>ome</groupId>
<artifactId>formats-gpl</artifactId>
<version>${bio-formats.version}</version>
</dependency>
I will let you know if I succeed. I will need a bigger computer than my laptop to actually run tests, these datasets are gigantic.
Thanks so much again guys!
Cheers,
Steffi
On May 13, 2014, at 14:06 , Melissa Linkert wrote:
> Hi Steffi,
>
>> 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).
>
> Probably you would need to add a dependency on the artifact that
> contains Bio-Formats readers:
>
> <dependency>
> <groupId>ome</groupId>
> <artifactId>formats-gpl</artifactId>
> <version>5.0.2-SNAPSHOT</version>
> </dependency>
>
>> 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();
>
> It is not necessary to use a ZeissCZIReader explicitly; file type
> detection is automatic.
>
>> // is that still necessary (code is below)?
>> if ( !createOMEXMLMetadata( r ) )
>> {
>> try { r.close(); } catch (IOException e) { e.printStackTrace(); }
>> return null;
>> }
>
> Yes, you will need this to be able to query the calibration later on.
>
>> try
>> {
>> r.setId( firstFile.getAbsolutePath() );
>>
>> // now I should be able to query all the details, right? But how do I get illuminations and angles?
>
> Each angle is stored in a separate series, so iterating:
>
> // --
> for (int angle=0; angle<r.getSeriesCount(); angle++) {
> r.setSeries(angle);
> int angleWidth = r.getSizeX();
> int angleHeight = r.getSizeY();
> // ... and so on
> }
> // --
>
> should work. Illuminations are contained within the channel count; to
> find the number of illuminations for the current angle:
>
> // --
> // Modulo is in the loci.formats package
> Modulo moduloC = r.getModuloC();
> int illuminations = moduloC.length();
> // --
>
> Everything else that you have there should work as before, just keep in
> mind that most of the getters on 'r' affect the current angle only.
>
> Do note as well that there have been a number of ongoing issues with .czi files,
> proposed fixes for which are here:
>
> https://github.com/openmicroscopy/bioformats/pull/1078
>
> That has not been deployed to OME's Artifactory, though, so just be
> aware that you may see some exceptions or incorrect behavior until that pull
> request is merged. The upcoming 5.0.2 release of Bio-Formats will
> contain those changes as well.
>
> Regards,
> -Melissa
>
> On Tue, May 13, 2014 at 01:11:09PM -0400, Stephan Preibisch 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, it looks like there is support for this metadata already. Looking at the calculateDimensions 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.
>>>
>>> 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 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
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openmicroscopy.org.uk/pipermail/ome-devel/attachments/20140513/e8f7d346/attachment-0001.html>
More information about the ome-devel
mailing list