using BAR Distribution plotter in a macro script

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

using BAR Distribution plotter in a macro script

Aryeh Weiss
I am trying to use the distribution plotter in a macro script. Here is
what the macro recorder provides me:

run("Distribution Plotter", "parameter=Mean tabulate=[Number of values]
automatic=[Specify manually below:] bins=50");

However, if I run this, is tells me "Automatic binning could not be
performed. Re-check settings or specify bins manually."

I looked at the source code here:
https://github.com/tferr/Scripts/blob/master/BAR/src/main/resources/scripts/BAR/Data_Analysis/Distribution_Plotter.ijm

and found that this message will happen with max-min is 0. This should
not be the case assuming I have a results table open, and it does not
happen when I run the script manually.

So i tried to use a local copy of the script (copied from github and
saved locally) so that i could add some print statements and try to
figure out what is happening.
The command I tried is
run("script:/home/amw/Desktop/83411LightMicroscopyData/studentDataSets/distPlot.ijm",
"parameter=Mean tabulate=[Number of values] automatic=[Specify manually
below:] bins=415");

However, this returns :

     ---
     <Error: java.io.FileNotFoundException:
http://wsr.imagej.net/download/Examples/Macro/script:/home/amw/Desktop/83411LightMicroscopyData/studentDataSets/distPlot.ijm>
in line 1:

     var ; initializeSciJavaParameters ( ) ; run (
"script:/home/amw/Desktop/83411LightMicroscopyData/studentDataSets/distPl...

So I have two questions:

1. How do I run the Distribution plotter from a macro?

2. How so I run any macro that is in a file from a macro?

I have a feeling that this second question maybe related to the use of
BARlib, which I have not succeeded in figuring out -- I am missing some
understanding of how that works. Maybe someone has a really simple
example of how to use that.

Thanks in advance\
--aryeh

--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051


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

Re: using BAR Distribution plotter in a macro script

Jan Eglinger
Hi Aryeh,

I don't know if Tiago Ferreira (the author of BAR) is still following
this mailing list. In general I'd recommend asking questions on
https://forum.image.sc instead.

 > 2. How so I run any macro that is in a file from a macro?

Two options:

- (if you use Fiji) put your macro file (with an underscore in the name)
in a subfolder of /Fiji.app/scripts/ such as
/Fiji.app/scripts/MyMacros/dist_plot.ijm so that it'll show up in the
menus, then use a command such as:
     run("dist plot")

or

- use the runMacro() function:
https://imagej.net/developer/macro/functions.html#runMacro


 > (copied from github and
 > saved locally)

To open the source of a script in the script editor, you can also
shift-click on its menu entry.


Hope that helps,
Jan


On 22.06.20 16:13, Aryeh Weiss wrote:

> I am trying to use the distribution plotter in a macro script. Here is
> what the macro recorder provides me:
>
> run("Distribution Plotter", "parameter=Mean tabulate=[Number of values]
> automatic=[Specify manually below:] bins=50");
>
> However, if I run this, is tells me "Automatic binning could not be
> performed. Re-check settings or specify bins manually."
>
> I looked at the source code here:
> https://github.com/tferr/Scripts/blob/master/BAR/src/main/resources/scripts/BAR/Data_Analysis/Distribution_Plotter.ijm 
>
>
> and found that this message will happen with max-min is 0. This should
> not be the case assuming I have a results table open, and it does not
> happen when I run the script manually.
>
> So i tried to use a local copy of the script (copied from github and
> saved locally) so that i could add some print statements and try to
> figure out what is happening.
> The command I tried is
> run("script:/home/amw/Desktop/83411LightMicroscopyData/studentDataSets/distPlot.ijm",
> "parameter=Mean tabulate=[Number of values] automatic=[Specify manually
> below:] bins=415");
>
> However, this returns :
>
>      ---
>      <Error: java.io.FileNotFoundException:
> http://wsr.imagej.net/download/Examples/Macro/script:/home/amw/Desktop/83411LightMicroscopyData/studentDataSets/distPlot.ijm>
> in line 1:
>
>      var ; initializeSciJavaParameters ( ) ; run (
> "script:/home/amw/Desktop/83411LightMicroscopyData/studentDataSets/distPl...
>
>
> So I have two questions:
>
> 1. How do I run the Distribution plotter from a macro?
>
> 2. How so I run any macro that is in a file from a macro?
>
> I have a feeling that this second question maybe related to the use of
> BARlib, which I have not succeeded in figuring out -- I am missing some
> understanding of how that works. Maybe someone has a really simple
> example of how to use that.
>
> Thanks in advance\
> --aryeh
>

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

Re: using BAR Distribution plotter in a macro script

Aryeh Weiss
Hi Jan,

Thank you for your immediate reply.


On 22/06/2020 18:27, Jan Eglinger wrote:

> Hi Aryeh,
>
> I don't know if Tiago Ferreira (the author of BAR) is still following
> this mailing list. In general I'd recommend asking questions on
> https://forum.image.sc instead.
>
> > 2. How so I run any macro that is in a file from a macro?
>
> Two options:
>
> - (if you use Fiji) put your macro file (with an underscore in the
> name) in a subfolder of /Fiji.app/scripts/ such as
> /Fiji.app/scripts/MyMacros/dist_plot.ijm so that it'll show up in the
> menus, then use a command such as:
>     run("dist plot")
>
> or
>
> - use the runMacro() function:
> https://imagej.net/developer/macro/functions.html#runMacro
>
this works as advertised...
>
> > (copied from github and
> > saved locally)
>
> To open the source of a script in the script editor, you can also
> shift-click on its menu entry.
>
I was not able to get this to work, with either shift-left-click or
shift-right-click. I also tried control and alt with click.

I run ubuntu 20.04 (POP OS distribution) .I wonder if this function is
OS dependent.

Best regards

--aryeh

>
> Hope that helps,
> Jan
>
>
> On 22.06.20 16:13, Aryeh Weiss wrote:
>> I am trying to use the distribution plotter in a macro script. Here
>> is what the macro recorder provides me:
>>
>> run("Distribution Plotter", "parameter=Mean tabulate=[Number of
>> values] automatic=[Specify manually below:] bins=50");
>>
>> However, if I run this, is tells me "Automatic binning could not be
>> performed. Re-check settings or specify bins manually."
>>
>> I looked at the source code here:
>> https://github.com/tferr/Scripts/blob/master/BAR/src/main/resources/scripts/BAR/Data_Analysis/Distribution_Plotter.ijm 
>>
>>
>> and found that this message will happen with max-min is 0. This
>> should not be the case assuming I have a results table open, and it
>> does not happen when I run the script manually.
>>
>> So i tried to use a local copy of the script (copied from github and
>> saved locally) so that i could add some print statements and try to
>> figure out what is happening.
>> The command I tried is
>> run("script:/home/amw/Desktop/83411LightMicroscopyData/studentDataSets/distPlot.ijm",
>> "parameter=Mean tabulate=[Number of values] automatic=[Specify
>> manually below:] bins=415");
>>
>> However, this returns :
>>
>>      ---
>>      <Error: java.io.FileNotFoundException:
>> http://wsr.imagej.net/download/Examples/Macro/script:/home/amw/Desktop/83411LightMicroscopyData/studentDataSets/distPlot.ijm>
>> in line 1:
>>
>>      var ; initializeSciJavaParameters ( ) ; run (
>> "script:/home/amw/Desktop/83411LightMicroscopyData/studentDataSets/distPl...
>>
>>
>> So I have two questions:
>>
>> 1. How do I run the Distribution plotter from a macro?
>>
>> 2. How so I run any macro that is in a file from a macro?
>>
>> I have a feeling that this second question maybe related to the use
>> of BARlib, which I have not succeeded in figuring out -- I am missing
>> some understanding of how that works. Maybe someone has a really
>> simple example of how to use that.
>>
>> Thanks in advance\
>> --aryeh
>>

--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051

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

Re: using BAR Distribution plotter in a macro script

Krs5
In reply to this post by Aryeh Weiss
Dear Aryeh

The macro code below works fine on my Windows10 system

-----------------------------
run("Set Measurements...", "area mean standard min limit redirect=None decimal=3");
run("Blobs (25K)");
setAutoThreshold("Default");
run("Analyze Particles...", "display");
run("Distribution Plotter", "parameter=Mean tabulate=[Number of values] automatic=[Specify manually below:] bins=50");
--------------------------------------------

Best wishes

Kees


Advanced Imaging Facility

University of Leicester
www.le.ac.uk/advanced-imaging-facility<http://www.le.ac.uk/advanced-imaging-facility>


________________________________
From: Aryeh Weiss <[hidden email]>
Sent: 22 June 2020 15:13
Subject: using BAR Distribution plotter in a macro script

I am trying to use the distribution plotter in a macro script. Here is
what the macro recorder provides me:

run("Distribution Plotter", "parameter=Mean tabulate=[Number of values]
automatic=[Specify manually below:] bins=50");

However, if I run this, is tells me "Automatic binning could not be
performed. Re-check settings or specify bins manually."

I looked at the source code here:
https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftferr%2FScripts%2Fblob%2Fmaster%2FBAR%2Fsrc%2Fmain%2Fresources%2Fscripts%2FBAR%2FData_Analysis%2FDistribution_Plotter.ijm&amp;data=02%7C01%7Ckrs5%40leicester.ac.uk%7Ccc0518724efb4fc084ca08d816b788f8%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C0%7C637284324825936320&amp;sdata=7gPg%2FScv8NARdEYv9dxefFQKQQTuB4qnhgoNyKmu4qw%3D&amp;reserved=0

and found that this message will happen with max-min is 0. This should
not be the case assuming I have a results table open, and it does not
happen when I run the script manually.

So i tried to use a local copy of the script (copied from github and
saved locally) so that i could add some print statements and try to
figure out what is happening.
The command I tried is
run("script:/home/amw/Desktop/83411LightMicroscopyData/studentDataSets/distPlot.ijm",
"parameter=Mean tabulate=[Number of values] automatic=[Specify manually
below:] bins=415");

However, this returns :

     ---
     <Error: java.io.FileNotFoundException:
https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwsr.imagej.net%2Fdownload%2FExamples%2FMacro%2Fscript%3A%2Fhome%2Famw%2FDesktop%2F83411LightMicroscopyData%2FstudentDataSets%2FdistPlot.ijm&amp;data=02%7C01%7Ckrs5%40leicester.ac.uk%7Ccc0518724efb4fc084ca08d816b788f8%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C0%7C637284324825936320&amp;sdata=vjG6m0z%2BXgfoqb1xjrzE2eWCeVfNIaAlqQqu6BL85M0%3D&amp;reserved=0>
in line 1:

     var ; initializeSciJavaParameters ( ) ; run (
"script:/home/amw/Desktop/83411LightMicroscopyData/studentDataSets/distPl...

So I have two questions:

1. How do I run the Distribution plotter from a macro?

2. How so I run any macro that is in a file from a macro?

I have a feeling that this second question maybe related to the use of
BARlib, which I have not succeeded in figuring out -- I am missing some
understanding of how that works. Maybe someone has a really simple
example of how to use that.

Thanks in advance\
--aryeh

--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051


--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Ckrs5%40leicester.ac.uk%7Ccc0518724efb4fc084ca08d816b788f8%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C0%7C637284324825936320&amp;sdata=FN%2F4AA96hGwKlxlzjLg4N1%2Fcbm8xiHDhokoYNsVb4wA%3D&amp;reserved=0

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

Re: using BAR Distribution plotter in a macro script

Aryeh Weiss
Dear Kees,

Thank you fro your reply.

On 22/06/2020 20:11, Straatman, Kees (Dr.) wrote:
> run("Set Measurements...", "area mean standard min limit redirect=None
> decimal=3");
> run("Blobs (25K)");
> setAutoThreshold("Default");
> run("Analyze Particles...", "display");
> run("Distribution Plotter", "parameter=Mean tabulate=[Number of
> values] automatic=[Specify manually below:] bins=50");

This script also runs correctly on my machine. It must have something to
do with my Results.

And so I looked again, and found that my results table was generated
forma binary image (by mistake), and all of the Means were 255. Sure
enough, max-min is really zero, and the script is doing what it is
supposed to.
Thank you again for getting me to see this.

Best regards
--aryeh

--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051

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