Login  Register

Re: Add ROIs from a list of coordinates in a .CSV file

Posted by Pariksheet Nanda on Aug 25, 2014; 2:24am
URL: http://imagej.273.s1.nabble.com/Add-ROIs-from-a-list-of-coordinates-in-a-CSV-file-tp5009300p5009325.html

Hi Joshua,

On Thu, Aug 21, 2014 at 11:49 PM, joshuamarcus
<[hidden email]> wrote:
>
> a .csv file of coordinates [...] lists frame, x
> coordinates, and y coordinates. I would like to write a macro that first
> imports the list of coordinates,

   // Import it into a results table.
   run("Results... ", "open=/path/to/coordinates.csv");


> then defines ROIs of a specified shape and
> size, with the pixel coordinate representing the center of each ROI, and add
> all of these to the ROI manager.

   for (i = 0; i < nResults; i++)
   {
      // You may need to change the "frame", etc strings to match your csv file.
      slice = getResult("frame", i);
      x = getResult("x", i);
      y = getResult("y", i);

      // Using square ROI of size 10x10 pixels centered around your coordinate.
      run("Specify...", "width=10 height=10 x=&x y=&y slice=&slice centered");

      // Add to the ROI manager.
      roiManager("Add");
   }


> Joshua

Pariksheet

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