Make windowCenter and windowWidth metadata optional

This commit is contained in:
RunasSudo 2025-10-27 18:51:35 +11:00
parent 1af98b893c
commit bcee88678d
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -93,10 +93,12 @@ def ev_files_to_dcm_file(study_uid, series_uid, series_number, image_number, inp
#ds.BitsAllocated = metadata['bytesPerSample'] * 8 # Incorrect value!
#ds.BitsStored = metadata['bytesPerSample'] * 8
ds.Columns = metadata['columns']
ds.WindowCenter = metadata['windowCenter']
if 'windowCenter' in metadata:
ds.WindowCenter = metadata['windowCenter']
ds.LossyImageCompression = '01' if metadata['isLossyImage'] else '00'
ds.PixelSpacing = [metadata['rowPixelSpacing'], metadata['columnPixelSpacing']]
ds.WindowWidth = metadata['windowWidth']
if 'windowWidth' in metadata:
ds.WindowWidth = metadata['windowWidth']
ds.PlanarConfiguration = 1 if metadata['planarConfiguration'] else 0
ds.Rows = metadata['rows']