Skip to content

Commit e2938c0

Browse files
committed
addressing comments from the review
1 parent 83be3af commit e2938c0

2 files changed

Lines changed: 30 additions & 14 deletions

File tree

src/main/java/net/preibisch/mvrecon/fiji/datasetmanager/OMEZARR.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,6 @@ public SpimData2 createDataset( final String xmlFileName )
262262

263263
final DatasetAttributes attr = reader.getDatasetAttributes( dataset + "/" + path );
264264

265-
if (attr == null) {
266-
continue;
267-
}
268265
IOFunctions.println( "NumDimensions: " + attr.getNumDimensions() );
269266
IOFunctions.println( "Dimensions: " + Arrays.toString( attr.getDimensions() ) );
270267
IOFunctions.println( "BlockSize: " + Arrays.toString( attr.getBlockSize() ) );

src/main/java/net/preibisch/mvrecon/fiji/spimdata/imgloaders/AllenOMEZarrProperties.java

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@
2323
package net.preibisch.mvrecon.fiji.spimdata.imgloaders;
2424

2525
import java.util.Arrays;
26-
import java.util.HashMap;
2726
import java.util.Map;
27+
import java.util.concurrent.ConcurrentHashMap;
28+
import java.util.concurrent.ConcurrentMap;
2829

2930
import org.janelia.saalfeldlab.n5.DataType;
3031
import org.janelia.saalfeldlab.n5.N5Reader;
3132
import org.janelia.saalfeldlab.n5.universe.metadata.ome.ngff.v04.OmeNgffMultiScaleMetadata;
3233
import org.janelia.saalfeldlab.n5.universe.metadata.ome.ngff.v04.OmeNgffMultiScaleMetadata.OmeNgffDataset;
3334
import org.janelia.saalfeldlab.n5.universe.metadata.ome.ngff.v04.coordinateTransformations.CoordinateTransformation;
3435
import org.janelia.saalfeldlab.n5.universe.metadata.ome.ngff.v04.coordinateTransformations.ScaleCoordinateTransformation;
36+
import org.janelia.saalfeldlab.n5.universe.metadata.ome.ngff.v04.coordinateTransformations.TranslationCoordinateTransformation;
3537

3638
import bdv.img.n5.N5Properties;
3739
import mpicbg.spim.data.generic.sequence.AbstractSequenceDescription;
@@ -49,7 +51,8 @@ public class AllenOMEZarrProperties implements N5Properties
4951
// N5Properties.getDatasetPath should require an N5Reader so that the dataset path could always be retrieved correctly (e.g., "s0", "s1", "s2" or "0", "1", "2")
5052
// To work around this problem for now, first time we retrieve the view setup we cache it so that next time
5153
// the dataset path is needed - we use the cached value.
52-
private final Map< ViewId, OmeNgffMultiScaleMetadata > viewIdToOmeMetadata = new HashMap<>();
54+
// TODO: Remove this and the method that populates it, once the signature for N5Properties.getDatasetPath was updated to use the N5 Reader
55+
private final ConcurrentMap< ViewId, OmeNgffMultiScaleMetadata > viewIdToOmeMetadata = new ConcurrentHashMap<>();
5356

5457
public AllenOMEZarrProperties(
5558
final AbstractSequenceDescription< ?, ?, ? > sequenceDescription,
@@ -143,6 +146,25 @@ private static double[][] getMipMapResolutions( final AllenOMEZarrProperties n5p
143146
mipMapResolutions[ i ][ d ] = Math.round(mipMapResolutions[ i ][ d ]*10000)/10000d; // round to the 5th digit
144147
}
145148
}
149+
if ( c instanceof TranslationCoordinateTransformation)
150+
{
151+
final TranslationCoordinateTransformation t = ( TranslationCoordinateTransformation ) c;
152+
153+
if (firstScale == null) {
154+
throw new IllegalStateException("Expected first scale to be set before the translation for level " + i + " dataset is processed");
155+
}
156+
157+
for ( int d = 0; d < mipMapResolutions[ i ].length; ++d )
158+
{
159+
// at this point firstScale should be available
160+
double pxTranslation = t.getTranslation()[ d ] / firstScale[ d ];
161+
double pxTranslationCorrection = (pxTranslation + 0.5) / mipMapResolutions[i][d] - 0.5;
162+
if (Math.abs(pxTranslationCorrection) >= 0.5) {
163+
System.out.printf("Pixel translation[%d][%d]=%f (=%fpx) and the pixel correction %f is more than 0.5px\n",
164+
i, d, t.getTranslation()[ d ], pxTranslation, pxTranslationCorrection);
165+
}
166+
}
167+
}
146168
}
147169
}
148170

@@ -153,17 +175,14 @@ private String getMultiscaleDatasetPathOrDefault( N5Reader n5, int timepointId,
153175
{
154176
OmeNgffMultiScaleMetadata omeNgffMultiScaleMetadata = getViewSetupMultiscaleMetadata(n5, timepointId, setupId);
155177

156-
String viewSetupPath = getPath( setupId, timepointId );
157-
String datasetPath;
158-
159-
if ( omeNgffMultiScaleMetadata != null ) {
160-
// get the first scale path from the metadata
161-
datasetPath = omeNgffMultiScaleMetadata.datasets[level].path;
162-
} else {
163-
// use the default level value
164-
datasetPath = String.valueOf( level );
178+
if (omeNgffMultiScaleMetadata == null) {
179+
throw new IllegalStateException("OME multiscale metadata could not be cached for (tp, setup) = (" +
180+
timepointId + "," + setupId + ") - current N5Reader is " + n5);
165181
}
166182

183+
String viewSetupPath = getPath( setupId, timepointId );
184+
// get the first scale path from the metadata
185+
String datasetPath = omeNgffMultiScaleMetadata.datasets[level].path;
167186
return String.format( "%s/%s", viewSetupPath, datasetPath);
168187
}
169188

0 commit comments

Comments
 (0)