http://imagej.273.s1.nabble.com/Batch-split-channels-and-save-tp3687341p3687345.html
Thanks very much. You're right; I was running an older version of ImageJ.
The macro works perfectly Kees. Thanks,
>Hi,
>
>On Aug 6, 2010, at 8:35 AM, Dr D.J. Metcalf wrote:
>
>> Dear Kees,
>>
>> Thanks for your reply. I've just tried the macro but I get an error
>> message:
>> '(' expected in line 19.
>>
>> title= File . nameWithoutExtension <;>
>>
>
>It might be that you have a different version of ImageJ than that
>required. The File.nameWithoutExtension requires at least 1.42d
>according to ...
>
>
http://rsb.info.nih.gov/ij/developer/macro/functions.html#F>
>Cheers,
>Ben
>
>
>
>
>> Regards,
>>
>> Dan
>>
>> On Aug 6 2010, Straatman, Kees R. (Dr.) wrote:
>>
>>> Dear Dan,
>>>
>>> See if the macro below does what you want. At the moment it saves
>>> the results to a new directory called "analysed". If you want to
>>> save the result files in the same directory as your original files
>>> delete the line "dir2 = ....." and change in the first lane "dir1"
>>> into "dir2"
>>>
>>>
>>> dir1 = getDirectory("Choose Source Directory ");
>>> list = getFileList(dir1);
>>> dir2 = dir1+"analysed"+File.separator;
>>> File.makeDirectory(dir2);
>>> for (i=0; i<list.length; i++) {
>>>
>>> if (File.isDirectory(dir1+list[i])){}
>>> else{
>>>
>>> path = dir1+list[i];
>>> if (endsWith(path, ".db")){} else{
>>>
>>> open(path);
>>> if (bitDepth!=24){} else {
>>> setBatchMode(true); title = File.nameWithoutExtension ;
>>> run("Split Channels");
>>> close();
>>>
>>> saveAs("Tiff", dir2+title+"d0.tif");
>>> saveAs("Tiff", dir2+title+"d1.tif");
>>> close();
>>> saveAs("Tiff", dir2+title+"d2.tif");
>>> close();
>>> setBatchMode(false);
>>> }
>>> }
>>> }
>>> }
>>>
>>> Best wishes
>>>
>>> Kees
>>>
>>>
>>> Dr K.R. Straatman
>>> Senior Experimental Officer
>>> Centre for Core Biotechnology Services
>>> College of Medicine, Biological Sciences and Psychology
>>>
http://www.le.ac.uk/biochem/microscopy/home.html>>>
>>>
>>> -----Original Message----- From: ImageJ Interest Group
>>> [mailto:
[hidden email] ] On Behalf Of Dr D.J. Metcalf Sent: 04
>>> August 2010 17:14 To:
[hidden email]
>>> Subject: Batch split channels and save
>>>
>>> Hi,
>>>
>>> I'd be grateful for some help on making my macro capable of batch
>>> processing a folder of images. I'm not sure if it's possible to
>>> modify the one I've written or if another approach is required.
>>>
>>> The aim is to open RGB tif files and then save the individual
>>> channels but with the added complication of discarding the blue
>>> image and saving the green and red images. Ideally I'd like to save
>>> the green image twice with different file names (see below).
>>>
>>> My starting file names are A_A##f##.tif My result file names are
>>> A_A##f##d0.tif, A_A##f##d1.tif, A_A##f##d2.tif (where d0 is the
>>> green chanel, d1 is the green channel and d2 is the red channel)
>>>
>>> Thanks,
>>>
>>> Dan
>>>
>>> open("V:\\Dan\\tif_files\\A_A06f12.tif"); run("Split Channels");
>>> run("Save", "save=V:\\Dan\\tif_files\\discards\\C3-A_A06f12.tif");
>>> close(); close(); run("Save", "save=[V:\\Dan\\tif_files\\discards\
>>> \C1-A_A06f12.tif]"); close(); open("V:\\Dan\\tif_files\\discards\
>>> \C1-A_A06f12.tif"); open("V:\\Dan\\tif_files\\discards\\C3-
>>> A_A06f12.tif"); run("Merge Channels...", "red=C3-A_A06f12.tif
>>> green=C1-A_A06f12.tif blue=C1-A_A06f12.tif gray=*None* create");
>>> run("Split Channels"); run("Save", "save=[V:\\Dan\\new files\
>>> \A_A06f12d0.tif]"); close(); run("Save", "save=[V:\\Dan\\new files\
>>> \A_A06f12d1.tif]"); close(); run("Save", "save=[V:\\Dan\\new files\
>>> \A_A06f12d2.tif]"); close();
>