# Question about pipeline structure and use of already co-registered T1 and DWI images Hello everyone, I am currently building a pipeline for tractography and connectome generation using MRtrix3, and I have a few questions regarding the correct workflow

**URL:** https://community.mrtrix.org/t/question-about-pipeline-structure-and-use-of-already-co-registered-t1-and-dwi-images-hello-everyone-i-am-currently-building-a-pipeline-for-tractography-and-connectome-generation-using-mrtrix3-and-i-have-a-few-questions-regarding-the-correct-workflow/8721
**Category:** Uncategorized
**Created:** [March 11, 2026, 9:24am UTC](https://community.mrtrix.org/t/question-about-pipeline-structure-and-use-of-already-co-registered-t1-and-dwi-images-hello-everyone-i-am-currently-building-a-pipeline-for-tractography-and-connectome-generation-using-mrtrix3-and-i-have-a-few-questions-regarding-the-correct-workflow/8721 "2026-03-11T09:24:51Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Julia\_Falces\_Donoso](https://community.mrtrix.org/user_avatar/community.mrtrix.org/julia_falces_donoso/32/5420_2.png) [@Julia\_Falces\_Donoso](https://community.mrtrix.org/u/Julia_Falces_Donoso)
#### Post date: [March 11, 2026, 9:24am UTC](https://community.mrtrix.org/t/question-about-pipeline-structure-and-use-of-already-co-registered-t1-and-dwi-images-hello-everyone-i-am-currently-building-a-pipeline-for-tractography-and-connectome-generation-using-mrtrix3-and-i-have-a-few-questions-regarding-the-correct-workflow/8721/1 "2026-03-11T09:24:52Z")

</div>

Hello everyone,

I am currently building a pipeline for tractography and connectome generation using MRtrix3, and I have a few questions regarding the correct workflow.

First, I would like to confirm whether the processing steps I am currently following are appropriate. I have attached an image of the pipeline for reference, and I would appreciate any feedback on whether the structure is correct or if any steps are missing or unnecessary.

One specific question concerns the T1-to-DWI registration step. In my case, the T1 and DWI images I received are already co-registered. Because of this, I assume that the registration step may not be necessary.

However, I am unsure at which point in the pipeline I should start using the co-registered images. Specifically, I would like to understand:

- Should the co-registered images be introduced during the **T1 processing stage**?

- Should they instead be used during the **DWI processing stage**?

- Or should they only be used later during **tractography or connectome generation**?

In other words, when working with already co-registered T1 and DWI data, I would like to know at which stage of the pipeline these images should be incorporated.

I am also unsure whether some steps still require the **original T1 and DWI images** , or whether the **co-registered versions** should be used directly from the beginning.

Finally, I would also like to ask about the methodology I am following. I am currently using a tutorial as a guide to build the pipeline, but I also have a complete script containing all the steps. I would appreciate any advice on whether the tutorial approach is appropriate, or if it would be better to rely on the full script instead.

Tutorial of MRtrix3 that I’m following:

 ![Screenshot_2026-03-11_10-10-51](https://community.mrtrix.org/uploads/default/original/2X/4/4a60710cdc8f37ee450f1ef72bd852f206b169a5.png)

Script of my pipeline:

#!/bin/bash  
set -e  
set -x

############################################################

# INPUTS

############################################################

T1\_NII=“T1.nii.gz”  
DWI\_NII=“DWI.nii.gz”  
BVEC=“DWI.bvec”  
BVAL=“DWI.bval”

FS\_SUBJECTS\_DIR=“$HOME/freesurfer\_subjects”  
FS\_SUBJECT=“subject04”

# Adjust if needed:

FREESURFER\_LUT=“/usr/local/freesurfer/luts/FreeSurferColorLUT.txt”  
MRTRIX\_FS\_MAP=“/opt/mrtrix3/share/mrtrix3/labelconvert/fs\_default.txt”

############################################################

# 0) PREPARE DIRECTORIES

############################################################  
echo “============================================================”  
echo “STEP 0: PREPARE DIRECTORIES”  
echo “============================================================”

mkdir -p work  
cd work

export SUBJECTS\_DIR=“$FS\_SUBJECTS\_DIR”

############################################################

# 1) CONVERT INPUTS TO MRTRIX FORMAT

############################################################  
echo “============================================================”  
echo “STEP 1: CONVERT INPUTS TO MRTRIX FORMAT”  
echo “============================================================”

mrconvert ../“$T1\_NII” T1.mif  
mrconvert ../“$DWI\_NII” DWI\_raw.mif -fslgrad ../“$BVEC” ../“$BVAL” -datatype float32 -stride 0,0,0,1

############################################################

# 2) DWI PREPROCESSING

############################################################

# Your acquisition appears to be single phase-encoding with no reverse PE.

# If you actually have reverse PE / fieldmap data, this section should be changed.

echo “============================================================”  
echo “STEP 2: DWI PREPROCESSING”  
echo “============================================================”

dwidenoise DWI\_raw.mif dwi\_denoised.mif  
mrdegibbs dwi\_denoised.mif dwi\_denoised\_degibbs.mif

dwifslpreproc dwi\_denoised\_degibbs.mif dwi\_preproc.mif  
-rpe\_none  
-pe\_dir AP  
-eddy\_options " --slm=linear --data\_is\_shelled "

dwibiascorrect ants dwi\_preproc.mif dwi\_preproc\_bias.mif

############################################################

# 3) CREATE DWI REFERENCE IMAGE (MEAN B0)

############################################################  
echo “============================================================”  
echo “STEP 3: CREATE DWI REFERENCE IMAGE (MEAN B0)”  
echo “============================================================”

dwiextract dwi\_preproc\_bias.mif - -bzero | mrmath - mean mean\_b0\_dwi.mif -axis 3  
mrconvert mean\_b0\_dwi.mif mean\_b0\_dwi.nii.gz

############################################################

# 4) T1 BRAIN EXTRACTION FOR REGISTRATION

############################################################

# T1 is a better registration target than 5TT for FLIRT.

# Brain extraction is commonly used to improve T1\<-\>DWI registration robustness.

echo “============================================================”  
echo “STEP 4: T1 BRAIN EXTRACTION FOR REGISTRATION”  
echo “============================================================”

mrconvert T1.mif T1.nii.gz  
bet T1.nii.gz T1\_brain.nii.gz -R

############################################################

# 5) GENERATE 5TT IN T1 SPACE

############################################################

# MRtrix ACT requires a 5TT image derived from T1 anatomy aligned to DWI space.

echo “============================================================”  
echo “STEP 5: GENERATE 5TT IN T1 SPACE”  
echo “============================================================”

5ttgen fsl T1.mif 5TT.mif -premasked  
5ttcheck 5TT.mif  
5tt2vis 5TT.mif vis\_5TT.mif

############################################################

# 6) FREESURFER PARCELLATION IN T1 SPACE

############################################################

# recon-all creates aparc+aseg in anatomical space.

echo “============================================================”  
echo “STEP 6: FREESURFER PARCELLATION IN T1 SPACE”  
echo “============================================================”

recon-all -i T1.nii.gz -s “$FS\_SUBJECT” -all

mri\_convert “$SUBJECTS\_DIR/$FS\_SUBJECT/mri/aparc+aseg.mgz” aparc+aseg.nii.gz

labelconvert aparc+aseg.nii.gz  
“$FREESURFER\_LUT”  
“$MRTRIX\_FS\_MAP”  
nodes.mif

labelsgmfix nodes.mif T1.nii.gz “$MRTRIX\_FS\_MAP” nodes\_fixSGM.mif -premasked

############################################################

# 7) REGISTER DWI TO T1

############################################################

# Estimate transform using mean b0 → T1 brain.

# 6 DOF is usually appropriate for same-subject rigid alignment.

# Then invert it to map T1-derived images into DWI space.

echo “============================================================”  
echo “STEP 7: REGISTER DWI TO T1”  
echo “============================================================”

flirt -in mean\_b0\_dwi.nii.gz  
-ref T1\_brain.nii.gz  
-dof 6  
-cost normmi  
-omat diff2struct\_fsl.mat

convert\_xfm -omat struct2diff\_fsl.mat -inverse diff2struct\_fsl.mat

############################################################

# 8) TRANSFORM T1-DERIVED IMAGES INTO DWI SPACE

############################################################  
echo “============================================================”  
echo “STEP 8: TRANSFORM T1-DERIVED IMAGES INTO DWI SPACE”  
echo “============================================================”

mrconvert 5TT.mif 5TT.nii.gz  
mrconvert nodes\_fixSGM.mif nodes\_fixSGM.nii.gz

# 5TT: use trilinear interpolation for reslicing

flirt -in 5TT.nii.gz  
-ref mean\_b0\_dwi.nii.gz  
-applyxfm  
-init struct2diff\_fsl.mat  
-interp trilinear  
-out 5TT\_coreg.nii.gz

# Nodes/parcellation: use nearest neighbour to preserve integer labels

flirt -in nodes\_fixSGM.nii.gz  
-ref mean\_b0\_dwi.nii.gz  
-applyxfm  
-init struct2diff\_fsl.mat  
-interp nearestneighbour  
-out nodes\_fixSGM\_coreg.nii.gz

mrconvert 5TT\_coreg.nii.gz 5TT\_coreg.mif  
mrconvert nodes\_fixSGM\_coreg.nii.gz nodes\_fixSGM\_coreg.mif

############################################################

# 9) CREATE GMWMI SEED MASK IN DWI SPACE

############################################################

# For ACT seeding.

echo “============================================================”  
echo “STEP 9: CREATE GMWMI SEED MASK IN DWI SPACE”  
echo “============================================================”

5tt2gmwmi 5TT\_coreg.mif gmwmi\_seed\_coreg.mif

############################################################

# 10) RESPONSE FUNCTION ESTIMATION

############################################################

# dhollander is a robust default when using single-shell or multi-shell data.

echo “============================================================”  
echo “STEP 10: RESPONSE FUNCTION ESTIMATION”  
echo “============================================================”

dwi2mask dwi\_preproc\_bias.mif dwi\_mask.mif

dwi2response dhollander dwi\_preproc\_bias.mif  
wm\_response.txt gm\_response.txt csf\_response.txt  
-mask dwi\_mask.mif

############################################################

# 11) FOD ESTIMATION

############################################################  
echo “============================================================”  
echo “STEP 11: FOD ESTIMATION”  
echo “============================================================”

dwi2fod msmt\_csd dwi\_preproc\_bias.mif  
-mask dwi\_mask.mif  
wm\_response.txt wm\_fod.mif  
gm\_response.txt gm.mif  
csf\_response.txt csf.mif

############################################################

# 12) NORMALISATION

############################################################  
echo “============================================================”  
echo “STEP 12: NORMALISATION”  
echo “============================================================”

mtnormalise  
wm\_fod.mif wm\_fod\_norm.mif  
gm.mif gm\_norm.mif  
csf.mif csf\_norm.mif  
-mask dwi\_mask.mif

############################################################

# 13) TRACTOGRAPHY WITH ACT

############################################################

# The tractogram and ACT image are both in DWI space.

echo “============================================================”  
echo “STEP 13: TRACTOGRAPHY WITH ACT”  
echo “============================================================”

tckgen wm\_fod\_norm.mif tracks\_10M.tck  
-act 5TT\_coreg.mif  
-backtrack  
-seed\_gmwmi gmwmi\_seed\_coreg.mif  
-select 10000000  
-maxlength 250  
-cutoff 0.06

############################################################

# 14) SIFT2

############################################################  
echo “============================================================”  
echo “STEP 14: SIFT2”  
echo “============================================================”

tcksift2 tracks\_10M.tck wm\_fod\_norm.mif sift2\_weights.txt  
-act 5TT\_coreg.mif

############################################################

# 15) CONNECTOME CONSTRUCTION

############################################################

# IMPORTANT: nodes image must be in DWI space.

echo “============================================================”  
echo “STEP 15: CONNECTOME CONSTRUCTION”  
echo “============================================================”

tck2connectome tracks\_10M.tck  
nodes\_fixSGM\_coreg.mif  
connectome\_counts.csv  
-assignment\_radial\_search 2

tck2connectome tracks\_10M.tck  
nodes\_fixSGM\_coreg.mif  
connectome\_sift2.csv  
-tck\_weights\_in sift2\_weights.txt  
-assignment\_radial\_search 2

############################################################

# 16) OPTIONAL: NODE-PAIR EXEMPLAR STREAMLINES

############################################################  
echo “============================================================”  
echo “STEP 16: OPTIONAL: NODE-PAIR EXEMPLAR STREAMLINES”  
echo “============================================================”

connectome2tck tracks\_10M.tck  
nodes\_fixSGM\_coreg.mif  
exemplar\_tracks  
-files single  
-exemplars nodes\_fixSGM\_coreg.mif

############################################################

# 17) QC VISUALISATION

############################################################  
echo “============================================================”  
echo “STEP 17: QC VISUALISATION”  
echo “============================================================”

mrview mean\_b0\_dwi.mif  
-overlay.load 5TT\_coreg.mif

mrview mean\_b0\_dwi.mif  
-overlay.load nodes\_fixSGM\_coreg.mif

echo “============================================================”  
echo “PIPELINE FINISHED SUCCESSFULLY”  
echo “============================================================”

Best regards.

Thank you very much in advance for your help.

Best regards.
