public static boolean isImgLoaderVirtual( final SpimData spimData ) { if ( MultiResolutionImgLoader.class.isInstance( spimData.getSequenceDescription().getImgLoader() ) ) return true; // TODO: check for Davids virtual implementation of the normal imgloader return false; }
public static boolean isMultiResolution( final SpimData spimData ) { if ( MultiResolutionImgLoader.class.isInstance( spimData.getSequenceDescription().getImgLoader() ) ) return true; else return false; }
public static int inputBytePerPixel( final ViewId viewId, final SpimData2 spimData ) { SetupImgLoader< ? > loader = spimData.getSequenceDescription().getImgLoader().getSetupImgLoader( viewId.getViewSetupId() ); Object type = loader.getImageType(); if ( UnsignedByteType.class.isInstance( type ) ) return 1; else if ( UnsignedShortType.class.isInstance( type ) ) return 2; else return 4; } }
public static void testDoM( final SpimData2 spimData ) { DoMParameters dom = new DoMParameters(); dom.imgloader = spimData.getSequenceDescription().getImgLoader(); dom.toProcess = new ArrayList< ViewDescription >(); dom.toProcess.addAll( spimData.getSequenceDescription().getViewDescriptions().values() ); // filter not present ViewIds final List< ViewDescription > removed = SpimData2.filterMissingViews( spimData, dom.toProcess ); IOFunctions.println( new Date( System.currentTimeMillis() ) + ": Removed " + removed.size() + " views because they are not present." ); dom.downsampleXY = 2; dom.radius1 = 2; final HashMap< ViewId, List< InterestPoint > > points = DoM.findInterestPoints( dom ); InterestPointTools.addInterestPoints( spimData, "beads", points, "DoM, sigma=2, downsample=2" ); }
public static < T extends RealType< T > & NativeType< T > > boolean maxProject( final SpimData data, final List< ? extends ViewId > viewIds, final T type ) { final ArrayList< ViewDescription > list = new ArrayList< ViewDescription >(); for ( final ViewId viewId : viewIds ) { final ViewDescription vd = data.getSequenceDescription().getViewDescription( viewId ); if ( vd != null && vd.isPresent() ) list.add( vd ); } return maxProject( list, data.getSequenceDescription().getImgLoader(), type ); }
public static void testDoG( SpimData2 spimData ) { DoGParameters dog = new DoGParameters(); dog.imgloader = spimData.getSequenceDescription().getImgLoader(); dog.toProcess = new ArrayList< ViewDescription >(); dog.toProcess.addAll( spimData.getSequenceDescription().getViewDescriptions().values() ); // filter not present ViewIds final List< ViewDescription > removed = SpimData2.filterMissingViews( spimData, dog.toProcess ); IOFunctions.println( new Date( System.currentTimeMillis() ) + ": Removed " + removed.size() + " views because they are not present." ); dog.downsampleXY = 4; dog.downsampleZ = 2; dog.sigma = 1.1; //dog.deviceList = spim.headless.cuda.CUDADevice.getSeparableCudaList( "lib/libSeparableConvolutionCUDALib.so" ); //dog.cuda = spim.headless.cuda.CUDADevice.separableConvolution; // DoG.findInterestPoints( dog ); // TODO: make cuda headless //dog.deviceList = spim.headless.cuda.CUDADevice.getSeparableCudaList( "lib/libSeparableConvolutionCUDALib.so" ); //dog.cuda = spim.headless.cuda.CUDADevice.separableConvolution; final HashMap< ViewId, List< InterestPoint > > points = DoG.findInterestPoints( dog ); InterestPointTools.addInterestPoints( spimData, "beads", points, "DoG, sigma=1.4, downsample=2" ); }
@Override public void preprocess() { if ( sameMinMax || groupIllums || groupTiles ) { // we set the min & max intensity for all individual views if ( Double.isNaN( minIntensity ) || Double.isNaN( maxIntensity ) ) { IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Determining it approximate Min & Max for all views at lowest resolution levels ... " ); IJ.showProgress( 0 ); final ImgLoader imgLoader = spimData.getSequenceDescription().getImgLoader(); double min = Double.MAX_VALUE; double max = -Double.MAX_VALUE; int count = 0; for ( final ViewId view : viewIdsToProcess ) { final double[] minmax = FusionTools.minMaxApprox( DownsampleTools.openAtLowestLevel( imgLoader, view ) ); min = Math.min( min, minmax[ 0 ] ); max = Math.max( max, minmax[ 1 ] ); IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): View " + Group.pvid( view ) + ", Min=" + minmax[ 0 ] + " max=" + minmax[ 1 ] ); IJ.showProgress( (double)++count / viewIdsToProcess.size() ); } this.minIntensity = min; this.maxIntensity = max; IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Total Min=" + this.minIntensity + " max=" + this.maxIntensity ); } } }
public static void testFresh( final SpimData2 sdTiff, final SpimData2 sdHdf5 ) { final DoGParameters dog = new DoGParameters(); /* dog.downsampleXY = 2; dog.downsampleZ = 2; dog.sigma = 1.8014999628067017; dog.threshold = 0.007973356172442436; */ dog.downsampleXY = 8; dog.downsampleZ = 8; dog.sigma = 1.1500000476837158; dog.threshold = 0.007973356172442436; dog.toProcess = new ArrayList< ViewDescription >(); dog.toProcess.addAll( sdTiff.getSequenceDescription().getViewDescriptions().values() ); dog.imgloader = sdTiff.getSequenceDescription().getImgLoader(); final HashMap< ViewId, List< InterestPoint > > pointsTiff = DoG.findInterestPoints( dog ); dog.imgloader = sdHdf5.getSequenceDescription().getImgLoader(); final HashMap< ViewId, List< InterestPoint > > pointsHdf5 = DoG.findInterestPoints( dog ); for ( final ViewId viewId : sdTiff.getSequenceDescription().getViewDescriptions().values() ) { statistics( viewId, pointsTiff.get( viewId ), pointsHdf5.get( viewId ) ); } }
public static double[] determineInputBitDepth( final Group< ViewDescription > group, final SpimData2 spimData, final RandomAccessibleInterval< FloatType > virtual ) { SetupImgLoader< ? > loader = spimData.getSequenceDescription().getImgLoader().getSetupImgLoader( group.iterator().next().getViewSetupId() ); Object type = loader.getImageType(); if ( UnsignedByteType.class.isInstance( type ) ) return new double[] { 0, 255 }; else if ( UnsignedShortType.class.isInstance( type ) ) return new double[] { 0, 65535 }; else { IOFunctions.println( "WARNING: You are saving a non-8/16 bit input as 16bit, have to manually determine min/max of the fused image." ); final float[] minmax = FusionTools.minMax( virtual ); return new double[]{ minmax[ 0 ], minmax[ 1 ] }; } }
public static < T extends RealType< T > > RandomAccessibleInterval< FloatType > transformView( final SpimData data, final ViewId viewId, final Interval boundingBox, final float outsideValue, final int interpolation ) { final ImgLoader il = data.getSequenceDescription().getImgLoader(); final ViewRegistration vr = data.getViewRegistrations().getViewRegistration( viewId ); vr.updateModel(); return transformView( il, viewId, vr.getModel(), boundingBox, outsideValue, interpolation ); }
public static < T extends RealType< T > > RandomAccessibleInterval< FloatType > transformView( final SpimData data, final ViewId viewId, final FinalInterval boundingBox, final OutOfBoundsFactory< T, RandomAccessible< T > > outOfBoundsFactory, final InterpolatorFactory< FloatType, RandomAccessible< FloatType > > interpolatorFactory ) { final ImgLoader il = data.getSequenceDescription().getImgLoader(); final ViewRegistration vr = data.getViewRegistrations().getViewRegistration( viewId ); vr.updateModel(); return transformView( il, viewId, vr.getModel(), boundingBox, outOfBoundsFactory, interpolatorFactory ); } }
public static void main(String[] args) { SpimData sd2 = createSpimDataFromUserInput(); RandomAccessibleInterval< UnsignedShortType > img2 = (RandomAccessibleInterval< UnsignedShortType >) sd2.getSequenceDescription().getImgLoader().getSetupImgLoader( 0 ).getImage( 0, null ); ImageJFunctions.show( img2 ); if (true) return; List<double[]> channelShifts = new ArrayList<>(); channelShifts.add( new double[3] ); List<double[]> illumShifts = new ArrayList<>(); illumShifts.add( new double[3] ); List<double[]> timeShifts = new ArrayList<>(); timeShifts.add( new double[3] ); timeShifts.add( new double[3] ); List<double[]> tileShifts = new ArrayList<>(); tileShifts.add( new double[3] ); SpimData sd = createSpimData( 1000, new double[] {1, 1, 3 }, Intervals.createMinMax( 0,0,0,256,256,100 ), Intervals.createMinMax( 0,0,0,256,256,100 ), 1, new double[] {0, 90}, channelShifts, illumShifts, timeShifts, tileShifts , 0.9, true); RandomAccessibleInterval< UnsignedShortType > img = (RandomAccessibleInterval< UnsignedShortType >) sd.getSequenceDescription().getImgLoader().getSetupImgLoader( 0 ).getImage( 1, null ); ImageJFunctions.show( img ); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public PSFExtraction( final SpimData2 data, final ViewId viewId, final String label, final boolean useCorresponding, final T type, final long[] size, final boolean multithreaded ) { this( (RandomAccessibleInterval)data.getSequenceDescription().getImgLoader().getSetupImgLoader( viewId.getViewSetupId() ).getImage( viewId.getTimePointId() ), getPoints( data, viewId, label, useCorresponding ), type, size, multithreaded ); }
final ImgLoader imgLoader = spimData.getSequenceDescription().getImgLoader(); final ViewRegistrations registrations = spimData.getViewRegistrations();
public static void main(String[] args) { GenericLoadParseQueryXML< SpimData2, SequenceDescription, ViewSetup, ViewDescription, ImgLoader, XmlIoSpimData2 > lpq = new GenericLoadParseQueryXML<>( new XmlIoSpimData2( "" ) ); lpq.queryXML(); SpimData2 data = lpq.getData(); // this will crash if il is not multires MultiResolutionImgLoader il = (MultiResolutionImgLoader) data.getSequenceDescription().getImgLoader(); MultiResolutionFlatfieldCorrectionWrappedImgLoader ffcil = new MultiResolutionFlatfieldCorrectionWrappedImgLoader( il ); ffcil.setDarkImage( new ViewId( 0, 0 ), new File( "/Users/david/desktop/ff.tif" ) ); data.getSequenceDescription().setImgLoader( ffcil ); new ImageJ(); RandomAccessibleInterval< FloatType > image = ( (MultiResolutionImgLoader) data.getSequenceDescription() .getImgLoader() ).getSetupImgLoader( 0 ).getFloatImage( 0, 1, false ); ImageJFunctions.show( image ); }
public static void main(String[] args) { GenericLoadParseQueryXML< SpimData2, SequenceDescription, ViewSetup, ViewDescription, ImgLoader, XmlIoSpimData2 > lpq = new GenericLoadParseQueryXML<>( new XmlIoSpimData2( "" ) ); lpq.queryXML(); SpimData2 data = lpq.getData(); ImgLoader il = data.getSequenceDescription().getImgLoader(); DefaultFlatfieldCorrectionWrappedImgLoader ffcil = new DefaultFlatfieldCorrectionWrappedImgLoader( il ); ffcil.setDarkImage( new ViewId( 0, 0 ), new File( "/Users/david/desktop/ff.tif" ) ); data.getSequenceDescription().setImgLoader( ffcil ); new ImageJ(); RandomAccessibleInterval< FloatType > image = data.getSequenceDescription().getImgLoader() .getSetupImgLoader( 0 ).getFloatImage( 0, false ); RandomAccessibleInterval< FloatType > downsampleBlock = MultiResolutionFlatfieldCorrectionWrappedImgLoader .downsampleHDF5( image, new int[] { 3, 3, 2 } ); ImageJFunctions.show( downsampleBlock, "" ); }
spimData.getSequenceDescription().getImgLoader(), viewDescription, new AffineTransform3D(),
public static void setModelToCalibration( final SpimData spimData, final ViewId viewId, final double minResolution ) { setModelToIdentity( spimData, viewId ); final ViewRegistrations viewRegistrations = spimData.getViewRegistrations(); final ViewRegistration r = viewRegistrations.getViewRegistration( viewId ); final ViewDescription viewDescription = spimData.getSequenceDescription().getViewDescription( viewId.getTimePointId(), viewId.getViewSetupId() ); VoxelDimensions voxelSize = ViewSetupUtils.getVoxelSizeOrLoad( viewDescription.getViewSetup(), viewDescription.getTimePoint(), spimData.getSequenceDescription().getImgLoader() ); final double calX = voxelSize.dimension( 0 ) / minResolution; final double calY = voxelSize.dimension( 1 ) / minResolution; final double calZ = voxelSize.dimension( 2 ) / minResolution; final AffineTransform3D m = new AffineTransform3D(); m.set( calX, 0.0f, 0.0f, 0.0f, 0.0f, calY, 0.0f, 0.0f, 0.0f, 0.0f, calZ, 0.0f ); final ViewTransform vt = new ViewTransformAffine( "calibration", m ); r.preconcatenateTransform( vt ); }
final RandomAccessibleInterval< UnsignedShortType > img = ( RandomAccessibleInterval< UnsignedShortType > ) spimData.getSequenceDescription().getImgLoader().getSetupImgLoader( vd.getViewSetupId() ).getImage( vd.getTimePointId() ); di.exportImage( img, name ); interval = img;
public static boolean loadDimensions( final SpimData2 spimData, final List< ViewSetup > viewsetups ) { boolean loadedDimensions = false; for ( final ViewSetup vs : viewsetups ) { if ( vs.getSize() == null ) { IOFunctions.println( "Dimensions of viewsetup " + vs.getId() + " unknown. Loading them ... " ); for ( final TimePoint t : spimData.getSequenceDescription().getTimePoints().getTimePointsOrdered() ) { final ViewDescription vd = spimData.getSequenceDescription().getViewDescription( t.getId(), vs.getId() ); if ( vd.isPresent() ) { Dimensions dim = spimData.getSequenceDescription().getImgLoader().getSetupImgLoader( vd.getViewSetupId() ).getImageSize( vd.getTimePointId() ); IOFunctions.println( "Dimensions: " + dim.dimension( 0 ) + "x" + dim.dimension( 1 ) + "x" + dim.dimension( 2 ) + ", loaded from tp:" + t.getId() + " vs: " + vs.getId() ); vs.setSize( dim ); loadedDimensions = true; break; } else { IOFunctions.println( "ViewSetup: " + vs.getId() + " not present in timepoint: " + t.getId() ); } } } } return loadedDimensions; }