public static < V extends ViewId > ArrayList< Pair< Channel, Channel > > identifyChannelPairs( final SpimData2 spimData, final List< V > viewIds ) { final SequenceDescription seq = spimData.getSequenceDescription(); final HashSet< Channel > channelSet = new HashSet<>(); for ( final V viewId : viewIds ) channelSet.add( seq.getViewDescription( viewId ).getViewSetup().getChannel() ); final ArrayList< Channel > channels = new ArrayList<>( channelSet ); Collections.sort( channels ); final ArrayList< Pair< Channel, Channel > > channelPairs = new ArrayList<>(); for ( int c1 = 0; c1 < channels.size() - 1; ++c1 ) for ( int c2 = c1 + 1; c2 < channels.size(); ++c2 ) channelPairs.add( new ValuePair< Channel, Channel >( channels.get( c1 ), channels.get( c2 ) ) ); return channelPairs; }
public static ArrayList< Channel > getAllChannelsSorted( final SpimData data, final Collection< ? extends ViewId > viewIds ) { final HashSet< Channel > channelSet = new HashSet< Channel >(); for ( final ViewId v : viewIds ) { final ViewDescription vd = data.getSequenceDescription().getViewDescription( v ); if ( vd.isPresent() ) channelSet.add( vd.getViewSetup().getChannel() ); } final ArrayList< Channel > channels = new ArrayList< Channel >(); channels.addAll( channelSet ); Collections.sort( channels ); return channels; }
public void add( final ViewDescription vd ) { if ( vd == null ) return; this.ts.add( vd.getTimePoint() ); this.cs.add( vd.getViewSetup().getChannel() ); this.is.add( vd.getViewSetup().getIllumination() ); this.as.add( vd.getViewSetup().getAngle() ); this.vds.add( vd ); }
@Override public int compare( final ViewId o1, final ViewId o2 ) { return sd.getViewDescription( o1 ).getViewSetup().getChannel().getId() - sd.getViewDescription( o2 ).getViewSetup().getChannel().getId(); } } );
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; }
private static final void locationForViewDescription( final int[] l, final ViewDescription vd, final HashMap< TimePoint, Integer > mapT, final HashMap< Channel, Integer > mapC, final HashMap< Illumination, Integer > mapI, final HashMap< Angle, Integer > mapA ) { final TimePoint t = vd.getTimePoint(); final Channel c = vd.getViewSetup().getChannel(); final Illumination i = vd.getViewSetup().getIllumination(); final Angle a = vd.getViewSetup().getAngle(); l[ 0 ] = mapA.get( a ); l[ 1 ] = mapI.get( i ); l[ 2 ] = mapC.get( c ); l[ 3 ] = mapT.get( t ); }
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< 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; }
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 void main( String args[] ) { new ImageJ(); IOFunctions.printIJLog = true; final LoadParseQueryXML lpq = new LoadParseQueryXML(); final ArrayList< String > queryFor = new ArrayList< String >(); queryFor.add( "Timepoint" ); queryFor.add( "channel" ); queryFor.add( "angle" ); queryFor.add( "Tile" ); queryFor.add( "illumination" ); lpq.queryXML( true, true, true, true, true ); for ( final TimePoint i : lpq.getTimePointsToProcess() ) System.out.println( i.getId() ); for ( final ViewSetup v : lpq.getViewSetupsToProcess() ) { System.out.println( v.getId() + " " + v.getAngle().getName() + " " + v.getChannel().getName() + " " + v.getIllumination().getName() ); } } }
protected String nameForGroup( final Group< ViewDescription > group ) { final ViewDescription vd1 = group.iterator().next(); String name = "TP=" + vd1.getTimePointId() + " Angle=" + vd1.getViewSetup().getAngle().getName() + " Channel=" + vd1.getViewSetup().getChannel().getName(); if ( !groupIllums ) name += " Illum=" + vd1.getViewSetup().getChannel().getName(); if ( !groupTiles ) name += " Tile=" + vd1.getViewSetup().getTile().getName(); return name; }
final ViewDescription vd2 = seq.getViewDescription( view2 ); final Channel c1 = vd1.getViewSetup().getChannel(); final Channel c2 = vd2.getViewSetup().getChannel();
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; }
/** * 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; }
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; }
@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 ); }
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(); } } } } }
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; } }
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; }
final Channel c = vd.getViewSetup().getChannel(); final Illumination i = vd.getViewSetup().getIllumination(); final Angle a = vd.getViewSetup().getAngle();