-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dicomanonymizer/dicomfields_selector.py
Co-authored-by: pchoisel <[email protected]>
- Loading branch information
Showing
1 changed file
with
18 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |