Re: How to pass an array from a plugin to a macro?

Posted by Emmanuel Levy on
URL: http://imagej.273.s1.nabble.com/How-to-pass-an-array-from-a-plugin-to-a-macro-tp5002492p5002498.html

Hi Johannes,

Thanks, I understand that this does sound a bit strange but the reason is that i started working on a macro a long time ago and it would require a significant amount of work to port the whole thing to Javascript.

I was thinking that there should already be a way to do this as the getSttatistics function gives access to an array of values (hist) that (i suppose) is calculated from java code.

I'm not sure I explained my question clearly, all I want is to pass an array of values back to the macro language to process it, not set or modify a ROI. E.g., just like one has access to the value of "hist" after calling getStatistics, id like to have access to myT.

I hope im clearer!

Thank you,

Emmanuel


On 1 Apr 2013, at 20:13, Johannes Schindelin <[hidden email]> wrote:

> Hi Emmanuel,
>
> On Mon, 1 Apr 2013, Emmanuel Levy wrote:
>
>> I wrote a simple plugin that puts all pixel values of a selected ROI
>> into a 1D table. What I can't figure out is how to pass the resulting 1D
>> array to a macro calling the plugin? i.e., similarly to getStatistics,
>> which makes a histogram array available in the macro calling the
>> function for example.
>
> I fear that you are trying to do something with the macro language that it
> was not designed for. Remember, the macro language is meant to be very
> simple so it is easy to learn, it is not meant to be fast (and it is
> indeed not fast) nor a fully-fledged scripting language. Javascript is.
>
> Sure, you may get Wayne to extend the macro language, but everytime the
> syntax gets extended, the macro interpreter becomes more brittle since the
> original design was not intended to be extended in that way.
>
> In your case, the easiest may be a work-around: you *can* set the ROI
> thusly:
>
>    dummy = new float[myT.length];
>    image.setRoi(new PointRoi(myT, dummy, dummy.length));
>
> Ciao,
> Johannes

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