diff --git a/src/main/java/org/janelia/saalfeldlab/paintera/data/n5/CommitCanvasN5.java b/src/main/java/org/janelia/saalfeldlab/paintera/data/n5/CommitCanvasN5.java index 0ed3b9007..be5e1743b 100644 --- a/src/main/java/org/janelia/saalfeldlab/paintera/data/n5/CommitCanvasN5.java +++ b/src/main/java/org/janelia/saalfeldlab/paintera/data/n5/CommitCanvasN5.java @@ -37,12 +37,7 @@ import org.janelia.saalfeldlab.labels.blocks.LabelBlockLookupKey; import org.janelia.saalfeldlab.labels.blocks.n5.IsRelativeToContainer; import org.janelia.saalfeldlab.labels.downsample.WinnerTakesAll; -import org.janelia.saalfeldlab.n5.ByteArrayDataBlock; -import org.janelia.saalfeldlab.n5.DataBlock; -import org.janelia.saalfeldlab.n5.DatasetAttributes; -import org.janelia.saalfeldlab.n5.LongArrayDataBlock; -import org.janelia.saalfeldlab.n5.N5Reader; -import org.janelia.saalfeldlab.n5.N5Writer; +import org.janelia.saalfeldlab.n5.*; import org.janelia.saalfeldlab.n5.imglib2.N5LabelMultisets; import org.janelia.saalfeldlab.n5.imglib2.N5Utils; import org.janelia.saalfeldlab.paintera.data.mask.persist.PersistCanvas; @@ -57,7 +52,6 @@ import java.io.IOException; import java.lang.invoke.MethodHandles; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -136,7 +130,8 @@ public void updateLabelBlockLookup(final List> blockDi LOG.debug("Found scale datasets {}", (Object)scaleUniqueLabels); for (int level = 0; level < scaleUniqueLabels.length; ++level) { - final DatasetSpec datasetUniqueLabels = DatasetSpec.of(n5Writer, Paths.get(uniqueLabelsPath, scaleUniqueLabels[level]).toString()); + final String uniqueLabelScalePath = N5URI.normalizeGroupPath(uniqueLabelsPath + n5Writer.getGroupSeparator() + scaleUniqueLabels[level]); + final DatasetSpec datasetUniqueLabels = DatasetSpec.of(n5Writer, uniqueLabelScalePath); final TLongObjectMap removedById = new TLongObjectHashMap<>(); final TLongObjectMap addedById = new TLongObjectHashMap<>(); final TLongObjectMap blockDiffs = blockDiffsByLevel.get(level); @@ -262,8 +257,8 @@ public List> persistCanvas(final CachedCellImg blockDiffsAt = new TLongObjectHashMap<>(); blockDiffs.add(blockDiffsAt); - final DatasetSpec targetDataset = DatasetSpec.of(n5Writer, Paths.get(dataset, scaleDatasets[level]).toString()); - final DatasetSpec previousDataset = DatasetSpec.of(n5Writer, Paths.get(dataset, scaleDatasets[level - 1]).toString()); + final DatasetSpec targetDataset = DatasetSpec.of(n5Writer, N5URI.normalizeGroupPath(dataset + n5Writer.getGroupSeparator() + scaleDatasets[level])); + final DatasetSpec previousDataset = DatasetSpec.of(n5Writer, N5URI.normalizeGroupPath(dataset + n5Writer.getGroupSeparator() + scaleDatasets[level - 1])); final double[] targetDownsamplingFactors = N5Helpers.getDownsamplingFactors(n5Writer, targetDataset.dataset); final double[] previousDownsamplingFactors = N5Helpers.getDownsamplingFactors(n5Writer, previousDataset.dataset); diff --git a/src/main/java/org/janelia/saalfeldlab/util/n5/N5Data.java b/src/main/java/org/janelia/saalfeldlab/util/n5/N5Data.java index 086577340..37749fbdb 100644 --- a/src/main/java/org/janelia/saalfeldlab/util/n5/N5Data.java +++ b/src/main/java/org/janelia/saalfeldlab/util/n5/N5Data.java @@ -380,7 +380,7 @@ ImagesWithTransform[] openRawMultiscale( final double[] initialDonwsamplingFactors = N5Helpers.getDownsamplingFactors( reader, - Paths.get(dataset, scaleDatasets[0]).toString() + N5URI.normalizeGroupPath(dataset + reader.getGroupSeparator() + scaleDatasets[0]) ); LOG.debug("Initial transform={}", transform); final ExecutorService es = Executors.newFixedThreadPool( @@ -393,7 +393,7 @@ ImagesWithTransform[] openRawMultiscale( final int fScale = scale; futures.add(es.submit(ThrowingSupplier.unchecked(() -> { LOG.debug("Populating scale level {}", fScale); - final String scaleDataset = Paths.get(dataset, scaleDatasets[fScale]).toString(); + final String scaleDataset = N5URI.normalizeGroupPath(dataset + reader.getGroupSeparator() + scaleDatasets[fScale]); imagesWithInvalidate[fScale] = openRaw(reader, scaleDataset, transform.copy(), queue, priority); final double[] downsamplingFactors = N5Helpers.getDownsamplingFactors(reader, scaleDataset); LOG.debug("Read downsampling factors: {}", Arrays.toString(downsamplingFactors)); @@ -685,7 +685,7 @@ public static ImagesWithTransform[ final double[] initialDonwsamplingFactors = N5Helpers.getDownsamplingFactors( reader, - Paths.get(dataset, scaleDatasets[0]).toString()); + N5URI.normalizeGroupPath(dataset + reader.getGroupSeparator() + scaleDatasets[0])); final ExecutorService es = Executors.newFixedThreadPool( scaleDatasets.length, new NamedThreadFactory("populate-mipmap-scales-%d", true)); @@ -695,7 +695,7 @@ public static ImagesWithTransform[ final int fScale = scale; futures.add(es.submit(ThrowingSupplier.unchecked(() -> { LOG.debug("Populating scale level {}", fScale); - final String scaleDataset = Paths.get(dataset, scaleDatasets[fScale]).toString(); + final String scaleDataset = N5URI.normalizeGroupPath(dataset + reader.getGroupSeparator() + scaleDatasets[fScale]); imagesWithInvalidate[fScale] = openLabelMultiset(reader, scaleDataset, transform.copy(), queue, priority); final double[] downsamplingFactors = N5Helpers.getDownsamplingFactors(reader, scaleDataset); LOG.debug("Read downsampling factors: {}", Arrays.toString(downsamplingFactors)); diff --git a/src/test/java/org/janelia/saalfeldlab/paintera/data/n5/CommitCanvasN5Test.java b/src/test/java/org/janelia/saalfeldlab/paintera/data/n5/CommitCanvasN5Test.java index 78b9e3029..05e73c8a7 100644 --- a/src/test/java/org/janelia/saalfeldlab/paintera/data/n5/CommitCanvasN5Test.java +++ b/src/test/java/org/janelia/saalfeldlab/paintera/data/n5/CommitCanvasN5Test.java @@ -352,10 +352,11 @@ private static void testPainteraData( testCanvasPersistance(container, dataset, s0, canvas, openLabels, asserts); // test highest level block lookups - final String uniqueBlock0 = String.join("/", dataset, "unique-labels", "s0"); + final String groupSeparator = container.getReader().getGroupSeparator(); + final String uniqueBlock0Group = N5URI.normalizeGroupPath(String.join(groupSeparator, dataset, "unique-labels","s0")); final Path mappingPattern = Paths.get(container.getUri().getPath(), dataset, "label-to-block-mapping", "s%d", "%d"); final Path mapping0 = Paths.get(container.getUri().getPath(), dataset, "label-to-block-mapping", "s0"); - final DatasetAttributes uniqueBlockAttributes = writer.getDatasetAttributes(uniqueBlock0); + final DatasetAttributes uniqueBlockAttributes = writer.getDatasetAttributes(uniqueBlock0Group); final List blocks = Grids.collectAllContainedIntervals(dims, blockSize); final TLongObjectMap labelToBLockMapping = new TLongObjectHashMap<>(); for (final Interval block : blocks) { @@ -375,7 +376,7 @@ private static void testPainteraData( } }); - final DataBlock uniqueBlock = writer.readBlock(uniqueBlock0, uniqueBlockAttributes, blockPos); + final DataBlock uniqueBlock = writer.readBlock(uniqueBlock0Group, uniqueBlockAttributes, blockPos); Assert.assertEquals(labels, new TLongHashSet((long[])uniqueBlock.getData())); }