Dear ImageJ fellows:
Many many thanks for your time reading my email. I am trying to do Analyze Particles in macro, using Fiji headless mode. I have two questions, and I am showing my code first, which will followed by the questions: Code: for (i=0; i<list.length; i++) // go through files in the folder { showProgress(i+1, list.length); if (endsWith(list[i], ".tif")) // process tiff { open(input_dir+list[i]); print(list[i]); run("Invert LUT"); run("8-bit"); setAutoThreshold(); run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 show=Overlay Outlines display record slice"); run("16-bit"); dotIndex = lastIndexOf(list[i], "."); if (dotIndex != -1) output_file = substring(list[i], 0, dotIndex); //remove extension saveAs("PNG", output_dir+output_file); close(output_file); close(list[i]); check++; } else if (list[i] == "Experiment.xml") // Experiment.xml file copied into output folder for review in ThorImageLS { print(list[i]); src = input_dir + list[i]; dst = output_dir + list[i]; print(src); print(dst); exec("cmd", "/c", "copy", src , dst); } } Questions 1: In my results, I can only see the Invert LUT works, but I cannot see run Analyze Particles work, because there is neither outline, nor object count showing on the result images. However, when I use the memu on Fiji UI to do the same thing, I can see outlines and object counts on the results images. I am wondering something wrong with my script? Questions 2: Even if I can show outlines and object counts with Fiji UI, I cannot save the outlines and object counts together with result images when they are saved as .TIFF, however, when the results are saved as .PNG, or .JPEG, I can see the outlines and objects counts saved together. I am wondering is there anyway to save outlines and object counts even when result images are saved as .TIFF? -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Nick,
@ Question 1: I would guess that the problem lies in the following line: run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 show=Overlay Outlines display record slice"); you need to put the show option in [] like this because due to the space inbetween it will otherwise not be recognized as correct command and then also the consecutive commands are potentially not recognized anymore. run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 show=[Overlay Outlines] display record slice"); @ Question 2: This is because during saving the image as PNG the shown overlays are destructively integrated into the image and thus are visible in the final output image. Saving the image as TIFF stores your outlines still as overlays which will be present when you reopen the TIFF image but they are not visible when you check the image e.g. watching it in the windows image galery or any other program. So, actually you save the outlines as overlays. In the case you want to save TIFF files and integrate the outlines destructively then you need to integrate a flattening beforehand: run("Flatten"); This gives you a copy of your image which you then can save. hope this works out for your images. regards, Jan 2014-03-07 22:41 GMT+01:00 Nick X. Tsui <[hidden email]>: > Dear ImageJ fellows: > > Many many thanks for your time reading my email. I am trying to do Analyze > Particles in macro, using Fiji headless mode. I have two questions, and I > am showing my code first, which will followed by the questions: > > Code: > > for (i=0; i<list.length; i++) // go through files in the folder > { > showProgress(i+1, list.length); > > if (endsWith(list[i], ".tif")) // process tiff > { > open(input_dir+list[i]); > print(list[i]); > run("Invert LUT"); > run("8-bit"); > setAutoThreshold(); > run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 > show=Overlay Outlines display record slice"); > run("16-bit"); > dotIndex = lastIndexOf(list[i], "."); > if (dotIndex != -1) output_file = substring(list[i], 0, > dotIndex); //remove extension > saveAs("PNG", output_dir+output_file); > close(output_file); > close(list[i]); > check++; > } > else if (list[i] == "Experiment.xml") // Experiment.xml file copied into > output folder for review in ThorImageLS > { > print(list[i]); > src = input_dir + list[i]; > dst = output_dir + list[i]; > print(src); > print(dst); > exec("cmd", "/c", "copy", src , dst); > } > } > > > Questions 1: > In my results, I can only see the Invert LUT works, but I cannot see run > Analyze Particles work, because there is neither outline, nor object count > showing on the result images. However, when I use the memu on Fiji UI to do > the same thing, I can see outlines and object counts on the results images. > I am wondering something wrong with my script? > > > Questions 2: > Even if I can show outlines and object counts with Fiji UI, I cannot save > the outlines and object counts together with result images when they are > saved as .TIFF, however, when the results are saved as .PNG, or .JPEG, I > can see the outlines and objects counts saved together. I am wondering is > there anyway to save outlines and object counts even when result images are > saved as .TIFF? > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- CEO: Dr. rer. nat. Jan Brocher phone: +49 (0)6234 917 03 39 mobile: +49 (0)176 705 746 81 e-mail: [hidden email] info: [hidden email] inquiries: [hidden email] web: www.biovoxxel.de -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Jan:
Thanks a lot for your reply. It seems working, however the result is not quite same as running with Fiji UI. Particularly, Runing Analyze Particles with Fiji UI gives less number of cell counted than using macros, although they both called run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 show=[Overlay Outlines] display record slice"); I am not sure what the problem is, perhaps some parameter settings that matter. In Fiji UI mode, I simply clicked "Analyze Particles" -> "Overlay Outlines -> "size=0-Infinity" -> "circularity=0.00-1.00". I guess I need to play with it a little more. The run("Flatten") works perfect! Thank you so much for your time and advice. I really appreciate it. Best, Nick On Sat, Mar 8, 2014 at 6:45 AM, BioVoxxel <[hidden email]> wrote: > Hi Nick, > > @ Question 1: > I would guess that the problem lies in the following line: > > run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 > show=Overlay > Outlines display record slice"); > > you need to put the show option in [] like this because due to the space > inbetween it will otherwise not be recognized as correct command and then > also the consecutive commands are potentially not recognized anymore. > > run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 > show=[Overlay > Outlines] display record slice"); > > @ Question 2: > > This is because during saving the image as PNG the shown overlays are > destructively integrated into the image and thus are visible in the final > output image. Saving the image as TIFF stores your outlines still as > overlays which will be present when you reopen the TIFF image but they are > not visible when you check the image e.g. watching it in the windows image > galery or any other program. > So, actually you save the outlines as overlays. > In the case you want to save TIFF files and integrate the outlines > destructively then you need to integrate a flattening beforehand: > > run("Flatten"); > > This gives you a copy of your image which you then can save. > > hope this works out for your images. > regards, > Jan > > > 2014-03-07 22:41 GMT+01:00 Nick X. Tsui <[hidden email]>: > > > Dear ImageJ fellows: > > > > Many many thanks for your time reading my email. I am trying to do > Analyze > > Particles in macro, using Fiji headless mode. I have two questions, and I > > am showing my code first, which will followed by the questions: > > > > Code: > > > > for (i=0; i<list.length; i++) // go through files in the folder > > { > > showProgress(i+1, list.length); > > > > if (endsWith(list[i], ".tif")) // process tiff > > { > > open(input_dir+list[i]); > > print(list[i]); > > run("Invert LUT"); > > run("8-bit"); > > setAutoThreshold(); > > run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 > > show=Overlay Outlines display record slice"); > > run("16-bit"); > > dotIndex = lastIndexOf(list[i], "."); > > if (dotIndex != -1) output_file = substring(list[i], 0, > > dotIndex); //remove extension > > saveAs("PNG", output_dir+output_file); > > close(output_file); > > close(list[i]); > > check++; > > } > > else if (list[i] == "Experiment.xml") // Experiment.xml file copied into > > output folder for review in ThorImageLS > > { > > print(list[i]); > > src = input_dir + list[i]; > > dst = output_dir + list[i]; > > print(src); > > print(dst); > > exec("cmd", "/c", "copy", src , dst); > > } > > } > > > > > > Questions 1: > > In my results, I can only see the Invert LUT works, but I cannot see run > > Analyze Particles work, because there is neither outline, nor object > count > > showing on the result images. However, when I use the memu on Fiji UI to > do > > the same thing, I can see outlines and object counts on the results > images. > > I am wondering something wrong with my script? > > > > > > Questions 2: > > Even if I can show outlines and object counts with Fiji UI, I cannot save > > the outlines and object counts together with result images when they are > > saved as .TIFF, however, when the results are saved as .PNG, or .JPEG, I > > can see the outlines and objects counts saved together. I am wondering is > > there anyway to save outlines and object counts even when result images > are > > saved as .TIFF? > > > > -- > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > > > > > -- > > CEO: Dr. rer. nat. Jan Brocher > phone: +49 (0)6234 917 03 39 > mobile: +49 (0)176 705 746 81 > e-mail: [hidden email] > info: [hidden email] > inquiries: [hidden email] > web: www.biovoxxel.de > > -- > 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 |