Obtain data from plot

Hi everyone ! I’m working with a set of images ( n>1 cells per image) using the clock scan protocol plugin (https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5608458/) for obtaining a radial plot of endosomes in a given slice. The plugin works perfectly and I can get to plot each radial intensity for any given cell.

This is the plot:

The thing is that while trying to automate a macro that uses this plugin I can’t export the data (x,y) from which the plot itself is made and save it, let’s say, as an independent .csv file for each image. If I click on the “list” button it shows all the plot values but doing this won’t get recorded in the macros recorder, so I’m trying ot figure out how to make the macros click on that button without telling the user to do so.

After this, a window named “Plot Values” comes up with everything and can be exported.

Any idea on how to achieve this so I can automate the way the data gets saved?
Thank you very much in advance!


You can try to take pieces of this standalone example code to see what might work in this case:

#@ File (label = "Output directory", style = "directory") output

// set up test image
run("Blobs (25K)");
makeLine(65, 161, 177, 64);
roiManager("Select", 0);

// Get profile and display values in "Results" window
  run("Clear Results");
  profile = getProfile();
  for (i=0; i<profile.length; i++)
      setResult("Value", i, profile[i]);

  // Plot profile
  Plot.create("Profile", "X", "Value", profile);

  // Save as spreadsheet compatible text file
  saveAs("Results", output + File.separator + "plotData.csv");

I’ve never used that particular plugin before… but the above should be applicable.


Thank you so much ! I’ll try this alternative and tell you how it went.
Best regards


Hi, I finally could fix this by adding the following code at the begining of my macros:

run("Plots...", "width=1000 height=340 font=14 draw_ticks list minimum=0 maximum=0 interpolate");

this will make every plot to show their Plot Values. Then you can automate the saving procedure as follows:

selectWindow("Plot Values");
saveAs("Results", PATH);

You can process your results within ImageJ by assigning them to variables using the following

getResult(“Column”, row)
Returns a measurement from the ImageJ results table or NaN if the specified column is not found. The first argument specifies a column in the table. It must be a “Results” window column label, such as “Area”, “Mean” or “Circ.”. The second argument specifies the row, where 0<= row <nResults. nResults is a predefined variable that contains the current measurement count. (Actually, it’s a built-in function with the “()” optional.) Omit the second argument and the row defaults to nResults-1 (the last row in the results table). See also: nResults, setResult, isNaN, getResultLabel.

getResultString(“Column”, row)
Returns a string from the ImageJ results table or “null” if the specified column is not found. The first argument specifies a column in the table. The second specifies the row, where 0<= row <nResults.

Returns the label of the specified row in the results table, or an empty string if Display Label is not checked in Analyze>Set Measurements .

If the values are in a table that isn’t the Results table, you can rename the table to Results and then get the values with these:

IJ.renameResults(name) - Changes the title of the “Results” table to the string name .
IJ.renameResults(oldName,newName) - Changes the title of a results table from oldName to newName .

1 Like