|
58 | 58 | from nipype.workflows.dmri.camino.connectivity_mapping import select_aparc_annot
|
59 | 59 | from nipype.utils.misc import package_check
|
60 | 60 | import warnings
|
61 |
| -from nipype.workflows.dmri.connectivity.group_connectivity import pullnodeIDs |
| 61 | +from nipype.workflows.dmri.connectivity.nx import create_networkx_pipeline, create_cmats_to_csv_pipeline |
62 | 62 |
|
63 | 63 | try:
|
64 | 64 | package_check('cmp')
|
|
307 | 307 | Here we choose the Lausanne2008 parcellation scheme, since we are incorporating the CMTK parcellation step.
|
308 | 308 | """
|
309 | 309 |
|
310 |
| -creatematrix = pe.Node(interface=cmtk.CreateMatrix(), name="CreateMatrix") |
| 310 | +parcellation_name = 'scale500' |
311 | 311 | cmp_config = cmp.configuration.PipelineConfiguration()
|
312 | 312 | cmp_config.parcellation_scheme = "Lausanne2008"
|
313 | 313 | createnodes = pe.Node(interface=cmtk.CreateNodes(), name="CreateNodes")
|
314 | 314 | createnodes.inputs.resolution_network_file = cmp_config._get_lausanne_parcellation('Lausanne2008')[parcellation_name]['node_information_graphml']
|
315 | 315 |
|
| 316 | +creatematrix = pe.Node(interface=cmtk.CreateMatrix(), name="CreateMatrix") |
| 317 | +creatematrix.inputs.count_region_intersections = True |
| 318 | + |
316 | 319 | """
|
317 | 320 | Next we define the endpoint of this tutorial, which is the CFFConverter node, as well as a few nodes which use
|
318 | 321 | the Nipype Merge utility. These are useful for passing lists of the files we want packaged in our CFF file.
|
|
329 | 332 | gpickledNetworks = pe.Node(interface=util.Merge(2), name="NetworkFiles")
|
330 | 333 |
|
331 | 334 | """
|
332 |
| -We also create a node to calculate several network metrics on our resulting file, and another CFF converter |
| 335 | +We also create a workflow to calculate several network metrics on our resulting file, and another CFF converter |
333 | 336 | which will be used to package these networks into a single file.
|
334 | 337 | """
|
335 | 338 |
|
336 |
| -ntwkMetrics = pe.Node(interface=cmtk.NetworkXMetrics(), name="NetworkXMetrics") |
| 339 | +networkx = create_networkx_pipeline(name='networkx') |
| 340 | +cmats_to_csv = create_cmats_to_csv_pipeline(name='cmats_to_csv') |
337 | 341 | NxStatsCFFConverter = pe.Node(interface=cmtk.CFFConverter(), name="NxStatsCFFConverter")
|
338 | 342 | NxStatsCFFConverter.inputs.script_files = op.abspath(inspect.getfile(inspect.currentframe()))
|
339 | 343 |
|
340 |
| -Matlab2CSV_node = pe.Node(interface=misc.Matlab2CSV(), name="Matlab2CSV_node") |
341 |
| -Matlab2CSV_global = Matlab2CSV_node.clone(name="Matlab2CSV_global") |
342 |
| -Matlab2CSV_cmatrix = Matlab2CSV_node.clone(name="Matlab2CSV_cmatrix") |
343 |
| -Matlab2CSV_meanfib = Matlab2CSV_node.clone(name="Matlab2CSV_meanfib") |
344 |
| -Matlab2CSV_medianfib = Matlab2CSV_node.clone(name="Matlab2CSV_medianfib") |
345 |
| -Matlab2CSV_fibstd = Matlab2CSV_node.clone(name="Matlab2CSV_fibstd") |
346 |
| - |
347 |
| -MergeCSVFiles_node = pe.Node(interface=misc.MergeCSVFiles(), name="MergeCSVFiles_node") |
348 |
| -rowIDs = pullnodeIDs(op.abspath(cmp_config._get_lausanne_parcellation('Lausanne2008')[parcellation_name]['node_information_graphml'])) |
349 |
| -MergeCSVFiles_node.inputs.row_headings = rowIDs |
350 |
| -MergeCSVFiles_node.inputs.extra_column_heading = 'subject' |
351 |
| -mergeCSVMatrices = pe.Node(interface=util.Merge(4), name="mergeCSVMatrices") |
352 |
| -MergeCSVFiles_cmatrices = pe.Node(interface=misc.MergeCSVFiles(), name="MergeCSVFiles_cmatrices") |
353 |
| -MergeCSVFiles_cmatrices.inputs.extra_column_heading = 'subject' |
354 |
| - |
355 | 344 | """
|
356 | 345 | Connecting the workflow
|
357 | 346 | =======================
|
|
547 | 536 |
|
548 | 537 | mapping.connect([(giftiSurfaces, CFFConverter,[("out","gifti_surfaces")])])
|
549 | 538 | mapping.connect([(giftiLabels, CFFConverter,[("out","gifti_labels")])])
|
550 |
| -mapping.connect([(creatematrix, CFFConverter,[("matrix_file","gpickled_networks")])]) |
| 539 | +mapping.connect([(creatematrix, CFFConverter,[("matrix_files","gpickled_networks")])]) |
551 | 540 | mapping.connect([(niftiVolumes, CFFConverter,[("out","nifti_volumes")])])
|
552 | 541 | mapping.connect([(fiberDataArrays, CFFConverter,[("out","data_files")])])
|
553 | 542 | mapping.connect([(creatematrix, CFFConverter,[("filtered_tractography","tract_files")])])
|
554 | 543 | mapping.connect([(inputnode, CFFConverter,[("subject_id","title")])])
|
555 | 544 |
|
556 | 545 | """
|
557 |
| -The graph theoretical metrics which have been generated are placed into another CFF file. |
| 546 | +The graph theoretical metrics are computed using the networkx workflow and placed in another CFF file |
558 | 547 | """
|
559 | 548 |
|
560 |
| -mapping.connect([(creatematrix, ntwkMetrics,[("matrix_file","in_file")])]) |
561 |
| -mapping.connect([(creatematrix, gpickledNetworks,[("matrix_file","in1")])]) |
562 |
| -mapping.connect([(ntwkMetrics, gpickledNetworks,[("gpickled_network_files","in2")])]) |
563 |
| -mapping.connect([(gpickledNetworks, NxStatsCFFConverter,[("out","gpickled_networks")])]) |
| 549 | +mapping.connect([(inputnode, networkx,[("subject_id","inputnode.extra_field")])]) |
| 550 | +mapping.connect([(creatematrix, networkx,[("intersection_matrix_file","inputnode.network_file")])]) |
564 | 551 |
|
| 552 | +mapping.connect([(networkx, NxStatsCFFConverter,[("outputnode.network_files","gpickled_networks")])]) |
565 | 553 | mapping.connect([(giftiSurfaces, NxStatsCFFConverter,[("out","gifti_surfaces")])])
|
566 | 554 | mapping.connect([(giftiLabels, NxStatsCFFConverter,[("out","gifti_labels")])])
|
567 | 555 | mapping.connect([(niftiVolumes, NxStatsCFFConverter,[("out","nifti_volumes")])])
|
568 | 556 | mapping.connect([(fiberDataArrays, NxStatsCFFConverter,[("out","data_files")])])
|
569 | 557 | mapping.connect([(inputnode, NxStatsCFFConverter,[("subject_id","title")])])
|
570 | 558 |
|
571 |
| -mapping.connect([(ntwkMetrics, Matlab2CSV_node,[("node_measures_matlab","in_file")])]) |
572 |
| -mapping.connect([(ntwkMetrics, Matlab2CSV_global,[("global_measures_matlab","in_file")])]) |
573 |
| -mapping.connect([(creatematrix, Matlab2CSV_cmatrix,[("matrix_mat_file","in_file")])]) |
574 |
| -mapping.connect([(creatematrix, Matlab2CSV_meanfib,[("mean_fiber_length_matrix_mat_file","in_file")])]) |
575 |
| -mapping.connect([(creatematrix, Matlab2CSV_medianfib,[("median_fiber_length_matrix_mat_file","in_file")])]) |
576 |
| -mapping.connect([(creatematrix, Matlab2CSV_fibstd,[("fiber_length_std_matrix_mat_file","in_file")])]) |
577 |
| -mapping.connect([(Matlab2CSV_node, MergeCSVFiles_node,[("csv_files","in_files")])]) |
578 |
| -mapping.connect([(inputnode, MergeCSVFiles_node,[("subject_id","out_file")])]) |
579 |
| -mapping.connect([(inputnode, MergeCSVFiles_node,[("subject_id","extra_field")])]) |
580 |
| - |
581 |
| -mapping.connect([(Matlab2CSV_cmatrix, mergeCSVMatrices,[("csv_files","in1")])]) |
582 |
| -mapping.connect([(Matlab2CSV_meanfib, mergeCSVMatrices,[("csv_files","in2")])]) |
583 |
| -mapping.connect([(Matlab2CSV_medianfib, mergeCSVMatrices,[("csv_files","in3")])]) |
584 |
| -mapping.connect([(Matlab2CSV_fibstd, mergeCSVMatrices,[("csv_files","in4")])]) |
585 |
| -mapping.connect([(mergeCSVMatrices, MergeCSVFiles_cmatrices,[("out","in_files")])]) |
586 |
| -mapping.connect([(inputnode, MergeCSVFiles_cmatrices,[("subject_id","out_file")])]) |
587 |
| -mapping.connect([(inputnode, MergeCSVFiles_cmatrices,[("subject_id","extra_field")])]) |
| 559 | +mapping.connect([(inputnode, cmats_to_csv,[("subject_id","inputnode.extra_field")])]) |
| 560 | +mapping.connect([(creatematrix, cmats_to_csv,[("matlab_matrix_files","inputnode.matlab_matrix_files")])]) |
588 | 561 |
|
589 | 562 | """
|
590 | 563 | Create a higher-level workflow
|
|
596 | 569 |
|
597 | 570 | connectivity = pe.Workflow(name="connectivity")
|
598 | 571 |
|
599 |
| -connectivity.base_dir = op.abspath('connectivity_tutorial_advanced') |
| 572 | +connectivity.base_dir = op.abspath('dmri_connectivity_advanced') |
600 | 573 | connectivity.connect([
|
601 | 574 | (infosource,datasource,[('subject_id', 'subject_id')]),
|
602 | 575 | (datasource,mapping,[('dwi','inputnode.dwi'),
|
|
0 commit comments