/** * Assembles the {@link ViewInterestPoints} object consisting of a list of {@link ViewInterestPointLists} objects for all {@link ViewDescription}s that are present * * @param viewDescriptions - the view description map * */ public void createViewInterestPoints( final Map< ViewId, ViewDescription > viewDescriptions ) { for ( final ViewDescription viewDescription : viewDescriptions.values() ) if ( viewDescription.isPresent() ) interestPointCollectionLookup.put( viewDescription, new ViewInterestPointLists( viewDescription.getTimePointId(), viewDescription.getViewSetupId() ) ); } }
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 ] }; } }
protected ViewId getViewSelection( final String dialogHeader, final String text ) { final ArrayList< ViewDescription > views = SpimData2.getAllViewDescriptionsSorted( spimData, viewIdsToProcess ); final String[] viewChoice = new String[ views.size() ]; for ( int i = 0; i < views.size(); ++i ) { final ViewDescription vd = views.get( i ); viewChoice[ i ] = "Timepoint " + vd.getTimePointId() + ", ViewSetupId " + vd.getViewSetupId(); } if ( defaultViewChoice >= views.size() ) defaultViewChoice = 0; final GenericDialog gd = new GenericDialog( dialogHeader ); gd.addMessage( text ); gd.addChoice( "View", viewChoice, viewChoice[ defaultViewChoice ] ); gd.showDialog(); if ( gd.wasCanceled() ) return null; final ViewId viewId = views.get( defaultViewChoice = gd.getNextChoiceIndex() ); return viewId; }
@Override public void run() { if ( ip.wasCanceled() ) return; final List< InterestPoint > ipList = ip.getInterestPointList(); if ( ipList.size() == 0 ) { IOFunctions.println( "No detections remaining. Quitting." ); return; } // add new label final InterestPointList newIpl = new InterestPointList( lists.getInterestPointList( label ).getBaseDir(), new File( lists.getInterestPointList( label ).getFile().getParentFile(), "tpId_" + vd.getTimePointId() + "_viewSetupId_" + vd.getViewSetupId() + "." + newLabel ) ); newIpl.setInterestPoints( ipList ); newIpl.setCorrespondingInterestPoints( new ArrayList<>() ); newIpl.setParameters( "manually removed detections from '" +label + "'" ); lists.addInterestPointList( newLabel, newIpl ); } }) );
IOFunctions.println( new Date( System.currentTimeMillis() ) + ": TP=" + vd.getTimePointId() + " ViewSetup=" + vd.getViewSetupId() + ", Detections: " + oldIpl.getInterestPointsCopy().size() + " >>> " + newIpl.getInterestPointsCopy().size() );
System.out.println( "Present: " + vd.isPresent() + " -- " + vd.getTimePointId() + " " + vd.getViewSetupId() );
public static ViewRegistrations createViewRegistrations( final Map< ViewId, ViewDescription > viewDescriptionList, final double minResolution ) { final HashMap< ViewId, ViewRegistration > viewRegistrationList = new HashMap< ViewId, ViewRegistration >(); for ( final ViewDescription viewDescription : viewDescriptionList.values() ) if ( viewDescription.isPresent() ) { final ViewRegistration viewRegistration = new ViewRegistration( viewDescription.getTimePointId(), viewDescription.getViewSetupId() ); final VoxelDimensions voxelSize = viewDescription.getViewSetup().getVoxelSize(); 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 ); viewRegistration.preconcatenateTransform( vt ); viewRegistrationList.put( viewRegistration, viewRegistration ); } return new ViewRegistrations( viewRegistrationList ); }
return DisplayImage.getImagePlusInstance( img, false, "tp: " + viewDescription.getTimePoint().getName() + " viewSetup: " + viewDescription.getViewSetupId(), Double.NaN, Double.NaN ); else return DisplayImage.getImagePlusInstance( img, false, "tp: " + viewDescription.getTimePoint().getName() + " viewSetup: " + viewDescription.getViewSetupId(), minIntensity, maxIntensity );
regMap.put( vDesc, new ViewRegistration( vDesc.getTimePointId(), vDesc.getViewSetupId() ) ); final ViewRegistrations viewRegistrations = new ViewRegistrations( regMap );
if ( viewDescription.isPresent() ) final ViewRegistration viewRegistration = new ViewRegistration( viewDescription.getTimePointId(), viewDescription.getViewSetupId() );
public static String getTitle( final int splittingType, final Group< ViewDescription > group ) { String title; final ViewDescription vd0 = group.iterator().next(); if ( splittingType == 0 ) // "Each timepoint & channel" title = "fused_tp_" + vd0.getTimePointId() + "_ch_" + vd0.getViewSetup().getChannel().getId(); else if ( splittingType == 1 ) // "Each timepoint, channel & illumination" title = "fused_tp_" + vd0.getTimePointId() + "_ch_" + vd0.getViewSetup().getChannel().getId() + "_illum_" + vd0.getViewSetup().getIllumination().getId(); else if ( splittingType == 2 ) // "All views together" title = "fused"; else // "All views" title = "fused_tp_" + vd0.getTimePointId() + "_vs_" + vd0.getViewSetupId(); return title; }
final ViewRegistration viewRegistration = new ViewRegistration( vDesc.getTimePointId(), vDesc.getViewSetupId() ); viewRegistration.identity(); regMap.put( viewRegistration, viewRegistration );
RandomAccessibleInterval< FloatType > img = spimData.getSequenceDescription().getImgLoader().getSetupImgLoader( vd.getViewSetupId() ).getFloatImage( vd.getTimePointId(), false );
public static < T extends RealType< T > & NativeType< T > > boolean maxProject( final List< ? extends ViewDescription > vds, final ImgLoader imgLoader, final T type ) { Collections.sort( vds ); final ArrayList< TimePoint > tps = SpimData2.getAllTimePointsSorted( vds ); final ArrayList< ViewSetup > setups = SpimData2.getAllViewSetups( vds ); for ( final ViewSetup setup : setups ) { ImageStack stack = null; for ( final TimePoint t : tps ) for ( final ViewDescription vd : vds ) if ( vd.getTimePointId() == t.getId() && vd.getViewSetupId() == setup.getId() ) { IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Loading image for timepoint " + t.getId() + " viewsetup " + vd.getViewSetupId() ); final RandomAccessibleInterval< T > img = getImage( type, imgLoader, vd, false ); final FloatProcessor fp = toProcessor( PSFCombination.computeMaxProjection( img, new ArrayImgFactory< T >(), 2, true ) ); if ( stack == null ) stack = new ImageStack( fp.getWidth(), fp.getHeight() ); stack.addSlice( "Timepoint=" + t.getId(), fp); } final ImagePlus imp = new ImagePlus( "ViewSetupId=" + setup.getId(), stack ); imp.setDimensions( 1, 1, stack.getSize() ); imp.show(); } return true; }
public static void updateMissingViews( final SpimData2 spimData, final List< ViewId > viewIds ) { for ( final ViewId viewId : viewIds ) { final ViewDescription vd = spimData.getSequenceDescription().getViewDescription( viewId ); if ( !vd.isPresent() ) { for ( final ViewDescription vdc : spimData.getSequenceDescription().getViewDescriptions().values() ) { if ( vd.getViewSetup().getAngle() == vdc.getViewSetup().getAngle() && vd.getViewSetup().getChannel() == vdc.getViewSetup().getChannel() && vd.getViewSetup().getTile() == vdc.getViewSetup().getTile() && vdc.getViewSetupId() != vd.getViewSetupId() ) { System.out.println( "Missing view " + Group.pvid( vd ) + " compensated from " + Group.pvid( vdc ) ); final ViewRegistration vrc = spimData.getViewRegistrations().getViewRegistration( vdc ); vrc.updateModel(); final ViewRegistration vr = spimData.getViewRegistrations().getViewRegistration( vd ); vr.getTransformList().clear(); vr.getTransformList().addAll( vrc.getTransformList() ); vr.updateModel(); } } } } }
IOFunctions.println( new Date( System.currentTimeMillis() ) + ": TP=" + vd.getTimePointId() + " ViewSetup=" + vd.getViewSetupId() + ", Detections: " + oldIpl.getInterestPointsCopy().size() + " >>> " + newIpl.getInterestPointsCopy().size() );
final ViewRegistration viewRegistration = new ViewRegistration( vd.getTimePointId(), vd.getViewSetupId() ); viewRegistration.identity(); regMap.put( vd, viewRegistration );
final String name = "TPId" + vd.getTimePointId() + "_SetupId" + vd.getViewSetupId() + "+(label='" + label + "')"; final Interval interval; final RandomAccessibleInterval< UnsignedShortType > img = ( RandomAccessibleInterval< UnsignedShortType > ) spimData.getSequenceDescription().getImgLoader().getSetupImgLoader( vd.getViewSetupId() ).getImage( vd.getTimePointId() ); di.exportImage( img, name ); interval = img;
if ( viewDescription.isPresent() ) final ViewRegistration viewRegistration = new ViewRegistration( viewDescription.getTimePointId(), viewDescription.getViewSetupId() ); final VoxelDimensions voxelSize = viewDescription.getViewSetup().getVoxelSize();
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; }