getProfile() x values

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

getProfile() x values

Teal, David
Hi,
Need some help with getProfile() and the x values. When I run the menu version of Plot Profile and click the List, Save, or Copy buttons, I see the x value with corresponding intensity. But I don't see how to get the x values in a macro so that it can be saved in a file.

I definitely have RTFM and searched the archive, but was not able to find much.

Here's a portion of the menu based Plot Profile result:

   X     Intensity
------------------
0.0000   193.4491
0.0008   193.4028
0.0017   193.5324
0.0025   193.8611
0.0033   193.7361
0.0042   193.9398
0.0050   193.6157
0.0058   193.6296
0.0067   193.5046
0.0075   193.6806
0.0083   193.4676

Here's the result of the macro below (and yes, I know that the macro is writing the value of the index i in the first column).

   X     Intensity
------------------
  1   193.4491
  2   193.4028
  3   193.5324
  4   193.8611
  5   193.7361
  6   193.9398
  7   193.6157
  8   193.6296
  9   193.5046
  10  193.6806
  11  193.4676

Here's a portion of the macro:

run("Clear Results");
makeRectangle(525, 600, 3000, 75);
profile = getProfile();
for (i=0; i<profile.length; i++)
    setResult("Distance", i, profile[i]);
updateResults;
saveAs("Measurements", "./macros/profile.xls");


It has to be something simple because the x data is there in the Plot Profile - I just don't know how to access it in the macro? Any help would be appreciated.

Thanks,
Dave Teal

- CONFIDENTIAL-

This email and any files transmitted with it are confidential, and may also be legally privileged.  If you are not the intended recipient, you may not review, use, copy, or distribute this message. If you receive this email in error, please notify the sender immediately by reply email and then delete this email.
Reply | Threaded
Open this post in threaded view
|

Re: getProfile() x values

Rasband, Wayne (NIH/NIMH) [E]
On Apr 26, 2012, at 11:02 AM, Teal, David wrote:

> Hi,
> Need some help with getProfile() and the x values. When I run the menu version of Plot Profile and click the List, Save, or Copy buttons, I see the x value with corresponding intensity. But I don't see how to get the x values in a macro so that it can be saved in a file.
>
> I definitely have RTFM and searched the archive, but was not able to find much.

You can use the Plot.getValues(x, y) macro function. Here is an example:

  run("CT (420K, 16-bit DICOM)");
  makeRectangle(0, 340, 888, 50);
  run("Plot Profile");
  Plot.getValues(x, y);
  run("Clear Results");
  for (i=0; i<x.length; i++) {
     setResult("x", i, x[i]);
     setResult("y", i, y[i]);
  }
  setOption("ShowRowNumbers", false);
  updateResults;

-wayne


>
> Here's a portion of the menu based Plot Profile result:
>
>   X     Intensity
> ------------------
> 0.0000   193.4491
> 0.0008   193.4028
> 0.0017   193.5324
> 0.0025   193.8611
> 0.0033   193.7361
> 0.0042   193.9398
> 0.0050   193.6157
> 0.0058   193.6296
> 0.0067   193.5046
> 0.0075   193.6806
> 0.0083   193.4676
>
> Here's the result of the macro below (and yes, I know that the macro is writing the value of the index i in the first column).
>
>   X     Intensity
> ------------------
>  1   193.4491
>  2   193.4028
>  3   193.5324
>  4   193.8611
>  5   193.7361
>  6   193.9398
>  7   193.6157
>  8   193.6296
>  9   193.5046
>  10  193.6806
>  11  193.4676
>
> Here's a portion of the macro:
>
> run("Clear Results");
> makeRectangle(525, 600, 3000, 75);
> profile = getProfile();
> for (i=0; i<profile.length; i++)
>    setResult("Distance", i, profile[i]);
> updateResults;
> saveAs("Measurements", "./macros/profile.xls");
>
>
> It has to be something simple because the x data is there in the Plot Profile - I just don't know how to access it in the macro? Any help would be appreciated.
>
> Thanks,
> Dave Teal
>
> - CONFIDENTIAL-
>
> This email and any files transmitted with it are confidential, and may also be legally privileged.  If you are not the intended recipient, you may not review, use, copy, or distribute this message. If you receive this email in error, please notify the sender immediately by reply email and then delete this email.
Reply | Threaded
Open this post in threaded view
|

Re: getProfile() x values

Teal, David
Thanks Wayne - that works just fine!

DT

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Rasband, Wayne (NIH/NIMH) [E]
Sent: Thursday, April 26, 2012 9:08 AM
To: [hidden email]
Subject: Re: getProfile() x values

On Apr 26, 2012, at 11:02 AM, Teal, David wrote:

> Hi,
> Need some help with getProfile() and the x values. When I run the menu version of Plot Profile and click the List, Save, or Copy buttons, I see the x value with corresponding intensity. But I don't see how to get the x values in a macro so that it can be saved in a file.
>
> I definitely have RTFM and searched the archive, but was not able to find much.

You can use the Plot.getValues(x, y) macro function. Here is an example:

  run("CT (420K, 16-bit DICOM)");
  makeRectangle(0, 340, 888, 50);
  run("Plot Profile");
  Plot.getValues(x, y);
  run("Clear Results");
  for (i=0; i<x.length; i++) {
     setResult("x", i, x[i]);
     setResult("y", i, y[i]);
  }
  setOption("ShowRowNumbers", false);
  updateResults;

-wayne


>
> Here's a portion of the menu based Plot Profile result:
>
>   X     Intensity
> ------------------
> 0.0000   193.4491
> 0.0008   193.4028
> 0.0017   193.5324
> 0.0025   193.8611
> 0.0033   193.7361
> 0.0042   193.9398
> 0.0050   193.6157
> 0.0058   193.6296
> 0.0067   193.5046
> 0.0075   193.6806
> 0.0083   193.4676
>
> Here's the result of the macro below (and yes, I know that the macro is writing the value of the index i in the first column).
>
>   X     Intensity
> ------------------
>  1   193.4491
>  2   193.4028
>  3   193.5324
>  4   193.8611
>  5   193.7361
>  6   193.9398
>  7   193.6157
>  8   193.6296
>  9   193.5046
>  10  193.6806
>  11  193.4676
>
> Here's a portion of the macro:
>
> run("Clear Results");
> makeRectangle(525, 600, 3000, 75);
> profile = getProfile();
> for (i=0; i<profile.length; i++)
>    setResult("Distance", i, profile[i]);
> updateResults;
> saveAs("Measurements", "./macros/profile.xls");
>
>
> It has to be something simple because the x data is there in the Plot Profile - I just don't know how to access it in the macro? Any help would be appreciated.
>
> Thanks,
> Dave Teal
>
> - CONFIDENTIAL-
>
> This email and any files transmitted with it are confidential, and may also be legally privileged.  If you are not the intended recipient, you may not review, use, copy, or distribute this message. If you receive this email in error, please notify the sender immediately by reply email and then delete this email.