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);
}
}
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;
}
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;
}
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();
}
}
}
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 };
}
Aggregations