channel-splitting macro

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

channel-splitting macro

Zuzanna Kurowska
Hello,

I would very much appreciate if someone could help me with writing a macro that splits channels in a 3-channel TIF and saves the 3 new TIFs, and does that with all the images in the same folder. So something like:

1. Open the ().tif image from a folder
2. Split channels
3. Save each of the 3 new files as a TIF
4. Open next file from the same folder and then 2-4 until all files from this folder are opened, converted and saved
5. Close all the windows

I tried to record such macro... but did not go very far.

I would be really grateful to someone who could help me with this macro.

Best regards
Zuzanna





_____________________________________
Zuzanna Kurowska, M.Sc.
Neural Plasticity and Repair Unit
Wallenberg Neuroscience Center
Lund University
BMC A10
221 84 Lund, Sweden

Phone: +46-46-2220524
E-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: channel-splitting macro

Rob van 't Hof
Hi,
This works for me. Hope it helps.

bye,
Rob


dir=getDirectory("Choose a Directory");
print(dir);
splitDir=dir + "\Split\\";
print(splitDir);
File.makeDirectory(splitDir);
list = getFileList(dir);

for (i=0; i<list.length; i++) {
     if (endsWith(list[i], ".tif")){
               print(i + ": " + dir+list[i]);
             open(dir+list[i]);
             imgName=getTitle();
         baseNameEnd=indexOf(imgName, ".tif");
         baseName=substring(imgName, 0, baseNameEnd);

         run("Split Channels");
         selectWindow(imgName + " (blue)");
         rename(baseName + "-blue.tiff");
         saveAs("Tiff", splitDir+baseName + "-blue.tif");
         close();
         selectWindow(imgName + " (green)");
         saveAs("Tiff", splitDir+baseName + "-green.tif");
         close();
         selectWindow(imgName + " (red)");
         saveAs("Tiff", splitDir+baseName + "-red.tif");

         run("Close All");
     }
}

On 04/01/2012 16:06, Zuzanna Kurowska wrote:

> Hello,
>
> I would very much appreciate if someone could help me with writing a macro that splits channels in a 3-channel TIF and saves the 3 new TIFs, and does that with all the images in the same folder. So something like:
>
> 1. Open the ().tif image from a folder
> 2. Split channels
> 3. Save each of the 3 new files as a TIF
> 4. Open next file from the same folder and then 2-4 until all files from this folder are opened, converted and saved
> 5. Close all the windows
>
> I tried to record such macro... but did not go very far.
>
> I would be really grateful to someone who could help me with this macro.
>
> Best regards
> Zuzanna
>
>
>
>
>
> _____________________________________
> Zuzanna Kurowska, M.Sc.
> Neural Plasticity and Repair Unit
> Wallenberg Neuroscience Center
> Lund University
> BMC A10
> 221 84 Lund, Sweden
>
> Phone: +46-46-2220524
> E-mail: [hidden email]
>

--
_____________________________
Dr. Rob van 't Hof
Senior Lecturer
Bone Group
Molecular Medicine Centre
Western General Hospital
Edinburgh EH4 2XU
UK

Phone: (+44)-131-6511031
email: [hidden email]
_____________________________



The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.