Skip to content

Commit 2e9c68e

Browse files
authored
Merge pull request #199 from jhlegarreta/enh/download-pet-sub02
ENH: Fetch `sub-02` data for PET notebook
2 parents cf23822 + 751aa9e commit 2e9c68e

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

scripts/fetch_pet_nb_gin_data.sh

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,49 @@
33
DEST_DIR=$1
44

55
# Define variables
6-
LIST_URL="gin.g-node.org/jhlegarreta/tests-nifreeze/raw/AddPETData"
6+
LIST_URL="gin.g-node.org/nipreps-data/tests-nifreeze/raw/master"
77

88
FOLDER="pet_data"
9-
SUB_LABEL="sub-01"
9+
SRC_SUB_LABELS=("sub-01")
10+
MTN_SUB_LABELS=("sub-02")
11+
SUB_LABELS=("${SRC_SUB_LABELS[@]}" "${MTN_SUB_LABELS[@]}")
1012
SESSION_LABEL="ses-baseline"
1113
ANAT_LABEL="anat"
1214
PET_LABEL="pet"
13-
ANAT_FNAMES=("sub-01_ses-baseline_T1w.nii")
14-
PET_FNAMES=("sub-01_ses-baseline_pet.json" "sub-01_ses-baseline_pet.nii.gz" "sub-01_ses-baseline_recording-manual_blood.json" "sub-01_ses-baseline_recording-manual_blood.tsv")
15+
ANAT_FNAMES_CMN_SSTR=("ses-baseline_T1w.nii")
16+
PET_FNAMES_CMN_SSTR=("ses-baseline_pet.json" "ses-baseline_pet.nii.gz" "ses-baseline_recording-manual_blood.json" "ses-baseline_recording-manual_blood.tsv")
17+
MOTION_FNAMES_CMN_SSTR=("ses-baseline_ground_truth_motion.csv")
18+
UNDERSCORE="_"
1519

1620
# Create target directory structure
17-
mkdir -p "${DEST_DIR}/${FOLDER}/${SUB_LABEL}/${SESSION_LABEL}/${ANAT_LABEL}"
18-
mkdir -p "${DEST_DIR}/${FOLDER}/${SUB_LABEL}/${SESSION_LABEL}/${PET_LABEL}"
21+
for sub_id in "${SUB_LABELS[@]}"; do
22+
mkdir -p "${DEST_DIR}/${FOLDER}/${sub_id}/${SESSION_LABEL}/${ANAT_LABEL}"
23+
mkdir -p "${DEST_DIR}/${FOLDER}/${sub_id}/${SESSION_LABEL}/${PET_LABEL}"
24+
done
1925

2026
# Download anatomical files
21-
for fname in "${ANAT_FNAMES[@]}"; do
22-
url="${LIST_URL}/${FOLDER}/${SUB_LABEL}/${SESSION_LABEL}/${ANAT_LABEL}/${fname}"
23-
wget -nv -O "${DEST_DIR}/${FOLDER}/${SUB_LABEL}/${SESSION_LABEL}/${ANAT_LABEL}/${fname}" "${url}"
27+
for sub_id in "${SUB_LABELS[@]}"; do
28+
fname="${ANAT_FNAMES_CMN_SSTR[@]/#/${sub_id}${UNDERSCORE}}"
29+
url="${LIST_URL}/${FOLDER}/${sub_id}/${SESSION_LABEL}/${ANAT_LABEL}/${fname}"
30+
wget -nv -O "${DEST_DIR}/${FOLDER}/${sub_id}/${SESSION_LABEL}/${ANAT_LABEL}/${fname}" "${url}"
2431
done
2532

2633
# Download PET files
27-
for fname in "${PET_FNAMES[@]}"; do
28-
url="${LIST_URL}/${FOLDER}/${SUB_LABEL}/${SESSION_LABEL}/${PET_LABEL}/${fname}"
29-
wget -nv -O "${DEST_DIR}/${FOLDER}/${SUB_LABEL}/${SESSION_LABEL}/${PET_LABEL}/${fname}" "${url}"
34+
for sub_id in "${SUB_LABELS[@]}"; do
35+
fnames=("${PET_FNAMES_CMN_SSTR[@]/#/${sub_id}${UNDERSCORE}}")
36+
for fname in "${fnames[@]}"; do
37+
url="${LIST_URL}/${FOLDER}/${sub_id}/${SESSION_LABEL}/${PET_LABEL}/${fname}"
38+
wget -nv -O "${DEST_DIR}/${FOLDER}/${sub_id}/${SESSION_LABEL}/${PET_LABEL}/${fname}" "${url}"
39+
done
40+
done
41+
42+
# Download motion files
43+
for sub_id in "${MTN_SUB_LABELS[@]}"; do
44+
fnames=("${MOTION_FNAMES_CMN_SSTR[@]/#/${sub_id}${UNDERSCORE}}")
45+
for fname in "${fnames[@]}"; do
46+
url="${LIST_URL}/${FOLDER}/${SUB_LABEL}/${SESSION_LABEL}/${PET_LABEL}/${fname}"
47+
wget -nv -O "${DEST_DIR}/${FOLDER}/${SUB_LABEL}/${SESSION_LABEL}/${PET_LABEL}/${fname}" "${url}"
48+
done
3049
done
3150

3251
echo "PET data successfully downloaded to the '${DEST_DIR}/${FOLDER}' directory."

0 commit comments

Comments
 (0)