diff --git a/src/main/java/bdv/ij/BigDataBrowserPlugIn.java b/src/main/java/bdv/ij/BigDataBrowserPlugIn.java index c1102e55177aac812801e8bd35084ae9ca26be3d..6907f3c46548f5f81a60cd64a1e8700ffacf0593 100644 --- a/src/main/java/bdv/ij/BigDataBrowserPlugIn.java +++ b/src/main/java/bdv/ij/BigDataBrowserPlugIn.java @@ -1,15 +1,12 @@ package bdv.ij; -import ij.IJ; -import ij.ImageJ; -import ij.plugin.PlugIn; - import java.awt.Component; import java.awt.Dimension; import java.awt.Font; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.image.BufferedImage; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -27,23 +24,26 @@ import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JScrollPane; -import mpicbg.spim.data.SpimDataException; - import org.apache.commons.lang.StringUtils; +import com.google.gson.stream.JsonReader; + import bdv.BigDataViewer; import bdv.ij.util.ProgressWriterIJ; - -import com.google.gson.stream.JsonReader; +import bdv.viewer.ViewerOptions; +import ij.IJ; +import ij.ImageJ; +import ij.plugin.PlugIn; +import mpicbg.spim.data.SpimDataException; /** * @author HongKee Moon <moon@mpi-cbg.de> */ public class BigDataBrowserPlugIn implements PlugIn { - private final Map< String, ImageIcon > imageMap = new HashMap< String, ImageIcon >(); + private final Map< String, ImageIcon > imageMap = new HashMap<>(); - private final Map< String, String > datasetUrlMap = new HashMap< String, String >(); + private final Map< String, String > datasetUrlMap = new HashMap<>(); public static String serverUrl = "http://"; @@ -68,7 +68,7 @@ public class BigDataBrowserPlugIn implements PlugIn serverUrl = remoteUrl.toString(); - final ArrayList< String > nameList = new ArrayList< String >(); + final ArrayList< String > nameList = new ArrayList<>(); try { getDatasetList( serverUrl, nameList ); diff --git a/src/main/java/bdv/ij/ExportImagePlusPlugIn.java b/src/main/java/bdv/ij/ExportImagePlusPlugIn.java index 5300891c06769dc56c8165294ccd985113091050..38935e9b528c74a2671b9c8fe4453ba5d6234aa9 100644 --- a/src/main/java/bdv/ij/ExportImagePlusPlugIn.java +++ b/src/main/java/bdv/ij/ExportImagePlusPlugIn.java @@ -1,14 +1,5 @@ package bdv.ij; -import fiji.util.gui.GenericDialogPlus; -import ij.IJ; -import ij.ImageJ; -import ij.ImagePlus; -import ij.WindowManager; -import ij.gui.DialogListener; -import ij.gui.GenericDialog; -import ij.plugin.PlugIn; - import java.awt.AWTEvent; import java.awt.Checkbox; import java.awt.Choice; @@ -19,16 +10,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import mpicbg.spim.data.generic.sequence.BasicViewSetup; -import mpicbg.spim.data.registration.ViewRegistration; -import mpicbg.spim.data.registration.ViewRegistrations; -import mpicbg.spim.data.sequence.Channel; -import mpicbg.spim.data.sequence.FinalVoxelDimensions; -import mpicbg.spim.data.sequence.TimePoint; -import mpicbg.spim.data.sequence.TimePoints; -import net.imglib2.FinalDimensions; -import net.imglib2.RandomAccessibleInterval; -import net.imglib2.realtransform.AffineTransform3D; import bdv.export.ExportMipmapInfo; import bdv.export.ProgressWriter; import bdv.export.ProposeMipmaps; @@ -45,6 +26,24 @@ import bdv.img.hdf5.Partition; import bdv.spimdata.SequenceDescriptionMinimal; import bdv.spimdata.SpimDataMinimal; import bdv.spimdata.XmlIoSpimDataMinimal; +import fiji.util.gui.GenericDialogPlus; +import ij.IJ; +import ij.ImageJ; +import ij.ImagePlus; +import ij.WindowManager; +import ij.gui.DialogListener; +import ij.gui.GenericDialog; +import ij.plugin.PlugIn; +import mpicbg.spim.data.generic.sequence.BasicViewSetup; +import mpicbg.spim.data.registration.ViewRegistration; +import mpicbg.spim.data.registration.ViewRegistrations; +import mpicbg.spim.data.sequence.Channel; +import mpicbg.spim.data.sequence.FinalVoxelDimensions; +import mpicbg.spim.data.sequence.TimePoint; +import mpicbg.spim.data.sequence.TimePoints; +import net.imglib2.FinalDimensions; +import net.imglib2.RandomAccessibleInterval; +import net.imglib2.realtransform.AffineTransform3D; /** * ImageJ plugin to export the current image to xml/hdf5. @@ -140,20 +139,20 @@ public class ExportImagePlusPlugIn implements PlugIn sourceTransform.set( pw, 0, 0, 0, 0, ph, 0, 0, 0, 0, pd, 0 ); // write hdf5 - final HashMap< Integer, BasicViewSetup > setups = new HashMap< Integer, BasicViewSetup >( numSetups ); + final HashMap< Integer, BasicViewSetup > setups = new HashMap<>( numSetups ); for ( int s = 0; s < numSetups; ++s ) { final BasicViewSetup setup = new BasicViewSetup( s, String.format( "channel %d", s + 1 ), size, voxelSize ); setup.setAttribute( new Channel( s + 1 ) ); setups.put( s, setup ); } - final ArrayList< TimePoint > timepoints = new ArrayList< TimePoint >( numTimepoints ); + final ArrayList< TimePoint > timepoints = new ArrayList<>( numTimepoints ); for ( int t = 0; t < numTimepoints; ++t ) timepoints.add( new TimePoint( t ) ); final SequenceDescriptionMinimal seq = new SequenceDescriptionMinimal( new TimePoints( timepoints ), setups, imgLoader, null ); Map< Integer, ExportMipmapInfo > perSetupExportMipmapInfo; - perSetupExportMipmapInfo = new HashMap< Integer, ExportMipmapInfo >(); + perSetupExportMipmapInfo = new HashMap<>(); final ExportMipmapInfo mipmapInfo = new ExportMipmapInfo( params.resolutions, params.subdivisions ); for ( final BasicViewSetup setup : seq.getViewSetupsOrdered() ) perSetupExportMipmapInfo.put( setup.getId(), mipmapInfo ); @@ -235,7 +234,7 @@ public class ExportImagePlusPlugIn implements PlugIn final Hdf5ImageLoader hdf5Loader = new Hdf5ImageLoader( params.hdf5File, partitions, null, false ); final SequenceDescriptionMinimal seqh5 = new SequenceDescriptionMinimal( seq, hdf5Loader ); - final ArrayList< ViewRegistration > registrations = new ArrayList< ViewRegistration >(); + final ArrayList< ViewRegistration > registrations = new ArrayList<>(); for ( int t = 0; t < numTimepoints; ++t ) for ( int s = 0; s < numSetups; ++s ) registrations.add( new ViewRegistration( t, s, sourceTransform ) ); diff --git a/src/main/java/bdv/ij/ExportSpimFusionPlugIn.java b/src/main/java/bdv/ij/ExportSpimFusionPlugIn.java index ac005f0722a6824377d164cdaf376b88f212cabe..742f2588181214b68006b2d316de81bcbab16102 100644 --- a/src/main/java/bdv/ij/ExportSpimFusionPlugIn.java +++ b/src/main/java/bdv/ij/ExportSpimFusionPlugIn.java @@ -1,14 +1,5 @@ package bdv.ij; -import fiji.plugin.Bead_Registration; -import fiji.plugin.Multi_View_Fusion; -import fiji.util.gui.GenericDialogPlus; -import ij.IJ; -import ij.ImagePlus; -import ij.gui.DialogListener; -import ij.gui.GenericDialog; -import ij.plugin.PlugIn; - import java.awt.AWTEvent; import java.awt.Checkbox; import java.awt.TextField; @@ -26,6 +17,31 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import bdv.export.ExportMipmapInfo; +import bdv.export.ProgressWriter; +import bdv.export.ProposeMipmaps; +import bdv.export.SubTaskProgressWriter; +import bdv.export.WriteSequenceToHdf5; +import bdv.ij.export.FusionResult; +import bdv.ij.export.SpimRegistrationSequence; +import bdv.ij.export.ViewSetupWrapper; +import bdv.ij.util.PluginHelper; +import bdv.ij.util.ProgressWriterIJ; +import bdv.img.hdf5.Hdf5ImageLoader; +import bdv.img.hdf5.MipmapInfo; +import bdv.img.hdf5.Partition; +import bdv.img.hdf5.Util; +import bdv.spimdata.SequenceDescriptionMinimal; +import bdv.spimdata.SpimDataMinimal; +import bdv.spimdata.XmlIoSpimDataMinimal; +import fiji.plugin.Bead_Registration; +import fiji.plugin.Multi_View_Fusion; +import fiji.util.gui.GenericDialogPlus; +import ij.IJ; +import ij.ImagePlus; +import ij.gui.DialogListener; +import ij.gui.GenericDialog; +import ij.plugin.PlugIn; import mpicbg.spim.data.SpimDataException; import mpicbg.spim.data.generic.sequence.BasicImgLoader; import mpicbg.spim.data.generic.sequence.BasicSetupImgLoader; @@ -48,23 +64,6 @@ import net.imglib2.realtransform.AffineTransform3D; import net.imglib2.util.Pair; import net.imglib2.util.ValuePair; import spimopener.SPIMExperiment; -import bdv.export.ExportMipmapInfo; -import bdv.export.ProgressWriter; -import bdv.export.ProposeMipmaps; -import bdv.export.SubTaskProgressWriter; -import bdv.export.WriteSequenceToHdf5; -import bdv.ij.export.FusionResult; -import bdv.ij.export.SpimRegistrationSequence; -import bdv.ij.export.ViewSetupWrapper; -import bdv.ij.util.PluginHelper; -import bdv.ij.util.ProgressWriterIJ; -import bdv.img.hdf5.Hdf5ImageLoader; -import bdv.img.hdf5.MipmapInfo; -import bdv.img.hdf5.Partition; -import bdv.img.hdf5.Util; -import bdv.spimdata.SequenceDescriptionMinimal; -import bdv.spimdata.SpimDataMinimal; -import bdv.spimdata.XmlIoSpimDataMinimal; public class ExportSpimFusionPlugIn implements PlugIn { @@ -137,27 +136,27 @@ public class ExportSpimFusionPlugIn implements PlugIn final Hdf5ImageLoader existingHdf5Loader = ( Hdf5ImageLoader ) existingSequence.getImgLoader(); // maps every existing timepoint id to itself, needed for partitions - final Map< Integer, Integer > timepointIdentityMap = new HashMap< Integer, Integer >(); + final Map< Integer, Integer > timepointIdentityMap = new HashMap<>(); for ( final TimePoint tp : existingSequence.getTimePoints().getTimePointsOrdered() ) timepointIdentityMap.put( tp.getId(), tp.getId() ); // maps every existing setup id to itself, needed for partitions - final Map< Integer, Integer > setupIdentityMap = new HashMap< Integer, Integer >(); + final Map< Integer, Integer > setupIdentityMap = new HashMap<>(); for ( final int s : existingSequence.getViewSetups().keySet() ) setupIdentityMap.put( s, s ); // create partition list for existing dataset - final ArrayList< Partition > partitions = new ArrayList< Partition >( existingHdf5Loader.getPartitions() ); + final ArrayList< Partition > partitions = new ArrayList<>( existingHdf5Loader.getPartitions() ); final boolean notYetPartitioned = partitions.isEmpty(); if ( notYetPartitioned ) // add one partition for the unpartitioned existing dataset partitions.add( new Partition( existingHdf5Loader.getHdf5File().getAbsolutePath(), timepointIdentityMap, setupIdentityMap ) ); // wrap fused data setups with unused setup ids - final HashSet< Integer > usedSetupIds = new HashSet< Integer >( existingSequence.getViewSetups().keySet() ); - final HashMap< Integer, ViewSetupWrapper > fusionSetups = new HashMap< Integer, ViewSetupWrapper >(); - final HashMap< Integer, BasicSetupImgLoader< ? > > fusionSetupImgLoaders = new HashMap< Integer, BasicSetupImgLoader< ? > >(); - final ArrayList< ViewRegistration > fusionRegistrations = new ArrayList< ViewRegistration >(); + final HashSet< Integer > usedSetupIds = new HashSet<>( existingSequence.getViewSetups().keySet() ); + final HashMap< Integer, ViewSetupWrapper > fusionSetups = new HashMap<>(); + final HashMap< Integer, BasicSetupImgLoader< ? > > fusionSetupImgLoaders = new HashMap<>(); + final ArrayList< ViewRegistration > fusionRegistrations = new ArrayList<>(); for ( final BasicViewSetup s : fusionSeq.getViewSetupsOrdered() ) { int fusionSetupId = 0; @@ -190,7 +189,7 @@ public class ExportSpimFusionPlugIn implements PlugIn fusionReg = new ViewRegistrations( fusionRegistrations ); // add partitions for the fused data and split if desired - final ArrayList< Partition > newPartitions = new ArrayList< Partition >(); + final ArrayList< Partition > newPartitions = new ArrayList<>(); final String xmlFilename = params.seqFile.getAbsolutePath(); final String basename = xmlFilename.endsWith( ".xml" ) ? xmlFilename.substring( 0, xmlFilename.length() - 4 ) : xmlFilename; if ( params.split ) @@ -209,7 +208,7 @@ public class ExportSpimFusionPlugIn implements PlugIn else { final String path = PluginHelper.createNewPartitionFile( basename ).getAbsolutePath(); - final HashMap< Integer, Integer > setupIdSequenceToPartition = new HashMap< Integer, Integer >(); + final HashMap< Integer, Integer > setupIdSequenceToPartition = new HashMap<>(); for ( final BasicViewSetup s : fusionSeq.getViewSetupsOrdered() ) setupIdSequenceToPartition.put( s.getId(), s.getId() ); final Partition partition = new Partition( path, timepointIdentityMap, setupIdSequenceToPartition ); @@ -218,7 +217,7 @@ public class ExportSpimFusionPlugIn implements PlugIn } // create ExportMipmapInfos for the fused data setups - final Map< Integer, ExportMipmapInfo > perSetupExportMipmapInfo = new HashMap< Integer, ExportMipmapInfo >(); + final Map< Integer, ExportMipmapInfo > perSetupExportMipmapInfo = new HashMap<>(); final ExportMipmapInfo mipmapInfo = new ExportMipmapInfo( params.resolutions, params.subdivisions ); for ( final BasicViewSetup setup : fusionSeq.getViewSetupsOrdered() ) perSetupExportMipmapInfo.put( setup.getId(), mipmapInfo ); @@ -240,7 +239,7 @@ public class ExportSpimFusionPlugIn implements PlugIn // TODO: For now the timepoints are just taken from the fusionSeq. // To do it properly, timepoints from existing dataset and fusionSeq should be combined. final TimePoints aggregateTimePoints = fusionSeq.getTimePoints(); - final HashMap< Integer, BasicViewSetup > aggregateSetups = new HashMap< Integer, BasicViewSetup >(); + final HashMap< Integer, BasicViewSetup > aggregateSetups = new HashMap<>(); for ( final BasicViewSetup s : existingSequence.getViewSetupsOrdered() ) aggregateSetups.put( s.getId(), s ); for ( final BasicViewSetup s : fusionSeq.getViewSetupsOrdered() ) @@ -256,7 +255,7 @@ public class ExportSpimFusionPlugIn implements PlugIn aggregateMissingViews ); // create aggregate ExportMipmapInfos - final HashMap< Integer, ExportMipmapInfo > aggregateMipmapInfos = new HashMap< Integer, ExportMipmapInfo >( perSetupExportMipmapInfo ); + final HashMap< Integer, ExportMipmapInfo > aggregateMipmapInfos = new HashMap<>( perSetupExportMipmapInfo ); for ( final BasicViewSetup s : existingSequence.getViewSetupsOrdered() ) { final MipmapInfo info = existingHdf5Loader.getSetupImgLoader( s.getId() ).getMipmapInfo(); @@ -266,7 +265,7 @@ public class ExportSpimFusionPlugIn implements PlugIn } // create aggregate ViewRegistrations - final ArrayList< ViewRegistration > regs = new ArrayList< ViewRegistration >(); + final ArrayList< ViewRegistration > regs = new ArrayList<>(); regs.addAll( existingSpimData.getViewRegistrations().getViewRegistrationsOrdered() ); regs.addAll( fusionReg.getViewRegistrationsOrdered() ); final ViewRegistrations aggregateViewRegistrstions = new ViewRegistrations( regs ); @@ -312,7 +311,7 @@ public class ExportSpimFusionPlugIn implements PlugIn final SequenceDescriptionMinimal desc = fusionResult.getSequenceDescription(); // create ExportMipmapInfos - final Map< Integer, ExportMipmapInfo > perSetupExportMipmapInfo = new HashMap< Integer, ExportMipmapInfo >(); + final Map< Integer, ExportMipmapInfo > perSetupExportMipmapInfo = new HashMap<>(); final ExportMipmapInfo mipmapInfo = new ExportMipmapInfo( params.resolutions, params.subdivisions ); for ( final BasicViewSetup setup : desc.getViewSetupsOrdered() ) perSetupExportMipmapInfo.put( setup.getId(), mipmapInfo ); @@ -571,7 +570,7 @@ public class ExportSpimFusionPlugIn implements PlugIn else { numChannels = 1; - channels = new ArrayList<Integer>(); + channels = new ArrayList<>(); channels.add( 0 ); } @@ -614,7 +613,7 @@ public class ExportSpimFusionPlugIn implements PlugIn // test which registration files are there for each channel // file = new File[ timepoints.length ][ channels.length ][ angles.length ]; - final ArrayList<ArrayList<Integer>> timepoints = new ArrayList<ArrayList<Integer>>(); + final ArrayList<ArrayList<Integer>> timepoints = new ArrayList<>(); int numChoices = 0; conf.zStretching = -1; @@ -987,7 +986,7 @@ public class ExportSpimFusionPlugIn implements PlugIn final Pair< String, Integer > pair = detectPatternAndNumSlices( subdir, someTimepoint ); if ( pair == null ) return null; - return new ValuePair< String, Integer >( "%1$d/" + pair.getA(), pair.getB() ); + return new ValuePair<>( "%1$d/" + pair.getA(), pair.getB() ); } String zeros = ""; @@ -1028,7 +1027,7 @@ public class ExportSpimFusionPlugIn implements PlugIn final int numSlices = files2.length; IOFunctions.println( "detected numSlices = " + numSlices ); - return new ValuePair< String, Integer >( pattern, new Integer( numSlices ) ); + return new ValuePair<>( pattern, new Integer( numSlices ) ); } } return null; diff --git a/src/main/java/bdv/ij/ExportSpimSequencePlugIn.java b/src/main/java/bdv/ij/ExportSpimSequencePlugIn.java index 0ccf6c7574d35d30d02ef3043fbb69c7d57bc17f..39b70b0bbcee418e1a144f448f142c7dce507ffb 100644 --- a/src/main/java/bdv/ij/ExportSpimSequencePlugIn.java +++ b/src/main/java/bdv/ij/ExportSpimSequencePlugIn.java @@ -1,13 +1,5 @@ package bdv.ij; -import fiji.plugin.Bead_Registration; -import fiji.plugin.Multi_View_Fusion; -import fiji.util.gui.GenericDialogPlus; -import ij.IJ; -import ij.gui.DialogListener; -import ij.gui.GenericDialog; -import ij.plugin.PlugIn; - import java.awt.AWTEvent; import java.awt.Checkbox; import java.awt.TextField; @@ -23,13 +15,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import mpicbg.spim.data.generic.sequence.BasicViewSetup; -import mpicbg.spim.data.sequence.TimePoint; -import mpicbg.spim.io.ConfigurationParserException; -import mpicbg.spim.io.IOFunctions; -import mpicbg.spim.io.SPIMConfiguration; -import mpicbg.spim.io.TextFileAccess; -import spimopener.SPIMExperiment; import bdv.export.ExportMipmapInfo; import bdv.export.ProgressWriter; import bdv.export.ProposeMipmaps; @@ -43,6 +28,20 @@ import bdv.img.hdf5.Partition; import bdv.spimdata.SequenceDescriptionMinimal; import bdv.spimdata.SpimDataMinimal; import bdv.spimdata.XmlIoSpimDataMinimal; +import fiji.plugin.Bead_Registration; +import fiji.plugin.Multi_View_Fusion; +import fiji.util.gui.GenericDialogPlus; +import ij.IJ; +import ij.gui.DialogListener; +import ij.gui.GenericDialog; +import ij.plugin.PlugIn; +import mpicbg.spim.data.generic.sequence.BasicViewSetup; +import mpicbg.spim.data.sequence.TimePoint; +import mpicbg.spim.io.ConfigurationParserException; +import mpicbg.spim.io.IOFunctions; +import mpicbg.spim.io.SPIMConfiguration; +import mpicbg.spim.io.TextFileAccess; +import spimopener.SPIMExperiment; public class ExportSpimSequencePlugIn implements PlugIn { @@ -63,7 +62,7 @@ public class ExportSpimSequencePlugIn implements PlugIn Map< Integer, ExportMipmapInfo > perSetupExportMipmapInfo; if ( params.setMipmapManual ) { - perSetupExportMipmapInfo = new HashMap< Integer, ExportMipmapInfo >(); + perSetupExportMipmapInfo = new HashMap<>(); final ExportMipmapInfo mipmapInfo = new ExportMipmapInfo( params.resolutions, params.subdivisions ); for ( final BasicViewSetup setup : desc.getViewSetupsOrdered() ) perSetupExportMipmapInfo.put( setup.getId(), mipmapInfo ); @@ -327,7 +326,7 @@ public class ExportSpimSequencePlugIn implements PlugIn else { numChannels = 1; - channels = new ArrayList< Integer >(); + channels = new ArrayList<>(); channels.add( 0 ); } @@ -372,7 +371,7 @@ public class ExportSpimSequencePlugIn implements PlugIn // test which registration files are there for each channel // file = new File[ timepoints.length ][ channels.length ][ // angles.length ]; - final ArrayList< ArrayList< Integer >> timepoints = new ArrayList< ArrayList< Integer >>(); + final ArrayList< ArrayList< Integer > > timepoints = new ArrayList<>(); int numChoices = 0; conf.zStretching = -1; diff --git a/src/main/java/bdv/ij/OpenImagePlusPlugIn.java b/src/main/java/bdv/ij/OpenImagePlusPlugIn.java index 71608a49143c5c52482bb1191b00ec7f6159de00..9110df3527da5fa531172e4ae11ed70f3674bbb2 100644 --- a/src/main/java/bdv/ij/OpenImagePlusPlugIn.java +++ b/src/main/java/bdv/ij/OpenImagePlusPlugIn.java @@ -148,7 +148,7 @@ public class OpenImagePlusPlugIn implements PlugIn final int numSetups = imp.getNChannels(); // create setups from channels - final HashMap< Integer, BasicViewSetup > setups = new HashMap< Integer, BasicViewSetup >( numSetups ); + final HashMap< Integer, BasicViewSetup > setups = new HashMap<>( numSetups ); for ( int s = 0; s < numSetups; ++s ) { final BasicViewSetup setup = new BasicViewSetup( s, String.format( "channel %d", s + 1 ), size, voxelSize ); @@ -157,7 +157,7 @@ public class OpenImagePlusPlugIn implements PlugIn } // create timepoints - final ArrayList< TimePoint > timepoints = new ArrayList< TimePoint >( numTimepoints ); + final ArrayList< TimePoint > timepoints = new ArrayList<>( numTimepoints ); for ( int t = 0; t < numTimepoints; ++t ) timepoints.add( new TimePoint( t ) ); final SequenceDescriptionMinimal seq = new SequenceDescriptionMinimal( new TimePoints( timepoints ), setups, imgLoader, null ); @@ -165,7 +165,7 @@ public class OpenImagePlusPlugIn implements PlugIn // create ViewRegistrations from the images calibration final AffineTransform3D sourceTransform = new AffineTransform3D(); sourceTransform.set( pw, 0, 0, 0, 0, ph, 0, 0, 0, 0, pd, 0 ); - final ArrayList< ViewRegistration > registrations = new ArrayList< ViewRegistration >(); + final ArrayList< ViewRegistration > registrations = new ArrayList<>(); for ( int t = 0; t < numTimepoints; ++t ) for ( int s = 0; s < numSetups; ++s ) registrations.add( new ViewRegistration( t, s, sourceTransform ) ); diff --git a/src/main/java/bdv/ij/export/FixAbsolutePathsInHdf5Partitions.java b/src/main/java/bdv/ij/export/FixAbsolutePathsInHdf5Partitions.java index a671318f17d1c670eaabcb432f544368d3b12f78..ac4e3d4a77771c4fc5b61fe96e626a984061ae29 100644 --- a/src/main/java/bdv/ij/export/FixAbsolutePathsInHdf5Partitions.java +++ b/src/main/java/bdv/ij/export/FixAbsolutePathsInHdf5Partitions.java @@ -5,8 +5,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; -import mpicbg.spim.data.SpimDataException; -import mpicbg.spim.data.generic.sequence.BasicViewSetup; import bdv.export.ExportMipmapInfo; import bdv.export.WriteSequenceToHdf5; import bdv.img.hdf5.Hdf5ImageLoader; @@ -16,6 +14,8 @@ import bdv.img.hdf5.Util; import bdv.spimdata.SequenceDescriptionMinimal; import bdv.spimdata.SpimDataMinimal; import bdv.spimdata.XmlIoSpimDataMinimal; +import mpicbg.spim.data.SpimDataException; +import mpicbg.spim.data.generic.sequence.BasicViewSetup; /** * Older versions of multi-partition hdf5 export had a bug that caused absolute @@ -38,7 +38,7 @@ public class FixAbsolutePathsInHdf5Partitions final SequenceDescriptionMinimal seq = spimData.getSequenceDescription(); final Hdf5ImageLoader il = ( Hdf5ImageLoader) seq.getImgLoader(); final String outfn = il.getHdf5File().getCanonicalPath() + "FIXED"; - final HashMap< Integer, ExportMipmapInfo > perSetupMipmapInfo = new HashMap< Integer, ExportMipmapInfo >(); + final HashMap< Integer, ExportMipmapInfo > perSetupMipmapInfo = new HashMap<>(); for ( final BasicViewSetup setup : seq.getViewSetupsOrdered() ) { final int setupId = setup.getId(); diff --git a/src/main/java/bdv/ij/export/FusionResult.java b/src/main/java/bdv/ij/export/FusionResult.java index 5475db5bef1ee388b4a3f91b6bd714f1aa207ae1..1a57fa72e76961a78342b424ed1ffd7cac0895a1 100644 --- a/src/main/java/bdv/ij/export/FusionResult.java +++ b/src/main/java/bdv/ij/export/FusionResult.java @@ -6,6 +6,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import bdv.ij.export.imgloader.FusionImageLoader; +import bdv.spimdata.SequenceDescriptionMinimal; import mpicbg.spim.data.generic.base.Entity; import mpicbg.spim.data.generic.sequence.BasicViewSetup; import mpicbg.spim.data.registration.ViewRegistration; @@ -17,9 +19,6 @@ import mpicbg.spim.data.sequence.TimePoints; import mpicbg.spim.data.sequence.VoxelDimensions; import net.imglib2.Dimensions; import net.imglib2.realtransform.AffineTransform3D; -import net.imglib2.type.numeric.real.FloatType; -import bdv.ij.export.imgloader.FusionImageLoader; -import bdv.spimdata.SequenceDescriptionMinimal; public class FusionResult { @@ -37,7 +36,7 @@ public class FusionResult final Map< Integer, AffineTransform3D > perTimePointFusionTransforms ) { // add one fused ViewSetup per channel in the SpimRegistrationSequence - final List< Integer > channels = new ArrayList< Integer >(); + final List< Integer > channels = new ArrayList<>(); for ( final BasicViewSetup setup : spimseq.getSequenceDescription().getViewSetupsOrdered() ) { final int channel = setup.getAttribute( Channel.class ).getId(); @@ -57,9 +56,9 @@ public class FusionResult final double sliceValueMax, final Map< Integer, AffineTransform3D > perTimePointFusionTransforms ) { - final HashMap< Integer, Integer > setupIdToChannelId = new HashMap< Integer, Integer >(); + final HashMap< Integer, Integer > setupIdToChannelId = new HashMap<>(); setupIdToChannelId.put( 0, 0 ); - final ImgLoader fusionLoader = new FusionImageLoader< FloatType >( filepath +"/" + filepattern, setupIdToChannelId, numSlices, new FusionImageLoader.Gray32ImagePlusLoader(), sliceValueMin, sliceValueMax ); + final ImgLoader fusionLoader = new FusionImageLoader<>( filepath +"/" + filepattern, setupIdToChannelId, numSlices, new FusionImageLoader.Gray32ImagePlusLoader(), sliceValueMin, sliceValueMax ); final int setupId = 0; final String name = "fused"; final int timepointId = timepoints.getTimePointsOrdered().get( 0 ).getId(); @@ -67,7 +66,7 @@ public class FusionResult final VoxelDimensions voxelSize = fusionLoader.getSetupImgLoader( setupId ).getVoxelSize( timepointId ); final BasicViewSetup setup = new BasicViewSetup( setupId, name, size, voxelSize ); desc = new SequenceDescriptionMinimal( timepoints, Entity.idMap( Arrays.asList( setup ) ), fusionLoader, null ); - final ArrayList< ViewRegistration > registrations = new ArrayList< ViewRegistration >(); + final ArrayList< ViewRegistration > registrations = new ArrayList<>(); for ( final TimePoint timepoint : timepoints.getTimePointsOrdered() ) registrations.add( new ViewRegistration( timepoint.getId(), 0, perTimePointFusionTransforms.get( timepoint.getId() ) ) ); regs = new ViewRegistrations( registrations ); @@ -83,13 +82,13 @@ public class FusionResult final double sliceValueMax, final Map< Integer, AffineTransform3D > perTimePointFusionTransforms ) { - final HashMap< Integer, Integer > setupIdToChannelId = new HashMap< Integer, Integer >(); + final HashMap< Integer, Integer > setupIdToChannelId = new HashMap<>(); for ( int setupId = 0; setupId < channels.size(); ++setupId ) { setupIdToChannelId.put( setupId, channels.get( setupId ) ); } - final ImgLoader fusionLoader = new FusionImageLoader< FloatType >( filepath +"/" + filepattern, setupIdToChannelId, numSlices, new FusionImageLoader.Gray32ImagePlusLoader(), sliceValueMin, sliceValueMax ); - final ArrayList< BasicViewSetup > setups = new ArrayList< BasicViewSetup >(); + final ImgLoader fusionLoader = new FusionImageLoader<>( filepath +"/" + filepattern, setupIdToChannelId, numSlices, new FusionImageLoader.Gray32ImagePlusLoader(), sliceValueMin, sliceValueMax ); + final ArrayList< BasicViewSetup > setups = new ArrayList<>(); for ( int setupId = 0; setupId < channels.size(); ++setupId ) { final String name = "fused c " + channels.get( setupId ); @@ -101,7 +100,7 @@ public class FusionResult setups.add( setup ); } desc = new SequenceDescriptionMinimal( timepoints, Entity.idMap( setups ), fusionLoader, null ); - final ArrayList< ViewRegistration > registrations = new ArrayList< ViewRegistration >(); + final ArrayList< ViewRegistration > registrations = new ArrayList<>(); for ( final TimePoint timepoint : timepoints.getTimePointsOrdered() ) for ( final BasicViewSetup setup : setups ) registrations.add( new ViewRegistration( timepoint.getId(), setup.getId(), perTimePointFusionTransforms.get( timepoint.getId() ) ) ); diff --git a/src/main/java/bdv/ij/export/Scripting.java b/src/main/java/bdv/ij/export/Scripting.java index 250149f1acbaacdb36a3cf1a3d05f699a1f6540b..e7f30ae7c10b33d04139e2f04fce84487b3211af 100644 --- a/src/main/java/bdv/ij/export/Scripting.java +++ b/src/main/java/bdv/ij/export/Scripting.java @@ -5,9 +5,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import mpicbg.spim.data.SpimDataException; -import mpicbg.spim.io.ConfigurationParserException; -import net.imglib2.realtransform.AffineTransform3D; import bdv.export.ExportMipmapInfo; import bdv.export.WriteSequenceToHdf5; import bdv.ij.util.PluginHelper; @@ -16,6 +13,9 @@ import bdv.img.hdf5.Partition; import bdv.spimdata.SequenceDescriptionMinimal; import bdv.spimdata.SpimDataMinimal; import bdv.spimdata.XmlIoSpimDataMinimal; +import mpicbg.spim.data.SpimDataException; +import mpicbg.spim.io.ConfigurationParserException; +import net.imglib2.realtransform.AffineTransform3D; public class Scripting { @@ -193,7 +193,7 @@ public class Scripting spimData = aggregator.createSpimData( seqFile ); perSetupMipmapInfo = aggregator.getPerSetupMipmapInfo(); this.deflate = deflate; - this.partitions = new ArrayList< Partition >( partitions ); + this.partitions = new ArrayList<>( partitions ); } public int numPartitions() diff --git a/src/main/java/bdv/ij/export/SetupAggregator.java b/src/main/java/bdv/ij/export/SetupAggregator.java index 6111c0dd3bd1cb75f9a4f41f294d0739294e94cf..b21d975da3db27e19f48c296a2657a215408b110 100644 --- a/src/main/java/bdv/ij/export/SetupAggregator.java +++ b/src/main/java/bdv/ij/export/SetupAggregator.java @@ -5,6 +5,11 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import bdv.export.ExportMipmapInfo; +import bdv.export.WriteSequenceToHdf5; +import bdv.ij.util.PluginHelper; +import bdv.spimdata.SequenceDescriptionMinimal; +import bdv.spimdata.SpimDataMinimal; import mpicbg.spim.data.generic.XmlIoAbstractSpimData; import mpicbg.spim.data.generic.base.Entity; import mpicbg.spim.data.generic.sequence.AbstractSequenceDescription; @@ -19,11 +24,6 @@ import mpicbg.spim.data.sequence.TimePoint; import mpicbg.spim.data.sequence.TimePoints; import mpicbg.spim.data.sequence.ViewId; import net.imglib2.img.cell.CellImg; -import bdv.export.ExportMipmapInfo; -import bdv.export.WriteSequenceToHdf5; -import bdv.ij.util.PluginHelper; -import bdv.spimdata.SequenceDescriptionMinimal; -import bdv.spimdata.SpimDataMinimal; /** * Aggregate {@link BasicViewSetup setups}, i.e., SPIM source angles and fused @@ -63,10 +63,10 @@ public class SetupAggregator public SetupAggregator() { timepoints = null; - registrations = new ArrayList< ViewRegistration >(); - setups = new ArrayList< ViewSetupWrapper >(); - setupImgLoaders = new ArrayList< BasicSetupImgLoader< ? > >(); - perSetupMipmapInfo = new HashMap< Integer, ExportMipmapInfo >(); + registrations = new ArrayList<>(); + setups = new ArrayList<>(); + setupImgLoaders = new ArrayList<>(); + perSetupMipmapInfo = new HashMap<>(); imgLoader = new BasicImgLoader() { @Override diff --git a/src/main/java/bdv/ij/export/SpimRegistrationSequence.java b/src/main/java/bdv/ij/export/SpimRegistrationSequence.java index 5a291b93bb315094bf317beee1a37665c6908208..55649650811640a44e3311fe8956a41c883bf5b4 100644 --- a/src/main/java/bdv/ij/export/SpimRegistrationSequence.java +++ b/src/main/java/bdv/ij/export/SpimRegistrationSequence.java @@ -7,6 +7,9 @@ import java.util.Map; import org.scijava.vecmath.Point3f; +import bdv.ij.export.imgloader.HuiskenImageLoader; +import bdv.ij.export.imgloader.StackImageLoader; +import bdv.spimdata.SequenceDescriptionMinimal; import mpicbg.spim.data.generic.base.Entity; import mpicbg.spim.data.generic.sequence.BasicImgLoader; import mpicbg.spim.data.registration.ViewRegistration; @@ -32,9 +35,6 @@ import net.imglib2.FinalRealInterval; import net.imglib2.RealInterval; import net.imglib2.realtransform.AffineTransform3D; import spimopener.SPIMExperiment; -import bdv.ij.export.imgloader.HuiskenImageLoader; -import bdv.ij.export.imgloader.StackImageLoader; -import bdv.spimdata.SequenceDescriptionMinimal; public class SpimRegistrationSequence { @@ -81,7 +81,7 @@ public class SpimRegistrationSequence protected static BasicImgLoader createImageLoader( final SPIMConfiguration conf, final ArrayList< ViewSetup > setups ) { final int numTimepoints = conf.timepoints.length; - final HashMap< ViewId, String > filenames = new HashMap< ViewId, String >(); + final HashMap< ViewId, String > filenames = new HashMap<>(); for ( int timepoint = 0; timepoint < numTimepoints; ++timepoint ) { final int timepointId = conf.timepoints[ timepoint ]; @@ -171,7 +171,7 @@ public class SpimRegistrationSequence protected static ArrayList< ViewSetup > createViewSetups( final SPIMConfiguration conf ) { - final ArrayList< ViewSetup > setups = new ArrayList< ViewSetup >(); + final ArrayList< ViewSetup > setups = new ArrayList<>(); int setup_id = 0; for ( int channelIndex = 0; channelIndex < conf.file[ 0 ].length; channelIndex++ ) for ( int angleIndex = 0; angleIndex < conf.file[ 0 ][ channelIndex ].length; angleIndex++ ) @@ -216,7 +216,7 @@ public class SpimRegistrationSequence protected static TimePoints createTimePoints( final SPIMConfiguration conf ) { - final ArrayList< TimePoint > timepoints = new ArrayList< TimePoint >(); + final ArrayList< TimePoint > timepoints = new ArrayList<>(); for ( final int tp : conf.timepoints ) timepoints.add( new TimePoint( tp ) ); return new TimePoints( timepoints ); @@ -229,7 +229,7 @@ public class SpimRegistrationSequence conf.cropOffsetZ = cropOffsetZ; conf.scale = scale; - final HashMap< Integer, AffineTransform3D > transforms = new HashMap< Integer, AffineTransform3D >(); + final HashMap< Integer, AffineTransform3D > transforms = new HashMap<>(); if ( conf.timeLapseRegistration ) { SPIMConfiguration refconf = conf; @@ -334,7 +334,7 @@ public class SpimRegistrationSequence protected static ViewRegistrations createViewRegistrations( final SPIMConfiguration conf, final ArrayList< ViewSetup > setups ) { - final ArrayList< ViewRegistration > regs = new ArrayList< ViewRegistration >(); + final ArrayList< ViewRegistration > regs = new ArrayList<>(); // for each time-point initialize the view structure, load&apply // registrations, instantiate the View objects for Tracking @@ -376,7 +376,7 @@ public class SpimRegistrationSequence protected static ArrayList< Integer > makeList( final int[] ints ) { - final ArrayList< Integer > list = new ArrayList< Integer >( ints.length ); + final ArrayList< Integer > list = new ArrayList<>( ints.length ); for ( final int i : ints ) list.add( i ); return list; diff --git a/src/main/java/bdv/ij/export/imgloader/FusionImageLoader.java b/src/main/java/bdv/ij/export/imgloader/FusionImageLoader.java index de05de48fe97165473e02a19f341bca5c5c0fe93..5b01a1dd587d8e59d9b3f947577100656ed6144b 100644 --- a/src/main/java/bdv/ij/export/imgloader/FusionImageLoader.java +++ b/src/main/java/bdv/ij/export/imgloader/FusionImageLoader.java @@ -1,12 +1,11 @@ package bdv.ij.export.imgloader; -import ij.ImagePlus; -import io.scif.img.ImgIOException; -import io.scif.img.ImgOpener; - import java.util.HashMap; import java.util.Map.Entry; +import ij.ImagePlus; +import io.scif.img.ImgIOException; +import io.scif.img.ImgOpener; import mpicbg.spim.data.generic.sequence.BasicSetupImgLoader; import mpicbg.spim.data.generic.sequence.ImgLoaderHint; import mpicbg.spim.data.sequence.FinalVoxelDimensions; @@ -72,10 +71,10 @@ public class FusionImageLoader< T extends RealType< T > > implements ImgLoader this.pattern = pattern; this.numSlices = numSlices; this.sliceLoader = sliceLoader; - converter = new RealUnsignedShortConverter< T >( sliceValueMin, sliceValueMax ); + converter = new RealUnsignedShortConverter<>( sliceValueMin, sliceValueMax ); this.factory = factory; type = new UnsignedShortType(); - setupIdToSetupImgLoader = new HashMap< Integer, SetupLoader >(); + setupIdToSetupImgLoader = new HashMap<>(); for ( final Entry< Integer, Integer > entry : setupIdToChannelId.entrySet() ) setupIdToSetupImgLoader.put( entry.getKey(), new SetupLoader( entry.getValue() ) ); } @@ -96,7 +95,7 @@ public class FusionImageLoader< T extends RealType< T > > implements ImgLoader public ArrayImgLoader( final T type ) { opener = new ImgOpener(); - factory = new ArrayImgFactory< T >(); + factory = new ArrayImgFactory<>(); this.type = type; } diff --git a/src/main/java/bdv/ij/export/imgloader/HuiskenImageLoader.java b/src/main/java/bdv/ij/export/imgloader/HuiskenImageLoader.java index 2cbc55dc430cb439f34111b3fafa94a3ff43d916..8dc85ba386139df45dd5af513d4bde0a2cdaafc0 100644 --- a/src/main/java/bdv/ij/export/imgloader/HuiskenImageLoader.java +++ b/src/main/java/bdv/ij/export/imgloader/HuiskenImageLoader.java @@ -1,11 +1,10 @@ package bdv.ij.export.imgloader; -import ij.ImagePlus; - import java.io.File; import java.util.HashMap; import java.util.Map.Entry; +import ij.ImagePlus; import mpicbg.spim.data.generic.sequence.BasicImgLoader; import mpicbg.spim.data.generic.sequence.BasicSetupImgLoader; import mpicbg.spim.data.generic.sequence.ImgLoaderHint; @@ -40,7 +39,7 @@ public class HuiskenImageLoader implements BasicImgLoader { expFile = file; exp = null; - setupIdToSetupImgLoader = new HashMap< Integer, SetupLoader >(); + setupIdToSetupImgLoader = new HashMap<>(); for ( final Entry< Integer, ViewSetup > entry : setups.entrySet() ) setupIdToSetupImgLoader.put( entry.getKey(), new SetupLoader( entry.getValue() ) ); } @@ -98,7 +97,7 @@ public class HuiskenImageLoader implements BasicImgLoader final float zStretching = ( float ) ( exp.pd / exp.pw ); final double[] calibration = new double[] { 1, 1, zStretching }; - return new ImgPlus< UnsignedShortType >( img, name, axes, calibration ); + return new ImgPlus<>( img, name, axes, calibration ); } @Override diff --git a/src/main/java/bdv/ij/export/imgloader/ImagePlusImgLoader.java b/src/main/java/bdv/ij/export/imgloader/ImagePlusImgLoader.java index 01f80652ca3d80aee18d609ad2bf6e7ed4c058d8..8d5192cc7549ac8df5a2b439c7a6b4fa0c1f1ce7 100644 --- a/src/main/java/bdv/ij/export/imgloader/ImagePlusImgLoader.java +++ b/src/main/java/bdv/ij/export/imgloader/ImagePlusImgLoader.java @@ -1,9 +1,11 @@ package bdv.ij.export.imgloader; -import ij.ImagePlus; - import java.util.ArrayList; +import bdv.img.cache.VolatileGlobalCellCache; +import bdv.img.imagestack.ImageStackImageLoader; +import bdv.img.virtualstack.VirtualStackImageLoader; +import ij.ImagePlus; import mpicbg.spim.data.generic.sequence.BasicImgLoader; import mpicbg.spim.data.generic.sequence.BasicSetupImgLoader; import mpicbg.spim.data.generic.sequence.ImgLoaderHint; @@ -19,9 +21,6 @@ import net.imglib2.type.Type; import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.integer.UnsignedShortType; import net.imglib2.type.numeric.real.FloatType; -import bdv.img.cache.VolatileGlobalCellCache; -import bdv.img.imagestack.ImageStackImageLoader; -import bdv.img.virtualstack.VirtualStackImageLoader; /** * This {@link BasicImgLoader} implementation returns a wrapped, converted @@ -51,9 +50,9 @@ public class ImagePlusImgLoader< T extends Type< T > > implements TypedBasicImgL if( imp.getType() != ImagePlus.GRAY8 ) throw new RuntimeException( "expected ImagePlus type GRAY8" ); if ( imp.getStack() != null && imp.getStack().isVirtual() ) - return new ImagePlusImgLoader< UnsignedShortType >( imp, VirtualStackImageLoader.createUnsignedByteInstance( imp ), minMaxOption, min, max, new UnsignedShortType(), new RealUnsignedShortConverterFactory() ); + return new ImagePlusImgLoader<>( imp, VirtualStackImageLoader.createUnsignedByteInstance( imp ), minMaxOption, min, max, new UnsignedShortType(), new RealUnsignedShortConverterFactory() ); else - return new ImagePlusImgLoader< UnsignedShortType >( imp, ImageStackImageLoader.createUnsignedByteInstance( imp ), minMaxOption, min, max, new UnsignedShortType(), new RealUnsignedShortConverterFactory() ); + return new ImagePlusImgLoader<>( imp, ImageStackImageLoader.createUnsignedByteInstance( imp ), minMaxOption, min, max, new UnsignedShortType(), new RealUnsignedShortConverterFactory() ); } public static ImagePlusImgLoader< FloatType > createFloatFromGray8( final ImagePlus imp, final MinMaxOption minMaxOption, final double min, final double max ) @@ -61,9 +60,9 @@ public class ImagePlusImgLoader< T extends Type< T > > implements TypedBasicImgL if( imp.getType() != ImagePlus.GRAY8 ) throw new RuntimeException( "expected ImagePlus type GRAY8" ); if ( imp.getStack() != null && imp.getStack().isVirtual() ) - return new ImagePlusImgLoader< FloatType >( imp, VirtualStackImageLoader.createUnsignedByteInstance( imp ), minMaxOption, min, max, new FloatType(), new RealFloatConverterFactory() ); + return new ImagePlusImgLoader<>( imp, VirtualStackImageLoader.createUnsignedByteInstance( imp ), minMaxOption, min, max, new FloatType(), new RealFloatConverterFactory() ); else - return new ImagePlusImgLoader< FloatType >( imp, ImageStackImageLoader.createUnsignedByteInstance( imp ), minMaxOption, min, max, new FloatType(), new RealFloatConverterFactory() ); + return new ImagePlusImgLoader<>( imp, ImageStackImageLoader.createUnsignedByteInstance( imp ), minMaxOption, min, max, new FloatType(), new RealFloatConverterFactory() ); } public static ImagePlusImgLoader< UnsignedShortType > createGray16( final ImagePlus imp, final MinMaxOption minMaxOption, final double min, final double max ) @@ -71,9 +70,9 @@ public class ImagePlusImgLoader< T extends Type< T > > implements TypedBasicImgL if( imp.getType() != ImagePlus.GRAY16 ) throw new RuntimeException( "expected ImagePlus type GRAY16" ); if ( imp.getStack() != null && imp.getStack().isVirtual() ) - return new ImagePlusImgLoader< UnsignedShortType >( imp, VirtualStackImageLoader.createUnsignedShortInstance( imp ), minMaxOption, min, max, new UnsignedShortType(), new RealUnsignedShortConverterFactory() ); + return new ImagePlusImgLoader<>( imp, VirtualStackImageLoader.createUnsignedShortInstance( imp ), minMaxOption, min, max, new UnsignedShortType(), new RealUnsignedShortConverterFactory() ); else - return new ImagePlusImgLoader< UnsignedShortType >( imp, ImageStackImageLoader.createUnsignedShortInstance( imp ), minMaxOption, min, max, new UnsignedShortType(), new RealUnsignedShortConverterFactory() ); + return new ImagePlusImgLoader<>( imp, ImageStackImageLoader.createUnsignedShortInstance( imp ), minMaxOption, min, max, new UnsignedShortType(), new RealUnsignedShortConverterFactory() ); } public static ImagePlusImgLoader< UnsignedShortType > createGray32( final ImagePlus imp, final MinMaxOption minMaxOption, final double min, final double max ) @@ -81,9 +80,9 @@ public class ImagePlusImgLoader< T extends Type< T > > implements TypedBasicImgL if( imp.getType() != ImagePlus.GRAY32 ) throw new RuntimeException( "expected ImagePlus type GRAY32" ); if ( imp.getStack() != null && imp.getStack().isVirtual() ) - return new ImagePlusImgLoader< UnsignedShortType >( imp, VirtualStackImageLoader.createFloatInstance( imp ), minMaxOption, min, max, new UnsignedShortType(), new RealUnsignedShortConverterFactory() ); + return new ImagePlusImgLoader<>( imp, VirtualStackImageLoader.createFloatInstance( imp ), minMaxOption, min, max, new UnsignedShortType(), new RealUnsignedShortConverterFactory() ); else - return new ImagePlusImgLoader< UnsignedShortType >( imp, ImageStackImageLoader.createFloatInstance( imp ), minMaxOption, min, max, new UnsignedShortType(), new RealUnsignedShortConverterFactory() ); + return new ImagePlusImgLoader<>( imp, ImageStackImageLoader.createFloatInstance( imp ), minMaxOption, min, max, new UnsignedShortType(), new RealUnsignedShortConverterFactory() ); } protected final ImagePlus imp; @@ -112,7 +111,7 @@ public class ImagePlusImgLoader< T extends Type< T > > implements TypedBasicImgL @Override public < S extends RealType< S > & NativeType< S > > Converter< S, UnsignedShortType > create( final double min, final double max ) { - return new RealUnsignedShortConverter< S >( min, max ); + return new RealUnsignedShortConverter<>( min, max ); } } @@ -121,7 +120,7 @@ public class ImagePlusImgLoader< T extends Type< T > > implements TypedBasicImgL @Override public < S extends RealType< S > & NativeType< S > > Converter< S, FloatType > create( final double min, final double max ) { - return new RealFloatConverter< S >(); + return new RealFloatConverter<>(); } } @@ -139,9 +138,9 @@ public class ImagePlusImgLoader< T extends Type< T > > implements TypedBasicImgL this.converterFactory = converterFactory; final int numSetups = imp.getNChannels(); - setupImgLoaders = new ArrayList< SetupImgLoader< ? > >(); + setupImgLoaders = new ArrayList<>(); for ( int setupId = 0; setupId < numSetups; ++setupId ) - setupImgLoaders.add( new SetupImgLoader< S >( loader.getSetupImgLoader( setupId ) ) ); + setupImgLoaders.add( new SetupImgLoader<>( loader.getSetupImgLoader( setupId ) ) ); if ( loader instanceof VirtualStackImageLoader ) this.loadercache = ( ( VirtualStackImageLoader< ?, ?, ? > ) loader ).getCache(); diff --git a/src/main/java/bdv/ij/export/imgloader/LegacyStackImageLoader.java b/src/main/java/bdv/ij/export/imgloader/LegacyStackImageLoader.java index 954547fccac16c0e60e81ceef0f997c6d669017d..c832d531e349749484db9e5c0fc4fa7de2cc35dc 100644 --- a/src/main/java/bdv/ij/export/imgloader/LegacyStackImageLoader.java +++ b/src/main/java/bdv/ij/export/imgloader/LegacyStackImageLoader.java @@ -1,12 +1,15 @@ package bdv.ij.export.imgloader; +import java.util.HashMap; + +import org.scijava.Context; +import org.scijava.app.AppService; +import org.scijava.app.StatusService; + import ij.ImagePlus; import io.scif.SCIFIOService; import io.scif.img.ImgIOException; import io.scif.img.ImgOpener; - -import java.util.HashMap; - import mpicbg.spim.data.legacy.LegacyBasicImgLoader; import mpicbg.spim.data.sequence.ImgLoader; import mpicbg.spim.data.sequence.ViewDescription; @@ -21,10 +24,6 @@ import net.imglib2.meta.ImgPlus; import net.imglib2.type.numeric.integer.UnsignedByteType; import net.imglib2.type.numeric.integer.UnsignedShortType; -import org.scijava.Context; -import org.scijava.app.AppService; -import org.scijava.app.StatusService; - /** * This {@link ImgLoader} loads images that represent a 3D stack in a single @@ -52,7 +51,7 @@ public class LegacyStackImageLoader implements LegacyBasicImgLoader< UnsignedSho this.filenames = filenames; this.useImageJOpener = useImageJOpener; opener = useImageJOpener ? null : new ImgOpener( new Context( SCIFIOService.class, AppService.class, StatusService.class ) ); - factory = new ArrayImgFactory< UnsignedShortType >(); + factory = new ArrayImgFactory<>(); type = new UnsignedShortType(); } @@ -64,12 +63,12 @@ public class LegacyStackImageLoader implements LegacyBasicImgLoader< UnsignedSho { final ImagePlus imp = new ImagePlus( fn ); if ( imp.getType() == ImagePlus.GRAY16 ) - return new ImgPlus< UnsignedShortType >( ImageJFunctions.wrapShort( imp ) ); + return new ImgPlus<>( ImageJFunctions.wrapShort( imp ) ); else if ( imp.getType() == ImagePlus.GRAY8 ) { System.out.println( "wrapping" ); - return new ImgPlus< UnsignedShortType >( - new ImgView< UnsignedShortType >( + return new ImgPlus<>( + new ImgView<>( Converters.convert( ( RandomAccessibleInterval<UnsignedByteType> ) ImageJFunctions.wrapByte( imp ), new Converter< UnsignedByteType, UnsignedShortType >() { diff --git a/src/main/java/bdv/ij/export/tiles/CellVoyagerDataExporter.java b/src/main/java/bdv/ij/export/tiles/CellVoyagerDataExporter.java index 29ce30f18c4673fd4876d2fb112a869d7ed36aa6..b4a8c636cddd3ec2f1a61e03d4465a34e0f9da00 100644 --- a/src/main/java/bdv/ij/export/tiles/CellVoyagerDataExporter.java +++ b/src/main/java/bdv/ij/export/tiles/CellVoyagerDataExporter.java @@ -1,26 +1,11 @@ package bdv.ij.export.tiles; -import ij.IJ; - import java.awt.Color; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import mpicbg.spim.data.generic.base.Entity; -import mpicbg.spim.data.generic.sequence.BasicViewSetup; -import mpicbg.spim.data.registration.ViewRegistration; -import mpicbg.spim.data.registration.ViewRegistrations; -import mpicbg.spim.data.sequence.Channel; -import mpicbg.spim.data.sequence.FinalVoxelDimensions; -import mpicbg.spim.data.sequence.TimePoint; -import mpicbg.spim.data.sequence.TimePoints; -import mpicbg.spim.data.sequence.VoxelDimensions; -import net.imglib2.Dimensions; -import net.imglib2.FinalDimensions; -import net.imglib2.realtransform.AffineTransform3D; - import org.jdom2.Document; import org.jdom2.Element; import org.jdom2.JDOMException; @@ -33,6 +18,19 @@ import bdv.img.hdf5.Hdf5ImageLoader; import bdv.spimdata.SequenceDescriptionMinimal; import bdv.spimdata.SpimDataMinimal; import bdv.spimdata.XmlIoSpimDataMinimal; +import ij.IJ; +import mpicbg.spim.data.generic.base.Entity; +import mpicbg.spim.data.generic.sequence.BasicViewSetup; +import mpicbg.spim.data.registration.ViewRegistration; +import mpicbg.spim.data.registration.ViewRegistrations; +import mpicbg.spim.data.sequence.Channel; +import mpicbg.spim.data.sequence.FinalVoxelDimensions; +import mpicbg.spim.data.sequence.TimePoint; +import mpicbg.spim.data.sequence.TimePoints; +import mpicbg.spim.data.sequence.VoxelDimensions; +import net.imglib2.Dimensions; +import net.imglib2.FinalDimensions; +import net.imglib2.realtransform.AffineTransform3D; public class CellVoyagerDataExporter { @@ -91,7 +89,7 @@ public class CellVoyagerDataExporter public List< ChannelInfo > readInfo() { - final List< ChannelInfo > channels = new ArrayList< ChannelInfo >(); + final List< ChannelInfo > channels = new ArrayList<>(); final Element root = document.getRootElement(); @@ -161,7 +159,7 @@ public class CellVoyagerDataExporter double ymin = Double.POSITIVE_INFINITY; double xmax = Double.NEGATIVE_INFINITY; double ymax = Double.NEGATIVE_INFINITY; - final ArrayList< double[] > offsetsUm = new ArrayList< double[] >(); + final ArrayList< double[] > offsetsUm = new ArrayList<>(); for ( final Element fieldElement : fieldElements ) { @@ -194,7 +192,7 @@ public class CellVoyagerDataExporter } // Convert in pixel position - final List< long[] > offsets = new ArrayList< long[] >(); + final List< long[] > offsets = new ArrayList<>(); for ( final double[] offsetUm : offsetsUm ) { final long x = ( long ) ( ( offsetUm[ 0 ] - xmin ) / ( channelInfo.unmagnifiedPixelWidth / magnification ) ); @@ -235,7 +233,7 @@ public class CellVoyagerDataExporter final Element root = document.getRootElement(); final int nTimePoints = Integer.parseInt( root.getChild( "TimelapsCondition" ).getChildText( "Iteration" ) ); - final List< TimePoint > timepoints = new ArrayList< TimePoint >( nTimePoints ); + final List< TimePoint > timepoints = new ArrayList<>( nTimePoints ); for ( int i = 0; i < nTimePoints; i++ ) { timepoints.add( new TimePoint( Integer.valueOf( i ) ) ); @@ -275,7 +273,7 @@ public class CellVoyagerDataExporter * Create view setups */ - final List< BasicViewSetup > setups = new ArrayList< BasicViewSetup >( channelInfos.size() ); + final List< BasicViewSetup > setups = new ArrayList<>( channelInfos.size() ); int viewSetupIndex = 0; for ( final ChannelInfo channelInfo : channelInfos ) { @@ -330,7 +328,7 @@ public class CellVoyagerDataExporter * Build views */ - final ArrayList< ViewRegistration > registrations = new ArrayList< ViewRegistration >(); + final ArrayList< ViewRegistration > registrations = new ArrayList<>(); for ( int setupIndex = 0; setupIndex < setups.size(); setupIndex++ ) { diff --git a/src/main/java/bdv/ij/export/tiles/LegacyTileImgLoader.java b/src/main/java/bdv/ij/export/tiles/LegacyTileImgLoader.java index cf56ec75b622c2d6612781abe6b1520bcd23d796..fdde49d7738d1542fcc5b30fe930ff2663ebd397 100644 --- a/src/main/java/bdv/ij/export/tiles/LegacyTileImgLoader.java +++ b/src/main/java/bdv/ij/export/tiles/LegacyTileImgLoader.java @@ -1,7 +1,5 @@ package bdv.ij.export.tiles; -import ij.ImagePlus; - import java.io.File; import java.io.IOException; import java.util.HashMap; @@ -10,6 +8,15 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; +import org.jdom2.DataConversionException; +import org.jdom2.Document; +import org.jdom2.Element; +import org.jdom2.JDOMException; +import org.jdom2.Namespace; +import org.jdom2.input.SAXBuilder; + +import bdv.ij.export.tiles.CellVoyagerDataExporter.ChannelInfo; +import ij.ImagePlus; import mpicbg.spim.data.legacy.LegacyBasicImgLoader; import mpicbg.spim.data.sequence.ViewId; import net.imglib2.Cursor; @@ -22,15 +29,6 @@ import net.imglib2.img.basictypeaccess.array.ShortArray; import net.imglib2.img.display.imagej.ImageJFunctions; import net.imglib2.type.numeric.integer.UnsignedShortType; -import org.jdom2.DataConversionException; -import org.jdom2.Document; -import org.jdom2.Element; -import org.jdom2.JDOMException; -import org.jdom2.Namespace; -import org.jdom2.input.SAXBuilder; - -import bdv.ij.export.tiles.CellVoyagerDataExporter.ChannelInfo; - public class LegacyTileImgLoader implements LegacyBasicImgLoader< UnsignedShortType > { @@ -84,7 +82,7 @@ public class LegacyTileImgLoader implements LegacyBasicImgLoader< UnsignedShortT // Map of z -> all the tiles. The tiles are a map of field index -> // filename - final TreeMap< Double, Map< Integer, String > > filenames = new TreeMap< Double, Map< Integer, String > >(); + final TreeMap< Double, Map< Integer, String > > filenames = new TreeMap<>(); final Element root = document.getRootElement(); for ( final Element element : root.getChildren( "MeasurementRecord", NAMESPACE ) ) @@ -118,7 +116,7 @@ public class LegacyTileImgLoader implements LegacyBasicImgLoader< UnsignedShortT Map< Integer, String > tilesAtZ = filenames.get( dz ); if ( null == tilesAtZ ) { - tilesAtZ = new HashMap< Integer, String >(); + tilesAtZ = new HashMap<>(); filenames.put( dz, tilesAtZ ); } tilesAtZ.put( field, filename ); diff --git a/src/main/java/bdv/ij/util/PluginHelper.java b/src/main/java/bdv/ij/util/PluginHelper.java index 9cd78813502179f93c808d28417f0d597c0e946c..a70660bdd7bb8657fd7e65a10727dc0a875a499b 100644 --- a/src/main/java/bdv/ij/util/PluginHelper.java +++ b/src/main/java/bdv/ij/util/PluginHelper.java @@ -1,7 +1,5 @@ package bdv.ij.util; -import ij.Prefs; - import java.awt.Button; import java.awt.FileDialog; import java.awt.FlowLayout; @@ -23,6 +21,7 @@ import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; import fiji.util.gui.GenericDialogPlus; +import ij.Prefs; public class PluginHelper { @@ -146,7 +145,7 @@ public class PluginHelper final Pattern pattern = Pattern.compile( regex ); final Matcher matcher = pattern.matcher( s ); - final ArrayList< int[] > tmp = new ArrayList< int[] >(); + final ArrayList< int[] > tmp = new ArrayList<>(); while ( matcher.find() ) { final int[] resolution = new int[] { Integer.parseInt( matcher.group( 1 ) ), Integer.parseInt( matcher.group( 2 ) ), Integer.parseInt( matcher.group( 3 ) ) }; diff --git a/src/main/java/bdv/img/imagestack/ImageStackImageLoader.java b/src/main/java/bdv/img/imagestack/ImageStackImageLoader.java index 9edcce0d48479748a876274a520ae38529d4e8b0..43affc871fe4d5f5ccc9f5a8e1b521d32dad44e4 100644 --- a/src/main/java/bdv/img/imagestack/ImageStackImageLoader.java +++ b/src/main/java/bdv/img/imagestack/ImageStackImageLoader.java @@ -1,9 +1,8 @@ package bdv.img.imagestack; -import ij.ImagePlus; - import java.util.ArrayList; +import ij.ImagePlus; import mpicbg.spim.data.generic.sequence.BasicImgLoader; import mpicbg.spim.data.generic.sequence.BasicSetupImgLoader; import mpicbg.spim.data.generic.sequence.ImgLoaderHint; @@ -110,7 +109,7 @@ public abstract class ImageStackImageLoader< T extends NumericType< T > & Native this.imp = imp; this.dim = new long[] { imp.getWidth(), imp.getHeight(), imp.getNSlices() }; final int numSetups = imp.getNChannels(); - setupImgLoaders = new ArrayList< SetupImgLoader >(); + setupImgLoaders = new ArrayList<>(); for ( int setupId = 0; setupId < numSetups; ++setupId ) setupImgLoaders.add( new SetupImgLoader( setupId ) ); } diff --git a/src/main/java/bdv/img/virtualstack/VirtualStackImageLoader.java b/src/main/java/bdv/img/virtualstack/VirtualStackImageLoader.java index c103ff3c232b064ca551cff444b410dd0f282c71..93618ec5adee8f15b2856777b344a177eaacda3f 100644 --- a/src/main/java/bdv/img/virtualstack/VirtualStackImageLoader.java +++ b/src/main/java/bdv/img/virtualstack/VirtualStackImageLoader.java @@ -1,9 +1,17 @@ package bdv.img.virtualstack; -import ij.ImagePlus; - import java.util.ArrayList; +import bdv.AbstractViewerSetupImgLoader; +import bdv.ViewerImgLoader; +import bdv.img.cache.CacheArrayLoader; +import bdv.img.cache.CacheHints; +import bdv.img.cache.CachedCellImg; +import bdv.img.cache.LoadingStrategy; +import bdv.img.cache.VolatileGlobalCellCache; +import bdv.img.cache.VolatileImgCells; +import bdv.img.cache.VolatileImgCells.CellCache; +import ij.ImagePlus; import mpicbg.spim.data.generic.sequence.BasicSetupImgLoader; import mpicbg.spim.data.generic.sequence.ImgLoaderHint; import mpicbg.spim.data.generic.sequence.TypedBasicImgLoader; @@ -27,15 +35,6 @@ import net.imglib2.type.volatiles.VolatileFloatType; import net.imglib2.type.volatiles.VolatileUnsignedByteType; import net.imglib2.type.volatiles.VolatileUnsignedShortType; import net.imglib2.util.Fraction; -import bdv.AbstractViewerSetupImgLoader; -import bdv.ViewerImgLoader; -import bdv.img.cache.CacheArrayLoader; -import bdv.img.cache.CacheHints; -import bdv.img.cache.CachedCellImg; -import bdv.img.cache.LoadingStrategy; -import bdv.img.cache.VolatileGlobalCellCache; -import bdv.img.cache.VolatileImgCells; -import bdv.img.cache.VolatileImgCells.CellCache; /** * ImageLoader backed by a ImagePlus. The ImagePlus may be virtual and in @@ -162,7 +161,7 @@ public abstract class VirtualStackImageLoader< T extends NativeType< T >, V exte final int numTimepoints = imp.getNFrames(); final int numSetups = imp.getNChannels(); cache = new VolatileGlobalCellCache( numTimepoints, numSetups, 1, 1 ); - setupImgLoaders = new ArrayList< SetupImgLoader >(); + setupImgLoaders = new ArrayList<>(); for ( int setupId = 0; setupId < numSetups; ++setupId ) setupImgLoaders.add( new SetupImgLoader( setupId, type, volatileType ) ); } @@ -221,9 +220,9 @@ public abstract class VirtualStackImageLoader< T extends NativeType< T >, V exte { final int priority = 0; final CacheHints cacheHints = new CacheHints( loadingStrategy, priority, false ); - final CellCache< A > c = cache.new VolatileCellCache< A >( view.getTimePointId(), view.getViewSetupId(), level, cacheHints, loader ); - final VolatileImgCells< A > cells = new VolatileImgCells< A >( c, new Fraction(), dimensions, cellDimensions ); - final CachedCellImg< T, A > img = new CachedCellImg< T, A >( cells ); + final CellCache< A > c = cache.new VolatileCellCache<>( view.getTimePointId(), view.getViewSetupId(), level, cacheHints, loader ); + final VolatileImgCells< A > cells = new VolatileImgCells<>( c, new Fraction(), dimensions, cellDimensions ); + final CachedCellImg< T, A > img = new CachedCellImg<>( cells ); return img; }