Skip to content

Commit

Permalink
Update dicomanonymizer/dicomfields_selector.py
Browse files Browse the repository at this point in the history
Co-authored-by: pchoisel <[email protected]>
  • Loading branch information
smasuda and pchoisel authored Jul 17, 2024
1 parent a4b82e8 commit 854bbe3
Showing 1 changed file with 18 additions and 29 deletions.
47 changes: 18 additions & 29 deletions dicomanonymizer/dicomfields_selector.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
from dicomanonymizer import dicomfields, dicomfields_2024b


def selector(dicom_version: str = "2013") -> dict:
if dicom_version == "2013":
return {
"D_TAGS": dicomfields.D_TAGS,
"Z_TAGS": dicomfields.Z_TAGS,
"X_TAGS": dicomfields.X_TAGS,
"U_TAGS": dicomfields.U_TAGS,
"Z_D_TAGS": dicomfields.Z_D_TAGS,
"X_Z_TAGS": dicomfields.X_Z_TAGS,
"X_D_TAGS": dicomfields.X_D_TAGS,
"X_Z_D_TAGS": dicomfields.X_Z_D_TAGS,
"X_Z_U_STAR_TAGS": dicomfields.X_Z_U_STAR_TAGS,
"ALL_TAGS": dicomfields.ALL_TAGS,
}
elif dicom_version == "2024b":
return {
"D_TAGS": dicomfields_2024b.D_TAGS,
"Z_TAGS": dicomfields_2024b.Z_TAGS,
"X_TAGS": dicomfields_2024b.X_TAGS,
"U_TAGS": dicomfields_2024b.U_TAGS,
"Z_D_TAGS": dicomfields_2024b.Z_D_TAGS,
"X_Z_TAGS": dicomfields_2024b.X_Z_TAGS,
"X_D_TAGS": dicomfields_2024b.X_D_TAGS,
"X_Z_D_TAGS": dicomfields_2024b.X_Z_D_TAGS,
"X_Z_U_STAR_TAGS": dicomfields_2024b.X_Z_U_STAR_TAGS,
"ALL_TAGS": dicomfields_2024b.ALL_TAGS,
}
else:
raise ValueError(f"Unknown DICOM version: {dicom_version}")
import dicomanonymizer.dicom_anonymization_databases

def dicom_anonymization_database_selector(dicom_version: str = "dicomfields_2023") -> dict:
anonymization_categories = ["D_TAGS", "Z_TAGS", "X_TAGS", "U_TAGS", "Z_D_TAGS", "X_Z_TAGS", "X_D_TAGS", "X_Z_D_TAGS", "X_Z_U_STAR_TAGS", "ALL_TAGS"]
try:
dicom_anonymization_database = getattr(
dicomanonymizer.dicom_anonymization_databases, "dicom_version")
except AttributeError:
raise ValueError(f"Unknown DICOM anonymization database: {dicom_version}")
try:
dicom_anonymization_dict = {
anonymization_category: getattr(
dicom_anonymization_database, anonymization_category)
for anonymization_category in anonymization_categories}
except AttributeError:
print(f"Anonymization database {dicom_version} is missing a category, please check it has them all.")
raise
return dicom_anonymization_dict

0 comments on commit 854bbe3

Please sign in to comment.