CoBrALab / iterativeN4_multispectral

A pipeline which performs iterative classification and bias field correction of T1-weighted MRIs
Other
1 stars 1 forks source link

QUARANTINE_PATH? #12

Closed dangom closed 3 years ago

dangom commented 3 years ago

Hello,

I tried running this script from the /opt/ directory of the MINC VM, but unfortunately the script won't run because the variable "QUARANTINE_PATH" is unbound. I was wondering what that should be set to.

This iterative N4 approach looks very interesting, and I'd love to compare it to SPM's bias field correction and see whether it helps to improve Freesurfer's recon-all.

Thank you!

Daniel

gdevenyi commented 3 years ago

Hi.

QUARANTINE_PATH needs to point to where you've downloaded the priors, you can see the defaults at, https://github.com/CoBrALab/iterativeN4_multispectral/blob/master/iterativeN4_multispectral.sh#L303-L318

In its basic configuration it requires the BeAST pirors library and the MNI sym 09c priors. Those aren't included in MINC-VM because they're simply too big to packup up along with the rest of the VM, which I was aiming to be smaller.

You can fun a fully functional containerized variant at https://github.com/CoBrALab/MAGeTDocker/blob/master/Dockerfile which sets up and places them in the right place.

dangom commented 3 years ago

Thank you very much, that worked. If I may ask another question: I note that the minc output file format is different from conventional minc files. Instead of NetCDF it seems to be an HDF5 file, and the intensities are scaled up considerably with respect to the input file.

Given these observations, what would be the best way to convert from these outputs to conventional niftis?

For completion, I'm running the command as follows:

mri_convert memprage_T1w.nii.gz memprage_T1w.mnc
singularity exec --pwd /maget --cleanenv -B $PWD:/maget  magetdocker_latest.sif \
     iterativeN4_multispectral.sh /maget/memprage_T1w.mnc /maget/memprage_bfc_T1w.mnc

I can convert the output to niftis using nibabel, but the values still seem very large and I don't know if I'm the one doing something wrong or that's how the outputs are supposed to look like. Regardless, I can see that the bias field correction did work, and noticeably better than a single pass of N4.

gdevenyi commented 3 years ago

Hi,

It sounds like your experience of MINC is the forked minctools inside freesurfer, which have not been updated in ~20 years. More than 10 years ago, MINC went to the MINC2 format, which is HDF5 based: https://en.wikibooks.org/wiki/MINC/SoftwareDevelopment/MINC2.0_File_Format_Reference

intensities are scaled up considerably with respect to the input file.

This tool includes a intensity standardization between 0 and 65535.

I can convert the output to niftis using nibabel,

nibabel does not implement the MINC standard properly, so I wouldn't trust it.

The supported version for going to and from minc/nifti is the pair nii2mnc/mnc2nii from minc-toolkit-v2.

(You may be interested in the --standalone and --autocrop options, which will save all the internal masks/classifications generated in the pipeline, and crop non-head FOV, respectively)

dangom commented 3 years ago

Perfect! It just occurred to me that I can use the container for that as well. Thank you for sharing the code!

Regards,

Daniel