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
197 stars 31 forks source link

Interpolating Thresholded Images #17

Closed neurolabusc closed 3 years ago

neurolabusc commented 4 years ago

As reported by Marcus Heldmann adding statistical overlays that have thresholded by SPM12 can look slightly eroded when saved as 32-bit float relative to saving as 16-bit integer. This only occurs when overlay loading is smoothed (Load Smooth Overlays in Options button menu is checked), and only for maps from SPM, not other tools. The reason for this is that SPM sets voxels that do not reach the threshold to not-a-number (NaN), whereas for the integer data the voxels that do not reach threshold are set to zero. Interpolating a positive value with a zero yields a (smaller) positive number, but interpolating a positive number with a NaN yields a NaN. The upcoming release will convert NaNs to zeros.

As ever, it is always recommended to apply a threshold AFTER reslicing the statistical map to the resolution of the background image. Since statistical maps are intentionally smoothed, sub-threshold voxels near the edge of a significant cluster are virtually always near threshold. Resampling before thresholding preserves this information. However, the upcoming release also changes the interpolation of thresholded images a little bit to ty to fight some of the artifacts of re-sampling a thresholded image. The issue is illustrated in the 1D figure below. The red rectangles represent original voxel values, and the red horizontal dotted line shows an arbitrary threshold applied to these voxels (here at 5.5). The voxels shown in solid red survive the threshold, those that do not survive are shown with a dashed outline. The blue line shows the interpolation one would get by linear interpolation of all the voxels regardless of whether they are above or below the threshold. The intersection of the blue line and the dotted red line shows the ideal thresholding. Simple linear interpolation applied to the thresholded data yields the green line. The artificially zeroed voxels have eroded this object: fewer voxels will survive the threshold. However, the interpolation also shows an artificial border of sub-threshold signal. The proposed solution is shown in orange. In this case, when an image is interpolated, one detects the smallest positive signal in the entire 3D volume (which is likely to be extremely close to the threshold applied to the input image). For our example, lets call say this is 5.52 (the picture only shows surviving voxels with an intensity of 6, but presumably other surviving voxels in the image are a bit closer to the threshold). We filter the interpolated image so any voxel less than 2.51 will get the value zero, and any voxel with an intensity between 2.51 and 5.52 will get the value 5.52. This preserves the volume of the ideal outcome, and avoids the artificial dark ring surrounding thresholded objects.

bleeding

neurolabusc commented 3 years ago

SPM users may find this script useful: it. interpolates the image to the target resolution PRIOR to applying the threshold. This will preserve more information.

This issue is also described in the Cluster Thresholds example in the MRIcroGL manual.