diff --git a/src/main/java/net/preibisch/mvrecon/fiji/plugin/PSF_Assign.java b/src/main/java/net/preibisch/mvrecon/fiji/plugin/PSF_Assign.java index 68d5f245a..f579ee5ca 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/plugin/PSF_Assign.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/plugin/PSF_Assign.java @@ -140,7 +140,7 @@ public static boolean assign( for ( final ViewId viewId : viewIds ) { IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Assigning '" + file + "' to " + Group.pvid( viewId ) ); - spimData.getPointSpreadFunctions().addPSF( viewId, new PointSpreadFunction( spimData.getBasePath(), file ) ); + spimData.getPointSpreadFunctions().addPSF( viewId, new PointSpreadFunction( spimData.getBasePathURI(), file ) ); if ( saveXml ) new XmlIoSpimData2().saveWithFilename( spimData, xmlFileName ); } @@ -181,7 +181,7 @@ else if ( assignType == 1 ) // "Assign new PSF to all selected views" } else { - spimData.getPointSpreadFunctions().addPSF( viewId, new PointSpreadFunction( spimData.getBasePath(), localFileName ) ); + spimData.getPointSpreadFunctions().addPSF( viewId, new PointSpreadFunction( spimData.getBasePathURI(), localFileName ) ); if ( saveXml ) new XmlIoSpimData2().saveWithFilename( spimData, xmlFileName ); } @@ -299,7 +299,7 @@ else if ( assignType == 2 ) // "Duplicate PSFs from other channel" IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Assigning '" + file + "' from " + Group.pvid( corresponding ) + " to " + Group.pvid( viewId ) ); - spimData.getPointSpreadFunctions().addPSF( viewId, new PointSpreadFunction( spimData.getBasePath(), file ) ); + spimData.getPointSpreadFunctions().addPSF( viewId, new PointSpreadFunction( spimData.getBasePathURI(), file ) ); if ( saveXml ) new XmlIoSpimData2().saveWithFilename( spimData, xmlFileName ); @@ -389,7 +389,7 @@ else if ( assignType == 3 ) // "Duplicate PSFs from other timepoint" IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Assigning '" + file + "' from " + Group.pvid( corresponding ) + " to " + Group.pvid( viewId ) ); - spimData.getPointSpreadFunctions().addPSF( viewId, new PointSpreadFunction( spimData.getBasePath(), file ) ); + spimData.getPointSpreadFunctions().addPSF( viewId, new PointSpreadFunction( spimData.getBasePathURI(), file ) ); if ( saveXml ) new XmlIoSpimData2().saveWithFilename( spimData, xmlFileName ); diff --git a/src/main/java/net/preibisch/mvrecon/fiji/plugin/PSF_Average.java b/src/main/java/net/preibisch/mvrecon/fiji/plugin/PSF_Average.java index 7ead0411c..8f0abd2fe 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/plugin/PSF_Average.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/plugin/PSF_Average.java @@ -124,7 +124,7 @@ public static boolean average( } else { - spimData.getPointSpreadFunctions().addPSF( viewId, new PointSpreadFunction( spimData.getBasePath(), localFileName ) ); + spimData.getPointSpreadFunctions().addPSF( viewId, new PointSpreadFunction( spimData.getBasePathURI(), localFileName ) ); } IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Assigning '" + localFileName + "' to " + Group.pvid( viewId ) ); diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/XmlIoSpimData2.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/XmlIoSpimData2.java index 6aa77f0ba..7dfe05723 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/XmlIoSpimData2.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/XmlIoSpimData2.java @@ -221,7 +221,7 @@ public SpimData2 fromXml( final Element root, final URI xmlFile ) throws SpimDat if ( elem == null ) psfs = new PointSpreadFunctions(); else - psfs = xmlPointSpreadFunctions.fromXml( elem, spimData.getBasePath() ); + psfs = xmlPointSpreadFunctions.fromXml( elem, spimData.getBasePathURI() ); spimData.setPointSpreadFunctions( psfs ); final StitchingResults stitchingResults; diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/explorer/popup/PointSpreadFunctionsPopup.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/explorer/popup/PointSpreadFunctionsPopup.java index 15cc29420..2a0d1b6ad 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/explorer/popup/PointSpreadFunctionsPopup.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/explorer/popup/PointSpreadFunctionsPopup.java @@ -295,7 +295,7 @@ public void run() for ( final ViewId viewId : views ) { IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Assigning '" + file + "' to " + Group.pvid( viewId ) ); - spimData.getPointSpreadFunctions().addPSF( viewId, new PointSpreadFunction( spimData.getBasePath(), file ) ); + spimData.getPointSpreadFunctions().addPSF( viewId, new PointSpreadFunction( spimData.getBasePathURI(), file ) ); } panel.updateContent(); // update panel diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/pointspreadfunctions/PointSpreadFunction.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/pointspreadfunctions/PointSpreadFunction.java index 470bd7151..621e9fb59 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/pointspreadfunctions/PointSpreadFunction.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/pointspreadfunctions/PointSpreadFunction.java @@ -23,6 +23,7 @@ package net.preibisch.mvrecon.fiji.spimdata.pointspreadfunctions; import java.io.File; +import java.net.URI; import ij.ImagePlus; import ij.io.FileSaver; @@ -35,17 +36,18 @@ import net.preibisch.mvrecon.fiji.spimdata.SpimData2; import net.preibisch.mvrecon.process.export.DisplayImage; import net.preibisch.mvrecon.process.fusion.FusionTools; +import util.URITools; public class PointSpreadFunction { private final static String subDir = "psf"; - private final File xmlBasePath; + private final URI xmlBasePath; private final String file; private Img< FloatType > img; private boolean modified; - public PointSpreadFunction( final File xmlBasePath, final String file, final Img< FloatType > img ) + public PointSpreadFunction( final URI xmlBasePath, final String file, final Img< FloatType > img ) { this.xmlBasePath = xmlBasePath; this.file = file; @@ -58,10 +60,10 @@ public PointSpreadFunction( final File xmlBasePath, final String file, final Img public PointSpreadFunction( final SpimData2 spimData, final ViewId viewId, final Img< FloatType > img ) { - this( spimData.getBasePath(), PointSpreadFunction.createPSFFileName( viewId ), img ); + this( spimData.getBasePathURI(), PointSpreadFunction.createPSFFileName( viewId ), img ); } - public PointSpreadFunction( final File xmlBasePath, final String file ) + public PointSpreadFunction( final URI xmlBasePath, final String file ) { this( xmlBasePath, file, null ); this.modified = false; @@ -80,20 +82,19 @@ public void setPSF( final Img< FloatType > img ) public Img< FloatType > getPSFCopy() { if ( img == null ) - img = IOFunctions.openAs32Bit( new File( new File( xmlBasePath, subDir ), file ), new ArrayImgFactory<>() ); + img = IOFunctions.openAs32Bit( new File( URITools.appendName( xmlBasePath, subDir ), file ), new ArrayImgFactory<>( new FloatType() ) ); return img.copy(); } // this is required for CUDA stuff - @SuppressWarnings("unchecked") public ArrayImg< FloatType, ? > getPSFCopyArrayImg() { final ArrayImg< FloatType, ? > arrayImg; if ( img == null ) { - img = arrayImg = IOFunctions.openAs32BitArrayImg( new File( new File( xmlBasePath, subDir ), file ) ); + img = arrayImg = IOFunctions.openAs32BitArrayImg( new File( URITools.appendName( xmlBasePath, subDir ), file ) ); } else if ( ArrayImg.class.isInstance( img ) ) { @@ -104,7 +105,7 @@ else if ( ArrayImg.class.isInstance( img ) ) final long[] size = new long[ img.numDimensions() ]; img.dimensions( size ); - arrayImg = new ArrayImgFactory< FloatType >().create( size, new FloatType() ); + arrayImg = new ArrayImgFactory<>(new FloatType()).create( size ); FusionTools.copyImg( img, arrayImg, null ); } @@ -117,7 +118,7 @@ public boolean save() if ( img == null ) return false; - final File dir = new File( xmlBasePath, subDir ); + final File dir = new File( URITools.appendName( xmlBasePath, subDir ) ); if ( !dir.exists() ) if ( !dir.mkdir() ) diff --git a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/pointspreadfunctions/XmlIoPointSpreadFunctions.java b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/pointspreadfunctions/XmlIoPointSpreadFunctions.java index de5d2432d..c21b19995 100644 --- a/src/main/java/net/preibisch/mvrecon/fiji/spimdata/pointspreadfunctions/XmlIoPointSpreadFunctions.java +++ b/src/main/java/net/preibisch/mvrecon/fiji/spimdata/pointspreadfunctions/XmlIoPointSpreadFunctions.java @@ -29,6 +29,7 @@ import static net.preibisch.mvrecon.fiji.spimdata.pointspreadfunctions.XmlKeysPointSpreadFunctions.PSF_TIMEPOINT_ATTRIBUTE_NAME; import java.io.File; +import java.net.URI; import java.util.ArrayList; import java.util.Collections; @@ -62,7 +63,7 @@ public Element toXml( final PointSpreadFunctions pointSpreadFunctions ) return elem; } - public PointSpreadFunctions fromXml( final Element allPSFs, final File basePath ) throws SpimDataException + public PointSpreadFunctions fromXml( final Element allPSFs, final URI basePathURI ) throws SpimDataException { final PointSpreadFunctions pointSpreadFunctions = super.fromXml( allPSFs ); @@ -73,7 +74,7 @@ public PointSpreadFunctions fromXml( final Element allPSFs, final File basePath final String file = psfElement.getChildText( PSF_FILE_TAG ); - pointSpreadFunctions.addPSF( new ViewId( tpId, vsId ), new PointSpreadFunction( basePath, file ) ); + pointSpreadFunctions.addPSF( new ViewId( tpId, vsId ), new PointSpreadFunction( basePathURI, file ) ); } return pointSpreadFunctions;