poldracklab / pydeface

defacing utility for MRI images
MIT License
110 stars 42 forks source link

Wrong registration with given mask and template #48

Open JiaBob opened 2 years ago

JiaBob commented 2 years ago

I use this command to run defacing:

pydeface [my data] --template pydeface/data/mean_reg2mean.nii.gz --facemask pydeface/data/facemask.nii.gz

It runs a long time and I got the output below. It seems that the registration was wrong. Do you know how can I solve this? Which template and mask should I use? Thank you! image

ofgulban commented 1 year ago

Hi @JiaBob , it seems there there were no responses for a long time. But, my 2 cents on the issue is that prrobably the registration algorithm is failing. This can happen for many reasons and it is hard to debug or give instructions without seeing your nifti files. However, one guess could be that maybe the nifti headers are incorrectly set in your input or template files.

rbonicel commented 7 months ago

Hi @ofgulban , I wish to add to this issue in order to not create a similar one, but I think I have the same issue.

I'm using pydeface 2.0.0, on child MRI data (T1w, T2w). With the default templates (facemask.nii.gz and mean_reg2mean.nii.gz) it gives me cropped brain on the frontal part. I assumed that the template data was from adult scans, so I used child templates provided by NIST : https://nist.mni.mcgill.ca/pediatric-atlases-4-5-18-5y/ . But instead of a facemask, they give a brainmask, which still crops a little because the mask is smaller.

Unable to find a child facemask yet, I wanted to use yours, but with a T1w child template from NIST. If i open data on the BrainVISA Anatomist tool (https://brainvisa.info/web/) , i seem to get proper origin registration: Here's the NIST T1w template fused with your facemask : Screenshot from 2024-02-06 12-05-53 No brain part is cropped.

Here's my data fused with your facemask (as the NIST brainmask still crops) :

Screenshot from 2024-02-06 12-08-44 Still alright.

But when I run the pydeface with the NIST T1w template and your facemask on my data, I get this :

Screenshot from 2024-02-06 12-10-20 I assume that the registration is not properly done, and the fused Anatomist image is misleading. Do you have an idea on how to perform a proper registration (SPM ?) beforehand, in order to properly set the origin of the images ?

I checked the https://github.com/nipy/quickshear tool in order to expand a bit the threshold, but it failed directly because images didn't have the same shape and something else (I guess that tool was really basic without registration)

Thanks Robin