Skip to content

Commit cd5ec2b

Browse files
authored
Merge pull request freesurfer#1317 from jnolan14/dev
Fixed bug calling the dissection_photo_gui tool on MacOS
2 parents 4c0e7f2 + 27459c9 commit cd5ec2b

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

dissection_photo/dissection_photo/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ if(BUILD_GUIS)
2222

2323
if(APPLE)
2424
mac_deploy_qt(TARGET dissection_photo BUNDLE bin/dissection_photo PLIST Info.plist)
25-
install(PROGRAMS mac_wrapper DESTINATION bin RENAME dissection_photo)
25+
install(PROGRAMS mac_wrapper DESTINATION bin RENAME dissection_photo_gui.sh)
2626
else()
2727
install(TARGETS dissection_photo DESTINATION bin)
28+
install_configured(dissection_photo_gui.sh DESTINATION bin)
2829
endif()
2930

30-
install_configured(dissection_photo_gui.sh DESTINATION bin)
31-
3231
endif()
Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
11
#!/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 "$@"
348
exit $?

0 commit comments

Comments
 (0)