Open tpenzkofer opened 3 years ago
Specifically: The Patientposition matrix within cornerstone-nifti-image-loader ist different from slicers Image Origin (that shouldn't happen, imho)
cornerstone:
slicer:
ok, some more digging, the matrices / images are apparently flipped in these two function calls in Volume.js:
this[convertToNeurologicalView]();
this[convertRAStoLPS]();
Omitting them restores the correct imageOrientation matrix and ijk->patient space calculations are okay again BUT images are flipped bottom-up and left-right in cornerstone...
even more digging, looks like all three functions call
this[ensureVoxelStorageInXYZ]();
this[convertToNeurologicalView]();
this[convertRAStoLPS]();
are distorting the coordinate calculations when displaying it in cornerstone / doing ijk->patientspace calculations (I presume the when flipping the rotation matrix signs the origin coordinates need to be recalculated as well, especially in case of off-axis imaging), any thoughts on that?
Hi @tpenzkofer! Did you manage to solve this? I am facing the same problem with the loader, Nifti files appear to be flipped.
For anyone that runs into the same issue, it seems OHIF changed from Neurological to Radiological convention hence the image looks flipped on latest versions. The issue can be easily fixed by changing line 181 of the Volume.js
file, instead of
// if 'X-', we need to flip x axis so patient's right is
// shown on the right
if (senses[0] === '-') {
matrix[0][0] *= -1;
matrix[0][1] *= -1;
matrix[0][2] *= -1;
matrix[0][3] *= -1;
steps[0] = -1;
}
// if 'Y+' we need to flip y axis so patient's anterior is shown on the
// top
if (senses[1] === '+') {
matrix[1][0] *= -1;
matrix[1][1] *= -1;
matrix[1][2] *= -1;
matrix[1][3] *= -1;
steps[1] = -1;
}
// if 'Z+' we need to flip z axis so patient's head is shown on the top
if (senses[2] === '+') {
matrix[2][0] *= -1;
matrix[2][1] *= -1;
matrix[2][2] *= -1;
matrix[2][3] *= -1;
steps[2] = -1;
}
}
you can change the convention to the Radiological view by switching the line to
// if 'X+', we need to flip x axis so patient's right is
// shown on the left
if (senses[0] === '+') {
matrix[0][0] *= -1;
matrix[0][1] *= -1;
matrix[0][2] *= -1;
matrix[0][3] *= -1;
steps[0] = -1;
}
// if 'Y+' we need to flip y axis so patient's anterior is shown on the
// top
if (senses[1] === '+') {
matrix[1][0] *= -1;
matrix[1][1] *= -1;
matrix[1][2] *= -1;
matrix[1][3] *= -1;
steps[1] = -1;
}
// if 'Z+' we need to flip z axis so patient's head is shown on the top
if (senses[2] === '+') {
matrix[2][0] *= -1;
matrix[2][1] *= -1;
matrix[2][2] *= -1;
matrix[2][3] *= -1;
steps[2] = -1;
}
}
Ideally the method should be renamed from convertToNeurologicalView
to convertToRadiologicalView
.
Hi,
I have two - maybe related issues,
I have some Nifti files (derived from DICOM using dcm2niix) which are flipped left-right in cornerstone when loaded through cornerstone-nifti-image-loader, any ideas?
when calculating the patient space positions using "imagePointToPatientPoint" from cornerstoneTools using the imagePlane metaData information from cornerstone-nifti-loader the derived x/y coordinates are from the opposite corner of the image and the z coordinate is completely off (imagePointToPatientPoint does not take into account imageOrientationPatient, maybe that's the problem), as compared to Slicer RAS fiducial coordinates
Any ideas?