|
1 | 1 | #!/usr/bin/env bash
|
2 |
| -$FREESURFER_HOME/bin/dissection_photo.app/Contents/MacOS/dissection_photo "$@" |
| 2 | + |
| 3 | +# check for required env vars |
| 4 | +if [ ! -e "$FREESURFER_HOME" ]; then |
| 5 | + echo "error: FREESURFER_HOME has not been properly set" |
| 6 | + exit 1 |
| 7 | +fi |
| 8 | + |
| 9 | +if [ ! -e "$NNUNET_MODEL_DIR" ]; then |
| 10 | + echo "WARNING: NNUNET_MODEL_DIR is not set" |
| 11 | + echo "This should be the path to the directory containing the model" |
| 12 | + echo "dependency 'nnUNetTrainer__nnUNetPlans__2d'" |
| 13 | + echo "Setting NNUNET_MODEL_DIR to be: $FREESURFER_HOME_FSPYTHON/models/nnUNetTrainer__nnUNetPlans__2d" |
| 14 | + export NNUNET_MODEL_DIR=$FREESURFER_HOME_FSPYTHON/models/nnUNetTrainer__nnUNetPlans__2d |
| 15 | +fi |
| 16 | + |
| 17 | +if [ ! -e "$NNUNET_SCRIPT_DIR" ]; then |
| 18 | + echo "WARNING: NNUNET_SCRIPT_DIR is not set" |
| 19 | + echo "Setting NNUNET_SCRIPT_DIR to be: $FREESURFER_HOME_FSPYTHON/python/packages/nnUNet_v2" |
| 20 | + export NNUNET_SCRIPT_DIR=$FREESURFER_HOME_FSPYTHON/python/packages/nnUNet_v2 |
| 21 | +fi |
| 22 | + |
| 23 | +# sanity check that the model files exist |
| 24 | +ls "$NNUNET_MODEL_DIR/plans.json" |
| 25 | +if [ $? -ne 0 ]; then |
| 26 | + echo "Unable to detect the required files in NNUNET_MODEL_DIR: $NNUNET_MODEL_DIR" |
| 27 | + echo "If this is your first time using this util, follow the instructions" |
| 28 | + echo "below to download, unpack, install, and configure the model files." |
| 29 | + echo "" |
| 30 | + echo " 1. Download the model file from the FTP server. Copying the following link" |
| 31 | + echo " into your browser will begin the download: https://ftp.nmr.mgh.harvard.edu/pub/dist/lcnpublic/dist/dissection_photo_model/nnUNetTrainer__nnUNetPlans__2d.tar.gz" |
| 32 | + echo "" |
| 33 | + echo " 2. Move the tarball to the FreeSurfer modles/ dir and cd into it:" |
| 34 | + echo " mv nnUNetTrainer__nnUNetPlans__2d.tar.gz \$FREESURFER_HOME/models" |
| 35 | + echo " cd \$FREESURFER_HOME/models" |
| 36 | + echo "" |
| 37 | + echo " 3. Unpack the tarball:" |
| 38 | + echo " tar -xzf nnUNetTrainer__nnUNetPlans__2d.tar.gz" |
| 39 | + echo "" |
| 40 | + echo " 4. Configure the nnUNet environment variables:" |
| 41 | + echo " export NNUNET_MODEL_DIR=\$FREESURFER_HOME/models/nnUNetTrainer__nnUNetPlans__2d" |
| 42 | + echo " export NNUNET_SCRIPTS_DIR=\$FREESURFER_HOME/python/packages/nnUNet_v2" |
| 43 | + echo "" |
| 44 | + exit 1 |
| 45 | +fi |
| 46 | + |
| 47 | +$FREESURFER_HOME/bin/dissection_photo/Contents/MacOS/dissection_photo "$@" |
3 | 48 | exit $?
|
0 commit comments