-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_retinotopy.py
106 lines (94 loc) · 3.58 KB
/
run_retinotopy.py
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
import re
import subprocess
from pathlib import Path
import sys
import pandas as pd
# /data/u_kieslinger_software/miniconda3/bin/conda run -n fmritools --live-stream python /data/u_kieslinger_software/code/spot/run_prep_and_ccf.py
def get_age(index, subject_info):
age = subject_info.at[index, "scan_age"]
if age > 44:
age = 44
return f"{age:.0f}" # round to whole week
path_derivatives = Path("/data/p_02915/dhcp_derivatives_SPOT")
path_anat_data = Path("/data/pt_02880/Package_1225541/fmriresults01/rel3_derivatives/rel3_dhcp_anat_pipeline") # path_derivatives / "dhcp_anat_pipeline"
path_func_data = Path("/data/pt_02880/Package_1225541/fmriresults01/rel3_derivatives/rel3_dhcp_fmri_pipeline") # path_derivatives / "dhcp_fmri_pipeline"
path_output_data = path_derivatives / "dhcp_surface"
path_templates = Path("/data/p_02915/templates")
# templates
name_volume_template_40wks = "dhcp40wk"
file_volume_template_40wks = (
path_templates
/ "template_augmentedvolumetricatlas_dhcp/atlas/T2/template-40.nii.gz"
)
name_surface_template = "dhcpSym"
path_surface_template = (
path_templates
/ "template_corticalsurfaceneonatessym_williams2023_dhcp/dhcpSym_template"
)
path_fsaverage = path_templates / "template_fsaverage/fsaverage"
path_HCPtemplates_standardmeshatlases = (
"/data/u_yoos_software/HCPpipelines/"
"global/templates/standard_mesh_atlases"
)
# --------------PATHS TO SOFTWARE--------------------------------------------------
path_newmsm = "/data/u_yoos_software/fsl/bin/msm-env/bin/newmsm"
path_wbcommand = "/bin/wb_command"
path_mirtk = "/afs/cbs.mpg.de/software/mirtk/0.20231123/debian-bullseye-amd64/bin/mirtk"
subject_info = pd.read_csv('/data/p_02915/SPOT/dhcp_subj_path_SPOT.csv')
sub_num = int(sys.argv[1])
#sub_ses_anat = {
# (
# re.search(r"(?<=sub-)[^_/]*", str(anat_file)).group(),
# re.search(r"(?<=ses-)[^_/]*", str(anat_file)).group(),
# )
# for anat_file in path_anat_data.glob("*/*/*/sub-*ses-*.gii")
#}
#sub_ses_func = {
# (
# re.search(r"(?<=sub-)[^_/]*", str(anat_file)).group(),
# re.search(r"(?<=ses-)[^_/]*", str(anat_file)).group(),
# )
# for anat_file in path_func_data.glob("*/*/*/sub-*ses-*.nii.gz")
#}
#sub_ses_todo = sub_ses_anat.intersection(sub_ses_func)
script_dir = Path(__file__).resolve().parent
surfaceprep_script = str(script_dir / "01_dataprep" / "run_surfaceprep.sh")
ccfmodel_script = str(script_dir / "02_ccfanalysis" / "run_model.py")
fillretinotopy_script = str(
script_dir / "03_retinotopyanalysis" / "analyse_retinotopy.py"
)
project_results_script = str(
script_dir / "03_retinotopyanalysis" / "project_ccf_to_fsaverage.sh"
)
for index, row in subject_info.iloc[sub_num:sub_num + 1].iterrows():
sub_id = subject_info.at[index, "sub_id"]
sess_id = subject_info.at[index, "sess_id"]
sub = sub_id.replace('sub-','')
ses = sess_id.replace('ses-','')
# for sub, ses in sub_ses_todo:
path_scaninfo = path_anat_data / f"sub-{sub}" / f"sub-{sub}_sessions.tsv"
age = get_age(index, subject_info)
cmd_fillretinotopy = [
"python",
fillretinotopy_script,
"-d",
str(path_derivatives),
"-sub",
sub,
"-ses",
ses,
"-th",
'00',
]
subprocess.run(cmd_fillretinotopy, check=True)
cmd_project_results = [
project_results_script,
sub,
ses,
str(path_anat_data),
str(path_derivatives),
str(path_HCPtemplates_standardmeshatlases),
str(path_fsaverage),
str(path_wbcommand),
]
subprocess.run(cmd_project_results, check=True)