docstr: Recognize the model_bundle in self.streamlines
  
  Parameters
  ----------
  model_bundle : Streamlines
      model bundle streamlines used as a reference to extract similar
      streamlines from input tractogram
  model_clust_thr : float
      MDF distance threshold for the model bundles
  reduction_thr : float, optional
      Reduce search space in the target tractogram by (mm) (default 10)
  reduction_distance : string, optional
      Reduction distance type can be mdf or mam (default mdf)
  slr : bool, optional
      Use Streamline-based Linear Registration (SLR) locally
      (default True)
  num_threads : int, optional
      Number of threads to be used for OpenMP parallelization. If None
      (default) the value of OMP_NUM_THREADS environment variable is used
      if it is set, otherwise all available threads are used. If < 0 the
      maximal number of threads minus |num_threads + 1| is used (enter -1
      to use as many threads as possible). 0 raises an error.
  slr_metric : BundleMinDistanceMetric
  slr_x0 : array or int or str, optional
      Transformation allowed. translation, rigid, similarity or scaling
      Initial parametrization for the optimization.
  
      If 1D array with:
          a) 6 elements then only rigid registration is performed with
          the 3 first elements for translation and 3 for rotation.
          b) 7 elements also isotropic scaling is performed (similarity).
          c) 12 elements then translation, rotation (in degrees),
          scaling and shearing are performed (affine).
  
          Here is an example of x0 with 12 elements:
          ``x0=np.array([0, 10, 0, 40, 0, 0, 2., 1.5, 1, 0.1, -0.5, 0])``
  
          This has translation (0, 10, 0), rotation (40, 0, 0) in
          degrees, scaling (2., 1.5, 1) and shearing (0.1, -0.5, 0).
  
      If int:
          a) 6
              ``x0 = np.array([0, 0, 0, 0, 0, 0])``
          b) 7
              ``x0 = np.array([0, 0, 0, 0, 0, 0, 1.])``
          c) 12
              ``x0 = np.array([0, 0, 0, 0, 0, 0, 1., 1., 1, 0, 0, 0])``
  
      If str:
          a) "rigid"
              ``x0 = np.array([0, 0, 0, 0, 0, 0])``
          b) "similarity"
              ``x0 = np.array([0, 0, 0, 0, 0, 0, 1.])``
          c) "affine"
              ``x0 = np.array([0, 0, 0, 0, 0, 0, 1., 1., 1, 0, 0, 0])
      (default None)
  slr_bounds : array, optional
      (default None)
  slr_select : tuple, optional
      Select the number of streamlines from model to neirborhood of
      model to perform the local SLR.
  slr_method : string, optional
      Optimization method 'L_BFGS_B' or 'Powell' optimizers can be used.
      (default 'L-BFGS-B')
  pruning_thr : float, optional
      Pruning after reducing the search space (default 5).
  pruning_distance : string, optional
      Pruning distance type can be mdf or mam (default mdf)
  
  Returns
  -------
  recognized_transf : Streamlines
      Recognized bundle in the space of the model tractogram
  recognized_labels : array
      Indices of recognized bundle in the original tractogram
  
  References
  ----------
  .. [Garyfallidis17] Garyfallidis et al. Recognition of white matter
      bundles using local and global streamline-based registration and
      clustering, Neuroimage, 2017.
docstr_tok: ["Recognize","the","model_bundle","in","self.streamlines","Parameters","--","--","--","--","--","model_bundle",":","Streamlines","model","bundle","streamlines","used","as","a","reference","to","extract","similar","streamlines","from","input","tractogram","model_clust_thr",":","float","MDF","distance","threshold","for","the","model","bundles","reduction_thr",":","float",",","optional","Reduce","search","space","in","the","target","tractogram","by","(","mm",")","(","default","10",")","reduction_distance",":","string",",","optional","Reduction","distance","type","can","be","mdf","or","mam","(","default","mdf",")","slr",":","bool",",","optional","Use","Streamline-based","Linear","Registration","(","SLR",")","locally","(","default","True",")","num_threads",":","int",",","optional","Number","of","threads","to","be","used","for","OpenMP","parallelization",".","If","None","(","default",")","the","value","of","OMP_NUM_THREADS","environment","variable","is","used","if","it","is","set",",","otherwise","all","available","threads","are","used",".","If","<","0","the","maximal","number","of","threads","minus","|num_threads","+","1|","is","used","(","enter","-1","to","use","as","many","threads","as","possible",")",".","0","raises","an","error",".","slr_metric",":","BundleMinDistanceMetric","slr_x0",":","array","or","int","or","str",",","optional","Transformation","allowed",".","translation",",","rigid",",","similarity","or","scaling","Initial","parametrization","for","the","optimization",".","If","1D","array","with",":","a",")","6","elements","then","only","rigid","registration","is","performed","with","the","3","first","elements","for","translation","and","3","for","rotation",".","b",")","7","elements","also","isotropic","scaling","is","performed","(","similarity",")",".","c",")","12","elements","then","translation",",","rotation","(","in","degrees",")",",","scaling","and","shearing","are","performed","(","affine",")",".","Here","is","an","example","of","x0","with","12","elements",":","``","x0=np.array","(","[","0",",","10",",","0",",","40",",","0",",","0",",","2.",",","1.5",",","1",",","0.1",",","-0.5",",","0","]",")","``","This","has","translation","(","0",",","10",",","0",")",",","rotation","(","40",",","0",",","0",")","in","degrees",",","scaling","(","2.",",","1.5",",","1",")","and","shearing","(","0.1",",","-0.5",",","0",")",".","If","int",":","a",")","6","``","x0","=","np.array","(","[","0",",","0",",","0",",","0",",","0",",","0","]",")","``","b",")","7","``","x0","=","np.array","(","[","0",",","0",",","0",",","0",",","0",",","0",",","1",".","]",")","``","c",")","12","``","x0","=","np.array","(","[","0",",","0",",","0",",","0",",","0",",","0",",","1.",",","1.",",","1",",","0",",","0",",","0","]",")","``","If","str",":","a",")","``","rigid","''","``","x0","=","np.array","(","[","0",",","0",",","0",",","0",",","0",",","0","]",")","``","b",")","``","similarity","''","``","x0","=","np.array","(","[","0",",","0",",","0",",","0",",","0",",","0",",","1",".","]",")","``","c",")","``","affine","''","``","x0","=","np.array","(","[","0",",","0",",","0",",","0",",","0",",","0",",","1.",",","1.",",","1",",","0",",","0",",","0","]",")","(","default","None",")","slr_bounds",":","array",",","optional","(","default","None",")","slr_select",":","tuple",",","optional","Select","the","number","of","streamlines","from","model","to","neirborhood","of","model","to","perform","the","local","SLR",".","slr_method",":","string",",","optional","Optimization","method","'L_BFGS_B","'","or","'Powell","'","optimizers","can","be","used",".","(","default","'","L-BFGS-B","'",")","pruning_thr",":","float",",","optional","Pruning","after","reducing","the","search","space","(","default","5",")",".","pruning_distance",":","string",",","optional","Pruning","distance","type","can","be","mdf","or","mam","(","default","mdf",")","Returns","--","--","--","-","recognized_transf",":","Streamlines","Recognized","bundle","in","the","space","of","the","model","tractogram","recognized_labels",":","array","Indices","of","recognized","bundle","in","the","original","tractogram","References","--","--","--","--","--","..","[","Garyfallidis17","]","Garyfallidis","et","al",".","Recognition","of","white","matter","bundles","using","local","and","global","streamline-based","registration","and","clustering",",","Neuroimage",",","2017","."]
code: def recognize(
      self,
      model_bundle,
      model_clust_thr,
      reduction_thr=10,
      reduction_distance="mdf",
      slr=True,
      num_threads=None,
      slr_metric=None,
      slr_x0=None,
      slr_bounds=None,
      slr_select=(400, 600),
      slr_method="L-BFGS-B",
      pruning_thr=5,
      pruning_distance="mdf",
  ):
      """Recognize the model_bundle in self.streamlines
  
      Parameters
      ----------
      model_bundle : Streamlines
          model bundle streamlines used as a reference to extract similar
          streamlines from input tractogram
      model_clust_thr : float
          MDF distance threshold for the model bundles
      reduction_thr : float, optional
          Reduce search space in the target tractogram by (mm) (default 10)
      reduction_distance : string, optional
          Reduction distance type can be mdf or mam (default mdf)
      slr : bool, optional
          Use Streamline-based Linear Registration (SLR) locally
          (default True)
      num_threads : int, optional
          Number of threads to be used for OpenMP parallelization. If None
          (default) the value of OMP_NUM_THREADS environment variable is used
          if it is set, otherwise all available threads are used. If < 0 the
          maximal number of threads minus |num_threads + 1| is used (enter -1
          to use as many threads as possible). 0 raises an error.
      slr_metric : BundleMinDistanceMetric
      slr_x0 : array or int or str, optional
          Transformation allowed. translation, rigid, similarity or scaling
          Initial parametrization for the optimization.
  
          If 1D array with:
              a) 6 elements then only rigid registration is performed with
              the 3 first elements for translation and 3 for rotation.
              b) 7 elements also isotropic scaling is performed (similarity).
              c) 12 elements then translation, rotation (in degrees),
              scaling and shearing are performed (affine).
  
              Here is an example of x0 with 12 elements:
              ``x0=np.array([0, 10, 0, 40, 0, 0, 2., 1.5, 1, 0.1, -0.5, 0])``
  
              This has translation (0, 10, 0), rotation (40, 0, 0) in
              degrees, scaling (2., 1.5, 1) and shearing (0.1, -0.5, 0).
  
          If int:
              a) 6
                  ``x0 = np.array([0, 0, 0, 0, 0, 0])``
              b) 7
                  ``x0 = np.array([0, 0, 0, 0, 0, 0, 1.])``
              c) 12
                  ``x0 = np.array([0, 0, 0, 0, 0, 0, 1., 1., 1, 0, 0, 0])``
  
          If str:
              a) "rigid"
                  ``x0 = np.array([0, 0, 0, 0, 0, 0])``
              b) "similarity"
                  ``x0 = np.array([0, 0, 0, 0, 0, 0, 1.])``
              c) "affine"
                  ``x0 = np.array([0, 0, 0, 0, 0, 0, 1., 1., 1, 0, 0, 0])
          (default None)
      slr_bounds : array, optional
          (default None)
      slr_select : tuple, optional
          Select the number of streamlines from model to neirborhood of
          model to perform the local SLR.
      slr_method : string, optional
          Optimization method 'L_BFGS_B' or 'Powell' optimizers can be used.
          (default 'L-BFGS-B')
      pruning_thr : float, optional
          Pruning after reducing the search space (default 5).
      pruning_distance : string, optional
          Pruning distance type can be mdf or mam (default mdf)
  
      Returns
      -------
      recognized_transf : Streamlines
          Recognized bundle in the space of the model tractogram
      recognized_labels : array
          Indices of recognized bundle in the original tractogram
  
      References
      ----------
      .. [Garyfallidis17] Garyfallidis et al. Recognition of white matter
          bundles using local and global streamline-based registration and
          clustering, Neuroimage, 2017.
      """
      if self.verbose:
          t = time()
          logger.info("## Recognize given bundle ## \n")
  
      model_centroids = self._cluster_model_bundle(
          model_bundle, model_clust_thr=model_clust_thr
      )
  
      neighb_streamlines, neighb_indices = self._reduce_search_space(
          model_centroids,
          reduction_thr=reduction_thr,
          reduction_distance=reduction_distance,
      )
  
      if len(neighb_streamlines) == 0:
          return Streamlines([]), []
  
      if slr:
          transf_streamlines, slr1_bmd = self._register_neighb_to_model(
              model_bundle,
              neighb_streamlines,
              metric=slr_metric,
              x0=slr_x0,
              bounds=slr_bounds,
              select_model=slr_select[0],
              select_target=slr_select[1],
              method=slr_method,
              num_threads=num_threads,
          )
      else:
          transf_streamlines = neighb_streamlines
  
      pruned_streamlines, labels = self._prune_what_not_in_model(
          model_centroids,
          transf_streamlines,
          neighb_indices,
          pruning_thr=pruning_thr,
          pruning_distance=pruning_distance,
      )
      if self.verbose:
          logger.info(
              f"Total duration of recognition time"
              f" is {time()-t:0.3f} s\n"
          )
  
      return pruned_streamlines, self.filtered_indices[labels]
  
imports: from time import time
  from itertools import chain
  import logging
  import numpy
  from dipy.tracking.streamline import set_number_of_points, nbytes, select_random_set_of_streamlines
  from dipy.segment.clustering import qbx_and_merge
  from dipy.tracking.distances import bundles_distances_mdf, bundles_distances_mam
  from dipy.align.streamlinear import StreamlineLinearRegistration, BundleMinDistanceMetric, BundleSumDistanceMatrixMetric, BundleMinDistanceAsymmetricMetric
  from dipy.tracking.streamline import Streamlines, length
  from dipy.utils.deprecator import deprecated_params
  from nibabel.affines import apply_affine
label_desc: Use image node_id 3 for calling the RecoBundles obj's underlying member method code with example usage: obj.recognize(model_bundle, model_clust_thr, reduction_thr, reduction_distance, slr, num_threads, slr_metric, slr_x0, slr_bounds, slr_select, slr_method, pruning_thr, pruning_distance) and returns: pruned_streamlines,  self, Streamlines,  list