code: def buan_bundle_profiles(
      model_bundle_folder,
      bundle_folder,
      orig_bundle_folder,
      metric_folder,
      group_id,
      subject,
      no_disks=100,
      out_dir="",
  ):
      """
      Applies statistical analysis on bundles 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.
      bundle_folder : string
          Path to the input bundle files in common space. This path may
          contain wildcards to process multiple inputs at once.
      orig_folder : string
          Path to the input bundle files in native space. This path may
          contain wildcards to process multiple inputs at once.
      metric_folder : string
          Path to the input dti metric or/and peak files. It will be used as
          metric for statistical analysis of bundles.
      group_id : integer
          what group subject belongs to either 0 for control or 1 for patient.
      subject : string
          subject id e.g. 10001.
      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)
  
      """
  
      t = time()
  
      dt = dict()
  
      mb = glob(os.path.join(model_bundle_folder, "*.trk"))
      print(mb)
  
      mb.sort()
  
      bd = glob(os.path.join(bundle_folder, "*.trk"))
  
      bd.sort()
      print(bd)
      org_bd = glob(os.path.join(orig_bundle_folder, "*.trk"))
      org_bd.sort()
      print(org_bd)
      n = len(org_bd)
      n = len(mb)
  
      for io in range(n):
          mbundles = load_tractogram(
              mb[io], reference="same", bbox_valid_check=False
          ).streamlines
          bundles = load_tractogram(
              bd[io], reference="same", bbox_valid_check=False
          ).streamlines
          orig_bundles = load_tractogram(
              org_bd[io], reference="same", bbox_valid_check=False
          ).streamlines
  
          if len(orig_bundles) > 5:
              indx = assignment_map(bundles, mbundles, no_disks)
              ind = np.array(indx)
  
              metric_files_names_dti = glob(
                  os.path.join(metric_folder, "*.nii.gz")
              )
  
              metric_files_names_csa = glob(
                  os.path.join(metric_folder, "*.pam5")
              )
  
              _, affine = load_nifti(metric_files_names_dti[0])
  
              affine_r = np.linalg.inv(affine)
              transformed_orig_bundles = transform_streamlines(
                  orig_bundles, affine_r
              )
  
              for mn in range(len(metric_files_names_dti)):
                  ab = os.path.split(metric_files_names_dti[mn])
                  metric_name = ab[1]
  
                  fm = metric_name[:-7]
                  bm = os.path.split(mb[io])[1][:-4]
  
                  logging.info("bm = " + bm)
  
                  dt = dict()
  
                  logging.info("metric = " + metric_files_names_dti[mn])
  
                  metric, _ = load_nifti(metric_files_names_dti[mn])
  
                  anatomical_measures(
                      transformed_orig_bundles,
                      metric,
                      dt,
                      fm,
                      bm,
                      subject,
                      group_id,
                      ind,
                      out_dir,
                  )
  
              for mn in range(len(metric_files_names_csa)):
                  ab = os.path.split(metric_files_names_csa[mn])
                  metric_name = ab[1]
  
                  fm = metric_name[:-5]
                  bm = os.path.split(mb[io])[1][:-4]
  
                  logging.info("bm = " + bm)
                  logging.info("metric = " + metric_files_names_csa[mn])
                  dt = dict()
                  metric = load_peaks(metric_files_names_csa[mn])
  
                  peak_values(
                      transformed_orig_bundles,
                      metric,
                      dt,
                      fm,
                      bm,
                      subject,
                      group_id,
                      ind,
                      out_dir,
                  )
  
      print("total time taken in minutes = ", (-t + time()) / 60)
  
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 1 for calling a global function with example usage: buan_bundle_profiles(model_bundle_folder, bundle_folder, orig_bundle_folder, metric_folder, group_id, subject, no_disks, out_dir) without return types