Arrow tool Macro for Multiple selections

Hello everyone, this is my first post so correct me if i take the wrong approach.

Long story short, i want to make an arrow from each centroid to each center of mass, but i cannot draw a single arrow using the stored variables from the table.

I have an image composed of cells in two channels, one for nuclei (DAPI-DNA) other for cytoplasm (Tubulin or gamma tubulin). I have found the way to get approximate selections of every cell, that i managed to get into the ROI manager using the nuceli image. By measuring the obtained ROIs on the Tubulin image i got the coordinates of the centroid and center of mass , which gives me the “center of the nuclei” and the “brightest spot in tubulin”, From this simple set of data which contains a results table containing X,Y,(centroid) XM, YM (center of mass) for each ROI i simply want to draw an arrow from each centroid (nucleus) to the Center of mass (tubulin bright spot). Sadly i cannot draw a single arrow using coordinates from the results table, and i dont manage to understand where i am failing,

I will show you my “progress” in the macro, plz help ! the first part is the 1 arrow draw try, the sencond part would be the attempt at making all the arrows

Yours Sincerely, Martin

//Arrow 115
x = getResult(“X”, 115-1);
y = getResult(“Y”, 115-1);
xm = getResult(“XM”, 115-1);
ym = getResult(“YM”, 115-1);
print(x, y, xm, ym);
makeArrow(x, y, xm, ym, “notched”);
Roi.setStrokeWidth(2);
Roi.setStrokeColor(“white”);

//for (i = 0; i < nResults; i++) {
// x = getResult(“X”, i-1);
// y = getResult(“Y”, i-1);
// x = getResult(“XM”, i-1);
// y = getResult(“YM”, i-1);
// makeArrow(x, y, xm, ym, “notched”);
//Roi.setStrokeColor(“white”);
//}
//run(“Select None”);

Hi,
For me, it’s ok. The only problem is that is your for loop, you start from i=0 and in your loop, you try to get results from i-1 ie -1, which is not possible.

Nico

1 Like

Hi Virtual Slide (nico)

the thing is that not even the “whithout loop” version is working… i will try it anyway

Thanks a lot for your quick response

are you suggesting this simple change

for (i = 1; i < nResults; i++) {
x = getResult(“X”, i);
y = getResult(“Y”, i);
x = getResult(“XM”, i);
y = getResult(“YM”, i);
makeArrow(x, y, xm, ym, “notched”);
Roi.setStrokeWidth(2);
Roi.setStrokeColor(“white”);
}
run(“Select None”);

I managed to solve the problem by removing the scale of the image, it seems that the data form the table was in a micrometer scale, but the arrow tool uses the pixel coordinates… thus the incopatibility

If i would like to correct the micrometer data by scale, and use the arrow tool, i would have to factor the variables i introduce to the makearrow function… i just need to access to the scale number from FIJI.

Correct me if i am wrong plz

Hi,
your loop has to start at 0 : for(i=0;i<nResults(); i++)

If you want to get the scale, you can use

getPixelSize(unit, pixelWidth, pixelHeight)

it returns the unit of length (as a string) and the pixel dimensions (from Built-in Macro Functions)

Nico

1 Like