/** * A group of ViewIds that represents itself as the first ViewId * * @param group - the ViewIds */ public GroupedViews( final List< ViewId > group ) { super( group.get( 0 ).getTimePointId(), group.get( 0 ).getViewSetupId() ); this.group = group; }
public static String createPSFFileName( final ViewId viewId ) { return "psf_t" + viewId.getTimePointId() + "_v" + viewId.getViewSetupId() + ".tif"; } }
public ViewLevelId( final ViewId viewId, final int level ) { this.timepointId = viewId.getTimePointId(); this.setupId = viewId.getViewSetupId(); this.level = level; }
public static String getGroupPath( final ViewId viewId, final int level ) { return String.format( groupFormatString, viewId.getTimePointId(), viewId.getViewSetupId(), level ); }
/** * Does this partition contain the given {@link ViewId view} * (timepoint-setup pair)? * * @param viewId * view (timepoint and setup id wrt. the full sequence) * @return whether this partition contains the given view. */ public boolean contains( final ViewId viewId ) { return timepointIdSequenceToPartition.containsKey( viewId.getTimePointId() ) && setupIdSequenceToPartition.containsKey( viewId.getViewSetupId() ); }
@Override public Dimensions getImageSize( final ViewId view ) { return sb.getImgs().get( view.getViewSetupId() ); }
public static String pvids( final ViewId viewId ) { return viewId.getTimePointId() + "-" + viewId.getViewSetupId(); } @SuppressWarnings("unchecked")
@Override public VoxelDimensions getVoxelSize( final ViewId view ) { // if there is no data for the viewId if ( !imageMetaDataCache.containsKey( view ) ) { // check if the data is present for the same viewsetup of another timepoint if ( !viewIdLookUp.containsKey( view.getViewSetupId() ) ) loadMetaData( view ); else return imageMetaDataCache.get( viewIdLookUp.get( view.getViewSetupId() ) ).getB(); } return imageMetaDataCache.get( view ).getB(); }
@Override public Dimensions getImageSize( final ViewId view ) { // if there is no data for the viewId if ( !imageMetaDataCache.containsKey( view ) ) { // check if the data is present for the same viewsetup of another timepoint if ( !viewIdLookUp.containsKey( view.getViewSetupId() ) ) loadMetaData( view ); else return imageMetaDataCache.get( viewIdLookUp.get( view.getViewSetupId() ) ).getA(); } final Pair< Dimensions, VoxelDimensions > dims = imageMetaDataCache.get( view ); return dims == null ? null : dims.getA(); }
public static < V extends ViewId > BoundingBox getBoundingBox( final V view, final Map< Integer, ? extends BasicViewSetup > vss, final ViewRegistrations vrs ) { return getBoundingBox( vss.get( view.getViewSetupId() ), vrs.getViewRegistration( view ) ); }
public static < V extends ViewId > RealInterval getBoundingBoxReal( final V view, final Map< Integer, ? extends BasicViewSetup > vss, final ViewRegistrations vrs ) { return getBoundingBoxReal( vss.get( view.getViewSetupId() ), vrs.getViewRegistration( view ) ); }
@Override public RandomAccessibleInterval<FloatType> getFloatImage( final ViewId view, boolean normalize ) { if ( normalize ) { return normalize( sb.getImgs().get( view.getViewSetupId() ).copy() ); } else { return sb.getImgs().get( view.getViewSetupId() ).copy(); } }
public static BasicViewDescription< ? > getAnyPresentViewDescriptionForViewSetup(AbstractSequenceDescription< ?, ?, ? > sd, int viewSetupId) { for (final ViewId vid : sd.getViewDescriptions().keySet()) if (vid.getViewSetupId() == viewSetupId) if (!sd.getMissingViews().getMissingViews().contains( vid )) return sd.getViewDescriptions().get( vid ); return null; }
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; } }
@SuppressWarnings({ "unchecked", "rawtypes" }) public static < T extends RealType< T > > RandomAccessibleInterval< T > getImage( final T type, ImgLoader imgLoader, final ViewId view, final boolean normalize ) { if ( (RealType)type instanceof FloatType ) return (RandomAccessibleInterval)imgLoader.getSetupImgLoader( view.getViewSetupId() ).getFloatImage( view.getTimePointId(), normalize, LOAD_COMPLETELY ); else if ( (RealType)type instanceof UnsignedShortType ) return (RandomAccessibleInterval)imgLoader.getSetupImgLoader( view.getViewSetupId() ).getImage( view.getTimePointId(), LOAD_COMPLETELY ); else return null; }
protected void updateMetaDataCache( final ViewId viewId, final int w, final int h, final int d, final double calX, final double calY, final double calZ ) { imageMetaDataCache.put( viewId, new ValuePair< Dimensions, VoxelDimensions >( new FinalDimensions( new long[] { w, h, d } ), new FinalVoxelDimensions( "", calX, calY, calZ ) ) ); // links the viewSetupId to the last added viewId, overwrites earlier entries viewIdLookUp.put( viewId.getViewSetupId(), viewId ); }
public AffineTransform3D getCroppedTransform( final ViewId view ) { final Pair< ?, AffineTransform3D > pair = getSetupImgLoader( view.getViewSetupId() ).cropView( view.getTimePointId() ); return pair.getB(); }
@Override public RandomAccessibleInterval< UnsignedShortType > getImage( final ViewId view ) { final long[] dim = new long[ sb.getImgs().get( view.getViewSetupId() ).numDimensions() ]; for ( int d = 0; d < dim.length; ++d ) dim[ d ] = sb.getImgs().get( view.getViewSetupId() ).dimension( d ); final Img< UnsignedShortType > img = ArrayImgs.unsignedShorts( dim ); final Cursor< FloatType > in = sb.getImgs().get( view.getViewSetupId() ).cursor(); final Cursor< UnsignedShortType > out = img.cursor(); while ( in.hasNext() ) out.next().set( Math.round( in.next().get() ) ); return img; }
protected Element affineModel1dToXml( final ViewId viewId, final AffineModel1D model ) { final Element elem = new Element( INTENSITYADJ_TAG ); elem.setAttribute( INTENSITYADJ_TIMEPOINT_ATTRIBUTE_NAME, Integer.toString( viewId.getTimePointId() ) ); elem.setAttribute( INTENSITYADJ_SETUP_ATTRIBUTE_NAME, Integer.toString( viewId.getViewSetupId() ) ); final double[] values = new double[ 2 ]; model.toArray( values ); elem.addContent( XmlHelpers.doubleArrayElement( INTENSITYADJ_VALUE_TAG, values ) ); return elem; } }
@Override protected void loadMetaData( final ViewId view ) { try { final MultipageTiffReader r = new MultipageTiffReader( mmFile ); updateMetaDataCache( view, r.width(), r.height(), r.depth(), r.calX(), r.calY(), r.calZ() ); r.close(); } catch ( Exception e ) { IOFunctions.println( "Failed to load metadata for viewsetup=" + view.getViewSetupId() + " timepoint=" + view.getTimePointId() + ": " + e ); e.printStackTrace(); } }