Macro vs. Script, where to start

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

Macro vs. Script, where to start

Rainer M. Engel
I'm not a developer by profession, but became more and more accustomed
to it over the years. I started with small macros and want to sum up,
what is/was making this language attractive for the use within ImageJ.


Macro-Language:.......................................................
Macros can be recorded inside of ImageJ Plugins>Macros>Record and
extended by some logic found here:
https://imagej.nih.gov/ij/developer/macro/macros.html

Using Fiji's script editor for macros helps you finding the right
function you may need, at least to the same extend useful to me is this
overview with all built-in functions:
https://imagej.nih.gov/ij/developer/macro/functions.html


Script-Languages:.....................................................
To automate things inside of ImageJ the Recorder (see above) can be
changed to output a desired language.
There are many examples available within the script editor of Fiji under
"Templates", or on other ImageJ/Fiji related websites and to some extent
the interactive search bar helps to find these.

What I'm missing is some method overview like the macro language offers
for it's functions to make a text search, because often you know what to
achieve but you miss the spelling of a potential method/function.

What IDE you would recommend for Jython, where I can see all available
methods of imported classes like Fiji's script editor is providing for
the macro language?

Are there resources (easily searchable) to find fitting methods of
classes closely related to ImageJ or how do you achieve finding these?


Thank you in advance and I hope this will help others as well..

Kind regards,
Rainer

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

Re: Macro vs. Script, where to start

Michael Schmid
Hi Rainer,

of course, the first thing to try is the macro recorder in JavaScript mode.

Script languages call the Java API, so you have to look up the functions
there.

Starting points:

- For run(...) functions, it is simply IJ.run, which can also take an
ImagePlus argument to specify on which image to run the function. The
ImagePlus is essentially what an image (with ImageID) is in macros, and
it can hold a single image or stack.
Each ImagePlus has an ImageProcessor, which just holds the data (if a
stack, of the current slice), but no spatial calibration, etc.

- Many ImageJ macro functions have an equivalent in IJ.java.

- If I know the macro command and not the java code, usually I search
for the code that executes the macro functions in:
   https://github.com/imagej/imagej1/blob/master/ij/macro/Functions.java

For more complex functions like, e.g. the Plot.??? functions, there is a
dispatch function, in this case doPlot(), and then the actual code is in
separate functions called by doPlot(), such as setPlotColor().

hth,

Michael
________________________________________________________________
On 10.10.19 13:47, Rainer M. Engel wrote:

> I'm not a developer by profession, but became more and more accustomed
> to it over the years. I started with small macros and want to sum up,
> what is/was making this language attractive for the use within ImageJ.
>
>
> Macro-Language:.......................................................
> Macros can be recorded inside of ImageJ Plugins>Macros>Record and
> extended by some logic found here:
> https://imagej.nih.gov/ij/developer/macro/macros.html
>
> Using Fiji's script editor for macros helps you finding the right
> function you may need, at least to the same extend useful to me is this
> overview with all built-in functions:
> https://imagej.nih.gov/ij/developer/macro/functions.html
>
>
> Script-Languages:.....................................................
> To automate things inside of ImageJ the Recorder (see above) can be
> changed to output a desired language.
> There are many examples available within the script editor of Fiji under
> "Templates", or on other ImageJ/Fiji related websites and to some extent
> the interactive search bar helps to find these.
>
> What I'm missing is some method overview like the macro language offers
> for it's functions to make a text search, because often you know what to
> achieve but you miss the spelling of a potential method/function.
>
> What IDE you would recommend for Jython, where I can see all available
> methods of imported classes like Fiji's script editor is providing for
> the macro language?
>
> Are there resources (easily searchable) to find fitting methods of
> classes closely related to ImageJ or how do you achieve finding these?
>
>
> Thank you in advance and I hope this will help others as well..
>
> Kind regards,
> Rainer
>
> --
> 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 vs. Script, where to start

Kenneth Sloan-2
Allow me to suggest an alternative: full Java.

I am old school and make do without an IDE, but it works for me.  I’ll let
someone else suggest an IDE to use with Java and ImageJ.

On Thu, Oct 10, 2019 at 08:48 Michael Schmid <[hidden email]>
wrote:

> Hi Rainer,
>
> of course, the first thing to try is the macro recorder in JavaScript mode.
>
> Script languages call the Java API, so you have to look up the functions
> there.
>
> Starting points:
>
> - For run(...) functions, it is simply IJ.run, which can also take an
> ImagePlus argument to specify on which image to run the function. The
> ImagePlus is essentially what an image (with ImageID) is in macros, and
> it can hold a single image or stack.
> Each ImagePlus has an ImageProcessor, which just holds the data (if a
> stack, of the current slice), but no spatial calibration, etc.
>
> - Many ImageJ macro functions have an equivalent in IJ.java.
>
> - If I know the macro command and not the java code, usually I search
> for the code that executes the macro functions in:
>    https://github.com/imagej/imagej1/blob/master/ij/macro/Functions.java
>
> For more complex functions like, e.g. the Plot.??? functions, there is a
> dispatch function, in this case doPlot(), and then the actual code is in
> separate functions called by doPlot(), such as setPlotColor().
>
> hth,
>
> Michael
> ________________________________________________________________
> On 10.10.19 13:47, Rainer M. Engel wrote:
> > I'm not a developer by profession, but became more and more accustomed
> > to it over the years. I started with small macros and want to sum up,
> > what is/was making this language attractive for the use within ImageJ.
> >
> >
> > Macro-Language:.......................................................
> > Macros can be recorded inside of ImageJ Plugins>Macros>Record and
> > extended by some logic found here:
> > https://imagej.nih.gov/ij/developer/macro/macros.html
> >
> > Using Fiji's script editor for macros helps you finding the right
> > function you may need, at least to the same extend useful to me is this
> > overview with all built-in functions:
> > https://imagej.nih.gov/ij/developer/macro/functions.html
> >
> >
> > Script-Languages:.....................................................
> > To automate things inside of ImageJ the Recorder (see above) can be
> > changed to output a desired language.
> > There are many examples available within the script editor of Fiji under
> > "Templates", or on other ImageJ/Fiji related websites and to some extent
> > the interactive search bar helps to find these.
> >
> > What I'm missing is some method overview like the macro language offers
> > for it's functions to make a text search, because often you know what to
> > achieve but you miss the spelling of a potential method/function.
> >
> > What IDE you would recommend for Jython, where I can see all available
> > methods of imported classes like Fiji's script editor is providing for
> > the macro language?
> >
> > Are there resources (easily searchable) to find fitting methods of
> > classes closely related to ImageJ or how do you achieve finding these?
> >
> >
> > Thank you in advance and I hope this will help others as well..
> >
> > Kind regards,
> > Rainer
> >
> > --
> > ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> >
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
--
-Kenneth Sloan

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

Re: Macro vs. Script, where to start

CARL Philippe (LBP)
In reply to this post by Michael Schmid
Dear Michael and Rainer,
The big difference also between macro and java is that the second one is an object oriented language.
And as far as I'm concerned, it took me quite some time to understand on one side how such languages are working and especially the power behind the principle of classes on the other side (and I'm still not sure I understand everything, at least I'm not convinced of it).
By chance when I needed to start to learn Java, I was doing a post-doc in an university and thus had the opportunity to sit as a spectator (i.e. I was not allowed to take exams and validate a diploma) in courses aimed for computer scientists.
And later on, knowing more or less how Java works, it took me only 2-3 days to discover php and be able to write a code I needed.
Thus if you know good ressources to explain the principles of object oriented languages, I'm as well interested in it.
And to illustrate my question, let me cite Richard Feynman: "there is always an easy way to explain everything, it is just very hard to find it".
My best regards,
Philippe

Philippe CARL
Laboratoire de Bioimagerie et Pathologies
UMR 7021 CNRS - Université de Strasbourg
Faculté de Pharmacie
74 route du Rhin
67401 ILLKIRCH
Tel : +33(0)3 68 85 41 84

----- Mail original -----
De: "Michael Schmid" <[hidden email]>
À: "imagej" <[hidden email]>
Envoyé: Jeudi 10 Octobre 2019 15:46:38
Objet: Re: Macro vs. Script, where to start

Hi Rainer,

of course, the first thing to try is the macro recorder in JavaScript mode.

Script languages call the Java API, so you have to look up the functions
there.

Starting points:

- For run(...) functions, it is simply IJ.run, which can also take an
ImagePlus argument to specify on which image to run the function. The
ImagePlus is essentially what an image (with ImageID) is in macros, and
it can hold a single image or stack.
Each ImagePlus has an ImageProcessor, which just holds the data (if a
stack, of the current slice), but no spatial calibration, etc.

- Many ImageJ macro functions have an equivalent in IJ.java.

- If I know the macro command and not the java code, usually I search
for the code that executes the macro functions in:
   https://github.com/imagej/imagej1/blob/master/ij/macro/Functions.java

For more complex functions like, e.g. the Plot.??? functions, there is a
dispatch function, in this case doPlot(), and then the actual code is in
separate functions called by doPlot(), such as setPlotColor().

hth,

Michael
________________________________________________________________
On 10.10.19 13:47, Rainer M. Engel wrote:

> I'm not a developer by profession, but became more and more accustomed
> to it over the years. I started with small macros and want to sum up,
> what is/was making this language attractive for the use within ImageJ.
>
>
> Macro-Language:.......................................................
> Macros can be recorded inside of ImageJ Plugins>Macros>Record and
> extended by some logic found here:
> https://imagej.nih.gov/ij/developer/macro/macros.html
>
> Using Fiji's script editor for macros helps you finding the right
> function you may need, at least to the same extend useful to me is this
> overview with all built-in functions:
> https://imagej.nih.gov/ij/developer/macro/functions.html
>
>
> Script-Languages:.....................................................
> To automate things inside of ImageJ the Recorder (see above) can be
> changed to output a desired language.
> There are many examples available within the script editor of Fiji under
> "Templates", or on other ImageJ/Fiji related websites and to some extent
> the interactive search bar helps to find these.
>
> What I'm missing is some method overview like the macro language offers
> for it's functions to make a text search, because often you know what to
> achieve but you miss the spelling of a potential method/function.
>
> What IDE you would recommend for Jython, where I can see all available
> methods of imported classes like Fiji's script editor is providing for
> the macro language?
>
> Are there resources (easily searchable) to find fitting methods of
> classes closely related to ImageJ or how do you achieve finding these?
>
>
> Thank you in advance and I hope this will help others as well..
>
> Kind regards,
> Rainer
>
> --
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Macro vs. Script, where to start

Curtis Rueden-2
In reply to this post by Rainer M. Engel
Hi Rainer,

For ImageJ2, we try to centralize the documentation here:
  https://github.com/imagej/tutorials

And in particular, using Jupyter Notebook, browsable here:
  https://imagej.github.io/tutorials

The API (Application Programming Interface—i.e. the full set of available
functions) is vast, and there is no single HTML page listing everything.
The Jupyter Notebooks linked above are an attempt to organize things in a
way that can train you on how to get started writing ImageJ scripts.

Note that the tutorials linked above are all organized around ImageJ2
concepts. For an ImageJ1-based set of scripting tutorials focused on
Jython, check out Albert Cardona's excellent Fiji Programming Tutorial:
  https://www.ini.uzh.ch/~acardona/fiji-tutorial/

Regards,
Curtis

--
Curtis Rueden
Software architect, LOCI/Eliceiri lab - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Have you tried the Image.sc Forum? https://forum.image.sc/



On Thu, Oct 10, 2019 at 6:59 AM Rainer M. Engel <[hidden email]> wrote:

> I'm not a developer by profession, but became more and more accustomed
> to it over the years. I started with small macros and want to sum up,
> what is/was making this language attractive for the use within ImageJ.
>
>
> Macro-Language:.......................................................
> Macros can be recorded inside of ImageJ Plugins>Macros>Record and
> extended by some logic found here:
> https://imagej.nih.gov/ij/developer/macro/macros.html
>
> Using Fiji's script editor for macros helps you finding the right
> function you may need, at least to the same extend useful to me is this
> overview with all built-in functions:
> https://imagej.nih.gov/ij/developer/macro/functions.html
>
>
> Script-Languages:.....................................................
> To automate things inside of ImageJ the Recorder (see above) can be
> changed to output a desired language.
> There are many examples available within the script editor of Fiji under
> "Templates", or on other ImageJ/Fiji related websites and to some extent
> the interactive search bar helps to find these.
>
> What I'm missing is some method overview like the macro language offers
> for it's functions to make a text search, because often you know what to
> achieve but you miss the spelling of a potential method/function.
>
> What IDE you would recommend for Jython, where I can see all available
> methods of imported classes like Fiji's script editor is providing for
> the macro language?
>
> Are there resources (easily searchable) to find fitting methods of
> classes closely related to ImageJ or how do you achieve finding these?
>
>
> Thank you in advance and I hope this will help others as well..
>
> Kind regards,
> Rainer
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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