poldracklab / pydeface

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

Not quite defaced #35

Open soichih opened 4 years ago

soichih commented 4 years ago

Hello.

I've run pydeface (2.0.0) on a test image, but the App is not quite completely defacing.

image

I see that I can set template / facemask, etc.. parameters with pydeface, but I am not sure which knobs to tweak to get it properly defaced in this case. Do you have any suggestions?

ofgulban commented 4 years ago

Hi @soichih , thank you for this question. You can try different cost options. One question though, is this the ‘Visible Male’ CT image? If it is, you should try an MRI T1-weighted image as your input instead of a CT image. If not, can you give some details of your input test image?

soichih commented 4 years ago

I will rerun with all different cost functions and see which one works the best.

I am feeding a normal t1w anatomy.(It's my brain image that I've taken recently at our imaging center). The scanner is a siemens 3T prisma.

Here is the mrinfo for the image I am running.

hayashis@xps13:~/Downloads $ mrinfo t1.nii.gz 
************************************************
Image name:          "t1.nii.gz"
************************************************
  Dimensions:        176 x 248 x 256
  Voxel size:        1 x 1 x 1
  Data strides:      [ 1 2 3 ]
  Format:            NIfTI-1.1 (GZip compressed)
  Data type:         signed 16 bit integer (little endian)
  Intensity scaling: offset = 0, multiplier = 1
  Transform:                    1           0           0       -87.5
                                0           1           0      -104.7
                                0           0           1      -114.1
  comments:          TE=3;Time=102319.417;phase=1

I am running pydeface with a command like this

singularity exec -e docker://brainlife/pydeface:2.0 pydeface $t1 --force --cost $cost --outfile output/t1.nii.gz --verbose

Thank you!

ofgulban commented 4 years ago

Thanks for the details. Try different datasets too. It is always possible to stumble upon specific cases where the default parameters will fail. I see that the volume is cut-off near the superior part of the head, which leads me to think that maybe your coverage is positioned more inferiorly than usual (e.g. including more of the neck). This might explain why registration to the default template is suboptimal which causes the masked region missing the eyes.

If defacing fails consistently the same way, use custom templates and facemasks tweaked for your imaging center’s standards.

soichih commented 4 years ago

I've ran with all 7 --cost algorithms but outputs were (suspiciously) similar.. I hope I've set it up correctly, but I believe changing --cost function doesn't fix it.

I see that the volume is cut-off near the superior part of the head, which leads me to think that maybe your coverage is positioned more inferiorly than usual

Yeah, this might be the case... although I'd like to argue that pydeface should be able to handle that? I can give you the test data if you are interested.

image

ofgulban commented 4 years ago

@soichih if you argue that pydeface should do better and if you think you can improve it, feel free to send a pull request and report exactly how you propose to improve it. This is an open source project build and improved with the help of volunteers.

Having said these, you can still create your own template and mask to deface to your liking.

Feel free to try the alternatives too. E.g. AFNI refacer: https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/tutorials/refacer/refacer_run.html