Search in sources :

Example 1 with SpimData

use of mpicbg.spim.data.SpimData in project bigwarp by saalfeldlab.

the class ExportTransformAsXmlTest method showFixedAndWarpedMoving.

private static void showFixedAndWarpedMoving(File warpedXml, File fixedImageXml) throws SpimDataException {
    final SpimData warpedSpimData = new XmlIoSpimData().load(warpedXml.getAbsolutePath());
    final BdvStackSource<?> bdvStackSource = BdvFunctions.show(warpedSpimData).get(0);
    bdvStackSource.setDisplayRange(0, 255);
    final SpimData fixedSpimData = new XmlIoSpimData().load(fixedImageXml.getAbsolutePath());
    final BdvStackSource<?> bdvStackSource2 = BdvFunctions.show(fixedSpimData, BdvOptions.options().addTo(bdvStackSource.getBdvHandle())).get(0);
    bdvStackSource2.setDisplayRange(0, 255);
}
Also used : XmlIoSpimData(mpicbg.spim.data.XmlIoSpimData) SpimData(mpicbg.spim.data.SpimData) XmlIoSpimData(mpicbg.spim.data.XmlIoSpimData)

Example 2 with SpimData

use of mpicbg.spim.data.SpimData in project bigwarp by saalfeldlab.

the class BigWarpBdvCommand method run.

@Override
public void run() {
    try {
        final SpimData fixedSpimData = new XmlIoSpimData().load(fixedImageXml.getAbsolutePath());
        final SpimData movingSpimData = new XmlIoSpimData().load(movingImageXml.getAbsolutePath());
        new RepeatingReleasedEventsFixer().install();
        final BigWarp.BigWarpData<?> bigWarpData = BigWarpInit.createBigWarpData(movingSpimData, fixedSpimData);
        bw = new BigWarp(bigWarpData, "Big Warp", new ProgressWriterIJ());
        bw.getViewerFrameP().getViewerPanel().requestRepaint();
        bw.getViewerFrameQ().getViewerPanel().requestRepaint();
        bw.getLandmarkFrame().repaint();
        bw.setMovingSpimData(movingSpimData, movingImageXml);
    } catch (final SpimDataException e) {
        e.printStackTrace();
        return;
    }
}
Also used : SpimDataException(mpicbg.spim.data.SpimDataException) XmlIoSpimData(mpicbg.spim.data.XmlIoSpimData) SpimData(mpicbg.spim.data.SpimData) RepeatingReleasedEventsFixer(org.janelia.utility.ui.RepeatingReleasedEventsFixer) BigWarp(bigwarp.BigWarp) XmlIoSpimData(mpicbg.spim.data.XmlIoSpimData) ProgressWriterIJ(bdv.ij.util.ProgressWriterIJ)

Example 3 with SpimData

use of mpicbg.spim.data.SpimData in project bigwarp by saalfeldlab.

the class BigWarpImagePlusPlugIn method run.

@Override
public void run(final String arg) {
    if (IJ.versionLessThan("1.40"))
        return;
    // don't need any open windows if we're using N5
    final int[] ids = WindowManager.getIDList();
    // Find any open images
    final int N = ids == null ? 0 : ids.length;
    final String[] titles = new String[N + 1];
    for (int i = 0; i < N; ++i) {
        titles[i] = (WindowManager.getImage(ids[i])).getTitle();
    }
    titles[N] = "<None>";
    // Build a dialog to choose the moving and fixed images
    final GenericDialogPlus gd = new GenericDialogPlus("Big Warp Setup");
    gd.addMessage("Image Selection:");
    ImagePlus currimg = WindowManager.getCurrentImage();
    String current = titles[N];
    if (currimg != null) {
        current = currimg.getTitle();
    }
    gd.addChoice("moving_image", titles, current);
    if (titles.length > 1)
        gd.addChoice("target_image", titles, current.equals(titles[0]) ? titles[1] : titles[0]);
    else
        gd.addChoice("target_image", titles, titles[0]);
    gd.addMessage("\nN5/Zarr/HDF5/BDV-XML");
    gd.addDirectoryOrFileField("Moving", "");
    gd.addStringField("Moving dataset", "");
    gd.addDirectoryOrFileField("Target", "");
    gd.addStringField("Target dataset", "");
    gd.addMessage("");
    gd.addFileField("Landmarks file", "");
    gd.addCheckbox("Apply transform from landmarks", true);
    gd.showDialog();
    if (gd.wasCanceled())
        return;
    final int mvgImgIdx = gd.getNextChoiceIndex();
    final int tgtImgIdx = gd.getNextChoiceIndex();
    movingIp = mvgImgIdx < N ? WindowManager.getImage(ids[mvgImgIdx]) : null;
    targetIp = tgtImgIdx < N ? WindowManager.getImage(ids[tgtImgIdx]) : null;
    final String mvgRoot = gd.getNextString();
    final String mvgDataset = gd.getNextString();
    final String tgtRoot = gd.getNextString();
    final String tgtDataset = gd.getNextString();
    final String landmarkPath = gd.getNextString();
    final boolean applyTransform = gd.getNextBoolean();
    // build bigwarp data
    BigWarpData<?> bigwarpdata = BigWarpInit.initData();
    int id = 0;
    if (movingIp != null) {
        id += BigWarpInit.add(bigwarpdata, movingIp, id, 0, true);
    }
    SpimData movingSpimData = null;
    if (!mvgRoot.isEmpty()) {
        if (openWithImageJ(mvgRoot)) {
            final ImagePlus mvgIpFromFile = IJ.openImage(mvgRoot);
            mvgIpFromFile.show();
            BigWarpInit.add(bigwarpdata, mvgIpFromFile, id, 0, true);
        } else {
            movingSpimData = BigWarpInit.addToData(bigwarpdata, true, id, mvgRoot, mvgDataset);
        }
        id++;
    }
    if (targetIp != null) {
        id += BigWarpInit.add(bigwarpdata, targetIp, id, 0, false);
    }
    if (!tgtRoot.isEmpty()) {
        if (openWithImageJ(tgtRoot)) {
            final ImagePlus tgtIpFromFile = IJ.openImage(tgtRoot);
            tgtIpFromFile.show();
            BigWarpInit.add(bigwarpdata, tgtIpFromFile, id, 0, false);
        } else {
            BigWarpInit.addToData(bigwarpdata, false, id, tgtRoot, tgtDataset);
        }
        id++;
    }
    bigwarpdata.wrapUp();
    // run BigWarp
    try {
        new RepeatingReleasedEventsFixer().install();
        final BigWarp<?> bw = new BigWarp<>(bigwarpdata, "Big Warp", new ProgressWriterIJ());
        if (landmarkPath != null && !landmarkPath.isEmpty()) {
            bw.loadLandmarks(landmarkPath);
            if (applyTransform)
                bw.setIsMovingDisplayTransformed(applyTransform);
        }
        if (movingSpimData != null)
            bw.setMovingSpimData(movingSpimData, new File(mvgRoot));
        bw.getViewerFrameP().getViewerPanel().requestRepaint();
        bw.getViewerFrameQ().getViewerPanel().requestRepaint();
        bw.getLandmarkFrame().repaint();
    } catch (final SpimDataException e) {
        e.printStackTrace();
        return;
    }
}
Also used : SpimDataException(mpicbg.spim.data.SpimDataException) GenericDialogPlus(fiji.util.gui.GenericDialogPlus) SpimData(mpicbg.spim.data.SpimData) RepeatingReleasedEventsFixer(org.janelia.utility.ui.RepeatingReleasedEventsFixer) ProgressWriterIJ(bdv.ij.util.ProgressWriterIJ) ImagePlus(ij.ImagePlus) BigWarp(bigwarp.BigWarp) File(java.io.File)

Example 4 with SpimData

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

the class SimulatedBeadsImgLoader method spimdataExample.

public static SpimData spimdataExample(final int[] angles, final int axis, final int numPoints, final double[] sigma, final Interval range) {
    final TimePoints timepoints = LegacySimulatedBeadsImgLoader.createTimepoints();
    final ArrayList<ViewSetup> setups = LegacySimulatedBeadsImgLoader.createViewSetups(angles, axis, range);
    final MissingViews missingViews = null;
    final SimulateBeads sb = new SimulateBeads(angles, axis, numPoints, range, range, sigma);
    final SequenceDescription sequenceDescription = new SequenceDescription(timepoints, setups, null, missingViews);
    final ImgLoader imgLoader = new SimulatedBeadsImgLoader(sb);
    sequenceDescription.setImgLoader(imgLoader);
    // get the minimal resolution of all calibrations
    final double minResolution = 1.0;
    final ViewRegistrations viewRegistrations = LegacySimulatedBeadsImgLoader.createViewRegistrations(sequenceDescription.getViewDescriptions(), minResolution);
    // finally create the SpimData itself based on the sequence description and the view registration
    final SpimData spimData = new SpimData(new File(""), sequenceDescription, viewRegistrations);
    return spimData;
}
Also used : TimePoints(mpicbg.spim.data.sequence.TimePoints) ViewRegistrations(mpicbg.spim.data.registration.ViewRegistrations) XmlIoSpimData(mpicbg.spim.data.XmlIoSpimData) SpimData(mpicbg.spim.data.SpimData) SequenceDescription(mpicbg.spim.data.sequence.SequenceDescription) ViewSetup(mpicbg.spim.data.sequence.ViewSetup) MissingViews(mpicbg.spim.data.sequence.MissingViews) ImgLoader(mpicbg.spim.data.sequence.ImgLoader) File(java.io.File) SimulateBeads(net.preibisch.simulation.SimulateBeads)

Example 5 with SpimData

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

the class SimulatedBeadsImgLoader2 method createSpimData.

public static SpimData createSpimData(int numPoints, double[] sigma, Interval rangeSimulation, Interval intervalRender, int rotAxis, double[] ratations, List<double[]> channelShifts, List<double[]> illumShifts, List<double[]> timeShifts, List<double[]> tileShifts, double relativeTileError, boolean centerAngles) {
    SimulateBeads2 sb = new SimulateBeads2(numPoints, sigma, rangeSimulation, intervalRender);
    SimulatedBeadsImgLoader2 loader = new SimulatedBeadsImgLoader2(sb, rotAxis, ratations, channelShifts, illumShifts, timeShifts, tileShifts);
    SequenceDescription sd = new SequenceDescription(createTimePointsFromImgLoader(loader), createViewSetupsFromImgLoader(loader), null, new MissingViews(new ArrayList<>()));
    sd.setImgLoader(loader);
    SpimData res = new SpimData(new File(""), sd, createViewRegistrationsFromImgLoader(loader, relativeTileError, centerAngles));
    return res;
}
Also used : SpimData(mpicbg.spim.data.SpimData) SequenceDescription(mpicbg.spim.data.sequence.SequenceDescription) MissingViews(mpicbg.spim.data.sequence.MissingViews) ArrayList(java.util.ArrayList) SimulateBeads2(net.preibisch.simulation.SimulateBeads2) File(java.io.File)

Aggregations

SpimData (mpicbg.spim.data.SpimData)28 XmlIoSpimData (mpicbg.spim.data.XmlIoSpimData)21 File (java.io.File)8 ArrayList (java.util.ArrayList)7 SpimDataException (mpicbg.spim.data.SpimDataException)7 AffineTransform3D (net.imglib2.realtransform.AffineTransform3D)7 BdvHandle (bdv.util.BdvHandle)6 ImagePlus (ij.ImagePlus)6 BdvStackSource (bdv.util.BdvStackSource)5 AbstractSpimData (mpicbg.spim.data.generic.AbstractSpimData)5 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)5 ARGBType (net.imglib2.type.numeric.ARGBType)5 VolatileSpimSource (bdv.VolatileSpimSource)3 ViewRegistrations (mpicbg.spim.data.registration.ViewRegistrations)3 ProgressWriterIJ (bdv.ij.util.ProgressWriterIJ)2 ConverterSetup (bdv.tools.brightness.ConverterSetup)2 BigWarp (bigwarp.BigWarp)2 BioFormatsBdvOpener (ch.epfl.biop.bdv.bioformats.bioformatssource.BioFormatsBdvOpener)2 SelectableVolatileARGBConverter (de.embl.cba.bdv.utils.converters.SelectableVolatileARGBConverter)2 SelectableARGBConvertedRealSource (de.embl.cba.bdv.utils.sources.SelectableARGBConvertedRealSource)2