Search in sources :

Example 1 with XmlIoSpimData

use of mpicbg.spim.data.XmlIoSpimData 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 XmlIoSpimData

use of mpicbg.spim.data.XmlIoSpimData 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 XmlIoSpimData

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

the class BigWarp method saveMovingImageXml.

public File saveMovingImageXml(String proposedFilePath) {
    if (movingSpimData == null) {
        IJ.log("Cannot save warped moving image XML, because the input image was not a BDV/XML.");
        return null;
    }
    final AffineTransform3D bigWarpTransform = getMovingToFixedTransformAsAffineTransform3D();
    System.out.println("bigWarp transform as affine 3d: " + bigWarpTransform.toString());
    movingSpimData.getViewRegistrations().getViewRegistration(0, 0).preconcatenateTransform(new ViewTransformAffine("Big Warp: " + bwTransform.getTransformType(), bigWarpTransform));
    File proposedFile;
    if (proposedFilePath == null) {
        final JFileChooser fileChooser = new JFileChooser(movingImageXml.getParent());
        proposedFile = new File(movingImageXml.getName().replace(".xml", "-bigWarp.xml"));
        fileChooser.setSelectedFile(proposedFile);
        final int returnVal = fileChooser.showSaveDialog(null);
        if (returnVal == JFileChooser.APPROVE_OPTION)
            proposedFile = fileChooser.getSelectedFile();
        else
            return null;
    } else {
        proposedFile = new File(proposedFilePath);
    }
    try {
        new XmlIoSpimData().save(movingSpimData, proposedFile.getAbsolutePath());
    } catch (SpimDataException e) {
        e.printStackTrace();
    }
    return proposedFile;
}
Also used : SpimDataException(mpicbg.spim.data.SpimDataException) JFileChooser(javax.swing.JFileChooser) ViewTransformAffine(mpicbg.spim.data.registration.ViewTransformAffine) XmlIoSpimData(mpicbg.spim.data.XmlIoSpimData) File(java.io.File) Point(java.awt.Point) RealPoint(net.imglib2.RealPoint) AffineTransform3D(net.imglib2.realtransform.AffineTransform3D)

Example 4 with XmlIoSpimData

use of mpicbg.spim.data.XmlIoSpimData in project imagej-utils by embl-cba.

the class ExampleSimpleViewCaptureBehaviour method main.

public static void main(String[] args) throws SpimDataException {
    /**
     * show first image
     */
    final String path = ExampleSimpleViewCaptureBehaviour.class.getResource("../mri-stack.xml").getFile();
    SpimData spimData = new XmlIoSpimData().load(path);
    final List<BdvStackSource<?>> stackSources = BdvFunctions.show(spimData);
    stackSources.get(0).setDisplayRange(0, 255);
    final BdvHandle bdv = stackSources.get(0).getBdvHandle();
    /**
     * add another image
     */
    // final IntervalView< UnsignedIntType > img = Views.translate( Utils.create2DGradientImage(), new long[]{ 0, 0, 0 } );
    // //
    // //		final BdvStackSource stackSource = BdvFunctions.show(
    // //				img, "image 0",
    // //				BdvOptions.options().addTo( bdv ) );
    // //		stackSource.setDisplayRange( 0, 300 );
    // //		stackSource.setColor( new ARGBType( ARGBType.rgba( 0, 255, 0, 0 ) ) );
    // //
    // //		final AffineTransform3D vt = new AffineTransform3D();
    // //		bdv.getViewerPanel().state().getViewerTransform( vt );
    // //		vt.set( 0, 2, 3 );
    // //		bdv.getViewerPanel().setCurrentViewerTransform( vt );
    /**
     * install view capture behaviour
     */
    Behaviours behaviours = new Behaviours(new InputTriggerConfig());
    behaviours.install(bdv.getTriggerbindings(), "");
    BdvBehaviours.addSimpleViewCaptureBehaviour(bdv, behaviours, "C");
}
Also used : BdvStackSource(bdv.util.BdvStackSource) XmlIoSpimData(mpicbg.spim.data.XmlIoSpimData) SpimData(mpicbg.spim.data.SpimData) XmlIoSpimData(mpicbg.spim.data.XmlIoSpimData) Behaviours(org.scijava.ui.behaviour.util.Behaviours) BdvBehaviours(de.embl.cba.bdv.utils.behaviour.BdvBehaviours) BdvHandle(bdv.util.BdvHandle) InputTriggerConfig(org.scijava.ui.behaviour.io.InputTriggerConfig)

Example 5 with XmlIoSpimData

use of mpicbg.spim.data.XmlIoSpimData in project imagej-utils by embl-cba.

the class ExampleViewCapture method main.

public static void main(String[] args) throws SpimDataException {
    new ImageJ().ui().showUI();
    Prefs.showScaleBar(true);
    /**
     * show first image
     */
    String path = ExampleViewCapture.class.getResource("../multi-resolution-mri-stack.xml").getFile();
    SpimData spimData = new XmlIoSpimData().load(path);
    List<BdvStackSource<?>> stackSources = BdvFunctions.show(spimData, BdvOptions.options().preferredSize(600, 600));
    stackSources.get(0).setDisplayRange(0, 255);
    stackSources.get(0).setColor(new ARGBType(ARGBType.rgba(255, 0, 0, 255)));
    final BdvHandle bdvHandle = stackSources.get(0).getBdvHandle();
    /**
     * add another image
     */
    path = ExampleViewCapture.class.getResource("../mri-stack-shifted.xml").getFile();
    spimData = new XmlIoSpimData().load(path);
    stackSources = BdvFunctions.show(spimData, BdvOptions.options().addTo(bdvHandle));
    stackSources.get(0).setDisplayRange(0, 255);
    /**
     * also add an ARBGType image
     */
    final ArrayImg<UnsignedIntType, IntArray> img = ArrayImgs.unsignedInts(256, 256, 1000);
    final ArrayCursor<UnsignedIntType> cursor = img.cursor();
    while (cursor.hasNext()) cursor.next().set(cursor.getIntPosition(0));
    final RandomAccessibleIntervalSource source = new RandomAccessibleIntervalSource(img, Util.getTypeFromInterval(img), "");
    final SelectableVolatileARGBConverter converter = new SelectableVolatileARGBConverter(new LinearARGBConverter(0, 255, Luts.BLUE_WHITE_RED));
    final ARGBConvertedRealSource convertedRealSource = new ARGBConvertedRealSource(source, converter);
    BdvFunctions.show(convertedRealSource, BdvOptions.options().addTo(bdvHandle));
    /**
     * capture a view
     */
    final ViewCaptureResult captureResult = BdvViewCaptures.captureView(bdvHandle, 1, "micron", true);
    captureResult.rawImagesStack.show();
    captureResult.rgbImage.show();
}
Also used : SelectableVolatileARGBConverter(de.embl.cba.bdv.utils.converters.SelectableVolatileARGBConverter) XmlIoSpimData(mpicbg.spim.data.XmlIoSpimData) SpimData(mpicbg.spim.data.SpimData) XmlIoSpimData(mpicbg.spim.data.XmlIoSpimData) ARGBConvertedRealSource(de.embl.cba.bdv.utils.sources.ARGBConvertedRealSource) ViewCaptureResult(de.embl.cba.bdv.utils.capture.ViewCaptureResult) ImageJ(net.imagej.ImageJ) LinearARGBConverter(de.embl.cba.bdv.utils.converters.LinearARGBConverter) IntArray(net.imglib2.img.basictypeaccess.array.IntArray) UnsignedIntType(net.imglib2.type.numeric.integer.UnsignedIntType) ARGBType(net.imglib2.type.numeric.ARGBType)

Aggregations

XmlIoSpimData (mpicbg.spim.data.XmlIoSpimData)21 SpimData (mpicbg.spim.data.SpimData)15 BdvHandle (bdv.util.BdvHandle)6 BdvStackSource (bdv.util.BdvStackSource)5 AffineTransform3D (net.imglib2.realtransform.AffineTransform3D)5 ImagePlus (ij.ImagePlus)4 File (java.io.File)4 SpimDataException (mpicbg.spim.data.SpimDataException)4 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)4 ARGBType (net.imglib2.type.numeric.ARGBType)4 AbstractSpimData (mpicbg.spim.data.generic.AbstractSpimData)3 ImageJ (net.imagej.ImageJ)3 VolatileSpimSource (bdv.VolatileSpimSource)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 IFormatReader (loci.formats.IFormatReader)2 Length (ome.units.quantity.Length)2 InputTriggerConfig (org.scijava.ui.behaviour.io.InputTriggerConfig)2 Behaviours (org.scijava.ui.behaviour.util.Behaviours)2