Skip to content
Snippets Groups Projects
Commit 3b8e1125 authored by pietzsch's avatar pietzsch
Browse files

Fix numTimepoints and improve transfer of LUT and visibility settings

parent 7d7e0cd4
No related branches found
No related tags found
No related merge requests found
...@@ -96,41 +96,44 @@ public class OpenImagePlusPlugIn implements Command ...@@ -96,41 +96,44 @@ public class OpenImagePlusPlugIn implements Command
AbstractSpimData< ? > spimData; AbstractSpimData< ? > spimData;
CacheControl cache = null; CacheControl cache = null;
int nTimepoints = 1;
int setup_id_offset = 0; int setup_id_offset = 0;
ArrayList< ImagePlus > imgList = new ArrayList< ImagePlus >(); ArrayList< ImagePlus > imgList = new ArrayList<>();
for ( int i = 0; i < nImages; i++ ) for ( int i = 0; i < nImages; i++ )
{ {
if ( !gd.getNextBoolean() ) if ( !gd.getNextBoolean() )
continue; continue;
ImagePlus imp = WindowManager.getImage( idList[ i ] ); ImagePlus imp = WindowManager.getImage( idList[ i ] );
imgList.add( imp );
spimData = load( imp, converterSetups, sources, setup_id_offset ); spimData = load( imp, converterSetups, sources, setup_id_offset );
if ( spimData != null ) if ( spimData != null )
{
imgList.add( imp );
cache = ( ( ViewerImgLoader ) spimData.getSequenceDescription().getImgLoader() ).getCacheControl(); cache = ( ( ViewerImgLoader ) spimData.getSequenceDescription().getImgLoader() ).getCacheControl();
setup_id_offset += imp.getNChannels(); setup_id_offset += imp.getNChannels();
nTimepoints = Math.max( nTimepoints, imp.getNFrames() );
}
} }
int nTimepoints = 1; if ( !imgList.isEmpty() )
{
final BigDataViewer bdv = BigDataViewer.open( converterSetups, sources, final BigDataViewer bdv = BigDataViewer.open( converterSetups, sources,
nTimepoints, cache, nTimepoints, cache,
"BigDataViewer", new ProgressWriterIJ(), ViewerOptions.options() ); "BigDataViewer", new ProgressWriterIJ(), ViewerOptions.options() );
final SetupAssignments sa = bdv.getSetupAssignments(); final SetupAssignments sa = bdv.getSetupAssignments();
final VisibilityAndGrouping vg = bdv.getViewer().getVisibilityAndGrouping(); final VisibilityAndGrouping vg = bdv.getViewer().getVisibilityAndGrouping();
vg.setFusedEnabled( true );
int channelOffset = 0; int channelOffset = 0;
int numActiveChannels = 0;
for ( ImagePlus imp : imgList ) for ( ImagePlus imp : imgList )
{ {
if ( imp.isComposite() ) numActiveChannels += transferChannelVisibility( channelOffset, imp,vg );
transferChannelSettings( channelOffset, ( CompositeImage ) imp, sa, vg ); transferChannelSettings( channelOffset, imp, sa );
else
transferImpSettings( channelOffset, imp, sa );
channelOffset += imp.getNChannels(); channelOffset += imp.getNChannels();
} }
vg.setDisplayMode( numActiveChannels > 1 ? DisplayMode.FUSED : DisplayMode.SINGLE );
}
} }
protected AbstractSpimData< ? > load( ImagePlus imp, ArrayList< ConverterSetup > converterSetups, ArrayList< SourceAndConverter< ? > > sources, protected AbstractSpimData< ? > load( ImagePlus imp, ArrayList< ConverterSetup > converterSetups, ArrayList< SourceAndConverter< ? > > sources,
...@@ -145,14 +148,14 @@ public class OpenImagePlusPlugIn implements Command ...@@ -145,14 +148,14 @@ public class OpenImagePlusPlugIn implements Command
case ImagePlus.COLOR_RGB: case ImagePlus.COLOR_RGB:
break; break;
default: default:
IJ.showMessage( "Only 8, 16, 32-bit images and RGB images are supported currently!" ); IJ.showMessage( imp.getShortTitle() + ": Only 8, 16, 32-bit images and RGB images are supported currently!" );
return null; return null;
} }
// check the image dimensionality // check the image dimensionality
if ( imp.getNDimensions() < 3 ) if ( imp.getNDimensions() < 3 )
{ {
IJ.showMessage( "Image must be at least 3-dimensional!" ); IJ.showMessage( imp.getShortTitle() + ": Image must be at least 3-dimensional!" );
return null; return null;
} }
...@@ -167,7 +170,7 @@ public class OpenImagePlusPlugIn implements Command ...@@ -167,7 +170,7 @@ public class OpenImagePlusPlugIn implements Command
final int w = imp.getWidth(); final int w = imp.getWidth();
final int h = imp.getHeight(); final int h = imp.getHeight();
final int d = imp.getNSlices(); final int d = imp.getNSlices();
final FinalDimensions size = new FinalDimensions( new int[] { w, h, d } ); final FinalDimensions size = new FinalDimensions( w, h, d );
// propose reasonable mipmap settings // propose reasonable mipmap settings
// final ExportMipmapInfo autoMipmapSettings = ProposeMipmaps.proposeMipmaps( new BasicViewSetup( 0, "", size, voxelSize ) ); // final ExportMipmapInfo autoMipmapSettings = ProposeMipmaps.proposeMipmaps( new BasicViewSetup( 0, "", size, voxelSize ) );
...@@ -247,9 +250,42 @@ public class OpenImagePlusPlugIn implements Command ...@@ -247,9 +250,42 @@ public class OpenImagePlusPlugIn implements Command
return spimData; return spimData;
} }
protected void transferChannelSettings( int channelOffset, final CompositeImage ci, final SetupAssignments setupAssignments, final VisibilityAndGrouping visibility ) /**
* @return number of setups that were set active.
*/
protected int transferChannelVisibility( int channelOffset, final ImagePlus imp, final VisibilityAndGrouping visibility )
{
final int nChannels = imp.getNChannels();
final CompositeImage ci = imp.isComposite() ? ( CompositeImage ) imp : null;
if ( ci != null && ci.getCompositeMode() == IJ.COMPOSITE )
{
final boolean[] activeChannels = ci.getActiveChannels();
int numActiveChannels = 0;
for ( int i = 0; i < activeChannels.length; ++i )
{
final int setup = channelOffset + i;
visibility.setSourceActive( setup, activeChannels[ i ] );
visibility.setCurrentSource( setup );
numActiveChannels += activeChannels[ i ] ? 1 : 0;
}
return numActiveChannels;
}
else
{
final int activeChannel = imp.getChannel() - 1;
for ( int i = 0; i < nChannels; ++i )
visibility.setSourceActive( channelOffset + i, i == activeChannel );
visibility.setCurrentSource( channelOffset + activeChannel );
return 1;
}
}
protected void transferChannelSettings( int channelOffset, final ImagePlus imp, final SetupAssignments setupAssignments )
{
final int nChannels = imp.getNChannels();
final CompositeImage ci = imp.isComposite() ? ( CompositeImage ) imp : null;
if ( ci != null )
{ {
final int nChannels = ci.getNChannels();
final int mode = ci.getCompositeMode(); final int mode = ci.getCompositeMode();
final boolean transferColor = mode == IJ.COMPOSITE || mode == IJ.COLOR; final boolean transferColor = mode == IJ.COMPOSITE || mode == IJ.COLOR;
for ( int c = 0; c < nChannels; ++c ) for ( int c = 0; c < nChannels; ++c )
...@@ -260,20 +296,19 @@ public class OpenImagePlusPlugIn implements Command ...@@ -260,20 +296,19 @@ public class OpenImagePlusPlugIn implements Command
setup.setColor( new ARGBType( lut.getRGB( 255 ) ) ); setup.setColor( new ARGBType( lut.getRGB( 255 ) ) );
setup.setDisplayRange( lut.min, lut.max ); setup.setDisplayRange( lut.min, lut.max );
} }
if ( mode == IJ.COMPOSITE )
{
final boolean[] activeChannels = ci.getActiveChannels();
for ( int i = 0; i < activeChannels.length; ++i )
visibility.setSourceActive( i, activeChannels[ i ] );
} }
else else
visibility.setDisplayMode( DisplayMode.SINGLE );
visibility.setCurrentSource( ci.getChannel() - 1 );
}
protected void transferImpSettings( int setupIndex, final ImagePlus imp, final SetupAssignments setupAssignments )
{ {
final ConverterSetup setup = setupAssignments.getConverterSetups().get( setupIndex ); final double displayRangeMin = imp.getDisplayRangeMin();
setup.setDisplayRange( imp.getDisplayRangeMin(), imp.getDisplayRangeMax() ); final double displayRangeMax = imp.getDisplayRangeMax();
for ( int i = 0; i < nChannels; ++i )
{
final ConverterSetup setup = setupAssignments.getConverterSetups().get( channelOffset + i );
final LUT[] luts = imp.getLuts();
if ( luts.length != 0 )
setup.setColor( new ARGBType( luts[ 0 ].getRGB( 255 ) ) );
setup.setDisplayRange( displayRangeMin, displayRangeMax );
}
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment