I am using the following code in python to read the series description from the dicom header.
ds = dicom.read_file(mydcmfile.dcm)
a=ds.SeriesDescription
However, I get the following error because this part is blank in the dicom header for this specific image:
AttributeError: Dataset does not have attribute 'SeriesDescription'.
How can I prevent this error message and replace it with NAN?
Catch the exception and then treat it:
try:
a = ds.SeriesDescription
except AttributeError:
pass or something else