http://imagej.273.s1.nabble.com/merging-and-z-projection-in-batch-mode-tp3692193p3692195.html
number 'n' to a string padded with '0'. Here it is for 3 digits:
So, n=1 will give s="001", etc.
> Johannes,
>
> to retrieve your header, use the method ij.util.Tools().split(String
> filename, String
> Delimiter)<
http://rsbweb.nih.gov/ij/developer/api/ij/util/Tools.html>.
> Once you know the format, you can easily split your name in order
> to get the
> numbers. But, in this case, the output will be an array of Strings.
> Using
> the expression:
>
> ----------------------------------------------------------------------
> ---------------
> String[] dummy = ij.util.Tools.split(filename,"C");
> String yy = dummy[0];
>
> String[] dummy2 = ij.util.Tools.split(dummy[1],"Z");
> int xxx = new Integer(dummy2[0]).parseInt();
>
> String[] dummy3 = ij.util.Tools.split(dummy[1],"T");
> int ttt = new Integer(dummy3[0]).parseInt();
> int zzz = new Integer(dummy3[1]).parseInt();
> ----------------------------------------------------------------------
> ---------------
>
> you will get the correct int value of your strings.
> Unfortunatelly, i don't know how to program with macros but it
> should be
> easy to convert this code to a macro code.
> I hope this works.
> Best regards,
> Fernando
>
>
> On Wed, Jun 10, 2009 at 11:27 AM, Johannes-P. KOCH <
>
[hidden email]> wrote:
>
>> Dear Listers,
>>
>> This might be quite an easy question for you, yet not for me, I
>> sort of
>> miss the logic...
>>
>> I have some (appr. 6000) files from a live cell imaging experiment
>> indexed
>> with "yyCxxxZyyyTzzz", where the yy stand for arbitrary letters
>> and xxx,
>> yyy, zzz indicate the numbers (001-999). C, Z, T of course are for
>> channel,
>> z-position, time...
>> as the header indicates I want to merge the channels of a Z-
>> projection and
>> save the files in another directory, maybe not only TIFF but even
>> as AVI.
>>
>> My starting point was the macro at the ImageJ homepage:
>>
http://rsbweb.nih.gov/ij/macros/Batch_RGB_Merge.txt>>
>> But the big problem here is, that this macro just accounts for
>> indexes at
>> the end of file names. My filename contains three indices and I
>> want to call
>> them separately, so I tried the "substring" macro function...does
>> not work
>> out though....
>>
>> maybe somebody has some simple and logic advice for me. I included my
>> modified macro in the end.
>>
>> Thanks
>> Johannes
>>
>> PS: by now I have just implemented the merge function and not the
>> z-projection, but that would be easy when my first problem is
>> solved...
>>
>>
>> Dialog.create("RGB Batch Convert");
>> Dialog.addString("Red Prefix:", "d1");
>> Dialog.addString("Green Prefix:", "d2");
>> Dialog.show();
>> redSuffix = Dialog.getString() + ".";
>> greenSuffix = Dialog.getString() + ".";
>> batchConvert();
>> exit;
>>
>> function batchConvert() {
>> dir1 = getDirectory("Choose Source Directory ");
>> dir2 = getDirectory("Choose Destination Directory ");
>> list = getFileList(dir1);
>> setBatchMode(true);
>> n = list.length;
>> if ((n%2)!=0)
>> exit("The number of files must be a multiple of 2");
>> stack = 0;
>> first = 0;
>> for (i=0; i<n/2; i++) {
>> showProgress(i+1, n/2);
>> red="?"; green="?";
>> for (j=first; j<first+2; j++) {
>> if (substring(list[j], redSuffix)!=-1)
>> red = list[j];
>> if (substring(list[j], greenSuffix)!=-1)
>> green = list[j];
>> }
>>
>> open(dir1 +red);
>> open(dir1 +green);
>>
>> run("RGB Merge...", "red=["+red+"] green=["+green+"]");
>> index = indexOf(red, redSuffix);
>> name = substring(red, 0, index);
>> saveAs("tiff", dir2+name);
>> first += 2;
>> }
>> }
>>
>>
>>
>>
>> ________________________________________
>> Johannes-P. KOCH
>> University of Vienna
>> Department of Biochemistry and Cell Biology
>> Dr. Bohrgasse 9/5
>> A-1030 Vienna
>> Austria
>>
>> phone: 00431427752809
>> fax: 0043142779528
>>
>> mail to:
[hidden email]
>>
>> --
>> Ich verwende die kostenlose Version von SPAMfighter für private
>> Anwender,
>> die bei mir bis jetzt 305 Spammails entfernt hat.
>> Rund 6 Millionen Leute nutzen SPAMfighter schon.
>> Laden Sie SPAMfighter kostenlos herunter: http://
>> www.spamfighter.com/lde
>>
>
>
>
> --
> **************************************************
> Fernando José Ribeiro Sales
> **************************************************
> Email:
[hidden email]
> Tel: (11) 82020303
> **************************************************