Skip to content

Commit 71c564e

Browse files
committed
fix(mknii): always return success on noquiet
1 parent c71fb52 commit 71c564e

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

mknii

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
#!/usr/bin/env bash
2-
env | grep ^DRYRUN= && DRYRUN=echo || DRYRUN=""
2+
#
3+
#run dcm2niix with 3dNotes wrapper. check for existing file
4+
#
5+
# 20201016WF init
6+
# 20210113WF use rename-recent. nest into "main" (source for testing)
7+
# 2026 support .zip
8+
9+
[ -n "${DRYRUN:-}" ] && DRYRUN='echo' || DRYRUN=""
310
# when we are give, change value to "check"
411
[ -v NOECHOCHECK ] && NOECHOCHECK="check" || NOECHOCHECK=""
512
[ ! -v VERBOSE ] && VERBOSE=""
613
verbose(){ [ -n "$VERBOSE" ] && echo "$*" >&2 || :; }
7-
noquiet() { [ -z "${MKNII_QUIET:-}" ] && echo "$*" || return 0; }
14+
noquiet() { [ -z "${MKNII_QUIET:-}" ] && echo "$*"; return 0; }
815

916
set_dcm2niix(){
1017
DCM2NIIX="${DCM2NII:-dcm2niix}"
1118
command -v "$DCM2NIIX" >/dev/null || DCM2NIIX=dcm2niix_afni
1219
! command -v "$DCM2NIIX" >/dev/null && warn "cannot find dcm2niix or dcm2niix_afni; try export DCM2NIIX=..." && exit 2
1320
return 0
14-
}
15-
21+
}
1622

17-
#
18-
#run dcm2niix with 3dNotes wrapper. check for existing file
19-
#
20-
# 20201016WF init
21-
# 20210113WF use rename-recent. nest into "main" (source for testing)
2223
usage() {
2324
cat <<HEREDOC
2425
USAGE:
@@ -149,6 +150,7 @@ main(){
149150
[ $# -ne 2 ] && usage
150151
nii_out="$1"; shift
151152
dcm_folder="$*"; shift
153+
# not a definiative check. multi-echo might not catch here.
152154
[ -r "$nii_out" ] && noquiet "# have '$nii_out'" && exit 0
153155
[ "${nii_out:(-7)}" != ".nii.gz" ] &&
154156
echo "ERROR: output '$nii_out' must have .nii.gz extention!" >&2 && exit 1
@@ -172,8 +174,9 @@ main(){
172174
outdir="$(dirname "$nii_out")"
173175
[ ! -d "$outdir" ] && $DRYRUN mkdir -p "$outdir"
174176

175-
#pretimestamp=$(mktemp /tmp/dcmnii_XXXXXX) # -newercm $pretimestamp
176177
# TODO: add trap to cleanup file?
178+
#pretimestamp=$(mktemp /tmp/dcmnii_XXXXXX) # -newercm $pretimestamp
179+
177180
$DRYRUN $DCM2NIIX -z y -b y -f "$outname" -o "$outdir" "$dcm_folder"
178181
[ -n "$DRYRUN" ] && exit 0
179182
# if above failed, script would bail (set -e)

0 commit comments

Comments
 (0)