# Beginner: Connectome pipeline (Updated)

**URL:** <https://community.mrtrix.org/t/beginner-connectome-pipeline-updated/373>\
**Category:** Uncategorized\
**Created:** [August 3, 2016, 12:19pm UTC](https://community.mrtrix.org/t/beginner-connectome-pipeline-updated/373 "2016-08-03T12:19:12Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![ElijahMak](https://community.mrtrix.org/user_avatar/community.mrtrix.org/elijahmak/32/204_2.png) [@ElijahMak](https://community.mrtrix.org/u/ElijahMak)\
**Post date:** [August 11, 2016, 6:19pm UTC](https://community.mrtrix.org/t/beginner-connectome-pipeline-updated/373/5 "2016-08-11T18:19:31Z")

</div>

Thanks for the tips. I have made some changes to the workflow to get from the DWI and Freesurfer-T1 to an ACT-informed connectome matrix.

I have pasted the steps and outputs for a single subject with a neurodegenerative disease. Will appreciate any comments especially with regards to the `tckgen` step. The next thing I will like to do is to weight these matrices by (a) mean FA and to (b) normalise the streamline counts by the average volumes between 2 regions 🙂

## A. Registration of T1 and aparc+aseg.mgz to processed DTI

1. `recon-all` the T1 data with [Freesurfer](http://freesurfer.net)

2. `bbregister` b0 images to orig.mgz / brainmask.mgz

3. `tkregister` to check/edit registration. This matrix will be used to perform inverse registration of the T1 to DTI space without losing resolution.

4. Refer to another MRtrix [thread](https://community.mrtrix.org/t/registration-of-structural-and-diffusion-weighted-data/203/11) for structural-diffusion registration  

## B. DWI processing

1. Denoise DWI  
`dwidenoise i.mif i_denoised.mif;`  
 ![](https://community.mrtrix.org/uploads/default/original/1X/c6c881af0d756c915123aedeb721ea0e74b67857.png)

2. Process diffusion data and perform bias-correction  
`dwipreproc -0 i_denoised.nii i_preproc.mif -rpe_none`  
`dwibiascorrect i_preproc.mif i_biascorrected.mif -fsl`  

3. Estimate response function  
`dwi2response tournier i_biascorrected.mif i_response.txt`  
 ![](https://community.mrtrix.org/uploads/default/original/1X/6bcb26549e96206cc32cad0e4982374ca1925a62.png)

4. FOD  
`dwi2fod csd i_biascorrected.mif i_response.txt i_fod.mif`  

## C. T1 Processing (after Freesurfer and Registration to DWI)

1. Derive tissue-segmented image  
`5ttgen freesurfer i_aparc+aseg_mrtransformed.mgz i_freesurfer_5TT.mif`

2. Visualise 5TT  
`5tt2vis i_freesurfer_5TT.mif i_freesurfer_5TT_vis.mif`  
@rsmith: Does this look right? The white spots (intensity = 2) correspond to locations of lesions on the WM. How can I deal with them?  

3. Modify the integer values in the parcellated image so that the numbers in the image corresponds to the rows and cols of the connectome  
`labelconvert i_aparc+aseg_mrtransformed.mgz /Applications/freesurfer/FreeSurferColorLUT.txt /Users/MacPro/mrtrix3/src/connectome/tables/fs_default.txt i_nodes.mif`

## C. Connectome generation

1. Streamline tractography  
`tckgen i_fod.mif i.tck -act i_FS_5TT.mif -backtrack -crop_at_gmwmi -seed_dynamic i_fod.mif -number 1M -maxlength 250`

2. Perform SIFT  
`tcksift i.tck i_fod.mif i_sift.tck -act i_FS_5TT.mif -term_number 500000`  

3. Map the streamlines to the parcellated T1 to produce the connectivity matrix  
`tck2connectome i.tck i_nodes.mif i_connectome.csv -zero_diagonal`  
Transform the matrix into a symmetric form where M is your matrix  
`M = M + triu(M,1)'` \<-- Thanks, @rsmith ! [[see MRtrix thread](https://community.mrtrix.org/t/the-output-of-tck2connectome/345/2)]  
 ![](https://community.mrtrix.org/uploads/default/original/1X/dc87397f70a2063222829a06b64cdfbb857c6bc4.png)

4. View the connectome  
`mrview i_nodes.mif -connectome.init i_nodes.mif -connectome.load i_connectome.csv`  
 ![](https://community.mrtrix.org/uploads/default/original/1X/8bf6ffb884e99e149b6fe12fc9665d7bea5289fd.png)

5. Load connectivity matrices in MATLAB for analyses with [Brain Connectivity Toolbox](https://sites.google.com/site/bctnet/construction)

---

_[View the full topic](https://community.mrtrix.org/t/beginner-connectome-pipeline-updated/373)._
