You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dear matRad experts:
I am currently working on converting PTV cube indices to word coordinates, and came across the relevant function:
function coord = matRad_cubeIndex2worldCoords(cubeIx, gridStruct)
specially, I noticed the following lines of the code:
lines 37-39:
if size(cubeIx,2) == 1
[cubeIx(:,1),cubeIx(:,2),cubeIx(:,3)] = ind2sub(gridStruct.dimensions,cubeIx);
end
and line 48: coord = cubeIx(:,[2 1 3]) .* [gridStruct.resolution.x gridStruct.resolution.y gridStruct.resolution.z];
I would like to understand the reasoning behind using cubeIx(:,[2 1 3]) in line 48 instead of cubeIx(:,[1 2 3]). It seems that the x- and y-indices are swapped, which leads me to think that:
• coordX = yindx * resolution.x
• coordY = xindx * resolution.y
To clarify my understanding: Suppose I have a CT image with dimensions 512 x 512 x 200, and I am working with a voxel index of 5000. Using the ind2sub function, I obtain the following indices:
[xind, yind, zind] = ind2sub([512 512 200], 5000);
which yields:
• xind = 392
• yind = 10
• zind = 1
I believe the original index can be restored using the formula:
index = (zind - 1) * 512 * 512 + (yind - 1) * 512 + xind;
Then, the world coordinates would be calculated as:
• coordX = xind * resolution.x
• coordY = yind * resolution.y
Could you kindly explain why the x- and y-indices are swapped in line 48? I appreciate your insights into this matter.
Thank you very much for your time and assistance. I look forward to your response.
The text was updated successfully, but these errors were encountered:
In short: Matlab's storage order of array data blocks is interpreted as the first two indices as swapped in many Matlab functions (due on of its big tasks being imaging problems) comapred to the left handed LPS grid we use as coordinate system. So, when we handle our lps manually our x-y-z coordinates we need to swap the indices. you can think of it as x / y / z coordinates representing j / i / k indices.
Dear matRad experts:
I am currently working on converting PTV cube indices to word coordinates, and came across the relevant function:
function coord = matRad_cubeIndex2worldCoords(cubeIx, gridStruct)
specially, I noticed the following lines of the code:
lines 37-39:
if size(cubeIx,2) == 1
[cubeIx(:,1),cubeIx(:,2),cubeIx(:,3)] = ind2sub(gridStruct.dimensions,cubeIx);
end
and line 48:
coord = cubeIx(:,[2 1 3]) .* [gridStruct.resolution.x gridStruct.resolution.y gridStruct.resolution.z];
I would like to understand the reasoning behind using cubeIx(:,[2 1 3]) in line 48 instead of cubeIx(:,[1 2 3]). It seems that the x- and y-indices are swapped, which leads me to think that:
• coordX = yindx * resolution.x
• coordY = xindx * resolution.y
To clarify my understanding: Suppose I have a CT image with dimensions 512 x 512 x 200, and I am working with a voxel index of 5000. Using the ind2sub function, I obtain the following indices:
[xind, yind, zind] = ind2sub([512 512 200], 5000);
which yields:
• xind = 392
• yind = 10
• zind = 1
I believe the original index can be restored using the formula:
index = (zind - 1) * 512 * 512 + (yind - 1) * 512 + xind;
Then, the world coordinates would be calculated as:
• coordX = xind * resolution.x
• coordY = yind * resolution.y
Could you kindly explain why the x- and y-indices are swapped in line 48? I appreciate your insights into this matter.
Thank you very much for your time and assistance. I look forward to your response.
The text was updated successfully, but these errors were encountered: