neurolabusc / MRIcroGL10_OLD

DEPRECATED development has moved to https://github.com/rordenlab/MRIcroGL
https://www.nitrc.org/plugins/mwiki/index.php/mricrogl:MainPage
BSD 2-Clause "Simplified" License
58 stars 24 forks source link

Feature request: Reduce edge effects with OVERLAYLOADSMOOTH #19

Closed mzunhammer closed 6 years ago

mzunhammer commented 6 years ago

I showed slides from MRIcroGL to my colleagues recently. When a colleague spotted edge effects, I was getting nervous about our analysis. It turned out, the data were fine, but OVERLAYLOADSMOOTH introduces edge effects (the phenomenon is highlighted in the manual). My request: Please get rid of the edge effects. Proposed solution: I don't know how smoothing is achieved in MRIcroGL, but I think this effect could be avoided by 1) creating a binary in parallel to the overlay 2) smoothing the overlay 3) printing the smoothed overlay, dividied by the smoothed binary mask instead of the smoothened overlay. (at least that's how its done with Gaussian smoothing in SPM) Keep up the good work! Cheers, Matthias

neurolabusc commented 6 years ago

Beyond the manuals, I would suggest you look at the cluster threshold script - you may also want to look at the Matlab script nii_threshreslicecluster.m. There are no good solutions for reslicing an image to a high resolution after the user has thresholded the data. During thresholding, one artificially sets all the sub-threshold voxels to have an intensity of zero. In reality, due to smoothing and partial volume effects, subthreshold voxels near surviving voxels typically have values near the threshold, but this information is thrown away. The user has willfully eliminated data that would be useful for spatial interpolation. The correct solution is to interpolate your raw data and then apply your threshold. Any other solution is open to criticisms.

I strongly recommend you open your unthresholded maps into MRIcroGL, and then apply your threshold. This will ensure that maximum data is preserved. If this is not possible, you have several options, each with its own limitations:

  1. Uncheck "Smooth when Loading" from the overlay menu. This will apply nearest neighbor interpolation that results in jagged images.
  2. Open your overlay as a smoothed threshold, and then apply a binary threshold at half the intensity of your threshold. For example, if your image was thresholded with Z=5, you would want to set the overlay to have a min=2.5 and a max = 2.5. This should roughly preserve your outline, but does not show variability in intensity.
  3. Open your overlay on a background scan resliced to the overlay - for example using my nii_reslice_target.m script. This creates a background image with the same (low) resolution as your statistical map - no interpolation is required, but the image will be blurry.

I will explore your third option, but I really think this is an issue of closing the barn door after the horse has bolted. You will be much happier if you work with unthresholded images.

neurolabusc commented 6 years ago

Why don't you try out this Matlab/SPM script nii_reslice_target_thresh to see if you like this solution. For example, the command nii_reslice_target_thresh('spmT_5.nii', '','mni152_2009_256.nii') will reslice the thresholded map spmT_5 to match the resolution of mni152_2009_256. The image below shows the results of nearest neighbor (left), your suggestion (middle) and the new script (right).

threshold

neurolabusc commented 6 years ago

@mzunhammer I am going to close this request: when I looked into this, the current MRIcroGL solution is close to optimal. Below you can see the results of nearest-neighbor (left), linear rescale then threshold and MRIcroGL's current threshold then linearly rescale (right). The left and middle images indicate the best case scenario, where we have all the data (perhaps with the exception of the brain mask for the middle image, where regions outside the brain are artificially set to zero despite smoothing). The current MRIcroGL solution detects that the image is thresholded (in this case at Z=5) and after rescaling any voxels less than 2.5 are set to zero and any voxels in the range 2.5...5 are set to 5. If you have an example of edge effects that you think could be addressed, I would like to see them. However, I suspect the real issue is upstream from MRIcroGL, and you can get a better solution by providing MRIcroGL with better data.

nn_linthresh_threshlin

mzunhammer commented 6 years ago

I've just revisited the issue based on your recommendations. I'm sorry, it was a mistake from my side: The issue occured only when loading thresholded images (binary brain mask) with a resolution of 2x2x2 mm on top of a 1x1x1 mm template, but not on a 2x2x2 mm template. The observed "edge effect" apparently was not caused by the smoothing, but by the re-sampling of the lower resolution image (which is unavoidable, I think). Thank you for your detailed reply and for looking into the issue!

neurolabusc commented 6 years ago

Understood. All my examples above are from low resolution statistical maps (2mm isotropic) loaded on the high-resolution template mni152_2009bet (0.5mm isotropic). Some interpolation is unavoidable. I also think the linear interpolation is appropriate as higher-order interpolation generates ringing artifacts near sharp edges, which is exactly what you get with a thresholded image. As you say, some artifacts are always going to result from up-sampling data, but I do think the current implementation is as good as any other I have seen.