Access AVI Virtual Stack reader from script

This is probably a trivial question, but I couldn’t find any exact description in the web.

I am processing a lot of large .avi files (15+ GB each) which can only be opened by using virtual stacks. As I want to automatize the processing, I need an option to open an avi file with a virtual stack by script. My scripting language is Python.

Problematically, only the following options seem to be possible Virtual Stack...","open="+file_path)","open="+file_path)
which is either the wrong format or does not use a virtual stack.

I need something like:"AVI Virtual Stack...","open="+file_path) which does not seem to exist.

I know that it is possible to open this files, because it works perfectly in the GUI via File > Open. Would please anybody be so kind to point me to the solution.

If I record the file open command (macro recorder, I record a BeanShell command - quite similar to Jython) I get:"AVI...", "open=C:/MyFile/mri-stack.avi use");

With ‘use’ as an argument to open as a virtual stack.

1 Like

Strangely enough, I also used macro recorder to infer about the command. But from there I only got IJ.openImage() which always opens the pop-up window.

I tried it with use and it works perfectly. Thanks for saving my time :slight_smile:

This bug is fixed in the latest ImageJ daily build (1.52e4).

Upgrade to the latest ImageJ daily build (1.52e4) and you can open AVI files as virtual stacks, without displaying them, using

imp = IJ.openImage("/path/to/file.avi")

Hey guys,

I am having a similar problem. I am trying to open very large .AVI files in a batch macro (.IJM format) as virtual stacks. I need to do this because if I try to open them as stacks imagej says they are corrupt when the files are above a certain size.

Within my script I use the command:
run(“AVI…”, “open=[input+”/"+list[i].avi] use");

Where “input” is the predefined file path and “list” is the current filename.

I know this is a simp,y syntax issue because imagej says it expects a “(” somewhere but I have tried all combinations I can think of and nothing works.

Any help is appreciated,


You must correct your quoting like this (without to know the whole macro):

run("AVI…", "open=["+input+"/"+list[i]+".avi] use");

to concatenate variables in a string.

Thanks for your help,
So the whole script is below - the standard imagej generated batch processing script. The corrections you suggested have given the error message “unrecognized command “AVI…”” which is odd because it seems to work for everyone above. Could it because I’m using .IJM language?

outputDir = "/D:/" 
#@ File (label = "Input directory", style = "directory") input
#@ File (label = "Output directory", style = "directory") output
#@ String (label = "File suffix", value = ".tif") suffix

// See also for a version of this code
// in the Python scripting language.


// function to scan folders/subfolders/files to find files with correct suffix
function processFolder(input) {
	list = getFileList(input);
	list = Array.sort(list);
	for (i = 0; i < list.length; i++) {
		if(File.isDirectory(input + File.separator + list[i]))
			processFolder(input + File.separator + list[i]);
		if(endsWith(list[i], suffix))
			processFile(input, output, list[i]);

function processFile(input, output, file) {
	// Do the processing here by adding your own code.
	// Leave the print statements until things work, then remove them.
	for (i = 0; i < list.length; i++) {
	//print(input + "/" + list[i]); 
	//filepath = input + "/" + list[i]; 
	run("AVI…", "open= ["+input+"/"+list[i]+".avi] use");
	title = getTitle(); 

Sorry, there was a typo - your suggestion actually works but my files are still being reported as damaged / truncated (which I hoped to circumvent by using less memory to open virtual stacks).

Can anyone explain these error messages:
AVI File Error: ‘’ @ 0x608f145ba has invalid length. File damaged/truncated?

AVI File Error: ‘<<<<’ @ 0x5fcde3888 has invalid length. File damaged/truncated?

AVI File Error: ’

’ @ 0x5fdf34578 has invalid length. File damaged/truncated?

First I would try to split the files if you can open a smaller *.avi.

But see also: