Wednesday, January 23, 2019

ML Toolkit




I developed a tiny Machine Learning (ML) toolkit written in JavaScript containing helper functions...


I usually put all my JavaScript scripts in a sub-directory of the plugins directory (for example, My_Scripts) and use my favorite text editor as described in this post [configure my dev environment].

1. Install

Now, in your plugins directory, create a new directory termed javascript your folder tree is now like this...

ImageJ/
  +--luts/
  +--macros/ 
  +--plugins/
      +--My_Scripts/
      +--javascript/


Then download the following files tip-gist.js and nashorn-polyfill.js located in github.
The first file contains various tools to manipulate the data
The second file contains missing JS system functions (polyfills in the jargon JS).

ImageJ/
  +--luts/
  +--macros/
  +--plugins/
      +--My_Scripts/
      +--javascript/
         +--tip-gist.js
         +--nashorn-polyfill.js 
         +--tml-gist.js
            

Now, we are ready to play with the data.

2. How to use it


In the folder My_Scripts, create a new file hello_ML.js and restart ImageJ. Now, in the menu, Plugins > My_Scripts, we'll see the file hello_ML in the sub-menu.

With your favorite text editor, copy the following lines...


// Import helper functions
const IJ_PLUGINS = IJ.getDir('plugins');
load(`${IJ_PLUGINS}/javascript/nashorn_polyfill.js`);
load(`${IJ_PLUGINS}/javascript/tip-gist.js`);
load(`${IJ_PLUGINS}/javascript/tml-gist.js`);

These three lines import the JS functions located in the two files nashorn-polyfill.js and tip-gist.js.

Note: The following JS script only works if you have a Java version greater or equal to 1.9 (it doesn't work with Java 1.8). To check your java version, in the main IJ window, go to Help > About ImageJ.

3. Some examples

  • distance(u,v): Multi-dimensional distance computation.




<<  Previous: Cleaning Data Next: k-NN  >>


4. Other crazybiocomputing posts

Further readings are available in ...

No comments:

Post a Comment