-
Notifications
You must be signed in to change notification settings - Fork 0
/
1_download_data
49 lines (40 loc) · 2.2 KB
/
1_download_data
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
#!/bin/bash
# INSTALL AND RUN PEP
# PEP can be installed on local machine or on computing cluster. For this project, the PEP docker image was converted into a Singularity image (.simg), then moved to a local home directory. From here, .simg can be run in an interactive job on the cluster or directly in local machine.
# https://gitlab.pep.cs.ru.nl/pep-public/user-docs/-/wikis/Using-pepcli-with-docker
module load singularity
singularity run ~/Desktop/pep-client.simg
echo "Singularity container ("Apptainer") is now the bash shell; /home and /project directories remain accessible."
# DOWNLOAD DATA
# https://gitlab.pep.cs.ru.nl/pep-public/user-docs/-/wikis/Uploading-and-downloading-data#downloading-data
PROJECT_DIR=~/Desktop
TOKEN=ChristienneDamatac_SensoryProcessingSensitivity.json
DATA_DIR=$PROJECT_DIR/pulled-data_$(date +"%d-%m-%Y")
cd $PROJECT_DIR
mkdir -p $DATA_DIR
/app/pepcli --client-working-directory /config --oauth-token $TOKEN -o $DATA_DIR -P Participants.300pps -C post_qst_BIG-5_NEO-FFI-3 -C post_qst_CTQ_2 -C post_qst_DHU_3 -C post_qst_HEC_3 -C post_qst_IDS_3 -C post_qst_LIE -C post_qst_MPD_3 -C post_qst_OCM_3 -C post_qst_PSS_3 -C post_qst_STS_3 -C post_qst_UBO_3 -C post_qst_adults_ADHD_self-report_scale -C post_qst_autistic_traits -C post_qst_sensory_processing_sensitivity -C pre_qst_LISS_background_variables -C pre_qst_SLS_3
exit
# RENAME
PROJECT_DIR=~/Desktop
DATA_DIR=$PROJECT_DIR/pulled-data_$(date +"%d-%m-%Y")
ANALYSIS_DIR=$PROJECT_DIR/analysis_sps_health_environment
cd $DATA_DIR
while read HBS IID; do
mv ${HBS} ${IID} # Rename directories because HBS anonymyzed data have long and nonsensical names
for FILE in ${IID}/*; do
mv -- "$FILE" "${FILE}_${IID}.zip" # Rename files because all downloaded files were actually zip files, but the extensions get lost in the PEP system
done
done < $ANALYSIS_DIR/subject_list_24-05-2022
# Unzip files
while read HBS IID; do
unzip -d ${IID}/ "${IID}/*"
done < $ANALYSIS_DIR/subject_list_24-05-2022
# Append unzipped .csv files with subject ID suffix
while read HBS IID; do
for FILE in ${IID}/*.csv; do
mv $FILE ${FILE%.csv}_${IID}.csv
done
done < $ANALYSIS_DIR/subject_list_24-05-2022
# Move all .csv files to analysis folder
mv */*.csv $ANALYSIS_DIR/
cd $ANALYSIS_DIR