Display pre-defined x-y coordinates in a stack

Hi everyone,
I am new to ImageJ and I have the following question. I have a stack and in each slice/frame of it I have put several coordinates with the multipoint tool. As a result, I have an excel/csv file with the following output:

1 297.3456338 56.00231476
2 302.6791672 48.00198408
3 302.0124832 55.66897274
4 309.3461298 48.33532992
5 306.3460058 56.33566442
6 311.0128552 48.66867958
7 307.6793739 56.33566442
8 311.6795392 47.00194274

I would like to load from the .csv file the corresponding for each frame coordinates in order to display them via the multi-point tool (i.e. as a crosshair) and correct the positions of some of them slightly. How do I do this?

Hi @pjjam83,

How did you get this coordinates ?
When I use Analyze>Measure, I get seveal column : X, Y, Channel and Slice.
So after saving/ loading, it can be “re-pointed” ?


This is what I do: I place 2 points with the multipoint tool for every slice of the stack. On each slice there are only 2 points/coordinates, but over the entire stack there are probably several hundred in different locations since the object I am tracking is moving over time (its only 1 channel). These coordinates have been saved with Analyze>Measure and then copied into excel or csv file. However, the tiff stack has not been saved with the coordinates, since I have multiple objects I measure there and I do not want to mix them for subsequent analysis. Also, I do not have a ROI manager file generated for the coordinates. Essentially, what I would like to do is either somehow load these coordinates back to the tiff file from a csv file or load them into the ROI manager for every separate slice and from there I can use the “overlay/from ROI manager” function. I tried several different macros/scripts which i googled, all do something similar, but none of them exactly what i need. The closest I found to what I need was a script that loads all coordinates into the stack, but it loads them alltogether and does not separate them by slices, so i cannot actually use it to see how the object I am interested in was tracked.

I did not understand what you mean by “re-point”, could you specify? Maybe there is a simple solution, which I am missing.

I guess that the tool you need is the ROI manager.
After selecting your multipoints, you add it (them) in the ROI manager (Ctrl +t). You can save and load your ROIs. After loading, every point is at the same location (x, y, z, c, t) and you can move it.
In addition to that, if you need to keep the positions, you can the save the result file after the Analyze>Measure.

@pjjam83 hopefully this solves your problem, or gives you a strong starting point.

The following script requires that your stack is open first. Then when run it will import values from a CSV file and plot the coordinates saving each pair as a separate ROI. It takes values from line 1 & 2 and displays them on the first stack slice then values from lines 3 & 4 on the second stack slice 2, and so on. This assumes your coordinate file has twice as many lines as your stack has slices and is formatted as below.


#@File (label="Co-ordinate file",style="file") csv

positions = File.openAsString(csv); //read in the data
lines = split(positions, "\n"); //split the data by line
getDimensions(width, height, channels, slices, frames);
j= 0
for (i = 0; i < slices; i++) {
	print("J  = "+j);
	//store 2 lines
	line1 = lines[j];
	line2 = lines[j+1];
	//split line based on commas
	values1 = split(line1, ",");
	values2 = split(line2, ",");
	//extract second & third value to new arrays
	xpoints = newArray(values1[1],values2[1]);
	ypoints = newArray(values1[2],values2[2]);
	//set slice & add points
	makeSelection("Point", xpoints, ypoints);