Skip to content

Commit 5e9bc32

Browse files
author
Katie Bottenhorn
committed
add try/except to pipeline and remove run from tsv name
1 parent 6973d15 commit 5e9bc32

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

idconn/connectivity/build_networks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def task_connectivity(layout, subject, session, task, atlas, confounds, connecti
156156
corrmat_df = pd.DataFrame(index=np.arange(1, avg_corrmat.shape[0]+1), columns=np.arange(1, avg_corrmat.shape[0]+1),data=avg_corrmat)
157157
avg_corrmats[condition] = corrmat_df
158158
corrmat_file = join(deriv_dir,
159-
f'sub-{subject}', f'ses-{session}', 'func', f'sub-{subject}_ses-{session}_task-{task}_condition-{condition}_run-{run}_desc-{atlas_name}_corrmat.tsv')
159+
f'sub-{subject}', f'ses-{session}', 'func', f'sub-{subject}_ses-{session}_task-{task}_condition-{condition}_desc-{atlas_name}_corrmat.tsv')
160160
try:
161161
corrmat_df.to_csv(corrmat_file, sep='\t')
162162
files.append(corrmat_file)

idconn/pipeline.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,20 @@ def idconn_workflow(dset_dir, atlas, task, out_dir, space="MNI152NLin2009cAsym",
9090
print(f"Session {session}")
9191
print(f"here are the inputs: {layout, subject, session, task, atlas, conn, space, confounds}")
9292
if 'rest' in task:
93-
adj_matrix = build_networks.connectivity(layout, subject, session, task, atlas, conn, space, confounds)
93+
try:
94+
adj_matrix = build_networks.connectivity(layout, subject, session, task, atlas, conn, space, confounds)
95+
except Exception as e:
96+
print(f'Error building corrmat for sub-{subject}, ses-{session}, task-{task}: {e}')
9497
if len(conditions) < 1:
95-
adj_matrix = build_networks.connectivity(layout, subject, session, task, atlas, conn, space, confounds)
98+
try:
99+
adj_matrix = build_networks.connectivity(layout, subject, session, task, atlas, conn, space, confounds)
100+
except Exception as e:
101+
print(f'Error building corrmat for sub-{subject}, ses-{session}, task-{task}: {e}')
96102
else:
97-
adj_matrix = build_networks.task_connectivity(layout=layout, subject=subject, session=session, task=task, atlas=atlas, confounds=confounds, connectivity_metric=conn)
103+
try:
104+
adj_matrix = build_networks.task_connectivity(layout=layout, subject=subject, session=session, task=task, atlas=atlas, confounds=confounds, connectivity_metric=conn)
105+
except Exception as e:
106+
print(f'Error building corrmat for sub-{subject}, ses-{session}, task-{task}: {e}')
98107

99108

100109
def _main(argv=None):

0 commit comments

Comments
 (0)