-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcoverage_mask
More file actions
executable file
·33 lines (28 loc) · 961 Bytes
/
coverage_mask
File metadata and controls
executable file
·33 lines (28 loc) · 961 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
33
#!/usr/bin/env bash
set -eou pipefail
usage(){
cat <<HEREDOC
USAGE:
coverage_mask outputmask.nii.gz input1.nii.gz [input2.nii.gz input3.nii.gz ....]
make mask of coverage.
1) idv masks: include any voxel with any non-zero value in the individual inputfiles
2) include only voxels in all idv masks.
This is a wrapper for 3dTstat -absmax ...; 3dMean -mask_inter ...
You may want 3dTstat -absmax ..; 3dMean -count ... # for a more descriptive coverage map
Input is expected to be timeseries. If you already have mask per run, you dont need this!
Consider:
3dMean -prefix \$outfile -count inputs*
HEREDOC
exit 1
}
[ $# -lt 2 ] && usage
outfile="$1"; shift
[ -r $outfile ] && echo -e "# already have output file.\n\t rm '$outfile' #to redo" && exit 0
tmpd=$(mktemp -d /tmp/mkmask_XXXX)
let i=1
for f in "$@"; do
3dTstat -absmax -prefix $tmpd/mask_$i.nii.gz $f
let ++i
done
3dMean -prefix $outfile -mask_inter $tmpd/mask_*.nii.gz
rm -r $tmpd