-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
198 additions
and
82 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
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
This file was deleted.
Oops, something went wrong.
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
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
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""You can set your own rules for specific DICOM tags. Be aware that this might | ||
mean the deidentification is no longer DICOM-complient | ||
""" | ||
|
||
import pydicom | ||
from idiscore.core import Core, Profile | ||
from idiscore.defaults import get_dicom_rule_sets | ||
from idiscore.identifiers import RepeatingGroup, SingleTag | ||
from idiscore.operators import Hash, Remove | ||
from idiscore.rules import Rule, RuleSet | ||
|
||
# Custom rules that will hash the patient name and remove all curve data | ||
my_ruleset = RuleSet( | ||
rules=[ | ||
Rule(SingleTag("PatientName"), Hash()), | ||
Rule(RepeatingGroup("50xx,xxxx"), Remove()), | ||
], | ||
name="My Custom RuleSet", | ||
) | ||
|
||
sets = get_dicom_rule_sets() # Contains official DICOM deidentification rules | ||
profile = Profile( # add custom rules to basic profile | ||
rule_sets=[sets.basic_profile, my_ruleset] | ||
) | ||
core = Core(profile) # Create an deidentification core | ||
|
||
# read a DICOM dataset from file and write to another | ||
core.deidentify(pydicom.read("my_file.dcm")).save_as("deidentified.dcm") |
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
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,14 +1,41 @@ | ||
"""How mark safe private tags and known PII locations""" | ||
|
||
import pydicom | ||
from idiscore.core import Core, Profile | ||
from idiscore.defaults import get_dicom_rule_sets | ||
from idiscore.defaults import create_default_core | ||
from idiscore.image_processing import PIILocation, PIILocationList, SquareArea | ||
from idiscore.private_processing import SafePrivateBlock, SafePrivateDefinition | ||
|
||
sets = get_dicom_rule_sets() # Contains official DICOM deidentification rules | ||
profile = Profile( # Choose which rule sets to use | ||
rule_sets=[sets.basic_profile, sets.retain_modified_dates, sets.retain_device_id] | ||
safe_private = SafePrivateDefinition( | ||
blocks=[ | ||
SafePrivateBlock( | ||
tags=[ | ||
"0023[SIEMENS MED SP DXMG WH AWS 1]10", | ||
"0023[SIEMENS MED SP DXMG WH AWS 1]11", | ||
"00b1[TestCreator]01", | ||
"00b1[TestCreator]02", | ||
], | ||
criterion=lambda x: x.Modality == "CT", | ||
comment="Some test tags, only valid for CT datasets", | ||
), | ||
SafePrivateBlock( | ||
tags=["00b1[othercreator]11", "00b1[othercreator]12"], | ||
comment="Some more test tags, without a criterion", | ||
), | ||
] | ||
) | ||
core = Core(profile) # Create an deidentification core | ||
|
||
# read a DICOM dataset from file and write to another | ||
core.deidentify(pydicom.read("my_file.dcm")).save_as("deidentified.dcm") | ||
location_list = PIILocationList( | ||
[ | ||
PIILocation( | ||
areas=[SquareArea(5, 10, 4, 12), SquareArea(0, 0, 20, 3)], | ||
criterion=lambda x: x.Rows == 265 and x.Columns == 512, | ||
), | ||
PIILocation( | ||
areas=[SquareArea(0, 200, 4, 12)], | ||
criterion=lambda x: x.Rows == 265 and x.Columns == 712, | ||
), | ||
] | ||
) | ||
|
||
core = create_default_core( | ||
safe_private_definition=safe_private, location_list=location_list | ||
) |
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
Oops, something went wrong.