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("tiff", 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 & channel 2 = grey color. Any help would be greatly appreciated! <nabble_img src="Capture-ImageJ.png" border="0" alt="Screenshot of ImageJ with 400 opened images and copy-pasted code"/> -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.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("tiff", 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 & channel 2 = grey color. > Any help would be greatly appreciated! > <nabble_img src="Capture-ImageJ.png" border="0" > alt="Screenshot of ImageJ with 400 opened images and copy-pasted > code"/> > > > > -- > 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 |
Do you not have to have a file separator between the dir and the title?
From memory it is dir+File.separator+title Best Kenton On Tue, 1 Jun 2021, 15:48 Jerome Mutterer, <[hidden email]> wrote: > 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("tiff", 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 & channel 2 = grey color. > > Any help would be greatly appreciated! > > <nabble_img src="Capture-ImageJ.png" border="0" > > alt="Screenshot of ImageJ with 400 opened images and copy-pasted > > code"/> > > > > > > > > -- > > 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 > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by jmutterer
Hi fiji-newbie,
a few more things for explanation: You cannot specify a String with backquotes like "M:\Confocal\20210507\NewStitch" The reason is that backslashes "\" are special characters. When between (single or double) quotes, i.e., in a String constant (String literal), the backslash plus the character that follows it forms one entity. E.g. "\n" is a line feed, "\t" a tab. "\\" forms one backslash. So you would have to specify "M:\\Confocal\\20210507\\NewStitch" If it is a directory, it is also a good practice to add another separator at the end. This is required if you add the filename: "M:\\Confocal\\20210507\\NewStitch\\" As Jeorme said, it is easier to use normal slashes instead of backslashes. "M:/Confocal/20210507/NewStitch/" I do not see why you would use getDirectory("M:/Confocal/20210507/NewStitch/"), The String argument to getDirectory is the text that is shown when asking the user for the directory, typically as a title at the top of the dialog box (not on contemporary Macintosh operating systems, where these boxes have no title). If you want to set the default directory, you can use this: defaultDir = ""M:/Confocal/20210507/NewStitch/"; File.setDefaultDir(defaultDir); getDirectory("Select directory of stitched images"); Michael ________________________________________________________________ On 01.06.21 16:47, Jerome Mutterer wrote: > 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("tiff", 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 & channel 2 = grey color. >> Any help would be greatly appreciated! >> <nabble_img src="Capture-ImageJ.png" border="0" >> alt="Screenshot of ImageJ with 400 opened images and copy-pasted >> code"/> >> >> >> >> -- >> 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 > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |