Macro to get "list-data" after custom histogram

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Macro to get "list-data" after custom histogram

javila0624
Hello community,
I've tried looking on previous posts but have not found anything to help me. I'm trying to write a script that will enable two things: 1. set a custom x_min and x_max on the histogram
                                        2. save THIS bin start, count list onto an excel sheet



No. 1 is solved with this: run("Histogram", "bins=256 x_min=0 x_max=65536 y_max=Auto");

It works fine.

But then, how can I continue the macro to get the list of Bin start/count from this specific histogram?
              Based on other posts, I've managed to get intensity counts saved to an excel sheet with these lines:


getHistogram(values, counts, );    
print(d, "Intensity Counts");
        for (k=0; k<256; k++) {
                print(d, k+" "+counts[k]);



I've tried to replace getHistogram(values, counts, 256);  with getHistogram(bin start, count, 256);

An error message pops up. In addition, I'd like the macro to get this list from the run("Histogram") script that I mentioned earlier.    

I am doing this for a composite image of three channels, and would like that each channel have a respective heading under its count list, so I'm trying these lines out:


title=getTitle()
c1Title = "C1-" + title;
c2Title = "C2-" + title;
c3Title = "C3-" + title;
Histc3Title= "Histogram of C1-" + title
Histc3Title= "Histogram of C2-" + title
Histc3Title= "Histogram of C3-" + title

selectWindow( "C1-" + title);
selectWindow( "Histogram of C1-" + title);


This is not in order but it's what I'm trying out to get my output.


Can someone help?
Reply | Threaded
Open this post in threaded view
|

Re: Macro to get "list-data" after custom histogram

Michael Entrup
Hello  Javila,

first you should check the website [1] and seach for the command
getHistogram(). The description tells you how to set histMin and
histMax. The example HistogramLister [2] creates a Results table that
you can save as xls (it's a txt-file with xls extension). I have never
created histograms from a composite image, but it should work the same
way, as for stacks. Use a loop to iterate over all channels (slices).

Concerning the headings, I don't understand what you want to do. Your
code creates new strings and tries to select a window with this strings
as title. It looks like you want to disassemble the composite image and
work with single images.

Maybe you should have a look at [3]. There are some nice examples, that
show how to work with stacks.

Best regards
Michael Entrup


[1] http://rsbweb.nih.gov/ij/developer/macro/functions.html
[2] http://rsbweb.nih.gov/ij/macros/HistogramLister.txt
[3] http://fiji.sc/Introduction_into_Macro_Programming


Am 17.07.2014 22:56, schrieb javila0624:

> Hello community,
> I've tried looking on previous posts but have not found anything to help me.
> I'm trying to write a script that will enable two things: 1. set a custom
> x_min and x_max on the histogram
>                                          2. save THIS bin start, count list
> onto an excel sheet
>
>
>
> No. 1 is solved with this: run("Histogram", "bins=256 x_min=0 x_max=65536
> y_max=Auto");
>
> It works fine.
>
> But then, how can I continue the macro to get the list of Bin start/count
> from this specific histogram?
>                Based on other posts, I've managed to get intensity counts
> saved to an excel sheet with these lines:
>
>
> getHistogram(values, counts, );
> print(d, "Intensity Counts");
>          for (k=0; k<256; k++) {
>                  print(d, k+" "+counts[k]);
>
>
>
> I've tried to replace getHistogram(values, counts, 256);  with
> getHistogram(bin start, count, 256);
>
> An error message pops up. In addition, I'd like the macro to get this list
> from the run("Histogram") script that I mentioned earlier.
>
> I am doing this for a composite image of three channels, and would like that
> each channel have a respective heading under its count list, so I'm trying
> these lines out:
>
>
> title=getTitle()
> c1Title = "C1-" + title;
> c2Title = "C2-" + title;
> c3Title = "C3-" + title;
> Histc3Title= "Histogram of C1-" + title
> Histc3Title= "Histogram of C2-" + title
> Histc3Title= "Histogram of C3-" + title
>
> selectWindow( "C1-" + title);
> selectWindow( "Histogram of C1-" + title);
>
>
> This is not in order but it's what I'm trying out to get my output.
>
>
> Can someone help?
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/Macro-to-get-list-data-after-custom-histogram-tp5008813.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Macro to get "list-data" after custom histogram

javila0624
Thank you! This helped me a lot.