-
Notifications
You must be signed in to change notification settings - Fork 0
/
bl_download.sh
62 lines (58 loc) · 2.49 KB
/
bl_download.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
#!/bin/bash
topDir=$1
projectID="5e2b98fbe51f7a9aeb88c43c"
datatypes="dwi mask tractmeasures networks snr parc_stats_cortex parc_stats_hcp vm-networks"
tags="run_1 run_2"
for DTYPES in ${datatypes}
do
for TAGS in ${tags}
do
echo "${DTYPES} ${TAGS}"
if [ ! -f data_${DTYPES}_${TAGS}.json ]; then
if [[ ${DTYPES} == 'mask' ]]; then
bl dataset query --project ${projectID} --datatype neuro/${DTYPES} --tag ${TAGS} --json > data_${DTYPES}_${TAGS}.json
fi
if [[ ${DTYPES} == 'dwi' ]]; then
bl dataset query --project ${projectID} --datatype neuro/${DTYPES} --tag ${TAGS} --json > data_${DTYPES}_${TAGS}.json
fi
if [[ ${DTYPES} == 'tractmeasures' ]]; then
bl dataset query --project ${projectID} --datatype neuro/${DTYPES} --datatype_tag "macro_micro" --tag ${TAGS} --json > data_${DTYPES}_${TAGS}.json
fi
if [[ ${DTYPES} == 'networks' ]]; then
bl dataset query --project ${projectID} --datatype raw --datatype_tag "networkmatrices" --tag ${TAGS} --json > data_${DTYPES}_${TAGS}.json
fi
if [[ ${DTYPES} == 'snr' ]]; then
bl dataset query --project ${projectID} --datatype raw --datatype_tag "snr-cc" --tag ${TAGS} --json > data_${DTYPES}_${TAGS}.json
fi
if [[ ${DTYPES} == 'parc_stats_cortex' ]]; then
bl dataset query --project ${projectID} --datatype neuro/parc-stats --datatype_tag "cortex_mapping_stats" --tag ${TAGS} --json > data_${DTYPES}_${TAGS}.json
fi
if [[ ${DTYPES} == 'parc_stats_hcp' ]]; then
bl dataset query --project ${projectID} --datatype neuro/parc-stats --datatype_tag "SupraTentorial" --json > data_${DTYPES}_${TAGS}.json
fi
if [[ ${DTYPES} == 'vm-networks' ]]; then
bl dataset query --project ${projectID} --datatype raw --datatype_tag "networkmatrices" --tag ${TAGS} --tag "visual_wm" --json > data_${DTYPES}_${TAGS}.json
fi
fi
for subject in $(jq -r '.[].meta.subject' data_${DTYPES}_${TAGS}.json | sort -u)
do
# make subject directory if not made
if [ ! -d $topDir/$subject ]; then
mkdir -p $topDir/$subject
fi
# make datatype directory if not made
if [ ! -d $topDir/$subject/${TAGS}/${DTYPES} ];
then
echo "downloading subject:$subject ---------------"
mkdir -p $topDir/$subject/${TAGS}/${DTYPES}
ids=$(jq -r '.[] | select(.meta.subject == '\"$subject\"') | ._id' data_${DTYPES}_${TAGS}.json)
for id in $ids
do
echo $id
outdir=$topDir/$subject/${TAGS}/${DTYPES}
bl dataset download -i $id --directory $outdir
done
fi
done
done
done