forked from tcama/olfactoryRSN
-
Notifications
You must be signed in to change notification settings - Fork 1
/
HCP_automated.sh
125 lines (109 loc) · 7.04 KB
/
HCP_automated.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
#!/bin/bash
# This script is used to execute all necessary command for preprocessing and
# processing of a subject from HCP. The script should be run as follows:
#
# ./HCP_automated ******
#
# Where the stars are replaced by the HCP subject ID code:
#
# ./HCP_automated 100206
#
# This script should be executed from the directory containing all of the
# necessary processing scripts, or should be altered to properly find the
# location of the needed scripts. There are four resting-state fmri (rsfmri)
# scans, two for each phase encoding used: right-left (RL) and left-right (LR).
# This code concatenates the two scans for each phase encoding.
# set the number of TRs and ROIs included
TRs=2400 # both phase encodings, each 1200 TRs long
ROIs=627 # determined by atlas
# Make directories for data
homedir=$PWD
mkdir "$homedir"/HCP/
mkdir "$homedir"/HCP/data/
mkdir "$homedir"/HCP/data/"$1"
mkdir "$homedir"/HCP/data/"$1"/rfMRI_REST1_RL/
mkdir "$homedir"/HCP/data/"$1"/rfMRI_REST2_RL/
mkdir "$homedir"/HCP/data/"$1"/rfMRI_REST1_LR/
mkdir "$homedir"/HCP/data/"$1"/rfMRI_REST2_LR/
# make directory for holding results
mkdir "$homedir"/HCP/results/
mkdir "$homedir"/HCP/results/"$1"
# Download data via AWS and gunzip (1_RL)
cd "$homedir"/HCP/data/"$1"/rfMRI_REST1_RL/
aws s3 cp s3://hcp-openaccess/HCP_900/"$1"/MNINonLinear/Results/rfMRI_REST1_RL/RibbonVolumeToSurfaceMapping/goodvoxels.nii.gz goodvoxels.nii.gz
aws s3 cp s3://hcp-openaccess/HCP_900/"$1"/MNINonLinear/Results/rfMRI_REST1_RL/rfMRI_REST1_RL_hp2000_clean.nii.gz rfMRI_REST1_RL_hp2000_clean.nii.gz
gunzip rfMRI_REST1_RL_hp2000_clean.nii.gz
gunzip goodvoxels.nii.gz
# copy needed functions to data directory and begin processing (1_RL)
cd "$homedir"/HCP/data/"$1"/rfMRI_REST1_RL/
cp "$homedir"/AAL627_10202016.nii "$homedir"/HCP/data/"$1"/rfMRI_REST1_RL/
"$homedir"/roi_preprocess rfMRI_REST1_RL_hp2000_clean.nii AAL627_10202016.nii goodvoxels.nii
mv "$homedir"/HCP/data/$1/rfMRI_REST1_RL/goodvoxels_new.csv "$homedir"/HCP/results/"$1"/goodvoxels_new1_RL.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST1_RL/mean_data.csv "$homedir"/HCP/results/"$1"/mean_data1_RL.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST1_RL/snr_data.csv "$homedir"/HCP/results/"$1"/snr_data1_RL.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST1_RL/roi_data.csv "$homedir"/HCP/results/"$1"/roi_data1_RL.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST1_RL/mc.csv "$homedir"/HCP/results/"$1"/meancenter1_RL.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST1_RL/voxels_summary.csv "$homedir"/HCP/results/"$1"/voxels_summary1_RL.csv
# Download data via AWS and gunzip (2_RL)
cd "$homedir"/HCP/data/"$1"/rfMRI_REST2_RL/
aws s3 cp s3://hcp-openaccess/HCP_900/"$1"/MNINonLinear/Results/rfMRI_REST2_RL/RibbonVolumeToSurfaceMapping/goodvoxels.nii.gz goodvoxels.nii.gz
aws s3 cp s3://hcp-openaccess/HCP_900/"$1"/MNINonLinear/Results/rfMRI_REST2_RL/rfMRI_REST2_RL_hp2000_clean.nii.gz rfMRI_REST2_RL_hp2000_clean.nii.gz
gunzip rfMRI_REST2_RL_hp2000_clean.nii.gz
gunzip goodvoxels.nii.gz
# copy needed functions to data directory and begin processing (2_RL)
cd "$homedir"/HCP/data/"$1"/rfMRI_REST2_RL/
cp "$homedir"/AAL627_10202016.nii "$homedir"/HCP/data/"$1"/rfMRI_REST2_RL/
"$homedir"/roi_preprocess rfMRI_REST2_RL_hp2000_clean.nii AAL627_10202016.nii goodvoxels.nii
mv "$homedir"/HCP/data/$1/rfMRI_REST2_RL/goodvoxels_new.csv "$homedir"/HCP/results/"$1"/goodvoxels_new2_RL.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST2_RL/mean_data.csv "$homedir"/HCP/results/"$1"/mean_data2_RL.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST2_RL/snr_data.csv "$homedir"/HCP/results/"$1"/snr_data2_RL.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST2_RL/roi_data.csv "$homedir"/HCP/results/"$1"/roi_data2_RL.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST2_RL/mc.csv "$homedir"/HCP/results/"$1"/meancenter2_RL.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST2_RL/voxels_summary.csv "$homedir"/HCP/results/"$1"/voxels_summary2_RL.csv
# change to resutls and concatenate processed results
cd "$homedir"/HCP/results/"$1"/
cat meancenter1_RL.csv meancenter2_RL.csv > meancenter_RL.csv
# Download data via AWS and gunzip (1_LR)
cd "$homedir"/HCP/data/"$1"/rfMRI_REST1_LR/
aws s3 cp s3://hcp-openaccess/HCP_900/"$1"/MNINonLinear/Results/rfMRI_REST1_LR/RibbonVolumeToSurfaceMapping/goodvoxels.nii.gz goodvoxels.nii.gz
aws s3 cp s3://hcp-openaccess/HCP_900/"$1"/MNINonLinear/Results/rfMRI_REST1_LR/rfMRI_REST1_LR_hp2000_clean.nii.gz rfMRI_REST1_LR_hp2000_clean.nii.gz
gunzip rfMRI_REST1_LR_hp2000_clean.nii.gz
gunzip goodvoxels.nii.gz
# copy needed functions to data directory and begin processing (1_LR)
cd "$homedir"/HCP/data/"$1"/rfMRI_REST1_LR/
cp "$homedir"/AAL627_10202016.nii "$homedir"/HCP/data/"$1"/rfMRI_REST1_LR/
"$homedir"/roi_preprocess rfMRI_REST1_LR_hp2000_clean.nii AAL627_10202016.nii goodvoxels.nii
mv "$homedir"/HCP/data/$1/rfMRI_REST1_LR/goodvoxels_new.csv "$homedir"/HCP/results/"$1"/goodvoxels_new1_LR.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST1_LR/mean_data.csv "$homedir"/HCP/results/"$1"/mean_data1_LR.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST1_LR/snr_data.csv "$homedir"/HCP/results/"$1"/snr_data1_LR.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST1_LR/roi_data.csv "$homedir"/HCP/results/"$1"/roi_data1_LR.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST1_LR/mc.csv "$homedir"/HCP/results/"$1"/meancenter1_LR.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST1_LR/voxels_summary.csv "$homedir"/HCP/results/"$1"/voxels_summary1_LR.csv
# Download data via AWS and gunzip (2_LR)
cd "$homedir"/HCP/data/"$1"/rfMRI_REST2_LR/
aws s3 cp s3://hcp-openaccess/HCP_900/"$1"/MNINonLinear/Results/rfMRI_REST2_LR/RibbonVolumeToSurfaceMapping/goodvoxels.nii.gz goodvoxels.nii.gz
aws s3 cp s3://hcp-openaccess/HCP_900/"$1"/MNINonLinear/Results/rfMRI_REST2_LR/rfMRI_REST2_LR_hp2000_clean.nii.gz rfMRI_REST2_LR_hp2000_clean.nii.gz
gunzip rfMRI_REST2_LR_hp2000_clean.nii.gz
gunzip goodvoxels.nii.gz
# copy needed functions to data directory and begin processing (2_LR)
cd "$homedir"/HCP/data/"$1"/rfMRI_REST2_LR/
cp "$homedir"/AAL627_10202016.nii "$homedir"/HCP/data/"$1"/rfMRI_REST2_LR/
"$homedir"/roi_preprocess rfMRI_REST2_LR_hp2000_clean.nii AAL627_10202016.nii goodvoxels.nii
mv "$homedir"/HCP/data/$1/rfMRI_REST2_LR/goodvoxels_new.csv "$homedir"/HCP/results/"$1"/goodvoxels_new2_LR.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST2_LR/mean_data.csv "$homedir"/HCP/results/"$1"/mean_data2_LR.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST2_LR/snr_data.csv "$homedir"/HCP/results/"$1"/snr_data2_LR.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST2_LR/roi_data.csv "$homedir"/HCP/results/"$1"/roi_data2_LR.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST2_LR/mc.csv "$homedir"/HCP/results/"$1"/meancenter2_LR.csv
mv "$homedir"/HCP/data/$1/rfMRI_REST2_LR/voxels_summary.csv "$homedir"/HCP/results/"$1"/voxels_summary2_LR.csv
# concatenate meancentered data
cd "$homedir"/HCP/results/"$1"/
cat meancenter1_LR.csv meancenter2_LR.csv > meancenter_LR.csv
# calculate correlation matrices
"$homedir"/fcMat_generation meancenter_RL.csv $ROIs $TRs
mv fcMap.csv fcMap_RL.csv
"$homedir"/fcMat_generation meancenter_LR.csv $ROIs $TRs
mv fcMap.csv fcMap_LR.csv
# remove extraneous data files
rm goodvoxels* meancenter*
# move data files to HCP_raw_data and delete zipped downloads
rm -R "$homedir"/HCP/data/"$1"