Recon-all-clinical command in Freesurfer Docker

Hi FreeSurfer experts,

I want to run recon-all-clinical to segment the T2w images I have where T1s are not available. I have pulled the Freesurfer 7.4.1 docker image but I cannot seem to find the command to use recon-all-clinical in that. Can anyone guide me regarding the docker command?

Appreciate your help,

Hi @wbano and welcome to neurostars!

I had no problem finding recon-all-clinical.sh in my containerized version of 7.4.1 (Docker)

As you can see here (recon-all-clinical - Free Surfer Wiki), one in a Docker container might contain a bug anyway. So you can do download the version they link to there, and they in your Docker command, mount that version as /usr/local/freesurfer/bin/recon-all-clinical.sh, and then run it.

Best,
Steven

Hi Steven

Thanks for the prompt reply. Does the docker command would then look like this? Please excuse my limited knowledge of docker commands.

docker run -ti --rm -v /Applications/freesurfer/license.txt:/opt/freesurfer/license.txt freesurfer/freesurfer:7.4.1/bin/recon-all-clinical.sh -s Sub09 -i /Users/finnbrainpons/Desktop/2023-05-Desktop/2022-Wajiha/freesurfer_test/sub-09/ses-01/anat/sub-09_ses-01_run-01_T2w.nii

Regards
Wajiha

Hi @wbano,

No, it may look like this

docker run -ti --rm \ # not docker run since we want to run a different command than the default
 -v /Applications/freesurfer/license.txt:/opt/freesurfer/license.txt \ # mount your license
 -v /PATH/TO/YOUR/recon-all-clinical.sh:/usr/local/freesurfer/bin/recon-all-clinical.sh \ # mount the fixed recon-all-clinical
 -v /Users/finnbrainpons/Desktop/2023-05-Desktop/2022-Wajiha/freesurfer_test:/bids \ # mount your data directory
 freesurfer/freesurfer:7.4.1 \ # the container
 recon-all-clinical.sh \ # the command you want to run
 bids/sub-09/ses-01/anat/sub-09_ses-01_run-01_T2w.nii \ # input data
 sub-09 \ # subject ID
 $NTHREADS \ # number of CPUs, defaults as 1 which is slow so you probably want to use more than that
 /bids/derivatives/freesurfer # output directory

Please confirm you understand the code above and give it a try.

Best,
Steven

Hi Steven

Thank you for sending me the command and bearing with me. I do get that docker exec is the command to run the script within the container but I am getting this error: first, it was ‘Unkown flag --rm’ and if I remove this then I get the error 'unknown shorthand flag: ‘v’ in -v.
Somehow it’s not recognising the mounting of the volumes. If you have any insights about it, that would be great.

Regards

Hi @wbano,

Sorry I made a mistake above (I mainly use Singularity). --rm is not a part of docker exec, and docker run should be the correct command to use. I have edited my above post to reflect the changes.

Best,
Steven

Thanks a lot for your help.

As I mentioned above, do not use docker exec, use the edited version of the code I posted.

Also,

This is not correct the way you put it. You can either just put 3 there, or keep just $NTHREADS there if you define it before the docker run command (e.g., with NTHREADS=3).

Best,
Steven