Login  Register

Re: Help writing a macro to merge channels + save with sequential names

Posted by jmutterer on Jun 01, 2021; 2:47pm
URL: http://imagej.273.s1.nabble.com/Help-writing-a-macro-to-merge-channels-save-with-sequential-names-tp5024674p5024676.html

Hi fiji-newbie

- getDirectory will prompt for a folder, you can simply use:
dir = "M:/Confocal/20210507/NewStitch";

- you never use your ids array, so you could remove that code.

- a closing curly brace is missing at the end of you code, which could
explain why your loop runs only once.

- you could add
Stack.setDisplayMode("composite");
before your save command to show both channels overlaid.

Jerome.





On Tue, 1 Jun 2021 at 14:12, fiji-newbie <[hidden email]> wrote:

> First of all, I wanted to say I ahve searched this question in the group
> before and I have copy-pasted the answers I have seen so far. However, this
> does not seem to work for me and I am pretty sure that it has to do with my
> ineptitude for understanding code.
> I set up a 20x20 stitching of my sample for the 1st time and the microscope
> software returned a single .czi file which, when opened with ImageJ,
> prompts
> 400 windows to open at the same time. I would like to save each of these as
> an independent tiff "merged" file with sequential names so that I can
> stitch
> them later using a tutorial I saw on YouTube.
> But right now I have tried the snippets of code that I have seen in the
> forum with no luck. I go to Plugins>New>Macro and write the code, save it
> in
> a folder, and then go to Plugins>Run>Macro and click on it. It just saves a
> single channel of the most recent image (number 400) in the output folder
> and calls it a day.
> This is the code I've tried so far:
> dir = getDirectory("M:\Confocal\20210507\NewStitch");
> ids=newArray(nImages);
> for (i=0;i<nImages;i++) {
>         selectImage(i+1);
>         title = getTitle;
>         print(title);
>         ids[i]=getImageID;
>
>         saveAs(&quot;tiff&quot;, dir+title);
> And I am not sure
> 1. Why it doesn't save 400 images in the output folder
> 2. How to add a line of code that merges both channels. In my case, channel
> 1 = red color &amp; channel 2 = grey color.
> Any help would be greatly appreciated!
> &lt;nabble_img src=&quot;Capture-ImageJ.png&quot; border=&quot;0&quot;
> alt=&quot;Screenshot of ImageJ with 400 opened images and copy-pasted
> code&quot;/>
>
>
>
> --
> Sent from: http://imagej.1557.x6.nabble.com/
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html