Login  Register

Re: display filename in results table in the macro "Measure Cumulative distance

Posted by Michael Schmid on Nov 29, 2013; 1:32pm
URL: http://imagej.273.s1.nabble.com/display-filename-in-results-table-in-the-macro-Measure-Cumulative-distance-tp5005739p5005741.html

Hi L,

you can use "setResult("Label", row, getTitle());" to set the row label to the image title.

See http://rsb.info.nih.gov/ij/developer/macro/functions.html#setResult

If the image title is not the filename, you can also try getInfo("image.filename") to get the filename.

Michael
________________________________________________________________
On Nov 29, 2013, at 07:39, L wrote:

> Hi i'd like to have the filename show up in the results table when running
> the following macro, is this possible?
>
> "Measure Cumulative Distances [1]" {
>      if (!(selectionType==6||selectionType==10))
>          exit("Segmented line or point selection required");
>      getSelectionCoordinates(x, y);
>      if (x.length<2)
>          exit("At least two points required");
>      getPixelSize(unit, pw, ph);
>      n = nResults;
>      distance = 0;
>      for (i=1; i<x.length; i++) {
>         dx = (x[i] - x[i-1])*pw;
>         dy = (y[i] - y[i-1])*ph;
>         distance += sqrt(dx*dx + dy*dy);
>         setResult("D"+i, n, distance);
> }
>
> updateResults;
>   }
>
> I thought something along the lines of setResult("Label", n, title);  where
> title = getTitle()
> might work to add the filename into the Label column but i just am not
> familiar enough with the coding to work out the right combo.
> thanks to any who can help
> Cheers
>
>
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/display-filename-in-results-table-in-the-macro-Measure-Cumulative-distance-tp5005739.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