Note
Go to the end to download the full example code
Particle Filtering Tractography#
Particle Filtering Tractography (PFT) [Girard2014] uses tissue partial volume estimation (PVE) to reconstruct trajectories connecting the gray matter, and not incorrectly stopping in the white matter or in the corticospinal fluid. It relies on a stopping criterion that identifies the tissue where the streamline stopped. If the streamline correctly stopped in the gray matter, the trajectory is kept. If the streamline incorrectly stopped in the white matter or in the corticospinal fluid, PFT uses anatomical information to find an alternative streamline segment to extend the trajectory. When this segment is found, the tractography continues until the streamline correctly stops in the gray matter.
PFT finds an alternative streamline segment whenever the stopping criterion returns a position classified as βINVALIDPOINTβ.
This example is an extension of An introduction to the Probabilistic Direction Getter and Using Various Stopping Criterion for Tractography examples. We begin by loading the data, fitting a Constrained Spherical Deconvolution (CSD) reconstruction model, creating the probabilistic direction getter and defining the seeds.
from dipy.tracking.stopping_criterion import CmcStoppingCriterion
import numpy as np
from dipy.core.gradients import gradient_table
from dipy.data import get_fnames, default_sphere
from dipy.direction import ProbabilisticDirectionGetter
from dipy.io.gradients import read_bvals_bvecs
from dipy.io.image import load_nifti, load_nifti_data
from dipy.io.stateful_tractogram import Space, StatefulTractogram
from dipy.io.streamline import save_trk
from dipy.reconst.csdeconv import (ConstrainedSphericalDeconvModel,
auto_response_ssst)
from dipy.tracking.local_tracking import (LocalTracking,
ParticleFilteringTracking)
from dipy.tracking.streamline import Streamlines
from dipy.tracking import utils
from dipy.viz import window, actor, colormap, has_fury
# Enables/disables interactive visualization
interactive = False
hardi_fname, hardi_bval_fname, hardi_bvec_fname = get_fnames('stanford_hardi')
label_fname = get_fnames('stanford_labels')
f_pve_csf, f_pve_gm, f_pve_wm = get_fnames('stanford_pve_maps')
data, affine, hardi_img = load_nifti(hardi_fname, return_img=True)
labels = load_nifti_data(label_fname)
bvals, bvecs = read_bvals_bvecs(hardi_bval_fname, hardi_bvec_fname)
gtab = gradient_table(bvals, bvecs)
pve_csf_data = load_nifti_data(f_pve_csf)
pve_gm_data = load_nifti_data(f_pve_gm)
pve_wm_data, _, voxel_size = load_nifti(f_pve_wm, return_voxsize=True)
shape = labels.shape
response, ratio = auto_response_ssst(gtab, data, roi_radii=10, fa_thr=0.7)
csd_model = ConstrainedSphericalDeconvModel(gtab, response)
csd_fit = csd_model.fit(data, mask=pve_wm_data)
dg = ProbabilisticDirectionGetter.from_shcoeff(csd_fit.shm_coeff,
max_angle=20.,
sphere=default_sphere,
sh_to_pmf=True)
seed_mask = (labels == 2)
seed_mask[pve_wm_data < 0.5] = 0
seeds = utils.seeds_from_mask(seed_mask, affine, density=2)
0%| | 0/77848.12 [00:00<?, ?it/s]
0%|β | 317/77848.12 [00:00<00:24, 3154.79it/s]
1%|ββ | 712/77848.12 [00:00<00:21, 3612.95it/s]
1%|ββ | 1082/77848.12 [00:00<00:21, 3647.03it/s]
2%|βββ | 1474/77848.12 [00:00<00:20, 3748.06it/s]
2%|ββββ | 1892/77848.12 [00:00<00:19, 3897.79it/s]
3%|ββββ | 2306/77848.12 [00:00<00:19, 3974.46it/s]
3%|βββββ | 2722/77848.12 [00:00<00:18, 4029.27it/s]
4%|ββββββ | 3125/77848.12 [00:00<00:18, 3995.69it/s]
5%|ββββββ | 3525/77848.12 [00:00<00:19, 3872.66it/s]
5%|βββββββ | 3976/77848.12 [00:01<00:18, 4060.50it/s]
6%|ββββββββ | 4384/77848.12 [00:01<00:18, 4048.89it/s]
6%|ββββββββ | 4846/77848.12 [00:01<00:17, 4207.21it/s]
7%|βββββββββ | 5284/77848.12 [00:01<00:17, 4253.18it/s]
7%|ββββββββββ | 5710/77848.12 [00:01<00:16, 4250.27it/s]
8%|βββββββββββ | 6162/77848.12 [00:01<00:16, 4325.90it/s]
8%|βββββββββββ | 6595/77848.12 [00:01<00:16, 4274.66it/s]
9%|ββββββββββββ | 7061/77848.12 [00:01<00:16, 4385.69it/s]
10%|βββββββββββββ | 7500/77848.12 [00:01<00:16, 4381.50it/s]
10%|ββββββββββββββ | 7939/77848.12 [00:01<00:16, 4287.17it/s]
11%|ββββββββββββββ | 8428/77848.12 [00:02<00:15, 4458.61it/s]
11%|βββββββββββββββ | 8875/77848.12 [00:02<00:15, 4405.90it/s]
12%|ββββββββββββββββ | 9325/77848.12 [00:02<00:15, 4428.16it/s]
13%|βββββββββββββββββ | 9792/77848.12 [00:02<00:15, 4496.08it/s]
13%|βββββββββββββββββ | 10243/77848.12 [00:02<00:15, 4455.30it/s]
14%|ββββββββββββββββββ | 10713/77848.12 [00:02<00:14, 4521.53it/s]
14%|βββββββββββββββββββ | 11185/77848.12 [00:02<00:14, 4571.85it/s]
15%|ββββββββββββββββββββ | 11643/77848.12 [00:02<00:14, 4516.29it/s]
16%|ββββββββββββββββββββ | 12095/77848.12 [00:02<00:14, 4499.85it/s]
16%|βββββββββββββββββββββ | 12557/77848.12 [00:02<00:14, 4530.33it/s]
17%|ββββββββββββββββββββββ | 13029/77848.12 [00:03<00:14, 4581.21it/s]
17%|βββββββββββββββββββββββ | 13488/77848.12 [00:03<00:14, 4537.19it/s]
18%|ββββββββββββββββββββββββ | 13961/77848.12 [00:03<00:13, 4591.47it/s]
19%|ββββββββββββββββββββββββ | 14446/77848.12 [00:03<00:13, 4661.57it/s]
19%|βββββββββββββββββββββββββ | 14913/77848.12 [00:03<00:13, 4589.49it/s]
20%|ββββββββββββββββββββββββββ | 15390/77848.12 [00:03<00:13, 4634.74it/s]
20%|βββββββββββββββββββββββββββ | 15866/77848.12 [00:03<00:13, 4665.38it/s]
21%|βββββββββββββββββββββββββββ | 16333/77848.12 [00:03<00:13, 4605.84it/s]
22%|ββββββββββββββββββββββββββββ | 16794/77848.12 [00:03<00:13, 4488.62it/s]
22%|βββββββββββββββββββββββββββββ | 17266/77848.12 [00:03<00:13, 4550.99it/s]
23%|ββββββββββββββββββββββββββββββ | 17729/77848.12 [00:04<00:13, 4567.89it/s]
23%|βββββββββββββββββββββββββββββββ | 18199/77848.12 [00:04<00:12, 4599.31it/s]
24%|βββββββββββββββββββββββββββββββ | 18660/77848.12 [00:04<00:12, 4568.73it/s]
25%|ββββββββββββββββββββββββββββββββ | 19133/77848.12 [00:04<00:12, 4609.82it/s]
25%|βββββββββββββββββββββββββββββββββ | 19595/77848.12 [00:04<00:12, 4598.61it/s]
26%|ββββββββββββββββββββββββββββββββββ | 20073/77848.12 [00:04<00:12, 4647.52it/s]
26%|ββββββββββββββββββββββββββββββββββ | 20543/77848.12 [00:04<00:12, 4656.12it/s]
27%|βββββββββββββββββββββββββββββββββββ | 21010/77848.12 [00:04<00:12, 4658.14it/s]
28%|ββββββββββββββββββββββββββββββββββββ | 21477/77848.12 [00:04<00:12, 4656.00it/s]
28%|βββββββββββββββββββββββββββββββββββββ | 21943/77848.12 [00:04<00:12, 4637.49it/s]
29%|ββββββββββββββββββββββββββββββββββββββ | 22409/77848.12 [00:05<00:11, 4637.83it/s]
29%|ββββββββββββββββββββββββββββββββββββββ | 22880/77848.12 [00:05<00:11, 4654.50it/s]
30%|βββββββββββββββββββββββββββββββββββββββ | 23351/77848.12 [00:05<00:11, 4664.58it/s]
31%|ββββββββββββββββββββββββββββββββββββββββ | 23818/77848.12 [00:05<00:11, 4661.13it/s]
31%|βββββββββββββββββββββββββββββββββββββββββ | 24285/77848.12 [00:05<00:11, 4624.35it/s]
32%|βββββββββββββββββββββββββββββββββββββββββ | 24763/77848.12 [00:05<00:11, 4665.01it/s]
32%|ββββββββββββββββββββββββββββββββββββββββββ | 25245/77848.12 [00:05<00:11, 4705.10it/s]
33%|βββββββββββββββββββββββββββββββββββββββββββ | 25716/77848.12 [00:05<00:11, 4644.45it/s]
34%|ββββββββββββββββββββββββββββββββββββββββββββ | 26181/77848.12 [00:05<00:11, 4534.40it/s]
34%|βββββββββββββββββββββββββββββββββββββββββββββ | 26662/77848.12 [00:05<00:11, 4609.59it/s]
35%|βββββββββββββββββββββββββββββββββββββββββββββ | 27124/77848.12 [00:06<00:11, 4550.20it/s]
35%|ββββββββββββββββββββββββββββββββββββββββββββββ | 27580/77848.12 [00:06<00:11, 4548.81it/s]
36%|βββββββββββββββββββββββββββββββββββββββββββββββ | 28036/77848.12 [00:06<00:11, 4520.10it/s]
37%|ββββββββββββββββββββββββββββββββββββββββββββββββ | 28489/77848.12 [00:06<00:11, 4464.49it/s]
37%|ββββββββββββββββββββββββββββββββββββββββββββββββ | 28936/77848.12 [00:06<00:10, 4460.71it/s]
38%|βββββββββββββββββββββββββββββββββββββββββββββββββ | 29383/77848.12 [00:06<00:10, 4445.47it/s]
38%|ββββββββββββββββββββββββββββββββββββββββββββββββββ | 29828/77848.12 [00:06<00:10, 4402.37it/s]
39%|βββββββββββββββββββββββββββββββββββββββββββββββββββ | 30269/77848.12 [00:06<00:11, 4136.01it/s]
39%|βββββββββββββββββββββββββββββββββββββββββββββββββββ | 30686/77848.12 [00:06<00:11, 4072.29it/s]
40%|ββββββββββββββββββββββββββββββββββββββββββββββββββββ | 31121/77848.12 [00:07<00:11, 4147.29it/s]
41%|βββββββββββββββββββββββββββββββββββββββββββββββββββββ | 31538/77848.12 [00:07<00:11, 4053.82it/s]
41%|βββββββββββββββββββββββββββββββββββββββββββββββββββββ | 31945/77848.12 [00:07<00:11, 4054.67it/s]
42%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 32395/77848.12 [00:07<00:10, 4172.53it/s]
42%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 32827/77848.12 [00:07<00:10, 4212.11it/s]
43%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 33293/77848.12 [00:07<00:10, 4338.20it/s]
43%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 33767/77848.12 [00:07<00:09, 4453.40it/s]
44%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 34214/77848.12 [00:07<00:09, 4454.11it/s]
45%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 34673/77848.12 [00:07<00:09, 4489.91it/s]
45%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 35123/77848.12 [00:07<00:09, 4474.18it/s]
46%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 35601/77848.12 [00:08<00:09, 4559.44it/s]
46%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 36075/77848.12 [00:08<00:09, 4609.93it/s]
47%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 36563/77848.12 [00:08<00:08, 4684.61it/s]
48%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 37044/77848.12 [00:08<00:08, 4716.17it/s]
48%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 37516/77848.12 [00:08<00:08, 4697.35it/s]
49%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 37986/77848.12 [00:08<00:08, 4677.42it/s]
49%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 38454/77848.12 [00:08<00:08, 4631.75it/s]
50%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 38930/77848.12 [00:08<00:08, 4656.61it/s]
51%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 39396/77848.12 [00:08<00:08, 4632.36it/s]
51%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 39877/77848.12 [00:08<00:08, 4678.85it/s]
52%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 40345/77848.12 [00:09<00:08, 4649.02it/s]
52%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 40810/77848.12 [00:09<00:08, 4616.15it/s]
53%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 41272/77848.12 [00:09<00:07, 4609.20it/s]
54%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 41733/77848.12 [00:09<00:07, 4562.42it/s]
54%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 42194/77848.12 [00:09<00:07, 4571.16it/s]
55%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 42652/77848.12 [00:09<00:07, 4554.98it/s]
55%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 43124/77848.12 [00:09<00:07, 4592.10it/s]
56%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 43584/77848.12 [00:09<00:07, 4508.24it/s]
57%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 44036/77848.12 [00:09<00:07, 4493.64it/s]
57%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 44491/77848.12 [00:09<00:07, 4502.48it/s]
58%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 44943/77848.12 [00:10<00:07, 4500.28it/s]
58%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 45394/77848.12 [00:10<00:07, 4462.75it/s]
59%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 45841/77848.12 [00:10<00:07, 4432.72it/s]
59%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 46285/77848.12 [00:10<00:07, 4428.97it/s]
60%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 46751/77848.12 [00:10<00:06, 4492.07it/s]
61%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 47209/77848.12 [00:10<00:06, 4512.29it/s]
61%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 47662/77848.12 [00:10<00:06, 4516.58it/s]
62%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 48140/77848.12 [00:10<00:06, 4590.19it/s]
62%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 48600/77848.12 [00:10<00:06, 4505.84it/s]
63%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 49060/77848.12 [00:11<00:06, 4533.61it/s]
64%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 49514/77848.12 [00:11<00:06, 4503.86it/s]
64%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 49965/77848.12 [00:11<00:06, 4479.81it/s]
65%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 50430/77848.12 [00:11<00:06, 4523.84it/s]
65%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 50883/77848.12 [00:11<00:05, 4498.96it/s]
66%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 51348/77848.12 [00:11<00:05, 4538.01it/s]
67%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 51813/77848.12 [00:11<00:05, 4566.46it/s]
67%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 52273/77848.12 [00:11<00:05, 4571.03it/s]
68%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 52731/77848.12 [00:11<00:05, 4568.67it/s]
68%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 53196/77848.12 [00:11<00:05, 4588.36it/s]
69%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 53663/77848.12 [00:12<00:05, 4604.81it/s]
70%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 54134/77848.12 [00:12<00:05, 4631.35it/s]
70%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 54605/77848.12 [00:12<00:04, 4650.48it/s]
71%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 55071/77848.12 [00:12<00:05, 4538.64it/s]
71%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 55553/77848.12 [00:12<00:04, 4614.98it/s]
72%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 56032/77848.12 [00:12<00:04, 4659.53it/s]
73%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 56499/77848.12 [00:12<00:04, 4647.64it/s]
73%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 56987/77848.12 [00:12<00:04, 4703.37it/s]
74%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 57458/77848.12 [00:12<00:04, 4630.05it/s]
74%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 57950/77848.12 [00:12<00:04, 4708.63it/s]
75%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 58422/77848.12 [00:13<00:04, 4677.94it/s]
76%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 58898/77848.12 [00:13<00:04, 4696.84it/s]
76%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 59371/77848.12 [00:13<00:03, 4700.94it/s]
77%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 59842/77848.12 [00:13<00:03, 4670.29it/s]
78%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 60344/77848.12 [00:13<00:03, 4767.50it/s]
78%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 60821/77848.12 [00:13<00:03, 4764.27it/s]
79%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 61307/77848.12 [00:13<00:03, 4785.82it/s]
79%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 61786/77848.12 [00:13<00:03, 4736.69it/s]
80%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 62265/77848.12 [00:13<00:03, 4748.02it/s]
81%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 62760/77848.12 [00:13<00:03, 4801.76it/s]
81%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 63241/77848.12 [00:14<00:03, 4783.14it/s]
82%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 63720/77848.12 [00:14<00:02, 4763.45it/s]
82%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 64197/77848.12 [00:14<00:02, 4737.88it/s]
83%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 64694/77848.12 [00:14<00:02, 4800.21it/s]
84%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 65196/77848.12 [00:14<00:02, 4860.27it/s]
84%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 65683/77848.12 [00:14<00:02, 4792.74it/s]
85%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 66170/77848.12 [00:14<00:02, 4809.94it/s]
86%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 66652/77848.12 [00:14<00:02, 4722.06it/s]
86%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 67168/77848.12 [00:14<00:02, 4845.22it/s]
87%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 67662/77848.12 [00:14<00:02, 4867.32it/s]
88%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 68150/77848.12 [00:15<00:01, 4861.52it/s]
88%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 68637/77848.12 [00:15<00:01, 4842.00it/s]
89%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 69122/77848.12 [00:15<00:01, 4710.42it/s]
89%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 69640/77848.12 [00:15<00:01, 4844.24it/s]
90%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 70126/77848.12 [00:15<00:01, 4847.19it/s]
91%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 70612/77848.12 [00:15<00:01, 4760.47it/s]
91%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 71089/77848.12 [00:15<00:01, 4689.78it/s]
92%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 71584/77848.12 [00:15<00:01, 4760.57it/s]
93%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 72070/77848.12 [00:15<00:01, 4779.60it/s]
93%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 72549/77848.12 [00:15<00:01, 4735.35it/s]
94%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 73023/77848.12 [00:16<00:01, 4731.86it/s]
94%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 73497/77848.12 [00:16<00:00, 4715.72it/s]
95%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 73989/77848.12 [00:16<00:00, 4775.24it/s]
96%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 74467/77848.12 [00:16<00:00, 4673.67it/s]
96%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 74935/77848.12 [00:16<00:00, 4655.32it/s]
97%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 75401/77848.12 [00:16<00:00, 4623.90it/s]
97%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 75881/77848.12 [00:16<00:00, 4670.31it/s]
98%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 76349/77848.12 [00:16<00:00, 4667.63it/s]
99%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 76816/77848.12 [00:16<00:00, 4620.86it/s]
99%|ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | 77279/77848.12 [00:17<00:00, 4578.46it/s]
100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 77781/77848.12 [00:17<00:00, 4707.84it/s]
78258it [00:17, 4713.64it/s]
78730it [00:17, 4701.11it/s]
79201it [00:17, 4613.42it/s]
79735it [00:17, 4820.47it/s]
80218it [00:17, 4762.26it/s]
80700it [00:17, 4772.89it/s]
81178it [00:17, 4645.37it/s]
81695it [00:17, 4793.67it/s]
82176it [00:18, 4775.54it/s]
82655it [00:18, 4752.83it/s]
83131it [00:18, 4666.96it/s]
83626it [00:18, 4743.06it/s]
84102it [00:18, 4742.97it/s]
84577it [00:18, 4669.34it/s]
85045it [00:18, 4651.32it/s]
85527it [00:18, 4693.91it/s]
85997it [00:18, 4600.60it/s]
86458it [00:18, 4455.74it/s]
86949it [00:19, 4581.86it/s]
87409it [00:19, 4567.60it/s]
87867it [00:19, 4461.40it/s]
88345it [00:19, 4549.23it/s]
88801it [00:19, 4442.70it/s]
89252it [00:19, 4456.77it/s]
89716it [00:19, 4506.04it/s]
90168it [00:19, 4419.01it/s]
90621it [00:19, 4445.29it/s]
91067it [00:20, 4379.44it/s]
91527it [00:20, 4439.09it/s]
91972it [00:20, 4386.45it/s]
92412it [00:20, 4335.34it/s]
92858it [00:20, 4366.82it/s]
93295it [00:20, 4235.37it/s]
93738it [00:20, 4287.64it/s]
94168it [00:20, 4187.85it/s]
94601it [00:20, 4223.16it/s]
95025it [00:20, 4078.10it/s]
95446it [00:21, 4111.05it/s]
95859it [00:21, 4068.62it/s]
96267it [00:21, 4009.42it/s]
96669it [00:21, 2633.45it/s]
96989it [00:21, 4482.88it/s]
CMC/ACT Stopping Criterion#
Continuous map criterion (CMC) [Girard2014] and Anatomically-constrained tractography (ACT) [Smith2012] both uses PVEs information from anatomical images to determine when the tractography stops. Both stopping criterion use a trilinear interpolation at the tracking position. CMC stopping criterion uses a probability derived from the PVE maps to determine if the streamline reaches a βvalidβ or βinvalidβ region. ACT uses a fixed threshold on the PVE maps. Both stopping criterion can be used in conjunction with PFT. In this example, we used CMC.
voxel_size = np.average(voxel_size[1:4])
step_size = 0.2
cmc_criterion = CmcStoppingCriterion.from_pve(pve_wm_data,
pve_gm_data,
pve_csf_data,
step_size=step_size,
average_voxel_size=voxel_size)
Particle Filtering Tractography#
pft_back_tracking_dist is the distance in mm to backtrack when the tractography incorrectly stops in the WM or CSF. pft_front_tracking_dist is the distance in mm to track after the stopping event using PFT.
The particle_count parameter is the number of samples used in the particle filtering algorithm.
min_wm_pve_before_stopping controls when the tracking can stop in the GM. The tractography must reaches a position where WM_pve >= min_wm_pve_before_stopping before stopping in the GM. As long as the condition is not reached and WM_pve > 0, the tractography will continue. It is particularlyusefull to set this parameter > 0.5 when seeding tractography at the WM-GM interface or in the sub-cortical GM. It allows streamlines to exit the seeding voxels until they reach the deep white matter where WM_pve > min_wm_pve_before_stopping.
pft_streamline_gen = ParticleFilteringTracking(dg,
cmc_criterion,
seeds,
affine,
max_cross=1,
step_size=step_size,
maxlen=1000,
pft_back_tracking_dist=2,
pft_front_tracking_dist=1,
particle_count=15,
return_all=False,
min_wm_pve_before_stopping=1)
streamlines = Streamlines(pft_streamline_gen)
sft = StatefulTractogram(streamlines, hardi_img, Space.RASMM)
save_trk(sft, "tractogram_pft.trk")
if has_fury:
scene = window.Scene()
scene.add(actor.line(streamlines, colormap.line_colors(streamlines)))
window.record(scene, out_path='tractogram_pft.png',
size=(800, 800))
if interactive:
window.show(scene)
Corpus Callosum using particle filtering tractography
# Local Probabilistic Tractography
prob_streamline_generator = LocalTracking(dg,
cmc_criterion,
seeds,
affine,
max_cross=1,
step_size=step_size,
maxlen=1000,
return_all=False)
streamlines = Streamlines(prob_streamline_generator)
sft = StatefulTractogram(streamlines, hardi_img, Space.RASMM)
save_trk(sft, "tractogram_probabilistic_cmc.trk")
if has_fury:
scene = window.Scene()
scene.add(actor.line(streamlines, colormap.line_colors(streamlines)))
window.record(scene, out_path='tractogram_probabilistic_cmc.png',
size=(800, 800))
if interactive:
window.show(scene)
Corpus Callosum using probabilistic tractography
References#
Girard, G., Whittingstall, K., Deriche, R., & Descoteaux, M. Towards quantitative connectivity analysis: reducing tractography biases. NeuroImage, 98, 266-278, 2014.
Smith, R. E., Tournier, J.-D., Calamante, F., & Connelly, A. Anatomically-constrained tractography: Improved diffusion MRI streamlines tractography through effective use of anatomical information. NeuroImage, 63(3), 1924-1938, 2012.
Total running time of the script: (2 minutes 26.696 seconds)