-
Notifications
You must be signed in to change notification settings - Fork 7
/
fs_mkeditpack.sh
executable file
·64 lines (54 loc) · 1.57 KB
/
fs_mkeditpack.sh
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# Collect necessary images, surfaces and editing files for one subject to
# pass to a FS editor
#
# USAGE : fs_mkeditpack <FS subject recon dir> <output directory>
#
# AUTHOR : Mike Tyszka
# PLACE : Caltech
# DATES : 2021-01-21 JMT From scratch
if [ $# -lt 2 ]
then
echo "USAGE : fs_mkeditpack <FS subject recon dir> <output directory>"
exit
fi
subj_dir=$1
subj_basedir=$(basename ${subj_dir})
out_dir=$2
pack_dir=${out_dir}/${subj_basedir}
mkdir -p ${pack_dir}/mri
mkdir -p ${pack_dir}/surf
mkdir -p ${pack_dir}/tmp
mkdir -p ${pack_dir}/outbox
# Volume images
cp ${subj_dir}/mri/T1.mgz ${pack_dir}/mri
cp ${subj_dir}/mri/brainmask.mgz ${pack_dir}/mri
cp ${subj_dir}/mri/wm.mgz ${pack_dir}/mri
cp ${subj_dir}/mri/brain.finalsurfs.mgz ${pack_dir}/mri
cp ${subj_dir}/mri/aseg.mgz ${pack_dir}/mri
# Deface T1
mgz_fname=${pack_dir}/mri/T1.mgz
nii_fname=${mgz_fname/.mgz/.nii.gz}
def_fname=${mgz_fname/.mgz/_defaced.nii.gz}
mri_convert ${mgz_fname} ${nii_fname} > /dev/null
pydeface.py -i ${nii_fname} --overwrite
mri_convert ${def_fname} ${mgz_fname} > /dev/null
# Cleanup after defacing
rm -rf ${pack_dir}/mri/*.nii.gz
# Manually edited brain.finalsurfs if present
bfs=${subj_dir}/mri/brain.finalsurfs.manedit.mgz
if [ -s ${bfs} ]
then
cp ${bfs} ${pack_dir}/mri
fi
# Surfaces
cp ${subj_dir}/surf/lh.pial ${pack_dir}/surf
cp ${subj_dir}/surf/rh.pial ${pack_dir}/surf
cp ${subj_dir}/surf/lh.white ${pack_dir}/surf
cp ${subj_dir}/surf/rh.white ${pack_dir}/surf
# Control points if present
cps=${subj_dir}/tmp/control.dat
if [ -s ${cps} ]
then
cp ${cps} ${pack_dir}/tmp
fi