code: def grab_files_recursive(
      input_directory,
      regex="*",
      return_dir=False,
      return_file=True,
      recursive=True,
  ):
      """Returns all files recursively in a directory. Essentially a convenience wrapper
      around os.walk.
  
      Parameters
      ----------
  
      input_directory: str
          The folder to search.
      regex: str
          A linux-style pattern to match.
  
      Returns
      -------
      output_list: list
          A list of found files.
      """
  
      output_list = []
  
      if recursive:
          for root, subFolders, files in os.walk(input_directory):
              if return_dir:
                  for subFolder in subFolders:
                      if fnmatch.fnmatch(subFolder, regex):
                          output_list += [os.path.join(root, subFolder)]
              if return_file:
                  for file in files:
                      if fnmatch.fnmatch(file, regex):
                          output_list += [os.path.join(root, file)]
  
      else:
          output_list = glob.glob(os.path.join(input_directory, regex))
  
      return output_list
  
file_path: DeepNeuro/deepneuro/utilities/util.py
imports: import glob
  import math
  import numpy
  import os
  import fnmatch
  import sys
label_desc: Use image node_id 5 for calling a global function with example usage: grab_files_recursive(input_directory, regex, return_dir, return_file, recursive) and returns: output_list