Plug-in for importing Image Sequence



Dear All,

I would like to create a GUI that has buttons to open a file and/or image sequence.
For opening an image file, the following simple Java code worked fine for me.

Opener op = new Opener();

But I am not sure how to write codes to call the dialog box that appears when importing image sequences from the File menu (File >> Import >> Image Sequence…)

I would appreciate your kind help.


Use the macro recorder to find the code.

You can use script parameters to easily harvest many of the same fields, but customize to your liking.

Here is a parameterized macro which replicates most of the Sequence Options dialog, passing through the inputted values to the plugin call internally:

// @File(label = "Input directory:", style = "directory") dir
// @int(label = "Number of images:") number
// @int(label = "Starting image:", value = 1) starting
// @int(label = "Increment:", value = 1) increment
// @int(label = "Scale images:", value = 100) scale
// @String(label = "File name contains:") file
// @String(visibility = "MESSAGE", value = "(enclose regex in parens)", persist = false) help1
// @boolean(label = "Convert to 8-bit Grayscale") convert
// @boolean(label = "Convert to RGB") convert_to_rgb
// @boolean(label = "sort names numerically") sort
// @boolean(label = "Use virtual stack") use

args = "open=" + dir;
args += " number=" + number;
args += " starting=" + starting;
args += " increment=" + increment;
args += " scale=" + 90;
args += " file=" + file;
if (convert) args += " convert";
if (convert_to_rgb) args += " convert_to_rgb";
if (sort) args += " sort";
if (use) args += " use";

run("Image Sequence...", args);

And here is a screenshot of it in action:


Thank you very much!!“Image Sequence…”);

was enough for my purpose.

I didn’t know that the macro recorder can be used not only for imageJ macro language but also Java/Java Script. Your comment greatly help.



I am reviving this topic to ask if it is possible to NOT show the image using (“Image Sequence…”)?

I am writing a jython script and wish to use this command in a loop.


In short: no, not when using"Image Sequence...").

Using the search bar, you can find out that File > Import > Image Sequence… is implemented in the ij.plugin.FolderOpener class:

In the source code you can find this hard-coded occurrence of ImagePlus#show():

But if you look at this class and its Javadoc a bit closer, you’ll find that there are two public static open() methods that return an ImagePlus object that you can use in scripting:

Something like this should work (example in Groovy):

import ij.plugin.FolderOpener

path = "/path/to/your/folder"
imp =

// do some processing with imp, without displaying it

Expanding jython scripting with the java api on the wiki

thanks @imagejan !
I managed to reproduce it in jython and add an option to it:

from ij import IJ
from ij.plugin import FolderOpener
path = "/home/kai/DATA/TC_BigStitcher/raw_data/FoxP2synG845612_reorganized/"
options = "virtual"
imp =, options)

I would like to add further options, but simply exchanging

options = " file=tile0001 sort"

did not work.

I imagine the same options as for the sequence import should be available, but I do not know how to add them in this context.


If you look at the source that I linked above, you’ll find that "virtual" is the only option handled by the method.

All the macro arguments are handled inside the run() method where also the image stack is shown.


you might be able to:

  • set Interpreter.batchMode = true,
  • then"Image Sequence...", options) as you did before,
  • then imp = IJ.getImage() to get the current image, and
  • Interpreter.batchMode = false again,

but that’s quite a dirty hack IMHO.


It will work if you upgrade to the latest ImageJ daily build (1.52e15). Sorting is done by default so the ‘sort’ is not needed. Note that the,options) method is now recordable. The daily build source code changes can be viewed at


thank you @imagejan for digging into this!

And of course thank you² @Wayne for upgrading this functionality into the daily build of ImageJ!! I tested it and it works like a charm :slight_smile: