given the PatientPosition tag is optional, if it doesn't exist on the DICOM file, then don't test for it
@@ -92,11 +92,14 @@ def require_dicom_patient_position(
required_image_orientation_patient = IMAGE_ORIENTATION_MAP[patient_position]
image_orientation_patient = dataset.ImageOrientationPatient
+ try:
if dataset.PatientPosition != patient_position:
raise ValueError(
f'The patient position is set to "{dataset.PatientPosition}", '
- f'however it is required to be "{patient_position}".'
+ f'however, if it is set, it is required to be "{patient_position}".'
)
+ except AttributeError:
+ pass
if image_orientation_patient != required_image_orientation_patient:
raise ValueError(
