Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pydeface missing when converting NIFTI to 256 conformed MGZ file #70

Closed
Tracked by #44
milanmlft opened this issue Aug 15, 2023 · 7 comments · Fixed by #72
Closed
Tracked by #44

pydeface missing when converting NIFTI to 256 conformed MGZ file #70

milanmlft opened this issue Aug 15, 2023 · 7 comments · Fixed by #72

Comments

@milanmlft
Copy link
Collaborator

When running the Converts NIFTI to 256 conformed MGZ file command, as part of the IDEAS workshop (see #44), we run into the following error:

/fastsurfer/nii_to_mgz.sh: line 27: pydeface: command not found
Deface failed

What is confusing is that in the workshop, the defacing is performed after the first run of FastSurfer (after which FastSurfer is re-run to see the impact on the results). So there is no need to have pydeface when we just want to convert the NIFTI files to MGZ, I think?

@milanmlft
Copy link
Collaborator Author

#51 (comment) suggests changing the image for the pydeface command. However, running the Defaces a T1 Nifti scan command on a NIFTI-converted scan works fine when using the healthbioscienceideas/pydeface:minify image.

So the problem seems to be a missing pydeface installation in the fastsurfer container (used for the MGZ conversion).

@p-j-smith
Copy link
Contributor

#51 (comment) suggests changing the image for the pydeface command. However, running the Defaces a T1 Nifti scan command on a NIFTI-converted scan works fine when using the healthbioscienceideas/pydeface:minify image.

So the problem seems to be a missing pydeface installation in the fastsurfer container (used for the MGZ conversio

ah good point!

@milanmlft
Copy link
Collaborator Author

milanmlft commented Aug 16, 2023

Not sure if there is anything we can do about this? Seems more like a problem on the XNAT side, not with our AWS setup?

I think there's a problem with the healthbioscienceideas/fastsurfer Docker container. I'm assuming https://github.com/HealthBioscienceIDEAS/MedICSS-Project-Repro-Pipelines/blob/6aa7368c6467f29eb5a72ff5a949e0f29e44a4fa/fastsurfer/nii_to_mgz.sh is the nii_to_mgz.sh script that is being run by the container. But I don't see any reference to pydeface there...

Maybe @HChughtai can help with this?

@milanmlft
Copy link
Collaborator Author

I had a look into the healthbioscienceideas/fastsurfer:gpu Docker container, and there the nii_to_mgz.sh actually looks like this:

#!/usr/bin/env bash
# Wrapper script around pydeface, so that it can yank the first
# probably only file from the inoput directory
# and preserve all other arguments

die(){
    echo >&2 "$@"
    exit 1
}

IN_DIR=$1
shift
OUT_DIR=$1
shift

IN_FILE=$(ls ${IN_DIR}/*.nii* | head -1)
[[ -f ${IN_FILE} ]] || die "Did not find nii or nii.gz file in ${IN_DIR}"
IN_BASE=`basename ${IN_FILE} .gz`
IN_BASE=`basename ${IN_BASE} .nii`
OUT_FILE=${OUT_DIR}/${IN_BASE}.mgz

export PATH=/opt/miniconda-latest/envs/neuro/bin:${PATH}
echo IN_FILE=${IN_FILE}
echo OUT_FILE=${OUT_FILE}
echo
echo mri_convert $@ ${IN_FILE} ${OUT_FILE}
pydeface $@ ${IN_FILE} ${OUT_FILE} || die "Deface failed"

So it does indeed call pydeface in the last line and is different from the script mentioned above. Not sure whether this is an error or not?

@HChughtai
Copy link
Member

That's an error and I think that Docker image is out of date, and so has the wrong version. You can see in https://github.com/HealthBioscienceIDEAS/MedICSS-Project-Repro-Pipelines/blob/gh-pages/fastsurfer/nii_to_mgz.sh that the line doesn't exist.

And you're right that it should be a separate step to the conversion. I think what happened was that Dave created nii_to_mgz.sh by copying run_pydeface.sh and that was left behind. I'd suggest rebuilding the fastsurfer image

@milanmlft
Copy link
Collaborator Author

Thanks @HChughtai! Can confirm that manually editing the nii_to_mgz.sh script in the Docker container on AWS and just replacing pydeface with mri_convert in that last line gets rid of the error. But now I'm getting this:

--------------------------------------------------------------------------
ERROR: FreeSurfer license file /fs60/license.txt not found.
  If you are outside the NMR-Martinos Center,
  go to http://surfer.nmr.mgh.harvard.edu/registration.html to 
  get a valid license file (it's free).
  If you are inside the NMR-Martinos Center,
  make sure to source the standard environment.
  A path to an alternative license file can also be
  specified with the FS_LICENSE environmental variable.
--------------------------------------------------------------------------
Deface failed

Do we just need to create a new license and add it to the Docker container?

@HChughtai
Copy link
Member

HChughtai commented Aug 16, 2023

Do we just need to create a new license and add it to the Docker container?

Yeah, that would do it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants