question: macro for automatic image stack summing

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

question: macro for automatic image stack summing

Sebastian Voigtländer
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: question: macro for automatic image stack summing

Straatman, Kees (Dr.)
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: question: macro for automatic image stack summing

Eric Denarier
In reply to this post by Sebastian Voigtländer
Hi Sebastian,
You can do it with the batch function :
Process/Batch/macro
without need to code.

Eric Denarier
Grenoble Institut des Neurosciences
Inserm U1216
Chemin Fortuné Ferrini
38700 La Tronche
France

Tél :33 (0)4 565 205 38

http://neurosciences.ujf-grenoble.fr/

Le 24/01/2017 21:09, Sebastian Voigtländer a écrit :

> 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

Capture.PNG (40K) Download Attachment
Loading...