public void addViewId(int idx, int tp, int angle, int channel, int tile, int illumination) { List< Integer > val = Arrays.asList( new Integer[] {tp, angle, channel, tile, illumination} ); vidToDescription.put( new ViewId(tp, idx), val ); }
public ViewInterestPointLists getViewInterestPointLists( final int tp, final int setupId ) { return getViewInterestPointLists( new ViewId( tp, setupId ) ); }
@Override public boolean isPresent( final int t ) { return t >= 0 && t < timePointsOrdered.size() && !missingViews.contains( new ViewId( timePointsOrdered.get( t ).getId(), setupId ) ); }
public static void main(String[] args) { DefaultFlatfieldCorrectionWrappedImgLoader testImgLoader = new DefaultFlatfieldCorrectionWrappedImgLoader( null ); testImgLoader.setBrightImage( new ViewId(0,0), new File("/Users/David/Desktop/ell2.tif" )); RandomAccessibleInterval< FloatType > brightImg = testImgLoader.getBrightImg( new ViewId( 0, 0 ) ); ImageJFunctions.show( brightImg ); }
@Override public Dimensions getImageSize(int timepointId) { // NB: in all current uses we should have size information in the sd BasicViewDescription< ? > vd = sd.getViewDescriptions().get( new ViewId( timepointId, setupId ) ); return vd.getViewSetup().getSize(); }
@Override public VoxelDimensions getVoxelSize(int timepointId) { // NB: in all current uses we should have size information in the sd BasicViewDescription< ? > vd = sd.getViewDescriptions().get( new ViewId( timepointId, setupId ) ); return vd.getViewSetup().getVoxelSize(); }
public static ArrayList< ViewId > getAllViewIdsSorted( final SpimData data, final List< ? extends ViewSetup > setups, final List< ? extends TimePoint > tps ) { final ArrayList< ViewId > viewIds = new ArrayList< ViewId >(); for ( final TimePoint tp : tps ) for ( final ViewSetup vs : setups ) { final ViewId v = new ViewId( tp.getId(), vs.getId() ); final ViewDescription vd = data.getSequenceDescription().getViewDescription( v ); if ( vd.isPresent() ) viewIds.add( vd ); } Collections.sort( viewIds ); return viewIds; }
public PointSpreadFunctions fromXml( final Element allPSFs, final File basePath ) throws SpimDataException { final PointSpreadFunctions pointSpreadFunctions = super.fromXml( allPSFs ); for ( final Element psfElement : allPSFs.getChildren( PSF_TAG ) ) { final int tpId = Integer.parseInt( psfElement.getAttributeValue( PSF_TIMEPOINT_ATTRIBUTE_NAME ) ); final int vsId = Integer.parseInt( psfElement.getAttributeValue( PSF_SETUP_ATTRIBUTE_NAME ) ); final String file = psfElement.getChildText( PSF_FILE_TAG ); pointSpreadFunctions.addPSF( new ViewId( tpId, vsId ), new PointSpreadFunction( basePath, file ) ); } return pointSpreadFunctions; }
public IntensityAdjustments fromXml( final Element allIntensityAdjustments ) throws SpimDataException { final IntensityAdjustments intensityAdjustments = super.fromXml( allIntensityAdjustments ); for ( final Element intensityAdjustmentElement : allIntensityAdjustments.getChildren( INTENSITYADJ_TAG ) ) { final int timepointId = Integer.parseInt( intensityAdjustmentElement.getAttributeValue( INTENSITYADJ_TIMEPOINT_ATTRIBUTE_NAME ) ); final int setupId = Integer.parseInt( intensityAdjustmentElement.getAttributeValue( INTENSITYADJ_SETUP_ATTRIBUTE_NAME ) ); final double[] modelArray = XmlHelpers.getDoubleArray( intensityAdjustmentElement, INTENSITYADJ_VALUE_TAG ); final AffineModel1D model = new AffineModel1D(); model.set( modelArray[ 0 ], modelArray[ 1 ] ); intensityAdjustments.addIntensityAdjustments( new ViewId( timepointId, setupId ), model ); } return intensityAdjustments; }
protected static BasicImgLoader createImageLoader( final SPIMConfiguration conf, final ArrayList< ViewSetup > setups ) { final int numTimepoints = conf.timepoints.length; final HashMap< ViewId, String > filenames = new HashMap<>(); for ( int timepoint = 0; timepoint < numTimepoints; ++timepoint ) { final int timepointId = conf.timepoints[ timepoint ]; final ViewStructure viewStructure = ViewStructure.initViewStructure( conf, timepoint, new mpicbg.models.AffineModel3D(), "ViewStructure Timepoint " + timepointId, conf.debugLevelInt ); for ( final ViewDataBeads viewDataBeads : viewStructure.getViews() ) { // get ViewId final int angle = viewDataBeads.getAcqusitionAngle(); final int illumination = viewDataBeads.getIllumination(); final int channel = viewDataBeads.getChannel(); final int setupId = getViewSetupId( setups, angle, illumination, channel ); filenames.put( new ViewId( timepointId, setupId ), viewDataBeads.getFileName() ); } } if ( conf.isHuiskenFormat() ) { final String exp = conf.inputdirectory.endsWith( "/" ) ? conf.inputdirectory.substring( 0, conf.inputdirectory.length() - 1 ) : conf.inputdirectory; return new HuiskenImageLoader( new File( exp + ".xml" ), Entity.idMap( setups ) ); } else { final boolean useImageJOpener = conf.inputFilePattern.endsWith( ".tif" ); return new StackImageLoader( filenames, useImageJOpener ); } }
protected void loadTimepoint( final int timepointIndex ) { currentTimePointIndex = timepointIndex; currentTimePointIsPresent = isPresent( timepointIndex ); if ( currentTimePointIsPresent ) { final int timepointId = timePointsOrdered.get( timepointIndex ).getId(); final ViewId viewId = new ViewId( timepointId, setupId ); final AffineTransform3D reg = viewRegistrations.get( viewId ).getModel(); for ( int level = 0; level < currentSourceTransforms.length; level++ ) { final AffineTransform3D mipmapTransform = getMipmapTransforms()[ level ]; currentSourceTransforms[ level ].set( reg ); currentSourceTransforms[ level ].concatenate( mipmapTransform ); } } else { for ( final AffineTransform3D t : currentSourceTransforms ) t.identity(); } }
/** * @param seqDesc the sequence description * @param t - the timepoint * @param c - the channel * @param a - the angle * @param i - the illumination * @param x - the tile * @return - the ViewId that fits to timepoint, angle, channel & illumination by ID (or null if it does not exist) */ public static ViewId getViewId( final SequenceDescription seqDesc, final TimePoint t, final Channel c, final Angle a, final Illumination i, final Tile x ) { final ViewSetup viewSetup = getViewSetup( seqDesc.getViewSetupsOrdered(), c, a, i, x ); if ( viewSetup == null ) return null; else return new ViewId( t.getId(), viewSetup.getId() ); }
public ViewInterestPoints fromXml( final Element allInterestPointLists, final File basePath, final Map< ViewId, ViewDescription > viewDescriptions ) throws SpimDataException { final ViewInterestPoints viewsInterestPoints = super.fromXml( allInterestPointLists ); viewsInterestPoints.createViewInterestPoints( viewDescriptions ); for ( final Element viewInterestPointsElement : allInterestPointLists.getChildren( VIEWINTERESTPOINTSFILE_TAG ) ) { final int timepointId = Integer.parseInt( viewInterestPointsElement.getAttributeValue( VIEWINTERESTPOINTS_TIMEPOINT_ATTRIBUTE_NAME ) ); final int setupId = Integer.parseInt( viewInterestPointsElement.getAttributeValue( VIEWINTERESTPOINTS_SETUP_ATTRIBUTE_NAME ) ); final String label = viewInterestPointsElement.getAttributeValue( VIEWINTERESTPOINTS_LABEL_ATTRIBUTE_NAME ); final String parameters = viewInterestPointsElement.getAttributeValue( VIEWINTERESTPOINTS_PARAMETERS_ATTRIBUTE_NAME ); final String interestPointFileName = viewInterestPointsElement.getTextTrim(); final ViewId viewId = new ViewId( timepointId, setupId ); final ViewInterestPointLists collection = viewsInterestPoints.getViewInterestPointLists( viewId ); // we do not load the interestpoints nor the correspondinginterestpoints, we just do that once it is requested final InterestPointList list = new InterestPointList( basePath, new File( interestPointFileName ) ); list.setParameters( parameters ); collection.addInterestPointList( label, list ); } return viewsInterestPoints; }
@Override public FileMapImgLoaderLOCI2 fromXml(Element elem, File basePath, AbstractSequenceDescription< ?, ?, ? > sequenceDescription) { final boolean zGrouped = XmlHelpers.getBoolean( elem, ZGROUPED_TAG, false ); // final File path = loadPath( elem, DIRECTORY_TAG, basePath ); final Element fileMapElement = elem.getChild( FILES_TAG ); final HashMap< BasicViewDescription< ? >, Pair< File, Pair< Integer, Integer > > > fileMap = new HashMap<>(); for ( Element e : fileMapElement.getChildren( FILE_MAPPING_TAG ) ) { int vs = Integer.parseInt( e.getAttribute( MAPPING_VS_TAG ).getValue() ); int tp = Integer.parseInt( e.getAttribute( MAPPING_TP_TAG ).getValue() ); int series = Integer.parseInt( e.getAttribute( MAPPING_SERIES_TAG ).getValue() ); int channel = Integer.parseInt( e.getAttribute( MAPPING_C_TAG ).getValue() ); File f = XmlHelpers.loadPath( e, MAPPING_FILE_TAG, basePath ); BasicViewDescription< ? > vd = sequenceDescription.getViewDescriptions().get( new ViewId( tp, vs ) ); Pair< File, Pair< Integer, Integer > > p = new ValuePair< File, Pair< Integer, Integer > >( f, new ValuePair< Integer, Integer >( series, channel ) ); fileMap.put( vd, p ); } return new FileMapImgLoaderLOCI2( fileMap, null, sequenceDescription, zGrouped ); }
static class LoopBackImageLoader extends Hdf5ImageLoader { private LoopBackImageLoader( final IHDF5Reader existingHdf5Reader, final AbstractSequenceDescription< ?, ?, ? > sequenceDescription ) { super( null, existingHdf5Reader, null, sequenceDescription, false ); } static LoopBackImageLoader create( final IHDF5Reader existingHdf5Reader, final int timepointIdPartition, final int setupIdPartition, final Dimensions imageDimensions ) { final HashMap< Integer, TimePoint > timepoints = new HashMap<>(); timepoints.put( timepointIdPartition, new TimePoint( timepointIdPartition ) ); final HashMap< Integer, BasicViewSetup > setups = new HashMap<>(); setups.put( setupIdPartition, new BasicViewSetup( setupIdPartition, null, imageDimensions, null ) ); final SequenceDescriptionMinimal seq = new SequenceDescriptionMinimal( new TimePoints( timepoints ), setups, null, null ); return new LoopBackImageLoader( existingHdf5Reader, seq ); } }
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, "" ); }