Last active
December 16, 2015 07:19
-
-
Save stowler/5398170 to your computer and use it in GitHub Desktop.
mm->vox integers per FSL fslview cursor widget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FSL fslview cursor widget | |
------------------------------------------------ | |
Appears to use explicit casting to convert float mmm coordinates to integer | |
voxel coordinates, truncating in the process: | |
line 266 from fslview's cursorwidget.cpp: | |
232 void CursorWidget::mmBoxChanged() | |
233 { | |
... | |
261 float xMm = m_xMmBox->text().toFloat(); | |
262 float yMm = m_yMmBox->text().toFloat(); | |
263 float zMm = m_zMmBox->text().toFloat(); | |
264 | |
265 short xCur(0), yCur(0), zCur(0); | |
266 image->getInfo()->mmToVoxCoord(xMm ,yMm, zMm , xCur, yCur, zCur); | |
267 | |
268 m_xVoxBox->setValue(xCur); | |
269 m_yVoxBox->setValue(yCur); | |
270 m_zVoxBox->setValue(zCur); | |
... | |
...which converts floats to integers via calls to short() in imageinfo.cpp: | |
231 void ImageInfo::mmToVoxCoord(float xmm, float ymm, float zmm, short& x, short& y, short& z) const | |
232 { | |
233 float xf, yf, zf; | |
234 if(m_sformcode != NIFTI_XFORM_UNKNOWN) | |
235 FslGetVoxCoord(inqStdMat(), xmm, ymm, zmm, &xf, &yf, &zf); | |
236 else | |
237 FslGetVoxCoord(inqRigidMat(), xmm, ymm, zmm, &xf, &yf, &zf); | |
238 x = short(xf); | |
239 y = short(yf); | |
240 z = short(zf); | |
241 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment