Pipeline making use of `postprocessing` nodes to generate a connectivity matrix and distance matrix.
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')])
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')
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)')