Re: appending file names to results window

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

Re: appending file names to results window

Ben.BigHair
bugjah wrote:

> what I REALLY want to do is to amend the standard "measureandsetlabel" macro
> in ImageJ to include the file name I am working with.
>
> The original code is below.  The key to my question, I think, is this line:
>
>     label = getString("Label:", "A");
>
> This prompts the user to add a label to each measurement.  What I would like
> to have happen is the name of the file to appear  instead of "a"
>
> So, for example, if I am doing a series of 10 measurements each in two files
> called "file1.jpg" and file2.jpg," it would be great if that pop up box
> prompting for a measurement label already contained (as the first part of
> the label displayed, in place of "A") "file1."  Then, for example, I could
> name the 20 measurements:
>
> file1a, file1b, ..., file1j, file2a, ...
>
> Does this make sense?  Sorry if I'm not explaining well.
>

Hi,

The adapted version of MeasuseAndSetLabel macro, pasted in below, will
pick the next "correct" label based upon the number of results in the
results window.  Will that do the trick?

Cheers,
Ben

***BEGIN
// This macro measures the current selection, outlines it in

// the current foreground color, prompts the user for a label,

// and draws the measurement number and label.

// Also adds the label to last row in the the "Results"

//  table if "Display Label" is checked in Analyze>

// Set Measurements.



   macro "Measure And AutoLabel" {

        requires("1.33u");

        fontSize = 12;

        alpha = newArray("nuts","A","B","C","D","E","F","G","H",
"I","J","K");

        title = getTitle();

        //label = getString("Label:", "A");

        label = alpha[nResults()+1];

        run("Rename...", "title='"+label+"'");

        run("Measure");

        run("Rename...", "title='"+title+"'");

        setJustification("center");

        setFont("SansSerif", fontSize);

        run("Draw");

        getBoundingRect(x, y, width, height);

        label2 = "" + nResults+"-"+label;

        drawString(label2, x+width/2, y+height/2+fontSize/2);

   }
***END