public static ArrayList< ViewDescription > getAllViewIdsForChannelSorted( final SpimData data, final Collection< ? extends ViewId > viewIds, final Channel channel ) { final ArrayList< ViewDescription > views = new ArrayList< ViewDescription >(); for ( final ViewId id : viewIds ) { final ViewDescription vd = data.getSequenceDescription().getViewDescription( id ); if ( vd.isPresent() && vd.getViewSetup().getChannel().getId() == channel.getId() ) views.add( vd ); } Collections.sort( views ); return views; }
@Override public int compare( final ViewId o1, final ViewId o2 ) { final int id1 = sd.getViewDescriptions().get( o1 ).getViewSetup().getAttribute( Channel.class ).getId(); final int id2 = sd.getViewDescriptions().get( o2 ).getViewSetup().getAttribute( Channel.class ).getId(); return id1 - id2; } } );
public static ArrayList< ViewDescription > getAllViewIdsForChannelTimePointSorted( final SpimData data, final Collection< ? extends ViewId > viewIds, final Channel channel, final TimePoint timePoint ) { final ArrayList< ViewDescription > views = new ArrayList< ViewDescription >(); for ( final ViewId id : viewIds ) { final ViewDescription vd = data.getSequenceDescription().getViewDescription( id ); if ( vd.isPresent() && vd.getViewSetup().getChannel().getId() == channel.getId() && id.getTimePointId() == timePoint.getId() ) views.add( vd ); } Collections.sort( views ); return views; }
public static ArrayList< Angle > getAllAnglesForChannelTimepointSorted( final SpimData data, final Collection< ? extends ViewId > viewIds, final Channel c, final TimePoint t ) { final HashSet< Angle > angleSet = new HashSet< Angle >(); for ( final ViewId v : viewIds ) { final ViewDescription vd = data.getSequenceDescription().getViewDescription( v ); if ( vd.isPresent() && v.getTimePointId() == t.getId() && vd.getViewSetup().getChannel().getId() == c.getId() ) angleSet.add( vd.getViewSetup().getAngle() ); } final ArrayList< Angle > angles = new ArrayList< Angle >(); angles.addAll( angleSet ); Collections.sort( angles ); return angles; }
public static ArrayList< Illumination > getAllIlluminationsForChannelTimepointSorted( final SpimData data, final Collection< ? extends ViewId > viewIds, final Channel c, final TimePoint t ) { final HashSet< Illumination > illumSet = new HashSet< Illumination >(); for ( final ViewId v : viewIds ) { final ViewDescription vd = data.getSequenceDescription().getViewDescription( v ); if ( vd.isPresent() && v.getTimePointId() == t.getId() && vd.getViewSetup().getChannel().getId() == c.getId() ) illumSet.add( vd.getViewSetup().getIllumination() ); } final ArrayList< Illumination > illums = new ArrayList< Illumination >(); illums.addAll( illumSet ); Collections.sort( illums ); return illums; }
t.setLocation( locations.get( new ViewSetupPrecursor( c.getId(), i.getId(), a.getId(), t.getId() ) ) ); final Calibration cal = calibrations.get( new ViewSetupPrecursor( c.getId(), i.getId(), a.getId(), t.getId() ) ); final VoxelDimensions voxelSize = new FinalVoxelDimensions( cal.calUnit, cal.calX, cal.calY, cal.calZ );
public static FusionResult create( final SpimRegistrationSequence spimseq, final String filepath, final String filepattern, final int numSlices, final double sliceValueMin, final double sliceValueMax, final Map< Integer, AffineTransform3D > perTimePointFusionTransforms ) { // add one fused ViewSetup per channel in the SpimRegistrationSequence final List< Integer > channels = new ArrayList<>(); for ( final BasicViewSetup setup : spimseq.getSequenceDescription().getViewSetupsOrdered() ) { final int channel = setup.getAttribute( Channel.class ).getId(); if ( ! channels.contains( channel ) ) channels.add( channel ); } final TimePoints timepoints = spimseq.getSequenceDescription().getTimePoints(); return new FusionResult( filepath, filepattern, channels, timepoints, numSlices, sliceValueMin, sliceValueMax, perTimePointFusionTransforms ); }
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; }
public static ViewSetup getViewSetup( final List< ? extends ViewSetup > list, final Channel c, final Angle a, final Illumination i, final Tile x ) { for ( final ViewSetup viewSetup : list ) { if ( viewSetup.getAngle().getId() == a.getId() && viewSetup.getChannel().getId() == c.getId() && viewSetup.getIllumination().getId() == i.getId() && viewSetup.getTile().getId() == x.getId() ) { return viewSetup; } } return null; }
public static final ArrayList< ViewDescription > assembleInputData( final SpimData2 spimData, final TimePoint timepoint, final Channel channel, final List< ViewId > viewIdsToProcess ) { final ArrayList< ViewDescription > inputData = new ArrayList< ViewDescription >(); for ( final ViewId viewId : viewIdsToProcess ) { final ViewDescription vd = spimData.getSequenceDescription().getViewDescription( viewId.getTimePointId(), viewId.getViewSetupId() ); if ( !vd.isPresent() || vd.getTimePointId() != timepoint.getId() || vd.getViewSetup().getChannel().getId() != channel.getId() ) continue; // get the most recent model spimData.getViewRegistrations().getViewRegistration( viewId ).updateModel(); inputData.add( vd ); } return inputData; }
/** * find ViewSetup index corresponding to given (angle, illumination, * channel) triple. * * @return setup index or -1 if no corresponding setup was found. */ protected static int getViewSetupId( final ArrayList< ViewSetup > setups, final int angle, final int illumination, final int channel ) { for ( final ViewSetup s : setups ) if ( s.getAngle().getId() == angle && s.getIllumination().getId() == illumination && s.getChannel().getId() == channel ) return s.getId(); return -1; }
@Override public RandomAccessibleInterval< FloatType > getFloatImage( final ViewId view, final boolean normalize ) { final BasicViewDescription< ? > vd = sd.getViewDescriptions().get( view ); final Dimensions d = vd.getViewSetup().getSize(); final VoxelDimensions dv = vd.getViewSetup().getVoxelSize(); final ArrayImg< FloatType, ? > img = ArrayImgs.floats( d.dimension( 0 ), d.dimension( 1 ), d.dimension( 2 ) ); final String ampOrPhaseDir; if ( vd.getViewSetup().getAttribute( Channel.class ).getId() == ampChannelId ) ampOrPhaseDir = amplitudeDir; else if ( vd.getViewSetup().getAttribute( Channel.class ).getId() == phaseChannelId ) ampOrPhaseDir = phaseDir; else throw new RuntimeException( "viewSetupId=" + view.getViewSetupId() + " is not Amplitude nor phase." ); populateImage( img, directory, stackDir, ampOrPhaseDir, zPlanes, timepoints.get( view.getTimePointId() ), extension ); if ( normalize ) normalize( img ); updateMetaDataCache( view, (int)d.dimension( 0 ), (int)d.dimension( 1 ), (int)d.dimension( 2 ), dv.dimension( 0 ), dv.dimension( 1 ), dv.dimension( 2 ) ); return img; }
@Override public RandomAccessibleInterval< UnsignedShortType > getImage( final ViewId view ) { final BasicViewDescription< ? > vd = sd.getViewDescriptions().get( view ); final Dimensions d = vd.getViewSetup().getSize(); final VoxelDimensions dv = vd.getViewSetup().getVoxelSize(); final ArrayImg< UnsignedShortType, ? > img = ArrayImgs.unsignedShorts( d.dimension( 0 ), d.dimension( 1 ), d.dimension( 2 ) ); final String ampOrPhaseDir; if ( vd.getViewSetup().getAttribute( Channel.class ).getId() == ampChannelId ) ampOrPhaseDir = amplitudeDir; else if ( vd.getViewSetup().getAttribute( Channel.class ).getId() == phaseChannelId ) ampOrPhaseDir = phaseDir; else throw new RuntimeException( "viewSetupId=" + view.getViewSetupId() + " is not Amplitude nor phase." ); populateImage( img, directory, stackDir, ampOrPhaseDir, zPlanes, timepoints.get( view.getTimePointId() ), extension ); updateMetaDataCache( view, (int)d.dimension( 0 ), (int)d.dimension( 1 ), (int)d.dimension( 2 ), dv.dimension( 0 ), dv.dimension( 1 ), dv.dimension( 2 ) ); return img; }
@Override public ImgPlus< UnsignedShortType > getImage( final int timepointId, final ImgLoaderHint... hints ) { ensureExpIsOpen(); final int channel = setup.getChannel().getId(); final int illumination = setup.getIllumination().getId(); final int angle = setup.getAngle().getId(); final ImagePlus imp = getImagePlus( timepointId ); final Img< UnsignedShortType > img = ImageJFunctions.wrapShort( imp ); final String name = getBasename( timepointId, angle, channel, illumination ); final AxisType[] axes = new AxisType[] { Axes.X, Axes.Y, Axes.Z }; final float zStretching = ( float ) ( exp.pd / exp.pw ); final double[] calibration = new double[] { 1, 1, zStretching }; return new ImgPlus<>( img, name, axes, calibration ); }
channel.getId() == viewDataBeads.getChannel() )
final int oc = old.getViewSetup().getChannel().getId(); if ( vs.getChannel().getId() == oc ) vsNew = vs; final int oc = old.getViewSetup().getChannel().getId(); final int oi = old.getViewSetup().getIllumination().getId(); if ( vs.getChannel().getId() == oc && vs.getIllumination().getId() == oi ) vsNew = vs;
private ImagePlus getImagePlus( final int timepointId ) { final int channel = setup.getChannel().getId(); final int illumination = setup.getIllumination().getId(); final int angle = setup.getAngle().getId(); final int s = exp.sampleStart; final int r = exp.regionStart; final int f = exp.frameStart; final int zMin = exp.planeStart; final int zMax = exp.planeEnd; final int xMin = 0; final int xMax = exp.w - 1; final int yMin = 0; final int yMax = exp.h - 1; ImagePlus imp; if ( hasAlternatingIllumination ) { final int zStep = 2; if ( illumination == 0 ) imp = exp.openNotProjected( s, timepointId, timepointId, r, angle, channel, zMin, zMax - 1, zStep, f, f, yMin, yMax, xMin, xMax, SPIMExperiment.X, SPIMExperiment.Y, SPIMExperiment.Z, false ); else imp = exp.openNotProjected( s, timepointId, timepointId, r, angle, channel, zMin + 1, zMax, zStep, f, f, yMin, yMax, xMin, xMax, SPIMExperiment.X, SPIMExperiment.Y, SPIMExperiment.Z, false ); } else { imp = exp.openNotProjected( s, timepointId, timepointId, r, angle, channel, zMin, zMax, f, f, yMin, yMax, xMin, xMax, SPIMExperiment.X, SPIMExperiment.Y, SPIMExperiment.Z, false ); } return imp; } }
final int c = vd.getViewSetup().getAttribute( Channel.class ).getId(); final int i = vd.getViewSetup().getAttribute( Illumination.class ).getId();