rordenlab / MRIcroGL

v1.2 GLSL volume rendering. Able to view NIfTI, DICOM, MGH, MHD, NRRD, AFNI format images.
https://www.nitrc.org/plugins/mwiki/index.php/mricrogl:MainPage
Other
204 stars 32 forks source link

Affine transform show in renderer? #50

Closed shangjiaxuan closed 1 year ago

shangjiaxuan commented 1 year ago

It seems affine transforms in NIfTI are not calculated into the MVP matrix in glvolume2.pas. How do I add that if needed for certain visualizations?

Consider this kind of layer to layer scan, with each layer's displacement not perpendicular to layer itself: Untitled Diagram drawioUntitled Diagram1 drawio

shangjiaxuan commented 1 year ago

This type of layered image info is expected in 3D backscatter imaging.

neurolabusc commented 1 year ago

MRIcroGL is able to use the S-Form and Q-Form to orient the closest orthogonal orientation and scale. However, it retains rectangular voxels. So with respect to the affine if handles the rotation, translation and scale but ignores the shear.

You may want to look at NiiVue or FSLeyes, both of which can show voxels in either image space or world space. You need to be aware that the NIfTI format has two spatial representations: the Q-Form (quaternion) stores 9 degrees of freedom (translation, rotation, scale each in 3 dimensions) while the S-Form (matrix) stores 12 DoF (adding shear). Therefore, to preserve shear you must properly define the S-Form of your NIfTI header.

Since most tools (including those built using the popular VTK library) assume that volumes do not have shear, another alternative is to resample your data into a large volume. If your source data is in DICOM format, dcm2niix can do this for you. For sample DICOM and dcm2niix converted data, see dcm_qa_ct where the DICOM images have gantry tilt, and dcm2nixi creates two volumes: one where the shear is reported in the S-Form, the other (_tilt) where the data is resampled.

shangjiaxuan commented 1 year ago

@neurolabusc Thanks for pointing out, it seems NiiVue is pretty fit for my use! My files are not from prebuilt commercial systems that comes with DICOM format, but instead we are developing new systems and thus chose Nifti as a simple format for storing scintilator or semiconductor detector event count. DICOM is simply an overkill for prototypes.