Skip to content

Instantly share code, notes, and snippets.

@bogovicj
Last active August 21, 2018 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bogovicj/b538ac9ee9a56ee3065fd0954c686077 to your computer and use it in GitHub Desktop.
Save bogovicj/b538ac9ee9a56ee3065fd0954c686077 to your computer and use it in GitHub Desktop.
concatOpenImages.groovy
// @UIService ui
// @ImageDisplayService disp
// @DatasetService data
// @LogService log
import java.util.ArrayList;
import net.imagej.axis.Axes
import net.imglib2.view.Views;
import net.imglib2.util.Intervals;
import net.imglib2.util.Util;
log.info( data.getDatasets( disp.getActiveImageDisplay()))
datasets = data.getDatasets()
if( datasets.size() == 0 )
{
ui.showDialog("No images found")
return
}
/*
* the size of the output will be the union
* of the input sizes
*/
total_interval = datasets.get( 0 )
for( d in datasets )
{
total_interval = Intervals.union( total_interval, d )
}
exp_imgs = new ArrayList();
for( d in datasets )
{
exp_imgs.add( Views.interval( Views.extendZero( d ), total_interval))
}
resdata = data.create( Views.stack( exp_imgs ))
// set the axis labels
resdata.axis(2).setType(Axes.Z)
resdata.axis(3).setType(Axes.TIME)
ui.show( resdata );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment