Skip to content

Commit

Permalink
continuing with OME-ZARR support
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanPreibisch committed Nov 11, 2024
1 parent 335203e commit d4d7046
Showing 1 changed file with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,84 @@
package net.preibisch.mvrecon.fiji.spimdata.imgloaders;

import java.net.URI;
import java.util.function.Function;

import org.janelia.saalfeldlab.n5.DatasetAttributes;
import org.janelia.saalfeldlab.n5.N5Reader;
import org.janelia.saalfeldlab.n5.universe.N5Factory.StorageFormat;
import org.janelia.saalfeldlab.n5.universe.metadata.axes.Axis;
import org.janelia.saalfeldlab.n5.universe.metadata.ome.ngff.v04.OmeNgffMultiScaleMetadata;
import org.janelia.saalfeldlab.n5.universe.metadata.ome.ngff.v04.OmeNgffMultiScaleMetadata.OmeNgffDataset;
import org.janelia.saalfeldlab.n5.universe.metadata.ome.ngff.v04.OmeNgffMultiScaleMetadata.OmeNgffDownsamplingMetadata;
import org.janelia.saalfeldlab.n5.universe.metadata.ome.ngff.v04.coordinateTransformations.CoordinateTransformation;
import org.janelia.saalfeldlab.n5.universe.metadata.ome.ngff.v04.coordinateTransformations.ScaleCoordinateTransformation;
import org.janelia.saalfeldlab.n5.universe.metadata.ome.ngff.v04.coordinateTransformations.TranslationCoordinateTransformation;

import net.imglib2.realtransform.AffineTransform3D;
import util.URITools;

public class OMEZarrAttibutes
{
/**
*
* @param n - num dimensions, 3-5 makes sense here (zyx to tczyx; TODO: which order?)
* @param numResolutionLevels - number of multiresolution levels (e.g. s0, s1, s2 would be 3), always includes full res
* @return
*/
public static OmeNgffMultiScaleMetadata[] createOMEZarrMetadata(
final int n,
final int numResolutionLevels,
final Function<Integer, String> levelToName,
final Function<Integer, AffineTransform3D> levelToMipmapTransform )
{
final OmeNgffMultiScaleMetadata[] meta = new OmeNgffMultiScaleMetadata[ 1 ];

// dataset name
final String path = null;
final String name = "setup0_timepoint5"; // I also saw "/"
final String type = null;

// axis descriptions
// TODO: for some reason they are in TCZYX order
final Axis[] axes = new Axis[ n ];

int index = 0;

if ( n >= 5 )
axes[ index++ ] = new Axis( "time", "t", "millisecond" );

if ( n >= 4 )
axes[ index++ ] = new Axis( "channel", "c", null );

axes[ index++ ] = new Axis( "space", "z", "micrometer" );
axes[ index++ ] = new Axis( "space", "y", "micrometer" );
axes[ index++ ] = new Axis( "space", "x", "micrometer" );

// multiresolution-pyramid
// TODO: for some reason in XYZCT order (but in the file it seems reversed)
final OmeNgffDataset[] datasets = new OmeNgffDataset[ numResolutionLevels ];

for ( int s = 0; s < numResolutionLevels; ++s )
{
datasets[ s ] = new OmeNgffDataset();

datasets[ s ].path = levelToName.apply( s );

datasets[ s ].coordinateTransformations = new CoordinateTransformation[ 2 ];
datasets[ s ].coordinateTransformations[ 0 ] = new ScaleCoordinateTransformation( new double[] { } ); // TODO
datasets[ s ].coordinateTransformations[ 1 ] = new TranslationCoordinateTransformation( new double[] { } ); // TODO
}

// just saw these being null everywhere
final DatasetAttributes[] childrenAttributes = null;
final CoordinateTransformation<?>[] coordinateTransformations = null; // I also saw ScaleTransform [1,1,1]
final OmeNgffDownsamplingMetadata metadata = null;

meta[ 0 ] = new OmeNgffMultiScaleMetadata( n, path, name, type, "0.4", axes, datasets, childrenAttributes, coordinateTransformations, metadata );

return meta;
}

public static void loadOMEZarr( final N5Reader n5, final String dataset )
{
//org.janelia.saalfeldlab.n5.universe.metadata.ome.ngff.v04.OmeNgffMetadata
Expand Down Expand Up @@ -60,6 +128,9 @@ public static void loadOMEZarr( final N5Reader n5, final String dataset )

public static void main( String[] args )
{
//final URI uri = URITools.toURI( "https://storage.googleapis.com/jax-public-ngff/KOMP/adult_lacZ/ndp/Moxd1/23420_K35061_FGut.zarr/0/" );
//final String dataset = "/";

final URI uri = URITools.toURI( "s3://aind-open-data/exaSPIM_708373_2024-04-02_19-49-38/SPIM.ome.zarr/" );
final String dataset = "tile_x_0001_y_0001_z_0000_ch_488.zarr";

Expand Down

0 comments on commit d4d7046

Please sign in to comment.