From 86d6ed973967aab88fc102d62d05ad78797fb72a Mon Sep 17 00:00:00 2001 From: Stephan Preibisch Date: Mon, 16 Sep 2024 14:59:47 -0400 Subject: [PATCH] switch to N5CloudImageLoader throughout --- pom.xml | 5 +++++ .../net/preibisch/mvrecon/fiji/plugin/XMLSaveAs.java | 11 ++++++++++- .../mvrecon/fiji/plugin/resave/Resave_N5Api.java | 5 ++++- .../mvrecon/process/n5api/SpimData2Tools.java | 10 ++++++++-- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index d2bbafda..d934fc78 100644 --- a/pom.xml +++ b/pom.xml @@ -138,6 +138,11 @@ like Selective Plane Illumination Microscopy (SPIM) Data. sc.fiji bigdataviewer-core + + org.bigdataviewer + bigdataviewer-n5 + 1.0.0 + diff --git a/src/main/java/net/preibisch/mvrecon/fiji/plugin/XMLSaveAs.java b/src/main/java/net/preibisch/mvrecon/fiji/plugin/XMLSaveAs.java index b9d72727..96e9f19e 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/plugin/XMLSaveAs.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/plugin/XMLSaveAs.java @@ -4,6 +4,8 @@ import java.net.URI; import java.net.URISyntaxException; +import org.bigdataviewer.n5.N5CloudImageLoader; + import bdv.img.hdf5.Hdf5ImageLoader; import bdv.img.n5.N5ImageLoader; import fiji.util.gui.GenericDialogPlus; @@ -81,7 +83,14 @@ public static URI saveAs( final SpimData2 data, final String suggestedFileName ) IOFunctions.println( "New XML: " + newXMLPath ); IOFunctions.println( "New base path: " + newBaseDir ); - if ( N5ImageLoader.class.isInstance( imgLoader ) ) + if ( N5CloudImageLoader.class.isInstance( imgLoader ) ) + { + final URI n5URI = ((N5CloudImageLoader)imgLoader).getN5URI(); + + IOFunctions.println( "Path of cloud N5 (stays in old location): " + n5URI ); + data.getSequenceDescription().setImgLoader( new N5CloudImageLoader( null, n5URI, data.getSequenceDescription() ) ); + } + else if ( N5ImageLoader.class.isInstance( imgLoader ) ) { final URI n5URI = ((N5ImageLoader)imgLoader).getN5URI(); diff --git a/src/main/java/net/preibisch/mvrecon/fiji/plugin/resave/Resave_N5Api.java b/src/main/java/net/preibisch/mvrecon/fiji/plugin/resave/Resave_N5Api.java index 1d96d554..8a228b8f 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/plugin/resave/Resave_N5Api.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/plugin/resave/Resave_N5Api.java @@ -36,6 +36,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; +import org.bigdataviewer.n5.N5CloudImageLoader; import org.janelia.saalfeldlab.n5.Compression; import org.janelia.saalfeldlab.n5.DataType; import org.janelia.saalfeldlab.n5.N5Writer; @@ -264,8 +265,10 @@ public static SpimData2 resaveN5( n5Writer.close(); - if ( format == StorageFormat.N5 ) + if ( format == StorageFormat.N5 && URITools.isFile( n5Params.n5URI )) // local file sdReduced.getSequenceDescription().setImgLoader( new N5ImageLoader( n5Params.n5URI, sdReduced.getSequenceDescription() ) ); + else if ( format == StorageFormat.N5 ) // some cloud location + sdReduced.getSequenceDescription().setImgLoader( new N5CloudImageLoader( null, n5Params.n5URI, sdReduced.getSequenceDescription() ) ); else if ( format == StorageFormat.HDF5 ) sdReduced.getSequenceDescription().setImgLoader( new Hdf5ImageLoader( new File( URITools.removeFilePrefix( n5Params.n5URI ) ), null, sdReduced.getSequenceDescription() ) ); else diff --git a/src/main/java/net/preibisch/mvrecon/process/n5api/SpimData2Tools.java b/src/main/java/net/preibisch/mvrecon/process/n5api/SpimData2Tools.java index a85b9727..a5fb3272 100644 --- a/src/main/java/net/preibisch/mvrecon/process/n5api/SpimData2Tools.java +++ b/src/main/java/net/preibisch/mvrecon/process/n5api/SpimData2Tools.java @@ -16,6 +16,7 @@ import java.util.Map; import java.util.Set; +import org.bigdataviewer.n5.N5CloudImageLoader; import org.janelia.saalfeldlab.n5.Compression; import org.janelia.saalfeldlab.n5.DataType; import org.janelia.saalfeldlab.n5.N5Writer; @@ -208,8 +209,10 @@ public static Pair writeSpimData( final SequenceDescription sequence = new SequenceDescription(timepoints, setups, null); - if ( StorageFormat.N5.equals(storageType) ) + if ( StorageFormat.N5.equals(storageType) && URITools.isFile( n5PathURI )) // local file sequence.setImgLoader( new N5ImageLoader( n5PathURI, sequence) ); + else if ( StorageFormat.N5.equals(storageType) ) // some cloud location + sequence.setImgLoader( new N5CloudImageLoader( null, n5PathURI, sequence) ); else if ( StorageFormat.HDF5.equals(storageType) ) sequence.setImgLoader( new Hdf5ImageLoader( new File( URITools.removeFilePrefix( n5PathURI ) ), null, sequence) ); else @@ -256,8 +259,11 @@ else if ( StorageFormat.HDF5.equals(storageType) ) final ViewRegistrations viewRegistrations = new ViewRegistrations( registrations ); final SequenceDescription sequence = new SequenceDescription(timepoints, setups, null); - if ( StorageFormat.N5.equals(storageType) ) + + if ( StorageFormat.N5.equals(storageType) && URITools.isFile( n5PathURI )) // local file sequence.setImgLoader( new N5ImageLoader( n5PathURI, sequence) ); + else if ( StorageFormat.N5.equals(storageType) ) // some cloud location + sequence.setImgLoader( new N5CloudImageLoader( null, n5PathURI, sequence) ); else if ( StorageFormat.HDF5.equals(storageType) ) sequence.setImgLoader( new Hdf5ImageLoader( new File( URITools.removeFilePrefix( n5PathURI ) ), null, sequence) ); else