-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmaskvolume
More file actions
executable file
·32 lines (27 loc) · 923 Bytes
/
maskvolume
File metadata and controls
executable file
·32 lines (27 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
# use 3dROIstats nzvolume with mask as own input. reformat and transpose
# columns are
# ROI# VOLUME(mm)
#
# 20230131WF - quick look at roi volume (mm^3)
# 20231218WF - add usage and allow other 3dROIstats switches
case $1 in
--help*|-h*)
echo "USAGE: $0 [-nzvoxels|-nzmean|-nzvolume] atlas.nii.gz"; exit;;
-*) measure="$1"; title="${measure/\-/}"; shift;;
*) measure="-nzvolume"; title="Volume_mm3";;
esac
[ ! -r "${1:?roi file to report mask volume}" ] &&
! 3dinfo -nt "${1}" >/dev/null &&
warn "ERROR: cannot read $1" && exit 1
[ $# -gt 1 ] &&
warn "ERROR: $0 given more than one input ($# != 1)" && exit 1;
# NB. removed neat bash trick: "$1"{,} same as "$1" "$1"
echo -e "#ROI\t$title"
3dROIstats -1Dformat -nomeanout "$measure" -mask "$1" "$1"|
sed '2s/#//;
s/\.0\+\(\s|$\)/\1/g;
s/[A-Za-z0-9]\+_//g;
s/^\t\+//'|
grep -v '#'|
datamash transpose