in pathology/transformation_pipeline/ingestion_lib/dicom_gen/wsi_to_dicom/dicom_util.py [0:0]
def get_default_icc_profile_color() -> Optional[bytes]:
"""Returns default ICC profile to that should be used if none is provided."""
default_icc_profile = ingest_flags.DEFAULT_ICC_PROFILE_FLG.value
if default_icc_profile is None:
return None
default_icc_profile = default_icc_profile.upper()
try:
if default_icc_profile == ingest_const.ICCProfile.SRGB:
profile = _get_srgb_iccprofile()
elif default_icc_profile == ingest_const.ICCProfile.ADOBERGB:
profile = _get_adobergb_iccprofile()
elif default_icc_profile == ingest_const.ICCProfile.ROMMRGB:
profile = _get_rommrgb_iccprofile()
elif default_icc_profile == ingest_const.ICCProfile.NONE:
# Not recommended, ICC Profile are required for all WSI imaging that
# do not encode monochrome imaging.
return None
else:
profile = _read_icc_profile_plugin_file(default_icc_profile)
if not profile:
raise ValueError(
f'Error occured loading ICC profile: {default_icc_profile}'
)
cloud_logging_client.info(
'ICC profile missing from source imaging; embedding default profile:'
f' {default_icc_profile} in DICOM.'
)
return profile
except FileNotFoundError as exp:
cloud_logging_client.error('Could not load default ICC Profile.', exp)
raise exp