code: def save_input_2_dso(
      input_data,
      reference_dicom_filepath,
      dso_metadata,
      reference_nifti_filepath=None,
      output_filepath=None,
      command="/home/abeers/Software/dcmqi-1.0.9-linux/bin/itkimage2segimage",
      verbose=True,
  ):
      """Given an DICOM directory to reference and a list of files (and in the future Nifti files), save these files
      to a DSO object.
      """
  
      reference_dicom_filepath = os.path.abspath(
          reference_dicom_filepath
      )
      output_filepath = os.path.abspath(output_filepath)
      dso_metadata = os.path.abspath(dso_metadata)
  
      base_command = [
          command,
          "--inputDICOMDirectory",
          quotes(reference_dicom_filepath),
          "--outputDICOM",
          output_filepath,
          "--inputMetadata",
          dso_metadata,
          "--inputImageList",
      ]
  
      if type(input_data) is not list:
          input_data = [input_data]
  
      input_data_string = ""
      for data_object in input_data:
          if input_data_string != "":
              input_data_string += ","
  
          # Check this typing syntax for Python 3
          if type(data_object) is str:
              data_object = os.path.abspath(data_object)
              input_data_string += data_object
          else:
              pass
              # TODO: Put in utility for converting numpy to DSO.
  
      base_command += [input_data_string]
  
      print((" ".join(base_command)))
      subprocess.call(" ".join(base_command), shell=True)
  
      return output_filepath
  
imports: import os
  import numpy
  import nibabel
  import nrrd
  import pydicom
  import subprocess
  from collections import defaultdict
  from imageio import imwrite, imread
  from deepneuro.utilities.util import grab_files_recursive, quotes
label_desc: Use image node_id 21 for calling a global function with example usage: save_input_2_dso(input_data, reference_dicom_filepath, dso_metadata, reference_nifti_filepath, output_filepath, command, verbose) and returns: output_filepath