:py:mod:`AFQ.recognition.cleaning` ================================== .. py:module:: AFQ.recognition.cleaning Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: AFQ.recognition.cleaning.clean_by_orientation AFQ.recognition.cleaning.clean_bundle Attributes ~~~~~~~~~~ .. autoapisummary:: AFQ.recognition.cleaning.logger .. py:data:: logger .. py:function:: clean_by_orientation(streamlines, primary_axis, tol=None) Compute the cardinal orientation of each streamline :Parameters: **streamlines** : sequence of N by 3 arrays Where N is number of nodes in the array, the collection of streamlines to filter down to. :Returns: cleaned_idx, indicies of streamlines that passed cleaning .. .. !! processed by numpydoc !! .. py:function:: clean_bundle(tg, n_points=100, clean_rounds=5, distance_threshold=3, length_threshold=4, min_sl=20, stat='mean', return_idx=False) Clean a segmented fiber group based on the Mahalnobis distance of each streamline :Parameters: **tg** : StatefulTractogram class instance or ArraySequence A whole-brain tractogram to be segmented. **n_points** : int, optional Number of points to resample streamlines to. Default: 100 **clean_rounds** : int, optional. Number of rounds of cleaning based on the Mahalanobis distance from the mean of extracted bundles. Default: 5 **distance_threshold** : float, optional. Threshold of cleaning based on the Mahalanobis distance (the units are standard deviations). Default: 3. **length_threshold: float, optional** Threshold for cleaning based on length (in standard deviations). Length of any streamline should not be *more* than this number of stdevs from the mean length. **min_sl** : int, optional. Number of streamlines in a bundle under which we will not bother with cleaning outliers. Default: 20. **stat** : callable or str, optional. The statistic of each node relative to which the Mahalanobis is calculated. Default: `np.mean` (but can also use median, etc.) **return_idx** : bool Whether to return indices in the original streamlines. Default: False. **Returns** .. **-------** .. **A StatefulTractogram class instance containing only the streamlines** .. **that have a Mahalanobis distance smaller than `clean_threshold` from** .. **the mean of each one of the nodes.** .. .. !! processed by numpydoc !!