2323package net .preibisch .mvrecon .fiji .spimdata .imgloaders ;
2424
2525import java .net .URI ;
26+ import java .net .URISyntaxException ;
27+ import java .util .Arrays ;
2628import java .util .function .Function ;
2729
2830import org .janelia .saalfeldlab .n5 .DatasetAttributes ;
2931import org .janelia .saalfeldlab .n5 .N5Reader ;
32+ import org .janelia .saalfeldlab .n5 .universe .N5Factory ;
3033import org .janelia .saalfeldlab .n5 .universe .N5Factory .StorageFormat ;
3134import org .janelia .saalfeldlab .n5 .universe .metadata .axes .Axis ;
3235import org .janelia .saalfeldlab .n5 .universe .metadata .ome .ngff .v04 .OmeNgffMultiScaleMetadata ;
3639import org .janelia .saalfeldlab .n5 .universe .metadata .ome .ngff .v04 .coordinateTransformations .ScaleCoordinateTransformation ;
3740import org .janelia .saalfeldlab .n5 .universe .metadata .ome .ngff .v04 .coordinateTransformations .TranslationCoordinateTransformation ;
3841
42+ import mpicbg .spim .data .sequence .VoxelDimensions ;
3943import net .imglib2 .realtransform .AffineTransform3D ;
4044import util .URITools ;
4145
@@ -59,7 +63,7 @@ public static OmeNgffMultiScaleMetadata[] createOMEZarrMetadata(
5963 final OmeNgffMultiScaleMetadata [] meta = new OmeNgffMultiScaleMetadata [ 1 ];
6064
6165 // dataset name and co
62- final String path = null ;
66+ final String path = "" ;
6367 final String type = null ;
6468
6569 // axis descriptions
@@ -102,7 +106,7 @@ public static OmeNgffMultiScaleMetadata[] createOMEZarrMetadata(
102106 // if 4d and 5d, add 1's for C and T
103107 for ( int d = 3 ; d < n ; ++d )
104108 {
105- translation [ d ] = 1 .0 ;
109+ translation [ d ] = 0 .0 ;
106110 scale [ d ] = 1.0 ;
107111 }
108112
@@ -126,6 +130,22 @@ public static OmeNgffMultiScaleMetadata[] createOMEZarrMetadata(
126130 return meta ;
127131 }
128132
133+ // TODO: this is inaccurate, we should actually estimate it from the final transformn that is applied
134+ public static double [] getResolutionS0 ( final VoxelDimensions vx , final double anisoF , final double downsamplingF )
135+ {
136+ final double [] resolutionS0 = vx .dimensionsAsDoubleArray ();
137+
138+ // not preserving anisotropy
139+ if ( Double .isNaN ( anisoF ) )
140+ resolutionS0 [ 2 ] = resolutionS0 [ 0 ];
141+
142+ // downsampling
143+ if ( !Double .isNaN ( downsamplingF ) )
144+ Arrays .setAll ( resolutionS0 , d -> resolutionS0 [ d ] * downsamplingF );
145+
146+ return resolutionS0 ;
147+ }
148+
129149 public static void loadOMEZarr ( final N5Reader n5 , final String dataset )
130150 {
131151 //org.janelia.saalfeldlab.n5.universe.metadata.ome.ngff.v04.OmeNgffMetadata
@@ -151,8 +171,19 @@ public static void loadOMEZarr( final N5Reader n5, final String dataset )
151171 }
152172 }
153173
154- public static void main ( String [] args )
174+ public static void main ( String [] args ) throws URISyntaxException
155175 {
176+ final URI uri2 = URITools .toURI ("https://keller-data.int.janelia.org/s12a/samples_for_stitching/Live%20zebra%20fish%20stitched/Live%20zebra%20plane%206/dataset.n5" );///setup0/time;t0/");
177+ System .out .println ( uri2 .toString () );
178+
179+ //FileSystemKeyValueAccess kva = new FileSystemKeyValueAccess( FileSystems.getDefault() );
180+
181+ String s = uri2 .toString ();
182+ N5Factory f = new N5Factory ();
183+ N5Reader r = f .openFileSystemReader ( s );
184+ r .close ();
185+ System .exit ( 0 );
186+
156187 //final URI uri = URITools.toURI( "https://storage.googleapis.com/jax-public-ngff/KOMP/adult_lacZ/ndp/Moxd1/23420_K35061_FGut.zarr/0/" );
157188 //final String dataset = "/";
158189
0 commit comments