Search in sources :

Example 1 with ViewId

use of mpicbg.spim.data.sequence.ViewId in project multiview-simulation by PreibischLab.

the class SimulatedBeadsImgLoader2 method createViewRegistrationsFromImgLoader.

public static ViewRegistrations createViewRegistrationsFromImgLoader(SimulatedBeadsImgLoader2 imgLoader, double relativeTileError, boolean centerAngles) {
    SimulateBeads2 sb = imgLoader.getSimulateBeads();
    final HashMap<ViewId, ViewRegistration> viewRegistrationList = new HashMap<ViewId, ViewRegistration>();
    final RealInterval tilesExtent = sb.getTilesExtent();
    double[] center = new double[tilesExtent.numDimensions()];
    tilesExtent.realMax(center);
    for (int d = 0; d < center.length; d++) center[d] /= -2.0;
    for (int tp : new ArrayList<>(sb.tpTransforms.keySet()).stream().sorted().collect(Collectors.toList())) {
        int vid = 0;
        for (int a : new ArrayList<>(sb.angleTransforms.keySet()).stream().sorted().collect(Collectors.toList())) for (int channel : new ArrayList<>(sb.channelTransforms.keySet()).stream().sorted().collect(Collectors.toList())) for (int illum : new ArrayList<>(sb.illumTransforms.keySet()).stream().sorted().collect(Collectors.toList())) for (int tile : new ArrayList<>(sb.tileTransforms.keySet()).stream().sorted().collect(Collectors.toList())) {
            final VoxelDimensions voxelSize = new FinalVoxelDimensions("pixels", 1, 1, 1);
            final Dimensions dim = imgLoader.getSimulateBeads().getImg(0, a, channel, tile, illum);
            final ViewRegistration viewRegistration = new ViewRegistration(tp, vid++);
            final double calX = voxelSize.dimension(0);
            final double calY = voxelSize.dimension(1);
            final double calZ = voxelSize.dimension(2);
            final AffineTransform3D m = new AffineTransform3D();
            m.set(calX, 0.0f, 0.0f, 0.0f, 0.0f, calY, 0.0f, 0.0f, 0.0f, 0.0f, calZ, 0.0f);
            final ViewTransform vt = new ViewTransformAffine("calibration", m);
            viewRegistration.preconcatenateTransform(vt);
            double[] translation = sb.tileTransforms.get(tile).inverse().getTranslation();
            for (int i = 0; i < translation.length; i++) translation[i] *= relativeTileError;
            AffineTransform3D atr = new AffineTransform3D();
            atr.translate(translation);
            final ViewTransform vtT = new ViewTransformAffine("translation", atr.copy());
            viewRegistration.preconcatenateTransform(vtT);
            if (centerAngles) {
                AffineTransform3D centerTr = new AffineTransform3D();
                centerTr.translate(center);
                final ViewTransform centerVt = new ViewTransformAffine("center angle", centerTr.copy());
                viewRegistration.preconcatenateTransform(centerVt);
            }
            final ViewTransform vtA = new ViewTransformAffine("rotation", sb.angleTransforms.get(a));
            viewRegistration.preconcatenateTransform(vtA);
            viewRegistrationList.put(viewRegistration, viewRegistration);
        }
    }
    return new ViewRegistrations(viewRegistrationList);
}
Also used : FinalVoxelDimensions(mpicbg.spim.data.sequence.FinalVoxelDimensions) HashMap(java.util.HashMap) ViewRegistration(mpicbg.spim.data.registration.ViewRegistration) ArrayList(java.util.ArrayList) ViewTransform(mpicbg.spim.data.registration.ViewTransform) FinalDimensions(net.imglib2.FinalDimensions) VoxelDimensions(mpicbg.spim.data.sequence.VoxelDimensions) Dimensions(net.imglib2.Dimensions) FinalVoxelDimensions(mpicbg.spim.data.sequence.FinalVoxelDimensions) RealInterval(net.imglib2.RealInterval) TimePoint(mpicbg.spim.data.sequence.TimePoint) VoxelDimensions(mpicbg.spim.data.sequence.VoxelDimensions) FinalVoxelDimensions(mpicbg.spim.data.sequence.FinalVoxelDimensions) ViewRegistrations(mpicbg.spim.data.registration.ViewRegistrations) ViewTransformAffine(mpicbg.spim.data.registration.ViewTransformAffine) ViewId(mpicbg.spim.data.sequence.ViewId) SimulateBeads2(net.preibisch.simulation.SimulateBeads2) AffineTransform3D(net.imglib2.realtransform.AffineTransform3D)

Example 2 with ViewId

use of mpicbg.spim.data.sequence.ViewId in project bigdataviewer-biop-tools by BIOP.

the class ReorderedImageLoader method getVoxelSize.

public VoxelDimensions getVoxelSize(int setupId, int timepointId) {
    SpimDataViewId svi = order.getOriginalLocation(new ViewId(timepointId, setupId));
    AbstractSpimData asd = svi.asd;
    int setupIdRedirect = svi.viewId.getViewSetupId();
    int timepointRedirect = svi.viewId.getTimePointId();
    return getOrFetchImageLoader(asd).getSetupImgLoader(setupIdRedirect).getVoxelSize(timepointRedirect);
}
Also used : AbstractSpimData(mpicbg.spim.data.generic.AbstractSpimData) ViewId(mpicbg.spim.data.sequence.ViewId) ImgLoaderHint(mpicbg.spim.data.generic.sequence.ImgLoaderHint)

Example 3 with ViewId

use of mpicbg.spim.data.sequence.ViewId in project bigdataviewer-biop-tools by BIOP.

the class ReorderedImageLoader method getImage.

public RandomAccessibleInterval getImage(int setupId, int timepointId, int level, ImgLoaderHint... hints) {
    SpimDataViewId sdvi = order.getOriginalLocation(new ViewId(timepointId, setupId));
    AbstractSpimData asd = sdvi.asd;
    int setupIdRedirect = sdvi.viewId.getViewSetupId();
    int timepointRedirect = sdvi.viewId.getTimePointId();
    return getOrFetchImageLoader(asd).getSetupImgLoader(setupIdRedirect).getImage(timepointRedirect, level, hints);
}
Also used : AbstractSpimData(mpicbg.spim.data.generic.AbstractSpimData) ViewId(mpicbg.spim.data.sequence.ViewId) ImgLoaderHint(mpicbg.spim.data.generic.sequence.ImgLoaderHint)

Example 4 with ViewId

use of mpicbg.spim.data.sequence.ViewId in project bigdataviewer-biop-tools by BIOP.

the class ReorderedImageLoader method getSetupImgLoader.

public ReorderedSetupLoader getSetupImgLoader(int setupId) {
    if (imgLoaders.containsKey(setupId)) {
        return imgLoaders.get(setupId);
    } else {
        logger.debug("loading setupId = " + setupId);
        ViewId currentViewId = new ViewId(0, setupId);
        SpimDataViewId svi = order.getOriginalLocation(currentViewId);
        AbstractSpimData originSpimData = svi.asd;
        ViewId originViewId = svi.viewId;
        BasicImgLoader originImageLoader = getOrFetchImageLoader(originSpimData);
        BasicSetupImgLoader setupImgLoader = originImageLoader.getSetupImgLoader(originViewId.getViewSetupId());
        if (!(setupImgLoader instanceof AbstractViewerSetupImgLoader)) {
            logger.error("Origin setup loader is not of instance AbstractViewerSetupImgLoader, reoredering is not supported");
            throw new UnsupportedOperationException("Unsupported setup loader class " + setupImgLoader.getClass());
        }
        if (!(setupImgLoader instanceof MultiResolutionSetupImgLoader)) {
            logger.error("Origin setup loader is not of instance MultiResolutionSetupImgLoader, reoredering is not supported");
            throw new UnsupportedOperationException("Unsupported setup loader class " + setupImgLoader.getClass());
        }
        T originSetupLoader = (T) setupImgLoader;
        originImgLoaders.put(setupId, originSetupLoader);
        ReorderedSetupLoader setupLoader = new ReorderedSetupLoader(this, setupId, (NumericType) originSetupLoader.getImageType(), originSetupLoader.getVolatileImageType());
        imgLoaders.put(setupId, setupLoader);
        return setupLoader;
    }
}
Also used : AbstractSpimData(mpicbg.spim.data.generic.AbstractSpimData) BasicSetupImgLoader(mpicbg.spim.data.generic.sequence.BasicSetupImgLoader) ViewId(mpicbg.spim.data.sequence.ViewId) AbstractViewerSetupImgLoader(bdv.AbstractViewerSetupImgLoader) MultiResolutionSetupImgLoader(mpicbg.spim.data.sequence.MultiResolutionSetupImgLoader) BasicImgLoader(mpicbg.spim.data.generic.sequence.BasicImgLoader)

Example 5 with ViewId

use of mpicbg.spim.data.sequence.ViewId 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)

Aggregations

ViewId (mpicbg.spim.data.sequence.ViewId)8 AbstractSpimData (mpicbg.spim.data.generic.AbstractSpimData)5 ImgLoaderHint (mpicbg.spim.data.generic.sequence.ImgLoaderHint)4 AbstractViewerSetupImgLoader (bdv.AbstractViewerSetupImgLoader)2 ViewRegistration (mpicbg.spim.data.registration.ViewRegistration)2 SpimSource (bdv.SpimSource)1 ViewerSetupImgLoader (bdv.ViewerSetupImgLoader)1 SpimDataMinimal (bdv.spimdata.SpimDataMinimal)1 XmlIoSpimDataMinimal (bdv.spimdata.XmlIoSpimDataMinimal)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 SpimDataException (mpicbg.spim.data.SpimDataException)1 BasicImgLoader (mpicbg.spim.data.generic.sequence.BasicImgLoader)1 BasicSetupImgLoader (mpicbg.spim.data.generic.sequence.BasicSetupImgLoader)1 ViewRegistrations (mpicbg.spim.data.registration.ViewRegistrations)1 ViewTransform (mpicbg.spim.data.registration.ViewTransform)1 ViewTransformAffine (mpicbg.spim.data.registration.ViewTransformAffine)1 FinalVoxelDimensions (mpicbg.spim.data.sequence.FinalVoxelDimensions)1 MultiResolutionSetupImgLoader (mpicbg.spim.data.sequence.MultiResolutionSetupImgLoader)1 TimePoint (mpicbg.spim.data.sequence.TimePoint)1