Batch Processing, channel split window name.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Batch Processing, channel split window name.

MickMunson
Hi,

I am very new to macro creating so apologies if it is something simple I am missing.

I have created a macro to first of all split a three colour image and then to process these channels relative to each other. This macro seems to work perfectly fine if I manually open a single image then run the macro, however I am having trouble when I use this to batch process a series of images from a folder. Normally if I open then split the channels it creates three windows, C1-/C2-/C3- file name. When batch processing it hits an error saying file by this name doesn't exist. I'm not sure if there is an easy way to troubleshoot this? Also is there any easy way to store the data from each file processed that can be included in the macro?

Macro:

T = getTitle();
selectWindow(T);
run("Split Channels");

selectWindow("C1-"+T);
Blue = getTitle();
selectWindow("C2-"+T);
Green = getTitle();
selectWindow("C3-"+T);
Red = getTitle();

selectWindow(Red);
setAutoThreshold("Default dark");
run("Threshold...");
setThreshold(20, 255);
setOption("BlackBackground", false);
run("Convert to Mask");

selectWindow(Green);
setAutoThreshold("Default dark");
run("Threshold...");
setThreshold(20, 255);
setOption("BlackBackground", false);
run("Convert to Mask");
run("Create Selection");

selectWindow(Red);
run("Restore Selection");
run("Enlarge...", "enlarge=2 pixel");
run("Clear", "slice");
run("Invert");
run("Select None");
run("Analyze Particles...", "size=0.10-Infinity pixel show=Outlines display exclude include summarize");

Many thanks for your time and help.
Reply | Threaded
Open this post in threaded view
|

Re: Batch Processing, channel split window name.

Olivier Burri
Hi,

How do you batch process your file? Are you sure that there are only images with 3 channels exactly in the folder where you are running the batch?
I have tested this with a few images in a folder and this works.
What is the error exactly? It can't find the C1 or the C2 or the C3?
I'd suggest adding a run("Close All"); at the end of your macro code, to make sure that there's no lingering images from a previous file.

Other than that, maybe using selectImage rather than selectWindow?


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of MickMunson
Sent: jeudi, 19 mai 2016 14:06
To: [hidden email]
Subject: Batch Processing, channel split window name.

Hi,

I am very new to macro creating so apologies if it is something simple I am missing.

I have created a macro to first of all split a three colour image and then to process these channels relative to each other. This macro seems to work perfectly fine if I manually open a single image then run the macro, however I am having trouble when I use this to batch process a series of images from a folder. Normally if I open then split the channels it creates three windows, C1-/C2-/C3- file name. When batch processing it hits an error saying file by this name doesn't exist. I'm not sure if there is an easy way to troubleshoot this? Also is there any easy way to store the data from each file processed that can be included in the macro?

Macro:

T = getTitle();
selectWindow(T);
run("Split Channels");

selectWindow("C1-"+T);
Blue = getTitle();
selectWindow("C2-"+T);
Green = getTitle();
selectWindow("C3-"+T);
Red = getTitle();

selectWindow(Red);
setAutoThreshold("Default dark");
run("Threshold...");
setThreshold(20, 255);
setOption("BlackBackground", false);
run("Convert to Mask");

selectWindow(Green);
setAutoThreshold("Default dark");
run("Threshold...");
setThreshold(20, 255);
setOption("BlackBackground", false);
run("Convert to Mask");
run("Create Selection");

selectWindow(Red);
run("Restore Selection");
run("Enlarge...", "enlarge=2 pixel");
run("Clear", "slice");
run("Invert");
run("Select None");
run("Analyze Particles...", "size=0.10-Infinity pixel show=Outlines display exclude include summarize");

Many thanks for your time and help.



--
View this message in context: http://imagej.1557.x6.nabble.com/Batch-Processing-channel-split-window-name-tp5016467.html
Sent from the ImageJ mailing list archive at Nabble.com.

--
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
|

Re: Batch Processing, channel split window name.

Nicholas George
In reply to this post by MickMunson
Hello,
when you get this error, look at the names of the images that are open. I bet that they are named T+ (“ green”) or T+ (“ red”) and so on as opposed to being named "C1-“ T as your macro states. If this is the case, it will split the channels and then give the error you are describing because ImageJ is looking to select the C1-T but can’t find it because it is named T+(“color”). I ran into a similar issue when I wrote a macro to split channels and then save the channels to appropriately named folders. Unfortunately, I am new to macro programming as well and I do not know how to solve this problem. It seems like different computers or versions of imageJ/FIJI name the output from Split Channels differently and this causes the error. I ended up writing two versions to process the images in either format, but I am sure there is an easier way to solve it that I am not aware of. Check if this is the issue though, it will help narrow down the source of the error at least.
hope this helps

> On May 19, 2016, at 8:06 AM, MickMunson <[hidden email]> wrote:
>
> Hi,
>
> I am very new to macro creating so apologies if it is something simple I am
> missing.
>
> I have created a macro to first of all split a three colour image and then
> to process these channels relative to each other. This macro seems to work
> perfectly fine if I manually open a single image then run the macro, however
> I am having trouble when I use this to batch process a series of images from
> a folder. Normally if I open then split the channels it creates three
> windows, C1-/C2-/C3- file name. When batch processing it hits an error
> saying file by this name doesn't exist. I'm not sure if there is an easy way
> to troubleshoot this? Also is there any easy way to store the data from each
> file processed that can be included in the macro?
>
> Macro:
>
> T = getTitle();
> selectWindow(T);
> run("Split Channels");
>
> selectWindow("C1-"+T);
> Blue = getTitle();
> selectWindow("C2-"+T);
> Green = getTitle();
> selectWindow("C3-"+T);
> Red = getTitle();
>
> selectWindow(Red);
> setAutoThreshold("Default dark");
> run("Threshold...");
> setThreshold(20, 255);
> setOption("BlackBackground", false);
> run("Convert to Mask");
>
> selectWindow(Green);
> setAutoThreshold("Default dark");
> run("Threshold...");
> setThreshold(20, 255);
> setOption("BlackBackground", false);
> run("Convert to Mask");
> run("Create Selection");
>
> selectWindow(Red);
> run("Restore Selection");
> run("Enlarge...", "enlarge=2 pixel");
> run("Clear", "slice");
> run("Invert");
> run("Select None");
> run("Analyze Particles...", "size=0.10-Infinity pixel show=Outlines display
> exclude include summarize");
>
> Many thanks for your time and help.
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Batch-Processing-channel-split-window-name-tp5016467.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> 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
|

Re: Batch Processing, channel split window name.

mese433
Hi there!

Really helpful post! I am new at macro coding as well. I wanted to do a macro to use one channel to select all my nuclei and then use this mask to count positive cells of the different channel and If I can I would like to do it in batch.

I used part of this code and it works nicely, it can do everything but it fails when I need to redirect my 'mask' channel to different channels to check if I have signal in my selections.

Not sure If I make a lot of sense so apologies for that!

Macro:

T = getTitle();
selectWindow(T);
run("Split Channels");

selectWindow(T + " (blue)");
Blue = getTitle();
selectWindow(T + " (green)");
Green = getTitle();
selectWindow(T + " (red)");
Red = getTitle();

selectWindow(Blue);
setAutoThreshold("Huang dark");
setAutoThreshold("Default");
//run("Threshold...");
setAutoThreshold("Default dark");
setAutoThreshold("Huang dark");
//setThreshold(23, 255);
setOption("BlackBackground", false);
run("Convert to Mask");
run("Erode");
run("Watershed");
run("Set Measurements...", "area mean modal min center redirect=None decimal=3");
run("Analyze Particles...", "clear add");
run("Clear Results");
selectWindow(Blue);
run("Set Measurements...", "area mean modal min center redirect=[Red] decimal=3");
run("Clear Results");
run("Analyze Particles...", "display clear add");

Thanks a lot!! :D