-
Notifications
You must be signed in to change notification settings - Fork 0
/
compute_hypergraph_correlation_matrix_v2.py
75 lines (65 loc) · 3.07 KB
/
compute_hypergraph_correlation_matrix_v2.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
from os import listdir, path
from os.path import join
import numpy as np
from nipype.interfaces.utility import IdentityInterface
from nipype.interfaces.io import SelectFiles, DataSink
from os.path import join as opj
from nipype import Workflow, Node
import interfaces.ComputeCorrelationMatrix as c
preprocessing_path = '/home/jrudascas/Desktop/Tesis/data/datasets/mcs/output/datasink/preprocessing'
hypergraph_path = '/home/jrudascas/PycharmProjects/hypergraph_analysis/_hypergraph_median.txt'
correlation_matrix_out_file = 'hypergraph_correlation_matrix.txt'
correlation_matrix_plot_out_file = 'hypergraph_correlation_matrix_plot.png'
experiment_dir = join(preprocessing_path, 'output/')
output_dir = 'datasink'
working_dir = 'workingdir'
subject_list = ['sub-MCS_AI',
'sub-MCS_BI',
'sub-MCS_BM',
'sub-MCS_CA',
'sub-MCS_DE',
'sub-MCS_DF',
'sub-MCS_DM',
'sub-MCS_DP',
'sub-MCS_FI',
'sub-MCS_FR',
'sub-MCS_HE',
'sub-MCS_HR',
'sub-MCS_MF',
'sub-MCS_MM',
'sub-MCS_MO',
'sub-MCS_MT',
'sub-MCS_MU',
'sub-MCS_NL']
#'sub-MCS_PA',
#'sub-MCS_PJ',
#'sub-MCS_RB',
#'sub-MCS_RP',
#'sub-MCS_SC',
#'sub-MCS_ST',
#'sub-MCS_TP',
#'sub-MCS_VW']
# Infosource-a function free node to iterate over the list of subject names
infosource = Node(IdentityInterface(fields=['subject_id']), name="infosource")
infosource.iterables = [('subject_id', subject_list)]
# SelectFiles-to grab the data (alternativ to DataGrabber)
time_serie_file = opj('{subject_id}', 'parcellation_from_lasso/time_series.txt')
templates = {'time_series': time_serie_file}
selectfiles = Node(SelectFiles(templates, base_directory=preprocessing_path), name="selectfiles")
datasink = Node(DataSink(base_directory=experiment_dir, container=output_dir), name="datasink")
experiment_dir = opj(preprocessing_path, 'output/')
preproc = Workflow(name='preproc')
preproc.base_dir = opj(experiment_dir, working_dir)
compute_correlation_matrix = Node(
c.ComputeCorrelationMatrix(hypergraph_path=hypergraph_path, correlation_matrix_out_file=correlation_matrix_out_file,
correlation_matrix_plot_out_file=correlation_matrix_plot_out_file),
name='compute_correlation_matrix')
preproc.connect([(infosource, selectfiles, [('subject_id', 'subject_id')]),
(selectfiles, compute_correlation_matrix, [('time_series', 'time_series_path')]),
(compute_correlation_matrix, datasink,
[('correlation_matrix_out_file', 'preprocessing.@correlation_matrix_out_file')]),
(compute_correlation_matrix, datasink,
[('correlation_matrix_plot_out_file', 'preprocessing.@correlation_matrix_plot_out_file')])])
plugin_args = {'n_procs':1}
preproc.run(plugin='MultiProc', plugin_args=plugin_args)
#14:33