Hello All,
I am trying to incorporate the directionality plugin into a macro I'm writing and would like to have it analyze an image and then have the histogram of orientations be saved into a file. I don't need a plot, and ideally I'd like no windows to pop-up while its analyzing. My problem is that with the code I have below I get three windows that pop-up: the results, a plot, and a summary window. I can save the results table and close it but I can't seem to access the plot and the summary window from the macro to close them. Ideally, one of two options would be possible: 1) I access the Directionality plugin without opening any windows and just save a histogram of the results (don't need the Gaussian fit that it does either) to a .csv 2) I access the Directionality plugin and close the plot and summary windows and save the results to a .csv Either is fine, one is obviously a little more clean but I'd take either. The reason why the other windows are a problem is because I'd like to batch analyze a few hundred images at a time and thus after analyzing the images I have to manually close hundreds of pop-up windows (also the hundreds of open windows tend to hog a lot of RAM). Thanks in advance. open(name0); run("Invert"); run("Skeletonize"); run("Directionality", "method=[Fourier components] nbins=180 histogram=-90 display_table"); saveAs("Results", path19); run("Close"); close(); run("Close All"); I'm working with the latest release of FIJI. I've also attached an example segmented image. Nathan -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html 199a_m04_S2.tif (1M) Download Attachment |
Hi Nathan,
Try using batch mode. http://imagejdocu.tudor.lu/doku.php?id=faq:macros:how_can_i_speed_up_a_macro http://imagej.net/developer/macro/functions.html#setBatchMode Regards, Curtis On Fri, Jul 17, 2015 at 3:55 PM, Nathan Hotaling <[hidden email]> wrote: > Hello All, > > I am trying to incorporate the directionality plugin into a macro I'm > writing and would like to have it analyze an image and then have the > histogram of orientations be saved into a file. I don't need a plot, and > ideally I'd like no windows to pop-up while its analyzing. > > My problem is that with the code I have below I get three windows that > pop-up: the results, a plot, and a summary window. I can save the results > table and close it but I can't seem to access the plot and the summary > window from the macro to close them. Ideally, one of two options would be > possible: > > 1) I access the Directionality plugin without opening any windows and just > save a histogram of the results (don't need the Gaussian fit that it does > either) to a .csv > 2) I access the Directionality plugin and close the plot and summary > windows and save the results to a .csv > > Either is fine, one is obviously a little more clean but I'd take either. > The reason why the other windows are a problem is because I'd like to batch > analyze a few hundred images at a time and thus after analyzing the images > I have to manually close hundreds of pop-up windows (also the hundreds of > open windows tend to hog a lot of RAM). > > Thanks in advance. > > open(name0); > run("Invert"); > run("Skeletonize"); > run("Directionality", "method=[Fourier components] > nbins=180 histogram=-90 display_table"); > saveAs("Results", path19); > run("Close"); > close(); > run("Close All"); > > I'm working with the latest release of FIJI. I've also attached an > example segmented image. > > Nathan > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hey Curtis,
Thanks for the suggestion. In my first post I should have said there was code above what I had pasted there. In it I've turned batch mode on and the problem persists. Below is the total macro I'm using right now to batch analyze my images. Any help would be greatly appreciated. // Asks for a directory where Tif files are stored that you wish to analyze dir1 = getDirectory("Choose Source Directory "); list = getFileList(dir1); setBatchMode(true); T1 = getTime(); // Creates file list from chosen directory and looks for .tif files for (i=0; i<list.length; i++) { showProgress(i+1, list.length); filename = dir1 + list[i]; if (endsWith(filename, "tif")) { open(filename); // Save Analyzed B&W image into a new folder called Orientation myDir = dir1+"Orientation"+File.separator; File.makeDirectory(myDir); if (!File.exists(myDir)) exit("Unable to create directory"); print(""); // Creates custom file names for use later var name0= getTitle; var name1= getTitle+"_orientation.csv"; name1= replace(name1,".tif",""); // Creates custom file paths for use later var path0 = myDir+name0; var path1 = myDir+name1; // Analyzes the orientation of the skeleton of the B&W Image run("Invert"); run("Skeletonize"); run("Directionality", "method=[Fourier components] nbins=180 histogram=-90 display_table"); saveAs("Results", path1); run("Close"); close(); run("Close All"); } }T2 = getTime();TTime = (T2-T1)/1000; print("All Images Analyzed Successfully in",TTime," Seconds"); Nathan > Date: Fri, 17 Jul 2015 16:39:57 -0500 > From: [hidden email] > Subject: Re: Directionality Results Table > To: [hidden email] > > Hi Nathan, > > Try using batch mode. > > http://imagejdocu.tudor.lu/doku.php?id=faq:macros:how_can_i_speed_up_a_macro > http://imagej.net/developer/macro/functions.html#setBatchMode > > Regards, > Curtis > > On Fri, Jul 17, 2015 at 3:55 PM, Nathan Hotaling <[hidden email]> wrote: > > > Hello All, > > > > I am trying to incorporate the directionality plugin into a macro I'm > > writing and would like to have it analyze an image and then have the > > histogram of orientations be saved into a file. I don't need a plot, and > > ideally I'd like no windows to pop-up while its analyzing. > > > > My problem is that with the code I have below I get three windows that > > pop-up: the results, a plot, and a summary window. I can save the results > > table and close it but I can't seem to access the plot and the summary > > window from the macro to close them. Ideally, one of two options would be > > possible: > > > > 1) I access the Directionality plugin without opening any windows and just > > save a histogram of the results (don't need the Gaussian fit that it does > > either) to a .csv > > 2) I access the Directionality plugin and close the plot and summary > > windows and save the results to a .csv > > > > Either is fine, one is obviously a little more clean but I'd take either. > > The reason why the other windows are a problem is because I'd like to batch > > analyze a few hundred images at a time and thus after analyzing the images > > I have to manually close hundreds of pop-up windows (also the hundreds of > > open windows tend to hog a lot of RAM). > > > > Thanks in advance. > > > > open(name0); > > run("Invert"); > > run("Skeletonize"); > > run("Directionality", "method=[Fourier components] > > nbins=180 histogram=-90 display_table"); > > saveAs("Results", path19); > > run("Close"); > > close(); > > run("Close All"); > > > > I'm working with the latest release of FIJI. I've also attached an > > example segmented image. > > > > Nathan > > > > -- > > 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 |
Wow that last reply formatted my code terribly. Here's another stab at it with hopefully easier to see formatting.
// Asks for a directory where Tif files are stored that you wish to analyze dir1 = getDirectory("Choose Source Directory "); list = getFileList(dir1); setBatchMode(true); T1 = getTime(); for (i=0; i<list.length; i++) { showProgress(i+1, list.length); filename = dir1 + list[i]; if (endsWith(filename, "tif")) { open(filename); // Save Analyzed B&W image into a new folder called Orientation myDir = dir1+"Orientation"+File.separator; File.makeDirectory(myDir); if (!File.exists(myDir)) exit("Unable to create directory"); print(""); // Creates custom file names for use later var name0= getTitle; var name1= getTitle+"_orientation.csv"; name1= replace(name1,".tif",""); // Creates custom file paths for use later var path0 = myDir+name0; var path1 = myDir+name1; // Analyzes the orientation of the skeleton of the B&W Image run("Invert"); run("Skeletonize"); run("Directionality", "method=[Fourier components] nbins=180 histogram=-90 display_table"); saveAs("Results", path1); run("Close"); close(); run("Close All"); } } T2 = getTime(); TTime = (T2-T1)/1000; print("All Images Analyzed Successfully in",TTime," Seconds"); Nathan > Date: Fri, 17 Jul 2015 19:36:41 -0400 > From: [hidden email] > Subject: Re: Directionality Results Table > To: [hidden email] > > Hey Curtis, > Thanks for the suggestion. In my first post I should have said there was code above what I had pasted there. In it I've turned batch mode on and the problem persists. Below is the total macro I'm using right now to batch analyze my images. Any help would be greatly appreciated. > > // Asks for a directory where Tif files are stored that you wish to analyze dir1 = getDirectory("Choose Source Directory "); list = getFileList(dir1); setBatchMode(true); > T1 = getTime(); // Creates file list from chosen directory and looks for .tif files for (i=0; i<list.length; i++) { showProgress(i+1, list.length); filename = dir1 + list[i]; if (endsWith(filename, "tif")) { open(filename); > // Save Analyzed B&W image into a new folder called Orientation myDir = dir1+"Orientation"+File.separator; > File.makeDirectory(myDir); if (!File.exists(myDir)) exit("Unable to create directory"); print(""); > // Creates custom file names for use later var name0= getTitle; var name1= getTitle+"_orientation.csv"; name1= replace(name1,".tif",""); // Creates custom file paths for use later var path0 = myDir+name0; var path1 = myDir+name1; > // Analyzes the orientation of the skeleton of the B&W Image run("Invert"); run("Skeletonize"); run("Directionality", "method=[Fourier components] nbins=180 histogram=-90 display_table"); saveAs("Results", path1); run("Close"); close(); run("Close All"); > } }T2 = getTime();TTime = (T2-T1)/1000; > print("All Images Analyzed Successfully in",TTime," Seconds"); > > > > Nathan > > Date: Fri, 17 Jul 2015 16:39:57 -0500 > > From: [hidden email] > > Subject: Re: Directionality Results Table > > To: [hidden email] > > > > Hi Nathan, > > > > Try using batch mode. > > > > http://imagejdocu.tudor.lu/doku.php?id=faq:macros:how_can_i_speed_up_a_macro > > http://imagej.net/developer/macro/functions.html#setBatchMode > > > > Regards, > > Curtis > > > > On Fri, Jul 17, 2015 at 3:55 PM, Nathan Hotaling <[hidden email]> wrote: > > > > > Hello All, > > > > > > I am trying to incorporate the directionality plugin into a macro I'm > > > writing and would like to have it analyze an image and then have the > > > histogram of orientations be saved into a file. I don't need a plot, and > > > ideally I'd like no windows to pop-up while its analyzing. > > > > > > My problem is that with the code I have below I get three windows that > > > pop-up: the results, a plot, and a summary window. I can save the results > > > table and close it but I can't seem to access the plot and the summary > > > window from the macro to close them. Ideally, one of two options would be > > > possible: > > > > > > 1) I access the Directionality plugin without opening any windows and just > > > save a histogram of the results (don't need the Gaussian fit that it does > > > either) to a .csv > > > 2) I access the Directionality plugin and close the plot and summary > > > windows and save the results to a .csv > > > > > > Either is fine, one is obviously a little more clean but I'd take either. > > > The reason why the other windows are a problem is because I'd like to batch > > > analyze a few hundred images at a time and thus after analyzing the images > > > I have to manually close hundreds of pop-up windows (also the hundreds of > > > open windows tend to hog a lot of RAM). > > > > > > Thanks in advance. > > > > > > open(name0); > > > run("Invert"); > > > run("Skeletonize"); > > > run("Directionality", "method=[Fourier components] > > > nbins=180 histogram=-90 display_table"); > > > saveAs("Results", path19); > > > run("Close"); > > > close(); > > > run("Close All"); > > > > > > I'm working with the latest release of FIJI. I've also attached an > > > example segmented image. > > > > > > Nathan > > > > > > -- > > > 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 -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |