Re: Import XY from text file to point selections
Posted by BenTupper on Jun 01, 2009; 11:58pm
URL: http://imagej.273.s1.nabble.com/Import-XY-from-text-file-to-point-selections-tp3692339p3692340.html
On Jun 1, 2009, at 3:13 PM, Kevin Marsh wrote:
> I have point data that was collected from an external process that has
> X and Y coordinates and a unique identifier. I was wondering if there
> was an easy way to create point selections (or some other type of
> marker) of the data on top of an image.
Hi,
The macro below will read a columnar text file, parse it, and plot the
contents on an image. The example text file is pasted below the macro.
// begin macro
file = File.openDialog("Select the text file to read");
allText = File.openAsString(file);
text = split(allText, "\n");
hdr = split(text[0]);
//these are the column indices
iX = 0;
iY = 1;
iLabel = 2;
setForegroundColor(255,255,255);
run("Blobs (25K)");
for (i = 1; i < (text.length); i++){
line = split(text[i]);
drawString(line[iLabel], parseInt(line[iX]), parseInt(line[iY]));
}
// end macro
// begin example file
X Y Label
10 20 "Bob"
50 70 "Jeff"
100 100 "Betty"
//end example file
Ben Tupper