From 4ceb54650d28cf9adc39d46dd586f78d2a2c13c8 Mon Sep 17 00:00:00 2001 From: Christian Tischer Date: Fri, 5 Jan 2024 19:52:50 +0100 Subject: [PATCH] Add ROIs to ScreenShotMaker --- .../context/AutomaticRegistrationCommand.java | 31 ++++--- .../context/ScreenShotMakerCommand.java | 10 +-- .../context/SetTransformationCommand.java | 5 +- .../context/ShowRasterImagesCommand.java | 2 +- .../context/SourceInfoLoggerCommand.java | 84 ------------------ .../command/context/SourcesInfoCommand.java | 8 +- .../embl/mobie/lib/bdv/ScreenShotMaker.java | 88 +++++++++++-------- .../embl/mobie/lib/bdv/view/SliceViewer.java | 3 +- .../embl/mobie/lib/image/SpimDataImage.java | 10 +-- .../em_xray_alignment/OpenEMXRAY.java | 2 +- 10 files changed, 88 insertions(+), 155 deletions(-) delete mode 100644 src/main/java/org/embl/mobie/command/context/SourceInfoLoggerCommand.java diff --git a/src/main/java/org/embl/mobie/command/context/AutomaticRegistrationCommand.java b/src/main/java/org/embl/mobie/command/context/AutomaticRegistrationCommand.java index 4c4484f57..2cdc86194 100644 --- a/src/main/java/org/embl/mobie/command/context/AutomaticRegistrationCommand.java +++ b/src/main/java/org/embl/mobie/command/context/AutomaticRegistrationCommand.java @@ -35,7 +35,11 @@ import ij.IJ; import ij.ImagePlus; import ij.ImageStack; +import ij.gui.Roi; +import ij.plugin.filter.ThresholdToSelection; +import ij.process.ByteProcessor; import ij.process.ImageConverter; +import ij.process.ImageProcessor; import net.imglib2.realtransform.AffineTransform3D; import org.embl.mobie.command.CommandConstants; import org.embl.mobie.lib.MoBIEHelper; @@ -51,6 +55,7 @@ import sc.fiji.bdvpg.bdv.BdvHandleHelper; import sc.fiji.bdvpg.scijava.command.BdvPlaygroundActionCommand; +import java.awt.*; import java.util.Arrays; import java.util.List; import java.util.concurrent.ExecutionException; @@ -75,9 +80,6 @@ public class AutomaticRegistrationCommand extends DynamicCommand implements BdvP @Parameter(label="Registration Voxel Size", persist = false, min = "0.0", style="format:#.00000") public Double voxelSize = 1D; - @Parameter(label="Out of Bounds Value") - public String outOfBoundsValue = "Do not use"; - @Parameter ( label = "Transformation", choices = { TRANSLATION, RIGID, SIMILARITY, AFFINE } ) private String transformationType = TRANSLATION; @@ -153,15 +155,7 @@ private void compute() // create two 2D ImagePlus that are to be aligned // ScreenShotMaker screenShotMaker = new ScreenShotMaker( bdvHandle, sacA.getSpimSource().getVoxelDimensions().unit() ); - try - { - // useful for images with bright background - // to avoid an edge with the black background of BDV - screenShotMaker.setOutOfBoundsValue( Float.parseFloat( this.outOfBoundsValue ) ); - } catch ( Exception e ) - { - // don't set an out-of-bounds value. - } + screenShotMaker.run( Arrays.asList( sacA, sacB ), voxelSize ); CompositeImage compositeImage = screenShotMaker.getCompositeImagePlus(); AffineTransform3D canvasToGlobalTransform = screenShotMaker.getCanvasToGlobalTransform(); @@ -170,16 +164,21 @@ private void compute() ImagePlus impA = new ImagePlus( imageA + " (fixed)", stack.getProcessor( 1 ) ); ImagePlus impB = new ImagePlus( imageB + " (moving)", stack.getProcessor( 2 ) ); - // set the display ranges and burn them in by converting to unit8 + // set the display ranges and burn them in by converting to uint8 // this is important for the intensity based registration methods compositeImage.setPosition( 1 ); impA.getProcessor().setMinAndMax( compositeImage.getDisplayRangeMin(), compositeImage.getDisplayRangeMax() ); + new ImageConverter( impA ).convertToGray8(); + compositeImage.setPosition( 2 ); impB.getProcessor().setMinAndMax( compositeImage.getDisplayRangeMin(), compositeImage.getDisplayRangeMax() ); - new ImageConverter( impA ).convertToGray8(); new ImageConverter( impB ).convertToGray8(); - double min = impA.getProcessor().getMax(); - double max = impA.getProcessor().getMax(); + + // set the rois within which the images contain valid pixel values + // those are used by some registration methods, e.g. turboReg + Roi[] rois = screenShotMaker.getMasks(); + impA.setRoi( rois[ 0 ] ); + impB.setRoi( rois[ 1 ] ); // compute the transformation that aligns the two images in 2D // diff --git a/src/main/java/org/embl/mobie/command/context/ScreenShotMakerCommand.java b/src/main/java/org/embl/mobie/command/context/ScreenShotMakerCommand.java index 0ce0c18d5..e1a8c2876 100644 --- a/src/main/java/org/embl/mobie/command/context/ScreenShotMakerCommand.java +++ b/src/main/java/org/embl/mobie/command/context/ScreenShotMakerCommand.java @@ -30,6 +30,8 @@ import bdv.util.BdvHandle; import ij.IJ; +import ij.gui.Roi; +import ij.plugin.frame.RoiManager; import org.embl.mobie.MoBIE; import org.embl.mobie.command.CommandConstants; import org.embl.mobie.lib.bdv.ScreenShotMaker; @@ -63,13 +65,13 @@ public class ScreenShotMakerCommand extends DynamicCommand implements BdvPlaygro @Override public void run() { + if ( MoBIE.getInstance().getSettings().values.isOpenedFromCLI() ) + MoBIE.imageJ.ui().showUI(); + ScreenShotMaker screenShotMaker = new ScreenShotMaker( bdvHandle, pixelUnit ); screenShotMaker.run( targetSamplingInXY ); screenShotMaker.getRGBImagePlus().show(); screenShotMaker.getCompositeImagePlus().show(); - - if ( MoBIE.getInstance().getSettings().values.isOpenedFromCLI() ) - MoBIE.imageJ.ui().showUI(); } @Override @@ -99,7 +101,5 @@ private void showNumPixels() { final long[] sizeInPixels = ScreenShotMaker.getCaptureImageSizeInPixels( bdvHandle, targetSamplingInXY ); IJ.log( CAPTURE_SIZE_PIXELS + Arrays.toString( sizeInPixels ) ); -// final MutableModuleItem< String > message = getInfo().getMutableInput("message", String.class); -// message.setValue( this, CAPTURE_SIZE_PIXELS + sizeInPixels[ 0 ] + ", " + sizeInPixels[ 1 ] ); } } diff --git a/src/main/java/org/embl/mobie/command/context/SetTransformationCommand.java b/src/main/java/org/embl/mobie/command/context/SetTransformationCommand.java index 8052d9915..96c7f1d97 100644 --- a/src/main/java/org/embl/mobie/command/context/SetTransformationCommand.java +++ b/src/main/java/org/embl/mobie/command/context/SetTransformationCommand.java @@ -157,8 +157,9 @@ else if ( mode.equals( AdditionMode.Concatenate ) ) } } - public static double[] parseStringToDoubleArray(String arrayStr) { - arrayStr = arrayStr.replaceAll("[^0-9.,]", ""); + public static double[] parseStringToDoubleArray(String arrayStr) + { + arrayStr = arrayStr.replaceAll("\\[|\\]", ""); String[] items = arrayStr.split(",\\s*"); double[] doubles = Arrays.stream(items).mapToDouble(Double::parseDouble).toArray(); return doubles; diff --git a/src/main/java/org/embl/mobie/command/context/ShowRasterImagesCommand.java b/src/main/java/org/embl/mobie/command/context/ShowRasterImagesCommand.java index ca9990498..fd032e1aa 100644 --- a/src/main/java/org/embl/mobie/command/context/ShowRasterImagesCommand.java +++ b/src/main/java/org/embl/mobie/command/context/ShowRasterImagesCommand.java @@ -61,7 +61,7 @@ import java.util.Optional; import java.util.Set; -@Plugin(type = BdvPlaygroundActionCommand.class, menuPath = CommandConstants.CONTEXT_MENU_ITEMS_ROOT + "Show " + ShowRasterImagesCommand.RAW + " Image(s)" ) +@Plugin(type = BdvPlaygroundActionCommand.class, menuPath = CommandConstants.CONTEXT_MENU_ITEMS_ROOT + "Show " + ShowRasterImagesCommand.RAW + " Images" ) public class ShowRasterImagesCommand< T extends NumericType< T > > implements BdvPlaygroundActionCommand { static { net.imagej.patcher.LegacyInjector.preinit(); } diff --git a/src/main/java/org/embl/mobie/command/context/SourceInfoLoggerCommand.java b/src/main/java/org/embl/mobie/command/context/SourceInfoLoggerCommand.java deleted file mode 100644 index d29f2248b..000000000 --- a/src/main/java/org/embl/mobie/command/context/SourceInfoLoggerCommand.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * #%L - * Fiji viewer for MoBIE projects - * %% - * Copyright (C) 2018 - 2023 EMBL - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package org.embl.mobie.command.context; - -import bdv.util.BdvHandle; -import bdv.viewer.Source; -import bdv.viewer.SourceAndConverter; -import ij.IJ; -import mpicbg.spim.data.sequence.VoxelDimensions; -import net.imglib2.realtransform.AffineTransform3D; -import org.embl.mobie.command.CommandConstants; -import org.scijava.plugin.Parameter; -import org.scijava.plugin.Plugin; -import sc.fiji.bdvpg.scijava.command.BdvPlaygroundActionCommand; - -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -@Plugin( type = BdvPlaygroundActionCommand.class, name = SourceInfoLoggerCommand.NAME, menuPath = CommandConstants.CONTEXT_MENU_ITEMS_ROOT + SourceInfoLoggerCommand.NAME ) -public class SourceInfoLoggerCommand implements BdvPlaygroundActionCommand -{ - static { net.imagej.patcher.LegacyInjector.preinit(); } - - public static final String NAME = "Log Source(s) Info"; - - @Parameter - BdvHandle bdvHandle; - - @Override - public void run() - { - new Thread( () -> { - final int t = bdvHandle.getViewerPanel().state().getCurrentTimepoint(); - - final Set< SourceAndConverter< ? > > sourceAndConverters = bdvHandle.getViewerPanel().state().getVisibleAndPresentSources(); - - final List< ? extends Source< ? > > sources = sourceAndConverters.stream().map( sac -> sac.getSpimSource() ).sorted( Comparator.comparing( s -> s.getName() ) ).collect( Collectors.toList() ); - - for ( Source< ? > source : sources ) - { - IJ.log( "\n## " + source.getName() ); - final AffineTransform3D affineTransform3D = new AffineTransform3D(); - source.getSourceTransform( t, 0, affineTransform3D ); - final VoxelDimensions voxelDimensions = source.getVoxelDimensions(); - if ( voxelDimensions.numDimensions() > 0 ) - IJ.log( voxelDimensions.toString() ); - IJ.log( "Resolution levels: " + source.getNumMipmapLevels() ); - IJ.log( "Data type: " + source.getType().getClass() ); - IJ.log( "Shape: " + Arrays.toString( source.getSource( 0,0 ).dimensionsAsLongArray() ) ); - IJ.log( "Transform from array to global space: " + affineTransform3D ); - - } - } ).start(); - } -} diff --git a/src/main/java/org/embl/mobie/command/context/SourcesInfoCommand.java b/src/main/java/org/embl/mobie/command/context/SourcesInfoCommand.java index c7088196b..0e6945e35 100644 --- a/src/main/java/org/embl/mobie/command/context/SourcesInfoCommand.java +++ b/src/main/java/org/embl/mobie/command/context/SourcesInfoCommand.java @@ -55,8 +55,6 @@ public class SourcesInfoCommand implements BdvPlaygroundActionCommand { static { net.imagej.patcher.LegacyInjector.preinit(); } - public static final String CAPTURE_SIZE_PIXELS = "Capture size [pixels]: "; - @Parameter public BdvHandle bdvHandle; @@ -68,6 +66,8 @@ public void run() { Source< ? > source = sac.getSpimSource(); IJ.log( "# " + source.getName() ); + IJ.log( "Data type: " + source.getType().getClass() ); + IJ.log( "Shape: " + Arrays.toString( source.getSource( 0,0 ).dimensionsAsLongArray() ) ); IJ.log( "Number of resolution levels: " + source.getNumMipmapLevels() ); IJ.log( "Voxel size: " + Arrays.toString( source.getVoxelDimensions().dimensionsAsDoubleArray() ) ); @@ -75,9 +75,9 @@ public void run() { AffineTransform3D transform3D = new AffineTransform3D(); ( ( TransformedSource ) source ).getFixedTransform( transform3D ); - IJ.log( "Additional transform: " + transform3D ); + IJ.log( "Additional transform:\n" + Arrays.toString( transform3D.getRowPackedCopy() ) ); source.getSourceTransform( 0, 0, transform3D ); - IJ.log( "Full transform: " + transform3D ); + IJ.log( "Full transform:\n" + Arrays.toString( transform3D.getRowPackedCopy() ) ); } }); } diff --git a/src/main/java/org/embl/mobie/lib/bdv/ScreenShotMaker.java b/src/main/java/org/embl/mobie/lib/bdv/ScreenShotMaker.java index f643f4a10..1e560eaf3 100644 --- a/src/main/java/org/embl/mobie/lib/bdv/ScreenShotMaker.java +++ b/src/main/java/org/embl/mobie/lib/bdv/ScreenShotMaker.java @@ -36,11 +36,15 @@ import ij.CompositeImage; import ij.IJ; import ij.ImagePlus; +import ij.gui.Overlay; +import ij.gui.Roi; import ij.plugin.Duplicator; +import ij.plugin.filter.ThresholdToSelection; import ij.process.LUT; import net.imglib2.*; import net.imglib2.Cursor; import net.imglib2.type.Type; +import net.imglib2.type.logic.BitType; import net.imglib2.type.numeric.real.FloatType; import net.imglib2.util.Intervals; import org.embl.mobie.lib.MoBIEHelper; @@ -83,8 +87,6 @@ public class ScreenShotMaker private long[] screenshotDimensions = new long[2]; private AffineTransform3D canvasToGlobalTransform; - private Float outOfBoundsValue = null; - public ScreenShotMaker( BdvHandle bdvHandle, String voxelUnit ) { this.bdvHandle = bdvHandle; this.voxelUnit = voxelUnit; @@ -100,9 +102,9 @@ public CompositeImage getCompositeImagePlus() return compositeImagePlus; } - public void setOutOfBoundsValue( Float outOfBoundsValue ) + public Roi[] getMasks() { - this.outOfBoundsValue = outOfBoundsValue; + return compositeImagePlus.getOverlay().toArray(); } public void run( Double targetSamplingInXY ) @@ -135,7 +137,8 @@ public void run( List< SourceAndConverter< ? > > sacs, double targetVoxelSpacing IJ.log( "Fetching data from " + sacs.size() + " images..." ); final ArrayList< RandomAccessibleInterval< FloatType > > floatCaptures = new ArrayList<>(); - final ArrayList< RandomAccessibleInterval< ARGBType > > argbSources = new ArrayList<>(); + final ArrayList< RandomAccessibleInterval< BitType > > maskCaptures = new ArrayList<>(); + final ArrayList< RandomAccessibleInterval< ARGBType > > argbCaptures = new ArrayList<>(); final ArrayList< ARGBType > colors = new ArrayList<>(); final ArrayList< double[] > displayRanges = new ArrayList<>(); @@ -154,8 +157,10 @@ public void run( List< SourceAndConverter< ? > > sacs, double targetVoxelSpacing final long currentTimeMillis = System.currentTimeMillis(); for ( SourceAndConverter< ? > sac : sacs ) { - final RandomAccessibleInterval< FloatType > rawCapture + final RandomAccessibleInterval< FloatType > floatCapture = ArrayImgs.floats( screenshotDimensions[ 0 ], screenshotDimensions[ 1 ] ); + final RandomAccessibleInterval< BitType > maskCapture + = ArrayImgs.bits( screenshotDimensions[ 0 ], screenshotDimensions[ 1 ] ); final RandomAccessibleInterval< ARGBType > argbCapture = ArrayImgs.argbs( screenshotDimensions[ 0 ], screenshotDimensions[ 1 ] ); @@ -181,17 +186,19 @@ public void run( List< SourceAndConverter< ? > > sacs, double targetVoxelSpacing ( ThreadHelper.ioExecutorService.submit( () -> { - RealRandomAccess< ? extends Type< ? > > access = getRealRandomAccess( ( Source< Type< ? > > ) source, currentTimepoint, level, interpolate ); + RealRandomAccess< ? extends Type< ? > > sourceAccess = getRealRandomAccess( ( Source< Type< ? > > ) source, currentTimepoint, level, interpolate ); RandomAccessibleInterval< ? > sourceInterval = source.getSource( currentTimepoint, level ); // to collect raw data - final IntervalView< FloatType > floatCrop = Views.interval( rawCapture, interval ); - final Cursor< FloatType > floatCaptureCursor = Views.iterable( floatCrop ).localizingCursor(); - final RandomAccess< FloatType > floatCaptureAccess = floatCrop.randomAccess(); + final IntervalView< FloatType > floatCrop = Views.interval( floatCapture, interval ); + final Cursor< FloatType > floatCursor = Views.iterable( floatCrop ).localizingCursor(); + final RandomAccess< FloatType > floatAccess = floatCrop.randomAccess(); + + // to collect masks + final RandomAccess< BitType > maskAccess = Views.interval( maskCapture, interval ).randomAccess(); // to collect colored data - final IntervalView< ARGBType > argbCrop = Views.interval( argbCapture, interval ); - final RandomAccess< ARGBType > argbCaptureAccess = argbCrop.randomAccess(); + final RandomAccess< ARGBType > argbAccess = Views.interval( argbCapture, interval ).randomAccess(); final double[] canvasPosition = new double[ 3 ]; final double[] sourceRealPosition = new double[ 3 ]; @@ -199,28 +206,30 @@ public void run( List< SourceAndConverter< ? > > sacs, double targetVoxelSpacing final ARGBType argbType = new ARGBType(); // iterate through the target image in pixel units - while ( floatCaptureCursor.hasNext() ) + while ( floatCursor.hasNext() ) { - floatCaptureCursor.fwd(); - floatCaptureCursor.localize( canvasPosition ); - floatCaptureAccess.setPosition( floatCaptureCursor ); - argbCaptureAccess.setPosition( floatCaptureCursor ); - + // set the positions + floatCursor.fwd(); + floatCursor.localize( canvasPosition ); + floatAccess.setPosition( floatCursor ); + maskAccess.setPosition( floatCursor ); + argbAccess.setPosition( floatCursor ); targetCanvasToSourceTransform.apply( canvasPosition, sourceRealPosition ); - access.setPosition( sourceRealPosition ); + sourceAccess.setPosition( sourceRealPosition ); - boolean contains = Intervals.contains( sourceInterval, new RealPoint( sourceRealPosition ) ); - if ( ! contains && outOfBoundsValue != null ) + // set the pixel values + if ( Intervals.contains( sourceInterval, new RealPoint( sourceRealPosition ) ) ) { - floatCaptureAccess.get().setReal( outOfBoundsValue ); - // TODO how to set the ARGB value? + maskAccess.get().set( true ); + setFloatPixelValue( sourceAccess, floatAccess ); + setArgbPixelValue( converter, sourceAccess, argbAccess, argbType ); } else { - setFloatPixelValue( access, floatCaptureAccess ); - setArgbPixelValue( converter, access, argbCaptureAccess, argbType ); + maskAccess.get().set( false ); } + // log progress pixelCount.incrementAndGet(); final double currentFractionDone = 1.0 * pixelCount.get() / numPixels; if ( currentFractionDone >= fractionDone.get() ) @@ -243,8 +252,9 @@ public void run( List< SourceAndConverter< ? > > sacs, double targetVoxelSpacing ThreadHelper.waitUntilFinished( futures ); - floatCaptures.add( rawCapture ); - argbSources.add( argbCapture ); + floatCaptures.add( floatCapture ); + maskCaptures.add( maskCapture ); + argbCaptures.add( argbCapture ); displayRanges.add( BdvHandleHelper.getDisplayRange( SourceAndConverterServices.getSourceAndConverterService().getConverterSetup( sac ) ) ); } @@ -255,8 +265,8 @@ public void run( List< SourceAndConverter< ? > > sacs, double targetVoxelSpacing if ( ! floatCaptures.isEmpty() ) { - rgbImagePlus = createRGBImagePlus( voxelUnit, argbSources, voxelSpacing, sacs ); - compositeImagePlus = createCompositeImagePlus( voxelSpacing, voxelUnit, floatCaptures, colors, displayRanges ); + rgbImagePlus = createRGBImagePlus( voxelUnit, argbCaptures, voxelSpacing, sacs ); + compositeImagePlus = createCompositeImagePlus( voxelSpacing, voxelUnit, floatCaptures, maskCaptures, displayRanges ); } } @@ -419,20 +429,19 @@ private ImagePlus asImagePlus( RandomAccessibleInterval< ARGBType > argbCapture, public static CompositeImage createCompositeImagePlus( double[] voxelSpacing, String voxelUnit, - ArrayList< RandomAccessibleInterval< FloatType > > rais, - ArrayList< ARGBType > colors, + ArrayList< RandomAccessibleInterval< FloatType > > floatCaptures, + ArrayList< RandomAccessibleInterval< BitType > > maskCaptures, ArrayList< double[] > displayRanges ) { - final RandomAccessibleInterval< FloatType > stack = Views.stack( rais ); - - final ImagePlus imp = ImageJFunctions.wrap( stack, "Multi-Channel" ); + final ImagePlus imp = ImageJFunctions.wrap( Views.stack( floatCaptures ), "Floats" ); + final ImagePlus mask = ImageJFunctions.wrap( Views.stack( maskCaptures ), "Masks" ); // duplicate: otherwise it is virtual and cannot be modified final ImagePlus dup = new Duplicator().run( imp ); IJ.run( dup, "Properties...", - "channels="+rais.size() + "channels="+floatCaptures.size() +" slices=1 frames=1 unit=" + voxelUnit +" pixel_width=" + voxelSpacing[ 0 ] +" pixel_height=" + voxelSpacing[ 1 ] @@ -440,6 +449,7 @@ public static CompositeImage createCompositeImagePlus( final CompositeImage compositeImage = new CompositeImage( dup ); + Overlay rois = new Overlay(); for ( int channel = 1; channel <= compositeImage.getNChannels(); ++channel ) { final LUT lut = compositeImage.createLutFromColor( Color.WHITE ); @@ -447,8 +457,16 @@ public static CompositeImage createCompositeImagePlus( compositeImage.setChannelLut( lut ); final double[] range = displayRanges.get( channel - 1 ); compositeImage.setDisplayRange( range[ 0 ], range[ 1 ] ); + mask.setPosition( channel ); + mask.getProcessor().setThreshold( 1.0, 255 ); + Roi roi = new ThresholdToSelection().convert( mask.getProcessor() ); + roi.setPosition( channel, 1, 1 ); + mask.getProcessor().setRoi( roi ); + rois.add( roi ); } + compositeImage.setOverlay( rois ); + compositeImage.setHideOverlay( true ); compositeImage.setTitle( "Multi-Channel" ); return compositeImage; } diff --git a/src/main/java/org/embl/mobie/lib/bdv/view/SliceViewer.java b/src/main/java/org/embl/mobie/lib/bdv/view/SliceViewer.java index 55c450e7d..7d2022216 100644 --- a/src/main/java/org/embl/mobie/lib/bdv/view/SliceViewer.java +++ b/src/main/java/org/embl/mobie/lib/bdv/view/SliceViewer.java @@ -148,10 +148,9 @@ private void installContextMenuAndKeyboardShortCuts( ) final ArrayList< String > actions = new ArrayList< String >(); actions.add( SourceAndConverterService.getCommandName( SourcesInfoCommand.class ) ); - actions.add( SourceAndConverterService.getCommandName( ScreenShotMakerCommand.class ) ); actions.add( SourceAndConverterService.getCommandName( ShowRasterImagesCommand.class ) ); + actions.add( SourceAndConverterService.getCommandName( ScreenShotMakerCommand.class ) ); actions.add( SourceAndConverterService.getCommandName( ViewerTransformLoggerCommand.class ) ); - actions.add( SourceAndConverterService.getCommandName( SourceInfoLoggerCommand.class ) ); actions.add( SourceAndConverterService.getCommandName( BigWarpRegistrationCommand.class ) ); actions.add( SourceAndConverterService.getCommandName( AutomaticRegistrationCommand.class ) ); actions.add( SourceAndConverterService.getCommandName( ManualRegistrationCommand.class ) ); diff --git a/src/main/java/org/embl/mobie/lib/image/SpimDataImage.java b/src/main/java/org/embl/mobie/lib/image/SpimDataImage.java index 27297f4ff..99c51cc3c 100644 --- a/src/main/java/org/embl/mobie/lib/image/SpimDataImage.java +++ b/src/main/java/org/embl/mobie/lib/image/SpimDataImage.java @@ -57,7 +57,7 @@ public class SpimDataImage< T extends NumericType< T > & RealType< T > > impleme private Boolean removeSpatialCalibration = false; @Nullable private RealMaskRealInterval mask; - private TransformedSource transformedSource; + private TransformedSource< T > transformedSource; private AffineTransform3D currentTransform = new AffineTransform3D(); public SpimDataImage( AbstractSpimData< ? > spimData, Integer setupId, String name, Boolean removeSpatialCalibration ) @@ -151,12 +151,12 @@ public void setMask( RealMaskRealInterval mask ) private void open() { - final AbstractSpimData spimData = openSpimData(); + final AbstractSpimData< ? > spimData = openSpimData(); createSourcePair( spimData, setupId, name ); } - private void createSourcePair( AbstractSpimData spimData, int setupId, String name ) + private void createSourcePair( AbstractSpimData< ? > spimData, int setupId, String name ) { final SpimSource< T > source = new SpimSource<>( spimData, setupId, name ); final VolatileSpimSource< ? extends Volatile< T > > vSource = new VolatileSpimSource<>( spimData, setupId, name ); @@ -169,10 +169,10 @@ private void createSourcePair( AbstractSpimData spimData, int setupId, String na SourceHelper.setVoxelDimensionsToPixels( vSource ); } - transformedSource = new TransformedSource( source ); + transformedSource = new TransformedSource<>( source ); transformedSource.setFixedTransform( currentTransform ); - sourcePair = new DefaultSourcePair( transformedSource, new TransformedSource( vSource, transformedSource ) ); + sourcePair = new DefaultSourcePair<>( transformedSource, new TransformedSource<>( vSource, transformedSource ) ); } private AbstractSpimData openSpimData( ) diff --git a/src/test/java/projects/em_xray_alignment/OpenEMXRAY.java b/src/test/java/projects/em_xray_alignment/OpenEMXRAY.java index 8b8a9ae01..e423ae853 100644 --- a/src/test/java/projects/em_xray_alignment/OpenEMXRAY.java +++ b/src/test/java/projects/em_xray_alignment/OpenEMXRAY.java @@ -14,7 +14,7 @@ public static void main( String[] args ) throws IOException // OpenerLogging.setLogging( true ); final ImageJ imageJ = new ImageJ(); imageJ.ui().showUI(); - MoBIESettings settings = new MoBIESettings().view( "em-sift-affine--xray-u8-manual-euler" ); + MoBIESettings settings = new MoBIESettings().view( "em-xray-manual" ); new MoBIE("/Volumes/cba/exchange/em-xray-alignment/mobie", settings ); } }