docstr: Workflow of bundle analytics.
  
  Applies statistical analysis on bundles of subjects and saves the
  results in a directory specified by ``out_dir``.
  
  Parameters
  ----------
  
  model_bundle_folder : string
      Path to the input model bundle files. This path may
      contain wildcards to process multiple inputs at once.
  
  subject_folder : string
      Path to the input subject folder. This path may contain
      wildcards to process multiple inputs at once.
  
  no_disks : integer, optional
      Number of disks used for dividing bundle into disks.
  
  out_dir : string, optional
      Output directory. (default current directory)
  
  References
  ----------
  .. [Chandio2020] Chandio, B.Q., Risacher, S.L., Pestilli, F.,
  Bullock, D., Yeh, FC., Koudoro, S., Rokem, A., Harezlak, J., and
  Garyfallidis, E. Bundle analytics, a computational framework for
  investigating the shapes and profiles of brain pathways across
  populations. Sci Rep 10, 17149 (2020)
docstr_tok: ["Workflow","of","bundle","analytics",".","Applies","statistical","analysis","on","bundles","of","subjects","and","saves","the","results","in","a","directory","specified","by","``","out_dir","``",".","Parameters","--","--","--","--","--","model_bundle_folder",":","string","Path","to","the","input","model","bundle","files",".","This","path","may","contain","wildcards","to","process","multiple","inputs","at","once",".","subject_folder",":","string","Path","to","the","input","subject","folder",".","This","path","may","contain","wildcards","to","process","multiple","inputs","at","once",".","no_disks",":","integer",",","optional","Number","of","disks","used","for","dividing","bundle","into","disks",".","out_dir",":","string",",","optional","Output","directory",".","(","default","current","directory",")","References","--","--","--","--","--","..","[","Chandio2020","]","Chandio",",","B.Q.",",","Risacher",",","S.L.",",","Pestilli",",","F.",",","Bullock",",","D.",",","Yeh",",","FC.",",","Koudoro",",","S.",",","Rokem",",","A.",",","Harezlak",",","J.",",","and","Garyfallidis",",","E.","Bundle","analytics",",","a","computational","framework","for","investigating","the","shapes","and","profiles","of","brain","pathways","across","populations",".","Sci","Rep","10",",","17149","(","2020",")"]
code: def run(
      self,
      model_bundle_folder,
      subject_folder,
      no_disks=100,
      out_dir="",
  ):
      """Workflow of bundle analytics.
  
      Applies statistical analysis on bundles of subjects and saves the
      results in a directory specified by ``out_dir``.
  
      Parameters
      ----------
  
      model_bundle_folder : string
          Path to the input model bundle files. This path may
          contain wildcards to process multiple inputs at once.
  
      subject_folder : string
          Path to the input subject folder. This path may contain
          wildcards to process multiple inputs at once.
  
      no_disks : integer, optional
          Number of disks used for dividing bundle into disks.
  
      out_dir : string, optional
          Output directory. (default current directory)
  
      References
      ----------
      .. [Chandio2020] Chandio, B.Q., Risacher, S.L., Pestilli, F.,
      Bullock, D., Yeh, FC., Koudoro, S., Rokem, A., Harezlak, J., and
      Garyfallidis, E. Bundle analytics, a computational framework for
      investigating the shapes and profiles of brain pathways across
      populations. Sci Rep 10, 17149 (2020)
  
      """
  
      if os.path.isdir(subject_folder) is False:
          raise ValueError("Invalid path to subjects")
  
      groups = os.listdir(subject_folder)
      groups.sort()
      for group in groups:
          if os.path.isdir(os.path.join(subject_folder, group)):
              logging.info("group = {0}".format(group))
              all_subjects = os.listdir(
                  os.path.join(subject_folder, group)
              )
              all_subjects.sort()
              logging.info(all_subjects)
          if group.lower() == "patient":
              group_id = 1  # 1 means patient
          elif group.lower() == "control":
              group_id = 0  # 0 means control
          else:
              print(group)
              raise ValueError(
                  "Invalid group. Neither patient nor control"
              )
  
          for sub in all_subjects:
              logging.info(sub)
              pre = os.path.join(subject_folder, group, sub)
              logging.info(pre)
              b = os.path.join(pre, "rec_bundles")
              c = os.path.join(pre, "org_bundles")
              d = os.path.join(pre, "anatomical_measures")
              buan_bundle_profiles(
                  model_bundle_folder,
                  b,
                  c,
                  d,
                  group_id,
                  sub,
                  no_disks,
                  out_dir,
              )
  
imports: import logging
  import numpy
  import os
  import json
  import warnings
  from time import time
  from scipy.ndimage import binary_dilation
  from dipy.utils.optpkg import optional_package
  from dipy.io import read_bvals_bvecs
  from dipy.io.image import load_nifti, save_nifti
  from dipy.core.gradients import gradient_table
  from dipy.reconst.dti import TensorModel
  from dipy.io.peaks import load_peaks
  from dipy.io.streamline import load_tractogram
  from dipy.segment.mask import segment_from_cfa
  from dipy.segment.mask import bounding_box
  from dipy.tracking.streamline import transform_streamlines
  from glob import glob
  from dipy.workflows.workflow import Workflow
  from dipy.segment.bundles import bundle_shape_similarity
  from dipy.stats.analysis import assignment_map
  from dipy.stats.analysis import anatomical_measures
  from dipy.stats.analysis import peak_values
label_desc: Use image node_id 2 for calling the BundleAnalysisTractometryFlow obj's underlying member method code with example usage: obj.run(model_bundle_folder, subject_folder, no_disks, out_dir) without return types