Search in sources :

Example 1 with XmlIoSpimDataMinimal

use of bdv.spimdata.XmlIoSpimDataMinimal in project labkit-ui by juglab.

the class HDF5Saver method writeXml.

private void writeXml() {
    try {
        BasicImgLoader imgLoader = new Hdf5ImageLoader(hdf5, partitions, data.getSequenceDescription());
        SpimDataMinimal spimData = new SpimDataMinimal(data, imgLoader);
        new XmlIoSpimDataMinimal().save(spimData, xml.getAbsolutePath());
    } catch (SpimDataException e) {
        throw new RuntimeException(e);
    }
}
Also used : XmlIoSpimDataMinimal(bdv.spimdata.XmlIoSpimDataMinimal) SpimDataException(mpicbg.spim.data.SpimDataException) Hdf5ImageLoader(bdv.img.hdf5.Hdf5ImageLoader) XmlIoSpimDataMinimal(bdv.spimdata.XmlIoSpimDataMinimal) SpimDataMinimal(bdv.spimdata.SpimDataMinimal) BasicImgLoader(mpicbg.spim.data.generic.sequence.BasicImgLoader)

Example 2 with XmlIoSpimDataMinimal

use of bdv.spimdata.XmlIoSpimDataMinimal in project mars-fx by duderstadt-lab.

the class MarsBdvFrame method loadAsSpimDataMinimal.

private Source<T> loadAsSpimDataMinimal(MarsBdvSource source, MarsMetadata meta) {
    SpimDataMinimal spimData;
    try {
        spimData = new XmlIoSpimDataMinimal().load(source.getPath());
        // Add transforms to spimData...
        Map<ViewId, ViewRegistration> registrations = spimData.getViewRegistrations().getViewRegistrations();
        for (ViewId id : registrations.keySet()) {
            if (source.getCorrectDrift()) {
                double dX = meta.getPlane(0, 0, 0, id.getTimePointId()).getXDrift();
                double dY = meta.getPlane(0, 0, 0, id.getTimePointId()).getYDrift();
                registrations.get(id).getModel().set(source.getAffineTransform3D(dX, dY));
            } else
                registrations.get(id).getModel().set(source.getAffineTransform3D());
        }
        if (spimData.getSequenceDescription().getTimePoints().size() > numTimePoints)
            numTimePoints = spimData.getSequenceDescription().getTimePoints().size();
        return new SpimSource<T>(spimData, 0, source.getName());
    } catch (SpimDataException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : XmlIoSpimDataMinimal(bdv.spimdata.XmlIoSpimDataMinimal) SpimDataException(mpicbg.spim.data.SpimDataException) SpimSource(bdv.SpimSource) XmlIoSpimDataMinimal(bdv.spimdata.XmlIoSpimDataMinimal) SpimDataMinimal(bdv.spimdata.SpimDataMinimal) ViewId(mpicbg.spim.data.sequence.ViewId) ViewRegistration(mpicbg.spim.data.registration.ViewRegistration)

Example 3 with XmlIoSpimDataMinimal

use of bdv.spimdata.XmlIoSpimDataMinimal in project mastodon-tracking by mastodon-sc.

the class DetectionUtil method loadData.

public static List<SourceAndConverter<?>> loadData(final String bdvFile) throws SpimDataException {
    // Try to emulate what SharedBigDataViewerData does, without the viewer
    // thingies.
    final SpimDataMinimal spimData = new XmlIoSpimDataMinimal().load(bdvFile);
    final ArrayList<ConverterSetup> converterSetups = new ArrayList<>();
    final ArrayList<SourceAndConverter<?>> sources = new ArrayList<>();
    BigDataViewer.initSetups(spimData, converterSetups, sources);
    // Manual transformation.
    final ManualTransformation manualTransformation = new ManualTransformation(sources);
    if (bdvFile.startsWith("http://")) {
        // load settings.xml from the BigDataServer
        final String settings = bdvFile + "settings";
        {
            try {
                final SAXBuilder sax = new SAXBuilder();
                final Document doc = sax.build(settings);
                final Element root = doc.getRootElement();
                manualTransformation.restoreFromXml(root);
            } catch (final FileNotFoundException e) {
            } catch (final Exception e) {
                e.printStackTrace();
            }
        }
    } else if (bdvFile.endsWith(".xml")) {
        final String settings = bdvFile.substring(0, bdvFile.length() - ".xml".length()) + ".settings" + ".xml";
        final File proposedSettingsFile = new File(settings);
        if (proposedSettingsFile.isFile()) {
            try {
                final SAXBuilder sax = new SAXBuilder();
                final Document doc = sax.build(proposedSettingsFile);
                final Element root = doc.getRootElement();
                manualTransformation.restoreFromXml(root);
            } catch (final Exception e) {
                e.printStackTrace();
            }
        }
    }
    return sources;
}
Also used : ManualTransformation(bdv.tools.transformation.ManualTransformation) SAXBuilder(org.jdom2.input.SAXBuilder) Element(org.jdom2.Element) ConverterSetup(bdv.tools.brightness.ConverterSetup) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) Document(org.jdom2.Document) FileNotFoundException(java.io.FileNotFoundException) SpimDataException(mpicbg.spim.data.SpimDataException) ExecutionException(java.util.concurrent.ExecutionException) XmlIoSpimDataMinimal(bdv.spimdata.XmlIoSpimDataMinimal) XmlIoSpimDataMinimal(bdv.spimdata.XmlIoSpimDataMinimal) SpimDataMinimal(bdv.spimdata.SpimDataMinimal) SourceAndConverter(bdv.viewer.SourceAndConverter) File(java.io.File)

Example 4 with XmlIoSpimDataMinimal

use of bdv.spimdata.XmlIoSpimDataMinimal in project bigdataviewer-biop-tools by BIOP.

the class ReorderDatasetCommand method run.

@Override
public void run() {
    if (xmlout.exists()) {
        IJ.error("The output file already exist! Skipping execution");
    } else {
        try {
            BioFormatsBdvOpener opener = BioFormatsConvertFilesToSpimData.getDefaultOpener(file.getAbsolutePath()).micrometer();
            IFormatReader reader = opener.getNewReader();
            // .getSeriesRootTransform()
            Length[] voxSizes = BioFormatsMetaDataHelper.getSeriesVoxelSizeAsLengths((IMetadata) reader.getMetadataStore(), 0);
            double pixSizeXYMicrometer = voxSizes[0].value(UNITS.MICROMETER).doubleValue();
            double scalingForBigStitcher = 1 / pixSizeXYMicrometer;
            reader.close();
            AbstractSpimData<?> asd = BioFormatsConvertFilesToSpimData.getSpimData(opener.voxSizeReferenceFrameLength(new Length(1, UNITS.MICROMETER)).positionReferenceFrameLength(new Length(1, UNITS.MICROMETER)));
            String intermediateXml = FilenameUtils.removeExtension(xmlout.getAbsolutePath()) + "_nonreordered.xml";
            System.out.println(intermediateXml);
            // Remove display settings attributes because this causes issues with BigStitcher
            SpimDataHelper.removeEntities(asd, Displaysettings.class, FileIndex.class);
            // Save non reordered dataset
            asd.setBasePath((new File(intermediateXml)).getParentFile());
            if (asd instanceof SpimData) {
                (new XmlIoSpimData()).save((SpimData) asd, intermediateXml);
            } else if (asd instanceof SpimDataMinimal) {
                (new XmlIoSpimDataMinimal()).save((SpimDataMinimal) asd, FilenameUtils.getName(intermediateXml));
            }
            // Creates reordered dataset
            LifReOrdered kd = new LifReOrdered(intermediateXml, nTiles, nChannels);
            kd.initialize();
            AbstractSpimData reshuffled = kd.constructSpimData();
            // TODO TOFIX
            reshuffled.setBasePath(new File(xmlout.getAbsolutePath()).getParentFile());
            new XmlIoSpimData().save((SpimData) reshuffled, xmlout.getAbsolutePath());
            SpimDataHelper.scale(reshuffled, "BigStitcher Scaling", scalingForBigStitcher);
            String bigstitcherXml = FilenameUtils.removeExtension(xmlout.getAbsolutePath()) + "_bigstitcher.xml";
            new XmlIoSpimData().save((SpimData) reshuffled, bigstitcherXml);
            IJ.log("- Dataset created - " + intermediateXml);
            IJ.log("- Reordered Dataset created - " + xmlout.getAbsolutePath());
            IJ.log("- Reordered Dataset created, rescaled for BigStitched - " + bigstitcherXml);
            IJ.log("Done!");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : IFormatReader(loci.formats.IFormatReader) AbstractSpimData(mpicbg.spim.data.generic.AbstractSpimData) XmlIoSpimData(mpicbg.spim.data.XmlIoSpimData) BioFormatsConvertFilesToSpimData(ch.epfl.biop.bdv.bioformats.export.spimdata.BioFormatsConvertFilesToSpimData) SpimData(mpicbg.spim.data.SpimData) LifReOrdered(ch.epfl.biop.spimdata.reordered.LifReOrdered) XmlIoSpimData(mpicbg.spim.data.XmlIoSpimData) AbstractSpimData(mpicbg.spim.data.generic.AbstractSpimData) XmlIoSpimDataMinimal(bdv.spimdata.XmlIoSpimDataMinimal) Length(ome.units.quantity.Length) XmlIoSpimDataMinimal(bdv.spimdata.XmlIoSpimDataMinimal) SpimDataMinimal(bdv.spimdata.SpimDataMinimal) BioFormatsBdvOpener(ch.epfl.biop.bdv.bioformats.bioformatssource.BioFormatsBdvOpener) File(java.io.File)

Example 5 with XmlIoSpimDataMinimal

use of bdv.spimdata.XmlIoSpimDataMinimal in project bigwarp by saalfeldlab.

the class XMLLoader method load.

@SuppressWarnings("unchecked")
@Override
public SpimDataMinimal[] load() {
    names = new ArrayList<String>();
    SpimDataMinimal spimData = null;
    try {
        spimData = new XmlIoSpimDataMinimal().load(xmlPath);
        numSources = spimData.getSequenceDescription().getViewSetupsOrdered().size();
        for (BasicViewSetup s : spimData.getSequenceDescription().getViewSetupsOrdered()) {
            names.add(s.getName());
        }
        if (WrapBasicImgLoader.wrapImgLoaderIfNecessary(spimData)) {
            System.err.println("WARNING:\nOpening <SpimData> dataset that is not suited for interactive browsing.\nConsider resaving as HDF5 for better performance.");
        }
    } catch (final SpimDataException e) {
        e.printStackTrace();
    }
    return new SpimDataMinimal[] { spimData };
}
Also used : XmlIoSpimDataMinimal(bdv.spimdata.XmlIoSpimDataMinimal) SpimDataException(mpicbg.spim.data.SpimDataException) XmlIoSpimDataMinimal(bdv.spimdata.XmlIoSpimDataMinimal) SpimDataMinimal(bdv.spimdata.SpimDataMinimal) BasicViewSetup(mpicbg.spim.data.generic.sequence.BasicViewSetup)

Aggregations

SpimDataMinimal (bdv.spimdata.SpimDataMinimal)7 XmlIoSpimDataMinimal (bdv.spimdata.XmlIoSpimDataMinimal)7 File (java.io.File)4 SpimDataException (mpicbg.spim.data.SpimDataException)4 Hdf5ImageLoader (bdv.img.hdf5.Hdf5ImageLoader)3 ArrayList (java.util.ArrayList)3 ViewRegistration (mpicbg.spim.data.registration.ViewRegistration)3 SequenceDescriptionMinimal (bdv.spimdata.SequenceDescriptionMinimal)2 BasicViewSetup (mpicbg.spim.data.generic.sequence.BasicViewSetup)2 ViewRegistrations (mpicbg.spim.data.registration.ViewRegistrations)2 SpimSource (bdv.SpimSource)1 bdv.export (bdv.export)1 ImagePlusImgLoader (bdv.ij.export.imgloader.ImagePlusImgLoader)1 PluginHelper (bdv.ij.util.PluginHelper)1 ProgressWriterIJ (bdv.ij.util.ProgressWriterIJ)1 Partition (bdv.img.hdf5.Partition)1 ConverterSetup (bdv.tools.brightness.ConverterSetup)1 ManualTransformation (bdv.tools.transformation.ManualTransformation)1 SourceAndConverter (bdv.viewer.SourceAndConverter)1 BioFormatsBdvOpener (ch.epfl.biop.bdv.bioformats.bioformatssource.BioFormatsBdvOpener)1