Image sequence with different sizes

imagej

#1

Hi all,

I’m trying to import an image sequence of multiple files in a folder with different sizes. Is it possible to still open them ?

Thanks.


#2

Good day,

afaik, in plain ImageJ not as a sequence!

You may open single images and adapt their canvas to create images of equal size.

Regards

Herbie


#3

The problem is that the 1st step of the pipeline is using the Grid stitching plugin and letting it calculate the overlap. Meaning that from experiment and even from timepoints, the canvas is different and can’t really be known previously :confused:

I already tried to crop and thought it would be enough but apparently not.


#4

Does your stitching algorithm work with an image sequence only?

No clue

Herbie


#5

In the beginning all the images are the same size but the calculated overlap makes the result of the stitching a different size.

Opening them as image sequence would be for a next step.

Thansk anyway :slight_smile:


#6

Hi @lguerard,

ImageJ2 should be able do this without too much trouble, though it’ll take some scripting.
I’ll have a crack at this later, unless someone beats me to it.

John


#7

Hi @bogovicj

Thanks, that would be awesome ! :slight_smile:. I’ll be waiting then, there’s no (immediate) rush !


#8

Hi @lguerard,

This script should do the trick:

It works on all the images that are currently open, and assumes the images are 3d.
If they’re 2d just delete these lines:

// set the axis labels
resdata.axis(2).setType(Axes.Z)
resdata.axis(3).setType(Axes.TIME)

If they’re 4-or-higher-D, then this probably wont work and will need some fiddling.

Let us know how it goes,
John


#9

Hi @bogovicj,

Thanks for the help ! I was looking at opening them as image sequence but maybe opening them first then making a stack is indeed better. I’ll try that and let you know ! :slight_smile:


#10

I get this error when running the script:

Started concatOpenImages.groovy at Tue Aug 21 16:13:23 CEST 2018
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script4.groovy: 47: unexpected token: ui @ line 47, column 1.
   ui.show( resdata );

Any ideas?


#11

You seem to be running a slightly different version of what @bogovicj posted above: his script has only 46 lines, while your error message is from line 47. Please have a look if your first line really looks like this:

// @UIService ui

This line is a script parameter input and is required for the variable ui to mean anything in your code.


#12

I uncommented that line after the script wouldn’t run in its untouched form.

Right now, I’m trying to run this exactly:

//@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 )

// uncomment for 3D images
//// set the axis labels
//resdata.axis(2).setType(Axes.Z)
//resdata.axis(3).setType(Axes.TIME)

ui.show( resdata );

But I still get the same error.


#13

You’re missing a closing parenthesis here that’s present in the original script.


#14

That’s my bad actually. Just updated the script a few minutes ago.
:blush:

Thanks for catching this @imagejan


#15

Oh, I see :slight_smile: (I should have checked the revisions before replying ;-))


#16

Thank you, bogovicj!