Login  Register

Re: question: macro for automatic image stack summing

Posted by Krs5 on Jan 25, 2017; 8:33am
URL: http://imagej.273.s1.nabble.com/question-macro-for-automatic-image-stack-summing-tp5017938p5017940.html

Dear Sebastian,

The line    run("Bio-Formats Windowless Importer", "open=input + filename"); should read run("Bio-Formats Windowless Importer", "open="+input+filename); or in the case you have spaces in your directory or file names run("Bio-Formats Windowless Importer", "open=["+input+filename+"]");
Input and filename are variables. You don't want to open a file with the name "input + filename" but with the directory and name stored in input and filename.

However, I never get the error message with your code if I do not also change the input and output code to:

input = getDirectory("specified input folder with stacks of .tif images");
output = getDirectory("specified empty output folder");

Also your run("Save", "save=[output+filename]"); should read run("Save", "save=["output+filename+"]");

Best wishes

Kees


Dr Ir K.R. Straatman
Senior Experimental Officer
Advanced Imaging Facility
Centre for Core Biotechnology Services
University of Leicester
http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Sebastian Voigtländer
Sent: 24 January 2017 20:09
To: [hidden email]
Subject: question: macro for automatic image stack summing

Dear all,

I try to write a simple macro to help me with image analysis for my thesis.
It should:

1. open .tif image stacks from an input folder 2. execute run("Z Project...", "projection=[Sum Slices]") 3. save the files in an output folder


my macro (so far):

function sum_stacks(input, output, filename) {

    run("Bio-Formats Windowless Importer", "open=input + filename");
    run("Z Project...", "projection=[Sum Slices]");
    run("Save", "save=[output+filename]");
    run("Close");
};

input = "*specified input folder with stacks of .tif images*"
output = "*specified empty output folder*"

list = getFileList(input);

for (k = 0; k < list.length; k++) {
    sum_stacks(input, output, list[k]);
};



When I run it I get the error message:

Sorry, there was an I/O problem during import.


Since I have no idea what's wrong, I would be very grateful for any help!

Cheers,
Sebastian

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html