forked from sgiavasis/CPAC_regtest_pack
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
run_cpac.sh
executable file
·163 lines (147 loc) · 4.12 KB
/
run_cpac.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/bash
# usage
# > ./run_cpac_container.sh {docker tag} {name} {data} {pipeline} {participant_ndx} {mode}
# /\ optional
# {mode} options:
# (leave this blank to simply run C-PAC)
# - enter = enter the container instead of running C-PAC
# - current = use C-PAC install from code in current branch of C-PAC repo listed in "repo"
# - enter-current = enter the container instead of running, with C-PAC install from code
# in current branch of C-PAC repo listed in "repo"
# - pre-182 = don't use '--num_ants_threads'
# - pre-182-current
docker_image=$1
run_name=$2
data=$3
pipe=$4
aux=$5
mode=$6
# Custom args for this run
#-------------------------
# Paths
repo="/media/ebs/C-PAC"
# Run settings
n_cpus=30
ants_cpus=15
mem_gb=45
# Automated args
#-------------------------
# Data
if [[ "${data}" == *".yml" || "${data}" == *".yaml" ]]
then
data_config="${data}"
bids_dir=/home/ubuntu # keep as /home/ubuntu when providing a data_config
else
bids_dir="${data}"
fi
if [[ "${pipe}" == "default" ]]
then
pipe_config=""
preconfig=""
elif [[ "${pipe}" == *".yml" || "${pipe}" == *".yaml" ]]
then
pipe_config="${pipe}"
pipe_name=""
else
# a preconfig name was given instead - this will be appended to {name}
preconfig="${pipe}"
pipe_name="_${pipe}"
fi
# Pipeline
run_name="${run_name}${pipe_name}"
#-------------------------
if [[ -z "$data_config" ]]
then
data_map="-v /tmp:/tmp"
data_config=""
else
data_map="-v $data_config:/configs/data_config.yml"
data_config="--data_config_file /configs/data_config.yml"
fi
if [[ -z "$bids_dir" ]]
then
bids_map="-v /tmp:/tmp"
bids_dir="/home/ubuntu"
else
bids_map="-v $bids_dir:$bids_dir"
fi
if [[ -z "$pipe_config" ]]
then
pipe_map="-v /tmp:/tmp"
pipe_config=""
else
pipe_map="-v $pipe_config:/configs/pipe_config.yml"
pipe_config="--pipeline_file /configs/pipe_config.yml"
fi
if [[ "$preconfig" ]]
then
pipe_config="--preconfig $preconfig"
fi
configs="${data_config} ${pipe_config}"
if [[ $mode != "pre-182" && $mode != "pre-182-current" ]]
then
configs="${configs} --num_ants_threads ${ants_cpus}"
fi
if [[ -n $aux && $aux != "all" ]]
then
configs="${configs} --participant_ndx ${aux}"
fi
if [[ $mode = "enter" ]]
then
sudo docker run -it \
-v /home/ubuntu:/home/ubuntu \
-v /media/ebs:/media/ebs \
-v /media/ebs/CPAC_regtest_pack:/media/ebs/CPAC_regtest_pack \
-v /media/ebs/runs/$run_name:/output \
--entrypoint bash \
$docker_image
elif [[ $mode = "enter-current" ]]
then
sudo docker run -it \
-v $repo/CPAC:/code/CPAC \
-v $repo/dev/docker_data/run.py:/code/run.py \
-v $repo/dev/docker_data:/cpac_resources \
-v /home/ubuntu:/home/ubuntu \
-v /media/ebs:/media/ebs \
-v /media/ebs/CPAC_regtest_pack:/media/ebs/CPAC_regtest_pack \
-v /media/ebs/runs/$run_name:/output \
$bids_map \
$data_map \
$pipe_map \
--entrypoint bash \
$docker_image
elif [[ $mode = "current" ]]
then
sudo docker run \
-v $repo/CPAC:/code/CPAC \
-v $repo/dev/docker_data/run.py:/code/run.py \
-v $repo/dev/docker_data:/cpac_resources \
-v /home/ubuntu:/home/ubuntu \
-v /media/ebs:/media/ebs \
-v /media/ebs/CPAC_regtest_pack:/media/ebs/CPAC_regtest_pack \
-v /media/ebs/runs/$run_name:/output \
$bids_map \
$data_map \
$pipe_map \
$docker_image $bids_dir /output participant \
--save_working_dir \
--skip_bids_validator \
--n_cpus $n_cpus \
--mem_gb $mem_gb \
$configs
else
sudo docker run \
-v /home/ubuntu:/home/ubuntu \
-v /media/ebs:/media/ebs \
-v /media/ebs/CPAC_regtest_pack:/media/ebs/CPAC_regtest_pack \
-v /media/ebs/runs/$run_name:/output \
$bids_map \
$data_map \
$pipe_map \
$docker_image $bids_dir /output participant \
--save_working_dir \
--skip_bids_validator \
--n_cpus $n_cpus \
--mem_gb $mem_gb \
$configs
fi