estenhl / pyment-public

Other
31 stars 15 forks source link

Normalization Question #29

Open amirro1 opened 1 month ago

amirro1 commented 1 month ago

Hi,

Thank you so much for all your work on this repo. I have a question about how your normalize your T1s before feeding them into the model.

I noticed that in your freesurfer_and_fsl.sh preprocessing script, you divide image values by 255:

https://github.com/estenhl/pyment-public/blob/7671d0046b42dadd4286fcbfa9786f15c380f35d/preprocessing/freesurfer_and_fsl.sh#L57 However, when I examine the output images created by freesufer_and_fsl, the values don't range from 0-1; they typically range between 0 and ~0.6. I think this is because the brainmask.mgz image typically takes values between 0 and ~110 (at least that is the case for my data which I ran with Freesurfer 7.2).

I ran a quick test to see if this normalization mattered. I just edited the cropping code inside freesufer_and_fsl (I added the edited code and then end of this script). Interestingly, the normalization did seem to change the predictions fairly significantly in our data (which was all pediatric) I was wondering:

  1. Would you expect these different normalization methods to impact predictions significantly?
  2. When using the model, would it be best to use the hard-coded "divide by 255 option"? I seem to get a better fit with that option compared to normalizing by image max

edited cropping code:

import sys
import nibabel as nib

input, output = sys.argv[1:]
img = nib.load(input)
img = img.slicer[6:173,2:214,0:160]
img_data = img.get_fdata()
img =   nib.Nifti1Image (img_data/ img_data.max(), img.affine, img.header)
nib.save(img, output)

Thanks, Amy

estenhl commented 1 month ago

Hi Amy, thanks for posting this! It is indeed interesting. Generally I would recommend dividing by 255 as this was applied to all the training data, but its intriguing that you see better results when normalizing to [0, 1]. Can you share the results you are seeing with the two different approaches? Ideally as a plot, but MAEs are also good. And just out of curiosity, what is the age range of your pediatric sample?

amirro1 commented 1 month ago

Hi,

Thanks for your quick response! I can email you the plots if you would like. Is estenleonardsen@gmail.com a good email address for you?

Thanks, Amy

estenhl commented 1 month ago

Yes, perfect, thanks!