Skip to content

Commit d8b8cdd

Browse files
committed
🔧mknii: DCM2NIIX tries dcm2niix_afni, can be user specified
1 parent 66ecd46 commit d8b8cdd

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

mknii

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ env | grep ^DRYRUN= && DRYRUN=echo || DRYRUN=""
55
[ ! -v VERBOSE ] && VERBOSE=""
66
verbose(){ [ -n "$VERBOSE" ] && echo "$*" >&2 || :; }
77

8+
set_dcm2niix(){
9+
DCM2NIIX="${DCM2NII:-dcm2niix}"
10+
command -v "$DCM2NIIX" >/dev/null || DCM2NIIX=dcm2niix_afni
11+
! command -v "$DCM2NIIX" >/dev/null && warn "cannot find dcm2niix or dcm2niix_afni; try export DCM2NIIX=..." && exit 2
12+
return 0
13+
}
14+
815

916
#
1017
#run dcm2niix with 3dNotes wrapper. check for existing file
@@ -107,6 +114,8 @@ add_json_task(){
107114

108115
main(){
109116
set -euo pipefail
117+
set_dcm2niix # DCM2NIIX might be dcm2niix_afni or given by user
118+
110119
[ $# -ne 2 ] && usage
111120
nii_out="$1"; shift
112121
dcm_folder="$*"; shift
@@ -125,7 +134,7 @@ main(){
125134

126135
#pretimestamp=$(mktemp /tmp/dcmnii_XXXXXX) # -newercm $pretimestamp
127136
# TODO: add trap to cleanup file?
128-
$DRYRUN dcm2niix -z y -b y -f "$outname" -o "$outdir" "$dcm_folder"
137+
$DRYRUN $DCM2NIIX -z y -b y -f "$outname" -o "$outdir" "$dcm_folder"
129138
[ -n "$DRYRUN" ] && exit 0
130139
# if above failed, script would bail (set -e)
131140
# so if we don't have the file it's probably has multiple echos

0 commit comments

Comments
 (0)