docs: def apply_scaling(data, dicom_headers):
      """
      Rescale the data based on the RescaleSlope and RescaleOffset
      Based on the scaling from pydicomseries
  
      :param dicom_headers: dicom headers to use to retreive the scaling factors
      :param data: the input data
      """
  
      # Apply the rescaling if needed
      private_scale_slope_tag = Tag(0x2005, 0x100E)
      private_scale_intercept_tag = Tag(0x2005, 0x100D)
      if 'RescaleSlope' in dicom_headers or 'RescaleIntercept' in dicom_headers \
              or private_scale_slope_tag in dicom_headers or private_scale_intercept_tag in dicom_headers:
          rescale_slope = 1
          rescale_intercept = 0
          if 'RescaleSlope' in dicom_headers:
              rescale_slope = dicom_headers.RescaleSlope
          if 'RescaleIntercept' in dicom_headers:
              rescale_intercept = dicom_headers.RescaleIntercept
          # try:
          #     # this section can sometimes fail due to unknown private fields
          #     if private_scale_slope_tag in dicom_headers:
          #         private_scale_slope = float(dicom_headers[private_scale_slope_tag].value)
          #     if private_scale_slope_tag in dicom_headers:
          #         private_scale_slope = float(dicom_headers[private_scale_slope_tag].value)
          # except:
          #     pass
          return do_scaling(data, rescale_slope, rescale_intercept)
      else:
          return data