use of bdv.SpimSource 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.SpimSource in project imagej-utils by embl-cba.
the class BdvToVoxelGridImageConverter method setSourceImageAndTransform.
private void setSourceImageAndTransform(String sourceBdvFilePath, InterpolationType interpolationType) {
final SpimData spimData = openSpimData(sourceBdvFilePath);
final SpimSource<T> spimSource = new SpimSource<>(spimData, 0, "");
int level = getClosestSourceLevel(targetVoxelSpacing, spimData);
sourceVoxelSpacing = BdvUtils.getVoxelSpacings(spimData, 0).get(level);
interpolatedSource = spimSource.getInterpolatedSource(0, level, getBdvInterpolation(interpolationType));
sourceTransform = new AffineTransform3D();
spimSource.getSourceTransform(0, level, sourceTransform);
final double[] scalingFactors = Arrays.stream(targetVoxelSpacing).map(x -> 1.0 / x).toArray();
scaleToVoxelGrid = new Scale3D(scalingFactors);
transformedSourceInterval = Intervals.largestContainedInterval(IntervalUtils.scale(targetRealInterval, scalingFactors));
sourceTransform.preConcatenate(scaleToVoxelGrid);
}
Aggregations