code: def parse_directories(
      data_collection, data_directories, case_list=None
  ):
      """Broken out from fill_data_groups."""
  
      if data_collection.verbose:
          print(
              ("Gathering image data from...", data_directories, "\n")
          )
  
      # Iterate through directories.. Always looking for a better way to check optional list typing.
      directory_list = []
      for d in data_directories:
          if not os.path.exists(d):
              print(
                  (
                      "WARNING: One of the data directories you have input,",
                      d,
                      "does not exist!",
                  )
              )
          directory_list += glob.glob(os.path.join(d, "*/"))
      directory_list = sorted(directory_list)
  
      for data_directory, data_groups in data_directories.items():
          directory_list = glob.glob(os.path.join(data_directory, "*/"))
  
          for directory in directory_list:
              case_name = os.path.abspath(directory)
  
              for data_group, sequence_labels in data_groups.items():
                  data_group_files = []
                  for sequence in sequence_labels:
                      # Iterate through patterns.. Always looking for a better way to check optional list typing.
                      if isinstance(sequence, str):
                          target_file = glob.glob(
                              os.path.join(case_name, sequence)
                          )
                      else:
                          target_file = []
                          for m in sequence:
                              target_file += glob.glob(
                                  os.path.join(case_name, m)
                              )
  
                      if len(target_file) == 1:
                          data_group_files.append(target_file[0])
                      else:
                          print(
                              (
                                  "Error loading",
                                  sequence,
                                  "from",
                                  os.path.basename(
                                      os.path.dirname(case_name)
                                  ),
                              )
                          )
                          if len(target_file) == 0:
                              print("No file found.\n")
                          else:
                              print("Multiple files found.\n")
                          return
  
                  if len(data_group_files) == len(sequence_labels):
                      data_collection.data_groups[data_group].add_case(
                          os.path.abspath(case_name),
                          list(data_group_files),
                      )
  
              data_collection.cases.append(case_name)
  
file_path: DeepNeuro/deepneuro/data/data_load.py
imports: import os
  import glob
  import csv
  import tables
  from deepneuro.utilities.util import grab_files_recursive, nifti_splitext
label_desc: Use image node_id 1 for calling a global function with example usage: parse_directories(data_collection, data_directories, case_list) without return types