# dist_thr (distance threshold) which affects number of clusters and their size # pts (number of points in each streamline) which will be used for downsampling before clustering # Default values : dist_thr = 4 & pts = 12 qb = QuickBundles(streamlines, dist_thr=20, pts=20) clusters = qb.clusters() print('Number of clusters %i' % qb.total_clusters) print('Cluster size', qb.clusters_sizes()) # Display streamlines ren = window.Renderer() ren.add(actor.streamtube(streamlines, window.colors.white)) window.show(ren) window.record(ren, out_path=filename + '_stream_lines_eu.png', size=(600, 600)) # Display centroids window.clear(ren) colormap = actor.create_colormap(np.arange(qb.total_clusters)) ren.add(actor.streamtube(streamlines, window.colors.white, opacity=0.1)) ren.add(actor.streamtube(qb.centroids, colormap, linewidth=0.5)) window.show(ren) window.record(ren, out_path=filename + '_centroids_eu.png', size=(600, 600)) # Display tracks window.clear(ren) colormap_full = np.ones((len(streamlines), 3)) for cluster, color in zip(clusters.items(), colormap): colormap_full[cluster[1]['indices']] = color ren.add(actor.streamtube(streamlines, colormap_full)) window.show(ren) window.record(ren, out_path=filename + '_stream_line_cluster_eu.png',
if interactive: window.show(ren) """ We can extract the peaks from the ODF, and plot these as well """ sf_peaks = dpp.peaks_from_model(sf_model, data_small, sphere, relative_peak_threshold=.5, min_separation_angle=25, return_sh=False) window.clear(ren) fodf_peaks = actor.peak_slicer(sf_peaks.peak_dirs, sf_peaks.peak_values, scale=1.3) ren.add(fodf_peaks) print('Saving illustration as sf_peaks.png') window.record(ren, out_path='sf_peaks.png', size=(1000, 1000)) if interactive: window.show(ren) """ Finally, we plot both the peaks and the ODFs, overlayed: """ fodf_spheres.GetProperty().SetOpacity(0.4) ren.add(fodf_spheres)