docstr: Extract bundles using existing indices (labels)
  
  Parameters
  ----------
  streamline_files : string
      The path of streamline files where you want to recognize bundles.
  labels_files : string
      The path of model bundle files.
  out_dir : string, optional
      Output directory. (default current directory)
  out_bundle : string, optional
      Recognized bundle in the space of the model bundle.
  
  References
  ----------
  .. [Garyfallidis17] Garyfallidis et al. Recognition of white matter
   bundles using local and global streamline-based registration and
   clustering, Neuroimage, 2017.
docstr_tok: ["Extract","bundles","using","existing","indices","(","labels",")","Parameters","--","--","--","--","--","streamline_files",":","string","The","path","of","streamline","files","where","you","want","to","recognize","bundles",".","labels_files",":","string","The","path","of","model","bundle","files",".","out_dir",":","string",",","optional","Output","directory",".","(","default","current","directory",")","out_bundle",":","string",",","optional","Recognized","bundle","in","the","space","of","the","model","bundle",".","References","--","--","--","--","--","..","[","Garyfallidis17","]","Garyfallidis","et","al",".","Recognition","of","white","matter","bundles","using","local","and","global","streamline-based","registration","and","clustering",",","Neuroimage",",","2017","."]
code: def run(
      self,
      streamline_files,
      labels_files,
      out_dir="",
      out_bundle="recognized_orig.trk",
  ):
      """Extract bundles using existing indices (labels)
  
      Parameters
      ----------
      streamline_files : string
          The path of streamline files where you want to recognize bundles.
      labels_files : string
          The path of model bundle files.
      out_dir : string, optional
          Output directory. (default current directory)
      out_bundle : string, optional
          Recognized bundle in the space of the model bundle.
  
      References
      ----------
      .. [Garyfallidis17] Garyfallidis et al. Recognition of white matter
       bundles using local and global streamline-based registration and
       clustering, Neuroimage, 2017.
  
      """
      logging.info("### Labels to Bundles ###")
  
      io_it = self.get_io_iterator()
      for f_steamlines, f_labels, out_bundle in io_it:
          logging.info(f_steamlines)
          sft = load_tractogram(
              f_steamlines, "same", bbox_valid_check=False
          )
          streamlines = sft.streamlines
  
          logging.info(f_labels)
          location = np.load(f_labels)
          if len(location) < 1:
              bundle = Streamlines([])
          else:
              bundle = streamlines[location]
  
          logging.info("Saving output files ...")
          new_sft = StatefulTractogram(bundle, sft, Space.RASMM)
          save_tractogram(new_sft, out_bundle, bbox_valid_check=False)
          logging.info(out_bundle)
  
imports: import logging
  from time import time
  import numpy
  from dipy.io.image import save_nifti, load_nifti
  from dipy.io.stateful_tractogram import Space, StatefulTractogram
  from dipy.io.streamline import load_tractogram, save_tractogram
  from dipy.tracking import Streamlines
  from dipy.segment.mask import median_otsu
  from dipy.segment.bundles import RecoBundles
  from dipy.workflows.workflow import Workflow
label_desc: Use image node_id 2 for calling the LabelsBundlesFlow obj's underlying member method code with example usage: obj.run(streamline_files, labels_files, out_dir, out_bundle) without return types