docstr: There is a lot of repeated code in the preprocessors. Think about preprocessor structures and work on this class.
          
docstr_tok: ["There","is","a","lot","of","repeated","code","in","the","preprocessors",".","Think","about","preprocessor","structures","and","work","on","this","class","."]
code: def execute(self, data_collection, return_array=False):
      """There is a lot of repeated code in the preprocessors. Think about preprocessor structures and work on this class."""
  
      if self.verbose:
          docker_print("Working on Preprocessor:", self.name)
  
      for label, data_group in list(self.data_groups.items()):
          self.generate_output_filenames(data_collection, data_group)
  
          if type(data_group.preprocessed_case) is not list:
              self.output_data = data_group.preprocessed_case
          else:
              for file_idx, output_filename in enumerate(
                  self.output_filenames
              ):
                  if os.path.isdir(
                      data_group.preprocessed_case[file_idx]
                  ):
                      if self.overwrite or not os.path.exists(
                          output_filename
                      ):
                          array_data, affine = read_image_files(
                              data_group.preprocessed_case[file_idx],
                              return_affine=True,
                          )
                          # TO-DO: Check if subsetting language behaviour below has edge cases.
                          save_data(
                              array_data[..., 0],
                              output_filename,
                              reference_data=affine,
                          )
                  else:
                      self.output_filenames[
                          file_idx
                      ] = data_group.preprocessed_case[file_idx]
  
              data_group.preprocessed_case = self.output_filenames
              self.output_data = data_group.preprocessed_case
  
          if return_array:
              self.convert_to_array_data(data_group)
  
imports: import os
  import numpy
  from deepneuro.utilities.util import add_parameter, replace_suffix, cli_sanitize, docker_print
  from deepneuro.utilities.conversion import read_image_files, save_data
label_desc: Use image node_id 2 for calling the DICOMConverter obj's underlying member method code with example usage: obj.execute(data_collection, return_array) without return types