Compute connectivity matrices and graph properties from nii files

The nii_to_graph pipeline performs graph analysis from functional MRI file in NIFTI format.

The input data should be preprocessed (i.e. realigned, coregistered, and segmented), and normalized in the same space (e.g. MNI space) as the template used to define the nodes in the graph.

The data used in this example are the anat and func from the sub-01 in the OpenNeuro database ds000208_R1.0.0, after preprocessing realized with Nipype pipeline create_preprocess_struct_to_mean_funct_4D_spm12, with parameters:

  • TR = 2.5,
  • slice_timing = False
  • fast_segmenting = True
  • fwhm = [7.5,7.5,8]
  • nb_scans_to_remove = 0

The template was generated from the HCP template called HCPMMP1_on_MNI152_ICBM2009a_nlin, by taking a mirror for the right hemisphere and compute a template with 360 ROIS - here 332 regions are kept, and time series length = 300

The input data should be a preprocessed, and in the same space (e.g. MNI space) as the template used to define the nodes in the graph.

# Authors: David Meunier <david_meunier_79@hotmail.fr>

# License: BSD (3-clause)
# sphinx_gallery_thumbnail_number = 2

import os
import os.path as op

import nipype.pipeline.engine as pe

from nipype.interfaces.utility import IdentityInterface
import nipype.interfaces.io as nio

import json  # noqa
import pprint  # noqa
# Check if data are available

from graphpype.utils_tests import load_test_data

data_path = load_test_data("data_nii")

data_path_mask = load_test_data("data_nii_HCP")

ROI_mask_file = op.join(data_path_mask, "indexed_mask-ROI_HCP.nii")
ROI_coords_file = op.join(data_path_mask, "ROI_coords-ROI_HCP.txt")
ROI_MNI_coords_file =op.join(data_path_mask, "ROI_MNI_coords-ROI_HCP.txt")
ROI_labels_file = op.join(data_path_mask, "ROI_labels-ROI_HCP.txt")

Then, we create our workflow and specify the base_dir which tells nipype the directory in which to store the outputs.

# workflow directory within the `base_dir`
conmat_analysis_name = 'nii_to_dyn_graph'

#from graphpype.pipelines import create_pipeline_nii_to_split_conmat # noqa
from graphpype.pipelines import create_pipeline_nii_to_conmat # noqa

main_workflow = pe.Workflow(name= conmat_analysis_name)
main_workflow.base_dir = data_path

Then we create a node to pass input filenames to DataGrabber from nipype

data_dyn_graph = json.load(open(op.join(op.dirname("__file__"),"params_dyn_graph.json")))
pprint.pprint({'graph parameters': data_dyn_graph})

subject_ids = data_dyn_graph["subject_ids"]
func_sessions = data_dyn_graph["func_sessions"]
conf_interval_prob = data_dyn_graph["conf_interval_prob"]

infosource = pe.Node(interface=IdentityInterface(
    fields=['subject_id','session']),
    name="infosource")

infosource.iterables = [('subject_id', subject_ids),
    ('session', func_sessions)]

Out:

{'graph parameters': {'con_den': 0.01,
                      'conf_interval_prob': 0.05,
                      'func_sessions': ['rest'],
                      'offset': 15,
                      'radatools_optim': 'WS tfrf 100',
                      'subject_ids': ['01'],
                      'win_length': 30}}

and a node to grab data. The template_args in this node iterate upon the values in the infosource node

datasource = pe.Node(interface=nio.DataGrabber(
    infields=['subject_id','session'],
    outfields= ['img_file','gm_anat_file','wm_anat_file','csf_anat_file']),
    name = 'datasource')

datasource.inputs.base_directory = data_path
datasource.inputs.template = '%ssub-%s%s%s%s'
datasource.inputs.template_args = dict(
img_file=[["wr",'subject_id',"_task-",'session',"_bold.nii"]],
gm_anat_file=[["rwc1",'subject_id',"",'',"_T1w.nii"]],
wm_anat_file=[["rwc2",'subject_id',"",'',"_T1w.nii"]],
csf_anat_file=[["rwc3",'subject_id',"",'',"_T1w.nii"]],
rp_file=[["rp_",'subject_id',"_task-",'session',"_bold.txt"]],
       )

datasource.inputs.sort_filelist = True
win_length = data_dyn_graph["win_length"]
offset = data_dyn_graph["offset"]

### reasample images, extract time series and compute correlations
#cor_wf = create_pipeline_nii_to_split_conmat(main_path=data_path,
                                       #conf_interval_prob=conf_interval_prob,
                                       #win_length=win_length,
                                       #offset=offset,
                                       #resample=True, background_val=0.0)

cor_wf = create_pipeline_nii_to_conmat(main_path=data_path,
                                       conf_interval_prob=conf_interval_prob,
                                       resample=True, background_val=0.0,
                                       split=True, win_length=win_length,
                                       offset=offset)

### link the datasource outputs to the pipeline inputs
main_workflow.connect(datasource, 'img_file', cor_wf, 'inputnode.nii_4D_file')
main_workflow.connect(datasource, 'gm_anat_file', cor_wf,
                      'inputnode.gm_anat_file')
main_workflow.connect(datasource, 'wm_anat_file', cor_wf,
                      'inputnode.wm_anat_file')
main_workflow.connect(datasource, 'csf_anat_file', cor_wf,
                      'inputnode.csf_anat_file')
main_workflow.connect(datasource, 'rp_file', cor_wf, 'inputnode.rp_file')

### extra arguments: the template used to define nodes
cor_wf.inputs.inputnode.ROI_mask_file = ROI_mask_file
cor_wf.inputs.inputnode.ROI_coords_file = ROI_coords_file
cor_wf.inputs.inputnode.ROI_MNI_coords_file = ROI_MNI_coords_file
cor_wf.inputs.inputnode.ROI_labels_file = ROI_labels_file

We then connect the nodes two at a time. We connect the output of the infosource node to the datasource node. So, these two nodes taken together can grab data.

main_workflow.connect(infosource, 'subject_id', datasource, 'subject_id')
main_workflow.connect(infosource, 'session', datasource, 'session')

# This parameter corrdesponds to the percentage of highest connections retains # for the analyses. con_den = 1.0 means a fully connected graphs (all edges # are present)

# density of the threshold
con_den = data_dyn_graph['con_den']

# The optimisation sequence
radatools_optim = data_dyn_graph['radatools_optim']

from graphpype.pipelines import create_pipeline_conmat_to_graph_density ## noqa

graph_workflow = create_pipeline_conmat_to_graph_density(
    data_path, con_den=con_den, optim_seq=radatools_optim, multi = True)

main_workflow.connect(cor_wf, 'compute_conf_cor_mat.Z_conf_cor_mat_file',
                      graph_workflow, "inputnode.conmat_file")

# To do so, we first write the workflow graph (optional) main_workflow.write_graph(graph2use=’colored’) # colored

# and visualize it. Take a moment to pause and notice how the connections # here correspond to how we connected the nodes.

#from scipy.misc import imread  # noqa
#import matplotlib.pyplot as plt  # noqa
#img = plt.imread(op.join(data_path, conmat_analysis_name, 'graph.png'))
#plt.figure(figsize=(8, 8))
#plt.imshow(img)
#plt.axis('off')
#plt.show()

# Finally, we are now ready to execute our workflow.

main_workflow.config['execution'] = {'remove_unnecessary_outputs': 'false'}

main_workflow.run()


## Run workflow locally on 2 CPUs
#main_workflow.run(plugin='MultiProc', plugin_args={'n_procs': 2})

Out:

(360, 3)
[  0   1   3   4   5   6   7   8   9  10  11  12  13  14  16  17  18  19
  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37
  39  40  42  51  52  54  55  56  57  58  59  60  61  62  63  64  65  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  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 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
 142 143 144 145 146 147 148 149 150 152 153 154 155 156 157 158 159 160
 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
 215 216 217 219 220 222 223 229 230 231 232 233 234 235 236 237 238 239
 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
 314 315 316 317 318 319 320 321 322 324 325 326 327 328 329 330 332 333
 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
 352 353 354 355 356 357 358 359]
Transposing data_matrix shape (332, 300) -> (300, 332)
(332, 300)
Split 0 :  0 30 (332, 30)
Split 1 :  15 45 (332, 30)
Split 2 :  30 60 (332, 30)
Split 3 :  45 75 (332, 30)
Split 4 :  60 90 (332, 30)
Split 5 :  75 105 (332, 30)
Split 6 :  90 120 (332, 30)
Split 7 :  105 135 (332, 30)
Split 8 :  120 150 (332, 30)
Split 9 :  135 165 (332, 30)
Split 10 :  150 180 (332, 30)
Split 11 :  165 195 (332, 30)
Split 12 :  180 210 (332, 30)
Split 13 :  195 225 (332, 30)
Split 14 :  210 240 (332, 30)
Split 15 :  225 255 (332, 30)
Split 16 :  240 270 (332, 30)
Split 17 :  255 285 (332, 30)
Split 18 :  270 300 (332, 30)
19
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
Transposing data
Computing Pearson correlation
(332, 332)
(82010, 3)
(332, 332)
(58140, 3)
(332, 332)
(51364, 3)
(332, 332)
(45840, 3)
(332, 332)
(55518, 3)
(332, 332)
(62114, 3)
(332, 332)
(60070, 3)
(332, 332)
(63184, 3)
(332, 332)
(61066, 3)
(332, 332)
(53962, 3)
(332, 332)
(55850, 3)
(332, 332)
(61642, 3)
(332, 332)
(65092, 3)
(332, 332)
(72346, 3)
(332, 332)
(69644, 3)
(332, 332)
(58350, 3)
(332, 332)
(57584, 3)
(332, 332)
(51204, 3)
(332, 332)
(39824, 3)
Loading Pajek_net_file for reading node_corres
[[   0    0    0 ...    0    0    0]
 [   0    0 1838 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(147,) (147, 147)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada0/Z_List.lol
[ 7  1  1  1  3  1  4  0  7  4  4  3  4  4  4  3  3  0  6  4  1  9  9  1
  5  6  6  6  5  3  3  3  3  3  3  2  5  2  3  3 10  2  2  2  0  0  0  0
  0  2  2  2  0  0  5  2  5  0  4  0  4  1  1  0  0  1  3  3  0  5  0  0
  2  4  4  1  1  1  1  1  3  1  4  1  0  1  0  7  4  4  3  4  4 11 11  1
  6  4  2  6 12  3  3 12  3  2  5  3  2  6  2  1  0  2  0  2  2  2  2  2
  0  8  8  0  5  2  0  2  2  1 10  2  1  4  1  1  0  1  2  5  1  5  0  0
  0  8  6]
Computing node roles

Node roles:
*Hubs 25/non-hubs 114
*provincials 96/connectors 51
Loading Pajek_net_file for reading node_corres
[[   0    0    0 ...    0    0    0]
 [   0    0 1343 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(155,) (155, 155)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada1/Z_List.lol
[ 1  4  4  1  3  4  2  2  3  0 10  1  5  2  7 11  2  2 12 13 14 14  9  7
  7 15 15  3  3  3  3  1  6  5  6  6 16 17 12  0  0  0  0  5  5  0  0  0
  5  5  0  2  0  3  0 18  1  7  1  3 10  8  1  2  2  1  1  0  1  1  2  0
  5  0  0 19 19  4  4  4  4  4  1 11  4  2  2  4 13  4  1  1  1  2  7  2
  2  1  1 20 20  7  3  6  0  8 21 21  9  9  0 22  8  8  8  6  6  0 17  6
  0  0  0  6  5  0 16  5  5  5  0  0  3  0  0  0  3  0 18  3 22  4 23 23
  2  1  4  0  1  1 24  9  0 24  3]
Computing node roles

Node roles:
*Hubs 26/non-hubs 99
*provincials 134/connectors 21
Loading Pajek_net_file for reading node_corres
[[   0    0    0 ...    0    0    0]
 [   0    0 1677 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(125,) (125, 125)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada2/Z_List.lol
[ 2  3  3  2  3  2  0  0  1  2  1  7 11  0  0  0  4 12 13  8 14  8  0  0
  1  0 15  1  5  3  1 16  1  6  1  5  1  0  1  0  6  2  2  0  0  3 17  0
  0  2  2  1  2  7 18  1 19  1  9  9  3  2  3  3  3  2  3 12  2  0  0  2
  2  1  2 11  0  0  0 18  4  4  4 13 14  8  1 20 21 21 10 10 20  1  0 22
 22  5 15  1  1  6  5 16  1  0  1  1  6  0  1  3  0  2 17  0  2  3  1 19
  7  2 10  1  9]
Computing node roles

Node roles:
*Hubs 18/non-hubs 83
*provincials 105/connectors 20
Loading Pajek_net_file for reading node_corres
[[   0    0    0 ...    0    0    0]
 [   0    0 1584 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(94,) (94, 94)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada3/Z_List.lol
[ 1  2  2  1  2  1  0  1  0  9 10  4 10 11  5 11  4 12 13  0  0  0  0  0
  0  0  0 14  3  3  2 15  1  1  0  1 16  0  0  0  0  6  6  2  2  2  2  1
  2  3  1  1  1  0  9  7  4  5  5  8  7  8  8  3 17 18  1 12  0 13  0  0
  0  0  0  0 14  0  1 18  1 15  1  2  0  0  0 16  2  3  7 17  0  6]
Computing node roles

Node roles:
*Hubs 19/non-hubs 55
*provincials 81/connectors 13
Loading Pajek_net_file for reading node_corres
[[   0    0    0 ...    0    0    0]
 [   0    0 1398 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(148,) (148, 148)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada4/Z_List.lol
[ 3  1  1  3  1 12  0  1  0  2  2  2 13  3  3  7 14 15 15  8  8  2  7  7
 16 17 18 19  3 19  3 20  0  4  0  1  0  0  0 21  0  1  0  3  5  5  9  2
  3  3  0  1  3 22  0 13  4  5 18  0  4  0  4  6  6  1  1  3  3  1  1  7
  5  2  5  1  5  0  0  0  5  9 12  2 17  6  2  7 23 23  6  8  2  2  2  2
  8 24  4  4  5 14  6  2 10  6 11  4 20 10  0  4  0 11  0  1  4  4  0  0
  0  1  4  0  9 25 25 10  5  5  2  2  3  1  0 21  0 22  1  4 16  6 24  0
 11  4  5  8]
Computing node roles

Node roles:
*Hubs 24/non-hubs 96
*provincials 124/connectors 24
Loading Pajek_net_file for reading node_corres
[[   0    0 1168 ...    0    0    0]
 [   0    0 1303 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(167,) (167, 167)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada5/Z_List.lol
[ 1  6  6  1  3  8  9 11  1 10 10  1 10  3 15  0  0  0  8  8  3  8  3  0
  3  0  0  0 13 13  7 16 14  6 12 12  1  2  4  6  3  1  1  1  0  0  4  2
  1  4  1  0  4  4 17  0  0  0  1  1  1 10  1 18  4  2  7 12  4  3  2  4
  2  5  3  6 18  6  1  1  2  3  9  0 11  9  2  9  4  1  1  4 15  0 11  2
 19  0  0  5  3  8  3  3  3  3  3 19  3 13  5  5  5  5  7  1 16  5  7  7
 14  7  2 12  2  1  2  4  7  6  1  2  2  0  0  2  4  4  4  2  2  1  0  2
  0  5  9 17  0  0  0  1  6  1  1  0  4 10 11  1 14  5  4  7  0  0  3]
Computing node roles

Node roles:
*Hubs 24/non-hubs 133
*provincials 130/connectors 37
Loading Pajek_net_file for reading node_corres
[[   0    0    0 ...    0    0    0]
 [   0    0 1138 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(182,) (182, 182)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada6/Z_List.lol
[ 6 13 13  6  2  1  5  3  0  4 14 15  3  0 16  5  2  2  2  2  2  4 10  0
  5 10  0  0  7  0  0  7  1  3 17  1 17  2  9  2  8  7  8  1  1  1  7  1
  7  2  2  4  1  4  3  1  3  9  0  9  3  3  4  6  5  1  0  0  3  3 14 11
  5  0  5  6  6  3 15  6  3  1  7  7  4  8  5 10 10  6  6  6  1  2  1  8
  5  0  8  9  8  8  3  3 11 11  0  0 16  2  2 18 18  8 10  2  2 11  1  5
  5  0  9  5  1  1  1  3  3  9 10  2  2  2 12 12  2  7 12  4  1  4  2  9
  1  9  0  0  3  3  4  4  4  1  1  3  0  5  2 10  8 11 11  0  5  0  6  3
  6  0  8  0  0  1  4  7  5  4  4  7  9 10]
Computing node roles

Node roles:
*Hubs 35/non-hubs 135
*provincials 133/connectors 49
Loading Pajek_net_file for reading node_corres
[[   0    0    0 ...    0    0    0]
 [   0    0 1584 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(168,) (168, 168)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada7/Z_List.lol
[ 2  2  2  2 11  0  1  0  5 12  0 13  0 14  0 15  5  5  3  5  5 12  3  3
  3  1  1  1  1  1  7  6  7  6  3  8  8  0  3  4  1  4  3  1  0  4  0  4
 16  0  4  0  4  0  7  0  0 15  6  1 13  9  6  5  2  0  2  0  4  4  3  0
  2  0  0  7  7  2  2  2  2  2 11  1  1  1  2  5  5  2  4  2  2  0  0 17
  9  5  5  3  5  3 18 18 10  1  1 19 19  1  7  6 20  1 21 21  1  1  1  0
  0 20 10  1  0  3 22  6  3 22  1  0  4 16  6  4  0  4  4  4  0  0  0  0
  4  1  0  8  6  3 10  2 17  9  3  5  3  2  2  0  2 14  2  0  0  0  0  0]
Computing node roles

Node roles:
*Hubs 27/non-hubs 114
*provincials 146/connectors 22
Loading Pajek_net_file for reading node_corres
[[   0    0    0 ...    0    0    0]
 [   0    0 1392 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(142,) (142, 142)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada8/Z_List.lol
[ 2  2  2  2  3  0  2  4  0  9  0  5  4 10  1  4  4  1  1  0  3  1  3  3
  3  3  3  3  6 11 11  0 12 12  6 13  7 14  7 15  1  4  0  1  2  0  1  5
  0  1  0  1  0 16  0  1  2  9  3  4  2  0  0  1  6  7  0 13  5  0  3  3
  2  2  2  2  1  2  4  4  2  0  2  1  0  0 10  1  4  4  1  1  3  3  0  4
  6 17 17  0  3  8 18  0  0 14  5  6  0  1  0 15 19  0  1  5 20  1  0 16
  0  0  1  0 19  1 18  2 20  4  2  2  0  0  2  2  0  8  8  0  0  0]
Computing node roles

Node roles:
*Hubs 19/non-hubs 96
*provincials 125/connectors 17
Loading Pajek_net_file for reading node_corres
[[   0 1167 1226 ...    0    0    0]
 [   0    0 1418 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(165,) (165, 165)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada9/Z_List.lol
[ 3  3  3  4  3  3  2  2  0  3 13 13  0  1  1 14  2  5  2  2  2 15  4  5
  4  5  4  7  4  6 16 17  6  6  8  7 18  6 18  6  5  1  1  1  1  1  1  9
  1  5  0  2  3  0  0  0  0  0  2  0  0  0  1  4  3  1  1  2  4  0  0 19
  2  1  1  0  9  4  4  3  3  3  3  3  3  0  3  2  2  3  0  3  0  0  1  5
 14  2  2  5  2  2  2 15 10 10  4  5  5  4  7  4 17  4  8 20  8 11  4 11
  4 21  1 20 12  1 12  1  1  9  1  0  2  0 12  0  0  0  0  0  0  5  0 21
  3  1  1  2  2  4  0 19 22 22  4 10  1 23  1 11  0  0  2 23 16]
Computing node roles

Node roles:
*Hubs 23/non-hubs 117
*provincials 162/connectors 3
Loading Pajek_net_file for reading node_corres
[[   0    0 1312 ...    0    0    0]
 [   0    0 1840 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(149,) (149, 149)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada10/Z_List.lol
[ 1  1  1  1  1  1  3  3  0  1 10 10  0  0  3 11  3  3  3  5 12  5  8 13
  6  5  4 14  4  4  9  6  4  4  4  4 15 12  2  0  2  2  2  0  2  2  2  8
  0 16  1  0  0  0  0  7  0 17 18  6  5 15  1  2  3  1  0 17  1  0 19  0
  2  0 20  0 21  1  1  1  1  1  1  1  1  3  3  1 22  1 22  0  0  2  2  7
  3 11  3  6  6 13  8  5  6  5  4 14  4  4  9  9  2  5 23  4  2  2  7  2
 24  2 24 20  0 16  0  7  0  0  0  0  0 18  1  2  2  7  1  1  0  1 19 25
  2 23  0 25 21]
Computing node roles

Node roles:
*Hubs 20/non-hubs 97
*provincials 149/connectors 0
Loading Pajek_net_file for reading node_corres
[[   0    0    0 ...    0    0    0]
 [   0    0 1684 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(165,) (165, 165)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada11/Z_List.lol
[ 1  1  1  1  1 13 13  1  3  3  0  1  0 11  3  3  3  3  3  2  9 14 14  4
  5  5  5  8 10 15  4  2  5  5  4  9 11  2  2 10  2 10  6  2  4  4  0  6
  6  1  0 11  0  0  6  0  0 16  7  7  2  4  1  8  3  1  0  7  1  0  4 17
 10  2  2  0  0 18 18  1 12 12  1  1  1  1  7  1  3  1  4  1  1  1  0  2
  9  3  3  3  0  4  4  5  8  8  5  5  8  8  2  4  0 19  5  2 20  2  2  2
  2  6  2  2  0  6  0  2  6  0  6  0  7  0  0 16  0 15  7  2  3  1  9  9
  8  3  7  1  1  0  0 12  0  1 17 21  2  2 19  0  0 20  7 21  5]
Computing node roles

Node roles:
*Hubs 33/non-hubs 114
*provincials 160/connectors 5
Loading Pajek_net_file for reading node_corres
[[   0    0    0 ...    0    0    0]
 [   0    0 1374 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(173,) (173, 173)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada12/Z_List.lol
[ 3  7  7  7  8  2  1  0 14  1 16  4 10 17 14  5  0  0  0  5  5  2  0  0
 11  0  6  6  6  2  5  2  0 11 11 18  0  8 10  0  6 19  9  3  3  3  9  2
  0  1  3  3  1 10  3  1  1  3 20  1  1  1  1  2  2  2 21  5  0 16  0 17
  0  4  1  2  4  4  0 15  4  6  9  1  3 10  3  7  7  2  0 12  0  0 12  2
  1 12 15  4  4  8 14  2  5  0  0  0  2  4  2  2 13 13 13  0  0  0  1  0
  0  5  0  0  1 11 18  0  2  1  3  9  3 13  0  1  3  1 19  3  1 20  3  1
  1  1  1  1  1  6  2 21  5  0 12  8  8  0  0  0  4  1  4  4  4 15  4  4
  9  0  2  1  1]
Computing node roles

Node roles:
*Hubs 30/non-hubs 131
*provincials 139/connectors 34
Loading Pajek_net_file for reading node_corres
[[   0 1420 1447 ...    0    0    0]
 [   0    0 1716 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(186,) (186, 186)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada13/Z_List.lol
[ 2  2  2  2 10  8  1  2  6  3  1 11  1  4  0  7  3  0  6  6  5  5  0  0
  0  5 12  3  4 12  3  3  7  7  7  0  1  8  0  9  3  9  6  5  0  0  0  0
  0  0  0  5  0  0  1  0  0  1  4  4  1  0  1  4  4 13  7  1  1  4  4  7
  7  0  5 11  5  6  7  6  2  4 14  4  1  0  0  1  4  0  2  2  2  2  2  2
 10  0  2  6  3  2  8  2  4  1  1  4  5  6  3  2  0  6  6  5  0 14  0  0
  0  0  0  3  3  3 15  6  3  6  1  7  3  1  1  9  3  6  0  5  0  5  0  5
  4  0  3  1  4  1  1  4  7 13 15  1  1  1  4  1  7  2  0  6  2  5  5  3
  3  3  2  2  4  1  2  4  2  4  1  0  0  0  3  3  1  1]
Computing node roles

Node roles:
*Hubs 27/non-hubs 147
*provincials 156/connectors 30
Loading Pajek_net_file for reading node_corres
[[   0 1481 1607 ...    0    0    0]
 [   0    0 1854 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(171,) (171, 171)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada14/Z_List.lol
[ 0  0  0  0  0 12  5  0 13 14  1  0 15  2  5 11 13  2  3  7  4  4  1  9
  2  9  9  2  2  6  6  6  4  1  3  2  4  3  3  3  5  3  4  3  4  4  1  5
  5  1 16 17  4  6  1  1  1  3  6  6  0  7  0  3 10  2  8  0 17  1  2  1
  3  1 16  9  0  0  0  0  0  0  0  5  0 14  0  1  0  7  1  7  1  3  7  6
  2 10 11  0  4  1  4 12 10 10  2  2  2  2  2  2  4  5  2  5  2  4  4  8
  3  3  3  4  3  7  5  5  0  1  6  1  7  6  6  5  3  1  1  5  3  6 11  3
  7  8  0  3  3  2  2  8  0  0  5  1  1  1 15  0  2  0  1  1  7  2  8  1
  3  4  2]
Computing node roles

Node roles:
*Hubs 30/non-hubs 129
*provincials 140/connectors 31
Loading Pajek_net_file for reading node_corres
[[   0 1391 1420 ...    0    0    0]
 [   0    0 1551 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(143,) (143, 143)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada15/Z_List.lol
[ 2  2  2  2 10  1  2  9  0  2  0  5  9  6  9  7  1  1  8  4  8  8  4  4
  4  4  1  1  1  3  3  5  1  3  3  1  1  0  0  0  0  5  0 11  4  0  0  3
  1  2  3  4  2 11  0  0  5  3  1  0  5  3  8  2  2  2  2  2  2 10 12  2
  7  2  1  2  2  0  1  0  3  7  6  1  1  1  4  4  4  4  4  1  1 13  1  0
 14 12  3  3  0  3  3  3 15  1  3  1  2  0 15  3  1  6  0  0  0  1  0  0
  4  6  1 14  2  3  3  4  7  2  2  0  0  0  2  0  5  3  3  0  5  5 13]
Computing node roles

Node roles:
*Hubs 24/non-hubs 107
*provincials 127/connectors 16
Loading Pajek_net_file for reading node_corres
[[   0 1409 1314 ...    0    0    0]
 [   0    0 1407 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(159,) (159, 159)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada16/Z_List.lol
[ 1  1  1  1 12  9  1  6  0  1  0  7  2  6  6  6  7  3  9 13  6 13  6  5
  5  5 14  0  3  8  4  4  2  2  3  2  4  5  2  3  0  0  0  0 15  2  0  0
  5  0  0  0  0  2  5  5  7  7  1  4  6  6  6  1  0  1  0 16  3  5  0  2
  2 10 10  1  1  1  1 12  1  6 17  1  3  0  1  0  0  0  3  4  7  0  3  3
 18 18  8  6  7 14  2 19 19  0  8  3  4  7  2  4  2 11  4  2  5  7  4  3
 10  0 11  2  7  0 11  5  8 20  0  0  0  2  0  5 20 15  3  1  4  4  6 17
  1  1  2  0  0  0  1 16 21  5  0  2  4 21  9]
Computing node roles

Node roles:
*Hubs 23/non-hubs 116
*provincials 133/connectors 26
Loading Pajek_net_file for reading node_corres
[[   0 1298    0 ...    0    0    0]
 [   0    0 1239 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(126,) (126, 126)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada17/Z_List.lol
[ 1  1  1  8  1  9  1  7  0  1  0  2  6  9  7  0 10  4 11 11  3  3  3  3
  4  0  4  3  5  6  6  6  4  0  2  2  0  6  0  0  0  3  0  0  0  6  3  3
 12  4  1  5  7  1  1  1  0  2  0  2  6  0  1  1  8  8  1  7  7  1  4  2
  1  2  0  2  0  3  0  5  2 13  3 13  2  4  5  2  2  2  3  6  5  4  2 10
  5  2  0  0  7  0  0  0  0  3 12  4  1  5  5  3  7  1  1  2  0  0  0 14
  0  1  0  0  2 14]
Computing node roles

Node roles:
*Hubs 23/non-hubs 93
*provincials 101/connectors 25
Loading Pajek_net_file for reading node_corres
[[   0    0    0 ...    0    0    0]
 [   0    0 1393 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 ...
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]
 [   0    0    0 ...    0    0    0]]
(123,) (123, 123)
Loading community belonging file /home/INT/meunier.d/miniconda3/Packages/graphpype/data/data_nii/nii_to_dyn_graph/graph_den_pipe_den_0_01/_session_rest_subject_id_01/community_rada/mapflow/_community_rada18/Z_List.lol
[ 1  1  1  1  1  1  0  1  0  3  2  4  2  6  6  6 10 10  4  2 11  4 12 13
  0 14 15 16  5 17 18  5 16  0  7  1  0  8  0 19  0  0  0  4  0  3 11  4
  1  9  1  0  3  7  0 15 20  0  8  8 19  1  1  1  1  1  1 21  1 12  3  1
  3  0  0  2  2  9 22  7  3  2 23  6  6 22 14  0  2  5  2  5 18  4  1  0
  0 24  7  7  0  0 24  0  3  4  1  9 21 23  1  1  0  0  0  5 17 20 13  0
  5  0  5]
Computing node roles

Node roles:
*Hubs 22/non-hubs 73
*provincials 119/connectors 4

## plotting

#from graphpype.utils_visbrain import visu_graph_modules, visu_graph_modules_roles
#from visbrain.objects import SceneObj, BrainObj # noqa

#sc = SceneObj(size=(1000, 1000), bgcolor=(1,1,1))

#res_path = op.join(
    #data_path, conmat_analysis_name,
    #"graph_den_pipe_den_"+str(con_den).replace(".", "_"),
    #"_session_rest_subject_id_01")

#lol_file = op.join(res_path, "community_rada", "Z_List.lol")
#net_file = op.join(res_path, "prep_rada", "Z_List.net")
#roles_file = op.join(res_path, "node_roles", "node_roles.txt")

#views = ["left",'top']

#for i_v,view in enumerate(views):

    #b_obj = BrainObj("B1", translucent=True)
    #sc.add_to_subplot(b_obj, row=0, col = i_v, use_this_cam=True, rotate=view,
                        #title=("Modules"),
                        #title_size=14, title_bold=True, title_color='black')

    #c_obj,s_obj = visu_graph_modules(lol_file=lol_file, net_file=net_file,
                                #coords_file=ROI_MNI_coords_file,
                                #inter_modules=False)

    #sc.add_to_subplot(c_obj, row=0, col = i_v)
    #sc.add_to_subplot(s_obj, row=0, col = i_v)

    #b_obj = BrainObj('B1', translucent=True)
    #sc.add_to_subplot(b_obj, row=1, col = i_v, use_this_cam=True, rotate=view,
                    #title=("Modules and node roles"),
                    #title_size=14, title_bold=True, title_color='black')

    #c_obj,list_sources = visu_graph_modules_roles(
        #lol_file=lol_file, net_file=net_file, roles_file=roles_file,
        #coords_file=ROI_MNI_coords_file, inter_modules=True, default_size=10,
        #hub_to_non_hub=3)

    #sc.add_to_subplot(c_obj, row=1, col = i_v)

    #for source in list_sources:
        #sc.add_to_subplot(source, row=1, col = i_v)



#sc.preview()

Total running time of the script: ( 7 minutes 16.839 seconds)

Gallery generated by Sphinx-Gallery