mpicbg.spim.data.SpimDataException Java Examples
The following examples show how to use
mpicbg.spim.data.SpimDataException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExportSpimData2TIFF.java From SPIM_Registration with GNU General Public License v2.0 | 6 votes |
@Override public boolean finish() { XmlIoSpimData2 io = new XmlIoSpimData2( "" ); try { io.save( spimData, new File( params.getXMLFile() ).getAbsolutePath() ); IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Saved xml '" + io.lastFileName() + "'." ); // this spimdata object was not modified, we just wrote a new one return false; } catch ( SpimDataException e ) { IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Could not save xml '" + io.lastFileName() + "'." ); e.printStackTrace(); return false; } }
Example #2
Source File: ExportSpimData2HDF5.java From SPIM_Registration with GNU General Public License v2.0 | 6 votes |
@Override public boolean finish() { System.out.println( "finish()" ); String path = params.getSeqFile().getAbsolutePath(); try { new XmlIoSpimData2( "" ).save( spimData, path ); IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Saved xml '" + path + "'." ); // this spimdata object was not modified, we just wrote a new one return false; } catch ( SpimDataException e ) { IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Could not save xml '" + path + "'." ); e.printStackTrace(); return false; } }
Example #3
Source File: Generic_Resave_HDF5.java From SPIM_Registration with GNU General Public License v2.0 | 6 votes |
public static < T extends AbstractSpimData< A >, A extends AbstractSequenceDescription< ?, ?, ? super ImgLoader > > void writeXML( final T spimData, final XmlIoAbstractSpimData< A, T > io, final Parameters params, final ProgressWriter progressWriter ) throws SpimDataException { final A seq = spimData.getSequenceDescription(); final ArrayList< Partition > partitions = getPartitions( spimData, params ); final Hdf5ImageLoader hdf5Loader = new Hdf5ImageLoader( params.hdf5File, partitions, null, false ); seq.setImgLoader( hdf5Loader ); spimData.setBasePath( params.seqFile.getParentFile() ); try { if ( !params.onlyRunSingleJob || params.jobId == 0 ) io.save( spimData, params.seqFile.getAbsolutePath() ); progressWriter.setProgress( 1.0 ); } catch ( final Exception e ) { progressWriter.err().println( "Failed to write xml file " + params.seqFile ); e.printStackTrace( progressWriter.err() ); } progressWriter.out().println( "done" ); }
Example #4
Source File: XmlIoBoundingBoxes.java From SPIM_Registration with GNU General Public License v2.0 | 6 votes |
public BoundingBoxes fromXml( final Element allBoundingBoxes ) throws SpimDataException { final BoundingBoxes boundingBoxes = super.fromXml( allBoundingBoxes ); for ( final Element boundingBoxElement : allBoundingBoxes.getChildren( BOUNDINGBOX_TAG ) ) { final String title = boundingBoxElement.getAttributeValue( BOUNDINGBOX_TAG_NAME ); final int[] min = XmlHelpers.getIntArray( boundingBoxElement, BOUNDINGBOX_TAG_MIN ); final int[] max = XmlHelpers.getIntArray( boundingBoxElement, BOUNDINGBOX_TAG_MAX ); boundingBoxes.addBoundingBox( new BoundingBox( title, min, max ) ); } return boundingBoxes; }
Example #5
Source File: XmlIoViewInterestPoints.java From SPIM_Registration with GNU General Public License v2.0 | 6 votes |
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; }
Example #6
Source File: StitchingUIHelper.java From BigStitcher with GNU General Public License v2.0 | 5 votes |
public static void main( String[] args ) throws SpimDataException { String xml = "/Users/spreibi/Documents/Grants and CV/BIMSB/Projects/CLARITY/Big Data Sticher/Dros_converted/dataset.xml"; XmlIoSpimData2 io = new XmlIoSpimData2( null ); final SpimData2 data = io.load( xml ); System.out.println( "chosen ds: " + Util.printCoordinates( askForDownsampling( data, false ) ) ); System.exit( 0 ); }
Example #7
Source File: StitchingExplorerPanel.java From BigStitcher with GNU General Public License v2.0 | 5 votes |
@Override public void saveXML() { try { io.save( data, xml ); for ( final SelectedViewDescriptionListener< AS > l : listeners ) l.save(); if ( SpimData2.class.isInstance( data ) ) { final ViewInterestPoints vip = ( (SpimData2) data ).getViewInterestPoints(); for ( final ViewInterestPointLists vipl : vip.getViewInterestPoints().values() ) { for ( final String label : vipl.getHashMap().keySet() ) { final InterestPointList ipl = vipl.getInterestPointList( label ); ipl.saveInterestPoints( false ); ipl.saveCorrespondingInterestPoints( false ); } } } IOFunctions.println( "Saved XML '" + xml + "'." ); } catch ( SpimDataException e ) { IOFunctions.println( "Failed to save XML '" + xml + "': " + e ); e.printStackTrace(); } }
Example #8
Source File: XmlIoSpimData2.java From SPIM_Registration with GNU General Public License v2.0 | 5 votes |
@Override public Element toXml( final SpimData2 spimData, final File xmlFileDirectory ) throws SpimDataException { final Element root = super.toXml( spimData, xmlFileDirectory ); root.addContent( xmlViewsInterestPoints.toXml( spimData.getViewInterestPoints() ) ); root.addContent( xmlBoundingBoxes.toXml( spimData.getBoundingBoxes() ) ); return root; }
Example #9
Source File: XmlIoSpimData2.java From SPIM_Registration with GNU General Public License v2.0 | 5 votes |
@Override public SpimData2 fromXml( final Element root, final File xmlFile ) throws SpimDataException { final SpimData2 spimData = super.fromXml( root, xmlFile ); final SequenceDescription seq = spimData.getSequenceDescription(); final ViewInterestPoints viewsInterestPoints; Element elem = root.getChild( xmlViewsInterestPoints.getTag() ); if ( elem == null ) { viewsInterestPoints = new ViewInterestPoints(); viewsInterestPoints.createViewInterestPoints( seq.getViewDescriptions() ); } else { viewsInterestPoints = xmlViewsInterestPoints.fromXml( elem, spimData.getBasePath(), seq.getViewDescriptions() ); } spimData.setViewsInterestPoints( viewsInterestPoints ); final BoundingBoxes boundingBoxes; elem = root.getChild( xmlBoundingBoxes.getTag() ); if ( elem == null ) boundingBoxes = new BoundingBoxes(); else boundingBoxes = xmlBoundingBoxes.fromXml( elem ); spimData.setBoundingBoxes( boundingBoxes ); return spimData; }
Example #10
Source File: Main.java From 3Dscript with BSD 2-Clause "Simplified" License | 5 votes |
public static void run(File xmlFile) { BDVRenderer renderer; try { renderer = new BDVRenderer(xmlFile); AnimationEditor editor = new AnimationEditor(renderer, Default3DRecordingProvider.getInstance()); editor.setVisible(true); } catch (SpimDataException e) { e.printStackTrace(); IJ.handleException(e); } }
Example #11
Source File: ViewSetupExplorerPanel.java From SPIM_Registration with GNU General Public License v2.0 | 5 votes |
public void saveXML() { try { io.save( data, xml ); for ( final SelectedViewDescriptionListener< AS > l : listeners ) l.save(); if ( SpimData2.class.isInstance( data ) ) { final ViewInterestPoints vip = ( (SpimData2)data ).getViewInterestPoints(); for ( final ViewInterestPointLists vipl : vip.getViewInterestPoints().values() ) { for ( final String label : vipl.getHashMap().keySet() ) { final InterestPointList ipl = vipl.getInterestPointList( label ); if ( ipl.getInterestPoints() == null ) ipl.loadInterestPoints(); ipl.saveInterestPoints(); if ( ipl.getCorrespondingInterestPoints() == null ) ipl.loadCorrespondingInterestPoints(); ipl.saveCorrespondingInterestPoints(); } } } IOFunctions.println( "Saved XML '" + xml + "'." ); } catch ( SpimDataException e ) { IOFunctions.println( "Failed to save XML '" + xml + "': " + e ); e.printStackTrace(); } }
Example #12
Source File: GenericLoadParseQueryXML.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
protected AS parseXML( final String xmlFilename ) throws SpimDataException { return io.load( xmlFilename ); }
Example #13
Source File: XmlIoSpimData2.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
@Override public void save( final SpimData2 spimData, String xmlFilename ) throws SpimDataException { if ( clusterExt != null && clusterExt.length() > 0 ) { if ( xmlFilename.toLowerCase().endsWith( ".xml" ) ) { xmlFilename = xmlFilename.substring( 0, xmlFilename.length() - 4 ) + "." + this.clusterExt + xmlFilename.substring( xmlFilename.length() - 4, xmlFilename.length() ); } else { xmlFilename += this.clusterExt + ".xml"; } } this.lastFileName = xmlFilename; // fist make a copy of the XML and save it to not loose it if ( new File( xmlFilename ).exists() ) { int maxExistingBackup = 0; for ( int i = 1; i < numBackups; ++i ) if ( new File( xmlFilename + "~" + i ).exists() ) maxExistingBackup = i; else break; // copy the backups try { for ( int i = maxExistingBackup; i >= 1; --i ) copyFile( new File( xmlFilename + "~" + i ), new File( xmlFilename + "~" + (i + 1) ) ); copyFile( new File( xmlFilename ), new File( xmlFilename + "~1" ) ); } catch ( final IOException e ) { IOFunctions.println( "Could not save backup of XML file: " + e ); e.printStackTrace(); } } super.save( spimData, xmlFilename ); }
Example #14
Source File: Resave_TIFF.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
@Override public void run( final String arg0 ) { final LoadParseQueryXML lpq = new LoadParseQueryXML(); if ( !lpq.queryXML( "Resaving as TIFF", "Resave", true, true, true, true ) ) return; final ProgressWriter progressWriter = new ProgressWriterIJ(); progressWriter.out().println( "starting export..." ); final Parameters params = getParameters(); if ( params == null ) return; final SpimData2 data = lpq.getData(); final List< ViewId > viewIds = SpimData2.getAllViewIdsSorted( data, lpq.getViewSetupsToProcess(), lpq.getTimePointsToProcess() ); // write the TIFF's writeTIFF( data, viewIds, new File( params.xmlFile ).getParent(), params.compress, progressWriter ); // write the XML try { final Pair< SpimData2, List< String > > result = createXMLObject( data, viewIds, params ); progressWriter.setProgress( 0.95 ); // write the XML lpq.getIO().save( result.getA(), new File( params.xmlFile ).getAbsolutePath() ); // copy the interest points if they exist copyInterestPoints( data.getBasePath(), new File( params.xmlFile ).getParentFile(), result.getB() ); } catch ( SpimDataException e ) { IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Could not save xml '" + params.xmlFile + "'." ); e.printStackTrace(); } finally { progressWriter.setProgress( 1.00 ); IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Saved xml '" + params.xmlFile + "'." ); } }
Example #15
Source File: Resave_HDF5.java From SPIM_Registration with GNU General Public License v2.0 | 4 votes |
@Override public void run( final String arg0 ) { boolean rememberClusterProcessing = Toggle_Cluster_Options.displayClusterProcessing; Toggle_Cluster_Options.displayClusterProcessing = false; final LoadParseQueryXML xml = new LoadParseQueryXML(); if ( !xml.queryXML( "Resaving as HDF5", "Resave", true, true, true, true ) ) return; Toggle_Cluster_Options.displayClusterProcessing = rememberClusterProcessing; // load all dimensions if they are not known (required for estimating the mipmap layout) if ( loadDimensions( xml.getData(), xml.getViewSetupsToProcess() ) ) { // save the XML again with the dimensions loaded SpimData2.saveXML( xml.getData(), xml.getXMLFileName(), xml.getClusterExtension() ); } final Map< Integer, ExportMipmapInfo > perSetupExportMipmapInfo = proposeMipmaps( xml.getViewSetupsToProcess() ); Generic_Resave_HDF5.lastExportPath = LoadParseQueryXML.defaultXMLfilename; final int firstviewSetupId = xml.getData().getSequenceDescription().getViewSetupsOrdered().get( 0 ).getId(); final Parameters params = Generic_Resave_HDF5.getParameters( perSetupExportMipmapInfo.get( firstviewSetupId ), true, true ); if ( params == null ) return; LoadParseQueryXML.defaultXMLfilename = params.getSeqFile().toString(); final ProgressWriter progressWriter = new ProgressWriterIJ(); progressWriter.out().println( "starting export..." ); final SpimData2 data = xml.getData(); final List< ViewId > viewIds = SpimData2.getAllViewIdsSorted( data, xml.getViewSetupsToProcess(), xml.getTimePointsToProcess() ); // write hdf5 Generic_Resave_HDF5.writeHDF5( reduceSpimData2( data, viewIds ), params, progressWriter ); // write xml sequence description if ( !params.onlyRunSingleJob || params.jobId == 0 ) { try { final Pair< SpimData2, List< String > > result = createXMLObject( data, viewIds, params, progressWriter, false ); xml.getIO().save( result.getA(), params.seqFile.getAbsolutePath() ); progressWriter.setProgress( 0.95 ); // copy the interest points if they exist Resave_TIFF.copyInterestPoints( xml.getData().getBasePath(), params.getSeqFile().getParentFile(), result.getB() ); } catch ( SpimDataException e ) { IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Could not save xml '" + params.getSeqFile() + "': " + e ); throw new RuntimeException( e ); } finally { IOFunctions.println( "(" + new Date( System.currentTimeMillis() ) + "): Saved xml '" + params.getSeqFile() + "'." ); } } progressWriter.setProgress( 1.0 ); progressWriter.out().println( "done" ); }
Example #16
Source File: BDVRenderer.java From 3Dscript with BSD 2-Clause "Simplified" License | 4 votes |
public void openBDV(File xmlFile) throws SpimDataException { options = ViewerOptions.options(); viewer = BigDataViewer.open(xmlFile.getAbsolutePath(), xmlFile.getName(), new ProgressWriterIJ(), options); }
Example #17
Source File: BDVRenderer.java From 3Dscript with BSD 2-Clause "Simplified" License | 4 votes |
public BDVRenderer(File xmlFile) throws SpimDataException { openBDV(xmlFile); // this.tgtW = 0; // TODO // this.tgtH = 0; // TODO float[] pdOut = new float[] {1, 1, 1}; float[] pdIn = new float[] {1, 1, 1}; this.rotationCenter = calculateRotationCenter(); System.out.println("rotcenter: " + Arrays.toString(rotationCenter)); float[] rotcenter = rotationCenter.clone(); CombinedTransform transformation = new CombinedTransform(pdIn, pdOut, rotcenter); DisplayMode mode = viewer.getViewer().getVisibilityAndGrouping().getDisplayMode(); int tp = viewer.getViewer().getState().getCurrentTimepoint(); Interpolation interpolation = viewer.getViewer().getState().getInterpolation(); int currentSource = viewer.getViewer().getState().getCurrentSource(); int nSources = viewer.getViewer().getState().numSources(); double[] min = new double[nSources]; double[] max = new double[nSources]; Color[] colors = new Color[nSources]; SetupAssignments setupAssignments = viewer.getSetupAssignments(); for(int s = 0; s < nSources; s++) { final ConverterSetup setup = setupAssignments.getConverterSetups().get(s); colors[s] = new Color(setup.getColor().get()); min[s] = setup.getDisplayRangeMin(); max[s] = setup.getDisplayRangeMax(); } this.rs = new BDVRenderingState(0, mode, tp, interpolation, currentSource, // current source transformation, colors, min, max); }