Pipeline making use of `postprocessing` nodes to generate a connectivity matrix and distance matrix.
/Users/bsipes/opt/anaconda3/envs/tracts/lib/python3.9/site-packages/bids/config.py:39: FutureWarning: Setting 'extension_initial_dot' will be removed in pybids 0.16.
  warnings.warn("Setting 'extension_initial_dot' will be removed in pybids 0.16.",
/Users/bsipes/opt/anaconda3/envs/tracts/lib/python3.9/site-packages/bids/config.py:39: FutureWarning: Setting 'extension_initial_dot' will be removed in pybids 0.16.
  warnings.warn("Setting 'extension_initial_dot' will be removed in pybids 0.16.",
/Users/bsipes/opt/anaconda3/envs/tracts/lib/python3.9/site-packages/nilearn/datasets/__init__.py:93: FutureWarning: Fetchers from the nilearn.datasets module will be updated in version 0.9 to return python strings instead of bytes and Pandas dataframes instead of Numpy arrays.
  warn("Fetchers from the nilearn.datasets module will be "

class connectome[source]

connectome(BIDS_dir, atlas_list, SIFT_mask=False, skip_tuples=[()], debug=False)

Create a pipeline that produces connectomes based on input atlases and streamlines, the pipeline will create sub-graphs based on inputs BIDS directory subject & session combinations.

Inputs:

 - BIDS_dir (str): base BIDS directory path
 - atlas_list (List of strings): names of atlases: aal, brainnectome, desikan-killiany, default is set to brainnectome for now.
 - SIFT_mask (bool): Uses 5ttgen tissue segmentation during SIFT2. Defaults to False. If in pipeline `gmwmi = False`, this should also be false.
 - debug (bool): Default = False; if True, saves node outputs and log files.

Example

Workflow creating a connectivity matrix and a distance adjacency matrix for brainnectome and desikan-killiany atlas.

post_wf = connectome(BIDS_dir='./testing/BIDS_dir', 
                     atlas_list=['./testing/Atlases/BN_Atlas_246_1mm.nii.gz', 
                                 './testing/Atlases/DK_Atlas_86_2mm.nii.gz'], 
                     skip_tuples=[('11045', '02')])
Creating layout of data directory, might take a while if there are a lot of subjects

Take a look at the post-processing workflow:

from IPython.display import Image

post_wf.create_nodes()
post_wf.connect_nodes(wf_name='connectomes')
post_wf.draw_pipeline(graph_type='flat')
Image('./testing/BIDS_dir/derivatives/pipetography/graph/postprocessing.png')
Data sink (output folder) is set to ./testing/BIDS_dir/derivatives/pipetography
211206-12:01:59,98 nipype.workflow INFO:
	 Generated workflow graph: /Users/xihe/lab/pipetography/testing/BIDS_dir/derivatives/pipetography/graph/postprocessing.png (graph2use=flat, simple_form=True).
post_wf.run_pipeline(parallel=2)

View outputs:

!tree ./testing/BIDS_dir/derivatives/pipetography
#example
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

# load matrices:
CM = pd.read_csv('./testing/BIDS_dir/derivatives/pipetography/sub-01/ses-002/connectomes/BN_Atlas_246_1mm/connectome.csv', header = None)
DM = pd.read_csv('./testing/BIDS_dir/derivatives/pipetography/sub-01/ses-002/connectomes/BN_Atlas_246_1mm/distances.csv', header = None)

# Visualize:
fig, (ax1, ax2) = plt.subplots(1,2, sharey = True, figsize = (12,12))
# log1p - calculates log(1+x)
cdk=ax1.imshow(np.log1p(CM), cmap = plt.get_cmap('inferno'), interpolation = 'nearest')
ax1.set_title('BNA246 Connectivity Matrix')
cbar=fig.colorbar(cdk, ax=ax1, shrink=0.4)
cbar.set_label('Log Scale Streamline Counts')

ddk=ax2.imshow(DM, interpolation = 'nearest')
ax2.set_title('BNA246 Distance Adjacency Matrix')
dbar=fig.colorbar(ddk, ax=ax2, shrink=0.4)
dbar.set_label('Mean Streamline Length (mm)')