Matthew
2012-06-04 23:00:49 UTC
Hello!
I am trying to use FIJI/ImageJ on a cluster and I need to run
headless. I have to process a large number of images. I have a macro
that I made for my local computer and I was wondering if anyone could
help me adapt it to jython which seems to not need a GUI?
The Macro I have is this (fijimacro1.ijm):
input = "/test/fiji1in/";
output = "/test/fiji1out/";
setBatchMode(true);
list = getFileList(input);
for (i = 0; i < list.length; i++)
action(input, output, list[i]);
setBatchMode(false);
function action(input, output, filename) {
open(input + filename);
run("16-bit");
run("TransformJ Scale", "x-factor=4.0 y-factor=4.0 z-
factor=1.0 interpolation=[quintic B-spline]");
saveAs("TIFF", output + filename);
close();
}
setBatchMode(false);
//setTool("angle");
I am able to get this to run from the command line with ‘fiji-linux64 –
Dplugins.dir=. –macro fijimacro1.ijm –batch &’. But I am connected
through xwindows and the display is being exported. I have been
reading forum posts and the main suggestion is to write a jython
script that doesn’t interact with a GUI at all. I have very little
experience in programming, and from what I found at Albert Cardona’s
python and ImageJ tutorial this was what I came up with.
My first attempt is this (fiji1_.py):
from ij import IJ
from ij.io import FileSaver
import os
# folder to read all images from:
folderin = "/test/fiji1in"
folderout = "/test/fiji1out"
for filename in os.listdir(folderin):
if filename.endswith(".tif"):
print "Processing", filename
imp =IJ.openImage(folderin + "/" +
filename)
IJ.run(imp, "16-bit")
IJ.run(imp, "TransformJ Scale", "x-
factor=2.0 y-factor=2.0 z-factor=1.0 interpolation=[quintic B-
spline]")
filepath = folderout + "/" +filename
else:
print "Ignoring", filename
Run from the command line with: ‘fiji-linux64 --headless --jython ./
scripts/fiji1_.py -batch &’
The error message that I get is:
“Processing 6_FA3-120217_26_2_6_DAPI.tif Traceback (most recent call
last):
File "./scripts/fiji1_.py", line 13, in <module>
IJ.run(imp, "16-bit")
TypeError: run(): 1st arg can't be coerced to String”
Any advice or assistance is greatly appreciated!!
Matt
I am trying to use FIJI/ImageJ on a cluster and I need to run
headless. I have to process a large number of images. I have a macro
that I made for my local computer and I was wondering if anyone could
help me adapt it to jython which seems to not need a GUI?
The Macro I have is this (fijimacro1.ijm):
input = "/test/fiji1in/";
output = "/test/fiji1out/";
setBatchMode(true);
list = getFileList(input);
for (i = 0; i < list.length; i++)
action(input, output, list[i]);
setBatchMode(false);
function action(input, output, filename) {
open(input + filename);
run("16-bit");
run("TransformJ Scale", "x-factor=4.0 y-factor=4.0 z-
factor=1.0 interpolation=[quintic B-spline]");
saveAs("TIFF", output + filename);
close();
}
setBatchMode(false);
//setTool("angle");
I am able to get this to run from the command line with ‘fiji-linux64 –
Dplugins.dir=. –macro fijimacro1.ijm –batch &’. But I am connected
through xwindows and the display is being exported. I have been
reading forum posts and the main suggestion is to write a jython
script that doesn’t interact with a GUI at all. I have very little
experience in programming, and from what I found at Albert Cardona’s
python and ImageJ tutorial this was what I came up with.
My first attempt is this (fiji1_.py):
from ij import IJ
from ij.io import FileSaver
import os
# folder to read all images from:
folderin = "/test/fiji1in"
folderout = "/test/fiji1out"
for filename in os.listdir(folderin):
if filename.endswith(".tif"):
print "Processing", filename
imp =IJ.openImage(folderin + "/" +
filename)
IJ.run(imp, "16-bit")
IJ.run(imp, "TransformJ Scale", "x-
factor=2.0 y-factor=2.0 z-factor=1.0 interpolation=[quintic B-
spline]")
filepath = folderout + "/" +filename
else:
print "Ignoring", filename
Run from the command line with: ‘fiji-linux64 --headless --jython ./
scripts/fiji1_.py -batch &’
The error message that I get is:
“Processing 6_FA3-120217_26_2_6_DAPI.tif Traceback (most recent call
last):
File "./scripts/fiji1_.py", line 13, in <module>
IJ.run(imp, "16-bit")
TypeError: run(): 1st arg can't be coerced to String”
Any advice or assistance is greatly appreciated!!
Matt
--
Please avoid top-posting, and please make sure to reply-to-all!
Mailing list web interface: http://groups.google.com/group/fiji-users
Please avoid top-posting, and please make sure to reply-to-all!
Mailing list web interface: http://groups.google.com/group/fiji-users