Search in sources :

Example 1 with SpimSource

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;
}
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 2 with SpimSource

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);
}
Also used : IntervalUtils(itc.utilities.IntervalUtils) RealViews(net.imglib2.realtransform.RealViews) Arrays(java.util.Arrays) XmlIoSpimData(mpicbg.spim.data.XmlIoSpimData) ImageJFunctions(net.imglib2.img.display.imagej.ImageJFunctions) Interpolation(bdv.viewer.Interpolation) ArrayList(java.util.ArrayList) Intervals(net.imglib2.util.Intervals) NativeType(net.imglib2.type.NativeType) SpimDataException(mpicbg.spim.data.SpimDataException) Scale3D(net.imglib2.realtransform.Scale3D) AffineTransform3D(net.imglib2.realtransform.AffineTransform3D) FileSaver(ij.io.FileSaver) Views(net.imglib2.view.Views) Calibration(ij.measure.Calibration) VoxelDimensions(mpicbg.spim.data.sequence.VoxelDimensions) BdvUtils(de.embl.cba.bdv.utils.BdvUtils) VectorUtils(itc.utilities.VectorUtils) Logger(de.embl.cba.bdv.utils.Logger) ImagePlus(ij.ImagePlus) CopyUtils(de.embl.cba.util.CopyUtils) net.imglib2(net.imglib2) RealType(net.imglib2.type.numeric.RealType) SpimData(mpicbg.spim.data.SpimData) SpimSource(bdv.SpimSource) XmlIoSpimData(mpicbg.spim.data.XmlIoSpimData) SpimData(mpicbg.spim.data.SpimData) SpimSource(bdv.SpimSource) Scale3D(net.imglib2.realtransform.Scale3D) AffineTransform3D(net.imglib2.realtransform.AffineTransform3D)

Aggregations

SpimSource (bdv.SpimSource)2 SpimDataException (mpicbg.spim.data.SpimDataException)2 SpimDataMinimal (bdv.spimdata.SpimDataMinimal)1 XmlIoSpimDataMinimal (bdv.spimdata.XmlIoSpimDataMinimal)1 Interpolation (bdv.viewer.Interpolation)1 BdvUtils (de.embl.cba.bdv.utils.BdvUtils)1 Logger (de.embl.cba.bdv.utils.Logger)1 CopyUtils (de.embl.cba.util.CopyUtils)1 ImagePlus (ij.ImagePlus)1 FileSaver (ij.io.FileSaver)1 Calibration (ij.measure.Calibration)1 IntervalUtils (itc.utilities.IntervalUtils)1 VectorUtils (itc.utilities.VectorUtils)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 SpimData (mpicbg.spim.data.SpimData)1 XmlIoSpimData (mpicbg.spim.data.XmlIoSpimData)1 ViewRegistration (mpicbg.spim.data.registration.ViewRegistration)1 ViewId (mpicbg.spim.data.sequence.ViewId)1 VoxelDimensions (mpicbg.spim.data.sequence.VoxelDimensions)1