fname = get_fnames("fornix")
streams, hdr = tv.read(fname)
streamlines = [i[0] for i in streams]
Perform QuickBundles clustering using our metric ``CosineMetric``.
from dipy.segment.clustering import QuickBundles
metric = CosineMetric()
qb = QuickBundles(threshold=0.1, metric=metric)
clusters = qb.cluster(streamlines)
We will now visualize the clustering result.
// Color each streamline according to the cluster they belong to.
colormap = actor.create_colormap(np.arange(len(clusters)))
colormap_full = np.ones((len(streamlines), 3))
for cluster, color in zip(clusters, colormap):
colormap_full[cluster.indices] = color
ren = window.Renderer()
ren.SetBackground(1, 1, 1)
After Change
from dipy.viz import window, actor
fname = get_fnames("fornix")
fornix = load_tractogram(fname, "same",
bbox_valid_check=False).streamlinesstreamlines = Streamlines(fornix)
Perform QuickBundles clustering using our metric ``CosineMetric``.
from dipy.segment.clustering import QuickBundles
metric = CosineMetric()
qb = QuickBundles(threshold=0.1, metric=metric)
clusters = qb.cluster(streamlines)
We will now visualize the clustering result.
// Color each streamline according to the cluster they belong to.
colormap = actor.create_colormap(np.arange(len(clusters)))
colormap_full = np.ones((len(streamlines), 3))
for cluster, color in zip(clusters, colormap):
colormap_full[cluster.indices] = color
ren = window.Renderer()
ren.SetBackground(1, 1, 1)