Configuration Guide#
A configuration file is a YAML file that sets the de-identification policy. The policy sets:
which tags are kept, removed, emptied, replaced or date-shifted
how far dates move
whether private tags go
which pixel zones are redacted on each machine
Keep the file under version control. It is the record of the policy you applied.
Load it with session.load_config("isocenter_config.yaml"). The policy in force is then session.configuration, an IsocenterConfiguration whose fields hold the file’s content:
Field |
Holds |
|---|---|
|
a dict from |
|
the |
|
|
|
|
|
|
|
the file |
|
whether each change is written to |
|
the |
A session that loads no file has the defaults in the table below, and applies the floor policy.
Quick Reference#
Section |
Description |
Default when absent |
|---|---|---|
The schema version, |
|
|
Base set of rules: |
the floor policy |
|
The range of the per-patient date shift, applied to tags whose rule is |
|
|
Removes vendor-specific private tags (odd groups). |
|
|
Overrides or adds tag rules, keyed by quoted |
none: the profile’s rules only |
|
Burned-in text redaction zones for specific equipment. |
none: no pixels are redacted |
|
Read the images a |
none: nothing is read by OCR |
Complete Example#
Save this as isocenter_config.yaml:
# 0. Schema version (optional; quoted)
version: "2.0"
# 1. Privacy Profile (Base Rules)
# Options: "basic@2026c" ("basic" is its short form), "none", or path to
# external YAML. Leave the line out for the floor policy.
privacy_profile: "basic@2026c"
# 2. Date Jitter
# Range for the per-patient date shift. It moves only the tags whose rule
# is SHIFT or JITTER (see "0008,0020" below).
date_jitter:
min_days: -30
max_days: -10
# 3. Private Tags
# Remove all odd-group tags (vendor specific)
remove_private_tags: true
# 4. Custom PHI Tags (Overrides Profile)
phi_tags:
"0008,0020":
action: "JITTER" # basic@2026c empties Study Date; shift it instead
name: "StudyDate"
"0008,1030":
action: "EMPTY"
name: "StudyDescription"
"0008,103e":
action: "REPLACE" # Writes "ANONYMIZED"
name: "SeriesDescription"
"0008,0080":
action: "KEEP" # Exception: Keep InstitutionName
# 5. Pixel Redaction Rules (Machine Specific)
machines:
- serial_number: "US-12345"
model_name: "Voluson E10"
redaction_zones:
# [row_start, row_end, col_start, col_end]
- [0, 50, 0, 800] # Top Banner
- [900, 1024, 0, 400] # Bottom Left Details
basic@2026c has no SHIFT or JITTER rule of its own. Without the "0008,0020" line, this file would shift no date, and every exported study would have an empty Study Date.
Schema (version 2)#
A configuration is read as exactly what it says. Every key and every value
type is listed below. An unknown key, a value of the wrong type, or a
version this library does not read makes load_config() and
audit(config_path=...) raise ValueError, naming the key, before
anything is assigned. A file written for 0.9.x may need small changes.
Level |
Key |
Type |
Default when absent |
|---|---|---|---|
top level |
|
a quoted |
|
top level |
|
|
the floor |
top level |
|
a mapping of quoted |
no overrides |
top level |
|
|
|
top level |
|
|
|
top level |
|
a list of machine rules |
no rules |
top level |
|
a mapping of |
no OCR |
machine rule |
|
a string, quoted if it is all digits. Write |
required, unless the rule has |
machine rule |
|
a mapping of |
none |
machine rule |
|
strings, as metadata. Nothing reads them, and |
none |
machine rule |
|
a list of zones |
no zones |
zone |
a list |
|
|
|
a string (the tag’s name), or a mapping of |
|
YAML sets three traps here. Isocenter refuses each one rather than read it:
An unquoted serial number is a number.
serial_number: 12345is the integer 12345, andserial_number: 0123is the octal integer 83. Neither ever equals a Device Serial Number, so the rule would match nothing. Quote it:serial_number: "0123".A quoted boolean is a string.
remove_private_tags: "false"is a non-empty string, which would read as true. A bareremove_private_tags:is null, which would read as false. Writetrueorfalseunquoted (yes/noalso work).An unquoted version is a number.
version: 2.10is the number 2.1. Quote it.
version. A file with no version line is version 2.0, and always
will be. A present version must be a quoted string whose major is 2, from
2.0 through this release’s own minor. It is written one way: "2.00"
and "02.0" are refused. A 1.x release raises the 2.x minor for one of
two reasons. Either it adds a key or a value, or it applies an unchanged
file differently (for example, a value-less REPLACE writing a dummy its
VR can hold). Either way, a file of an older 2.x still loads unchanged in
every later release. A file declaring a newer minor than this release’s
is refused, whatever it contains. The reason is that this release cannot
apply such a file the way it was written for: ValueError: cfg.yaml: version '2.1' is newer than this isocenter's configuration version 2.0, which may apply it differently than it was written for; upgrade isocenter, or set version: '2.0' to apply it as 2.0 does (#784).
An external profile file declaring a newer minor is refused the same way.
So are two writes onto a file that declares a newer minor. One is a
save() by a session whose config_path was assigned rather than loaded,
plainly or under auto_save. The other is a create_config(). Each
raises ValueError: cfg.yaml: declares version '2.1', newer than this isocenter's configuration version 2.0; saving would rewrite it as 2.0. Nothing was written: upgrade isocenter, or save to another path. A target that is missing,
cannot be read, or declares no newer minor is written as before.
When the way a file is applied changes, a store scanned under the older
minor is not treated as scanned under the new one. The minor is part of
the policy each PHI status records. So after such an upgrade, run
audit() and anonymize() before you export. An export made first writes
a WARNING row that stays in the store’s audit log, and every later
report of that store grades REVIEW_REQUIRED (see What to keep).
Detailed Options#
Privacy Profile#
Sets the baseline rules that phi_tags then extends or overrides. Default: with no privacy_profile line, the floor policy.
privacy_profile: "basic@2026c"
Value |
Base rules |
|---|---|
absent, or a bare |
the floor policy |
|
|
|
no base: the file’s |
a path, such as |
Any other value is refused: load_config() raises ValueError naming it.
A built-in profile’s name is pinned to the PS3.15 edition its table was taken from. basic@2026c is the name, and a bare basic means basic@2026c in every 1.x. Both load the same rules. After either, session.configuration.privacy_profile holds "basic@2026c", so save() writes the pinned name back. create_config() writes it. A later PS3.15 edition arrives in a minor release as a new name, under a new configuration schema minor. It never arrives as a new meaning for this name. A name is looked up exactly. basic@2026C is refused, and so is Basic unless a file of that name exists. If such a file exists, Basic loads as an external profile. A value containing @ that this version does not ship raises ValueError saying which names it ships. Such a value is never read as a file path.
The floor policy#
A session that has loaded no configuration applies the floor policy: basic@2026c with three of its 649 rules changed to the research defaults create_config() writes. Study Date is shifted rather than emptied, and Patient’s Sex and Patient’s Age are kept. Private tags are removed, as remove_private_tags defaults to true. The floor is built on basic@2026c in every 1.x. The compliance report names it (None (session defaults: the floor policy over basic@2026c)). For a session under privacy_profile: none, or under an external profile that contributed no rules, the report says None (no base profile).
Omitting privacy_profile means the floor beneath your phi_tags. A file with a few tags and no profile line extends the floor rather than replacing it. So a one-tag configuration cannot disable the floor by accident. A bare privacy_profile: line (YAML null) is the same as leaving the line out. To opt a single tag out, give it action: "KEEP". To opt out of the floor entirely, write privacy_profile: "none".
none#
No base. The file’s phi_tags are the whole policy. Patient’s Name, Patient ID and Study Date are still replaced unless a rule says otherwise (see below). Any other standard tag the file does not name is exported as ingested. Private tags still follow remove_private_tags, which defaults to true.
External profile file#
A path to another YAML file (e.g., ./profiles/my_hospital_standard.yaml) inherits its rules. That file carries its rules under a phi_tags: mapping and nothing else, beside an optional version. Any other key raises ValueError naming it. A profile file contributes only its phi_tags. So a privacy_profile: basic or remove_private_tags: line inside it would be ignored, and is refused instead: a configuration is not a profile. A bare tag map at its root raises ValueError too.
What basic@2026c contains#
basic@2026c (short form basic) is the Basic Profile column of DICOM PS3.15 Annex E, Table E.1-1, edition 2026c, as 649 tag rules. The table has 656 rows, and 647 of them give a rule. The other nine give none:
the two
X/Z/U*sequences, Referenced Image Sequence and Source Image Sequence. They are kept, and the UIDs inside them are replaced as rows of their own.the private-attribute row
gggg,eeee, which is theremove_private_tagssweep.the four sequences listed below as having no rule (Verifying Observer, Flow Identifier, Waveform Annotation and Icon Image).
Overlay Data and Overlay Comments, which are folded into the overlay group rule.
The other two rules are on keys the table has no row for: the overlay group 60xx,xxxx and Referenced File ID (0004,1500). A row’s code maps to a rule as follows:
Xremoves the attribute.ZandX/Zempty it, so a Type 2 attribute stays present.D, and every code with a D arm (X/D,Z/D,X/Z/D), isREPLACEwith no value, which writes a dummy value consistent with the attribute’s VR.
PS3.15 Table E.1-1a defines D as “replace with a non-zero length value that may be a dummy value and consistent with the VR”, and Z as “a zero length value, or a non-zero length value that may be a dummy value and consistent with the VR”. So the dummy is what the code asks for where it resolves to D (an attribute Type 1 in its IOD, such as Verifying Observer Name in a Structured Report). Where the code resolves to Z, the dummy is a value the code permits. The dummies are the same constant for every instance and carry nothing of the original:
VR |
Dummy written |
|---|---|
AE, CS, LO, LT, PN, SH, ST, UC, UR, UT |
|
DA, DT |
|
TM |
|
AS |
|
OB, OW, UN |
two zero bytes |
OF, OL |
four zero bytes |
OD, OV |
eight zero bytes |
The table’s 50xx,xxxx row is a rule, and the whole overlay group is one: see Repeating groups. A rule on a sequence removes the sequence, or empties it to zero items. Identifiers nested inside any sequence are handled wherever they sit.
It is not the whole of Annex E. Where it departs from the table:
UIDs are replaced by UIDs derived from the project secret. Each
Urow, and Annotation Group UID’sD, isREPLACEwith no value. On a UI attribute, that is UID replacement: the value becomes2.25.followed by a UUID derived from the value and the store’s project secret. One source UID gets one replacement wherever it appears in the store. For example, the Study Instance UID gets one replacement on every file of the study. A Referenced SOP Instance UID nested in a sequence gets the same replacement as the SOP Instance UID it names. So references between exported files still resolve, and the next pass recognises a replacement and leaves it alone. The replacement names the entity from then on.export(subset=...)accepts the UID a study, series or instance had before the pass as well as its replacement. A lateringest()of another file of a replaced study or series joins that study or series. Withremove_private_tags: false, a private element whose value is a UID replaced in the same instance takes the same replacement, in the element’s own form. That UID is the instance’s Study, Series or SOP Instance UID, or any other UID the policy replaces in it. A private creator, and a private tag the configuration has a rule for, are left to that rule (#765). There are three limits. A private element holding a UID that only another instance carries is not replaced. A UID written into free text, such as a description or a private text element, is not found. A redacted instance’s new SOP Instance UID is derived from its source UID and its zones. So a reference to the redacted instance from another file names the replacement of the source UID, which no exported file carries. The table’s twoX/Z/U*sequences (Referenced Image Sequence and Source Image Sequence) have no rule: they are kept, and the UIDs inside them are replaced.REPLACEwith avalue:on a UI attribute writes that value. On SOP Instance UID, it does not move what the export is organised by: a file whose SOP Instance UID is given a value is still named by its source UID. On Study and Series Instance UID, it is refused when it is loaded. UseREPLACEwith no value on all three.No code from CID 7050 is written to De-identification Method Code Sequence
(0012,0064), not even113100(Basic Application Confidentiality Profile). The departures listed here are whybasic@2026cdoes not claim that profile. What the export writes instead is under What an exported file says about itself.Patient’s Name is
REPLACErather than the table’sZ: it becomesANONYMIZED, a dummyZpermits. Patient ID follows itsZ/Dcode.REPLACEwith no value on Patient ID is the keyedANON_pseudonym, which is its dummy. A Patient ID rule may not empty or remove Patient ID. Study Date follows the table and is exported zero-length. The floor shifts it instead.Where an
X/DorX/Z/Dattribute is Type 3 in its IOD, the table’s code removes it, and Isocenter writes the dummy instead. This departs from the code’s X arm. PS3.15 E.1.1 permits it as protection (“either be removed from the Data Set, or have its value replaced by a different ‘replacement value’ that does not allow identification of the patient”). Isocenter does not know each attribute’s type in each IOD, so it cannot tell which arm applies to an instance (#558). Isocenter writes the value that is valid under every arm. Series Date and Time, Instance Creation Date and Protocol Name are the ones most image files carry. Each is present in the export holding its dummy.Six sequences whose code has a D arm keep
EMPTYorREMOVE. D on a sequence asks for items that are themselves valid. What makes an item valid depends on the IOD, so no dummy item is written:Emptied to zero items: Institution Code Sequence and Referenced Performed Procedure Step Sequence (
X/Z/D), and Person Identification Code Sequence (D).Removed: Operator Identification Sequence (
X/D), and Content Sequence and Graphic Annotation Sequence (D). Each of the last two must hold one or more items when present: Content Sequence is Type 1C and Graphic Annotation Sequence is Type 1. A zero-item one breaks that rule, and an absent one keeps it. An SR’s root content item becomes a leaf, which PS3.3 allows. A presentation state that applies no annotations has no Graphic Annotation Module, which PS3.3 requires only while annotations are applied. 1.0.0rc4 emptied both. They are removed since 1.0.0rc5 (#848).The rest of the file is not made to fit, under either action. An SR’s template can require content items: a Key Object Selection must reference, in its content, every instance its Current Requested Procedure Evidence Sequence names. A presentation state keeps its Graphic Layer Module, which no rule removes. PS3.3 requires that module only while annotations or overlays are applied, and a conditional module whose condition is not met shall not be present.
Person Identification Code Sequence is Type 1 inside the Person Identification Macro, so emptying it and removing it both break that rule. It stays emptied.
A Structured Report is exported without its content tree, and a presentation state without its annotations. Content Sequence
(0040,A730)holds the content items of an SR document (a report, a measurement report, a Key Object Selection). A TEXT item’s Text Value(0040,A160)is free text that no row of the table reaches. Graphic Annotation Sequence(0070,0001)holds a presentation state’s text and graphic objects. An object’s Tracking ID(0062,0020)and a major tick’s Tick Label(0070,0289)are free text that no row reaches either. The rows nested inside cannot clean such text, so the sequence is removed. To keep either, give its keyaction: "KEEP". The rows inside a kept sequence still apply: names and dates hold their dummies, Unformatted Text Value is replaced, and UIDs are replaced. The free text no row reaches is exported as written. This is because the table’s Clean Structured Content and Clean Graphics options, which would clean it, are not implemented. A kept SR’s Text Values can be cleaned withSCRUB.The table’s other sequences coded
Dhave no rule: Verifying Observer Sequence and Flow Identifier Sequence. Every identifying attribute their items can hold is a row of its own and is handled where it sits, so the items stay valid. Waveform Annotation Sequence is below.Study and Series Description are emptied rather than removed, because the export directory names read them.
Waveform Annotation Sequence (the Murmur annotation bridge reads it) and Icon Image Sequence have no rule. Attributes inside them are still scanned. An icon is dropped when its pixels may show what redaction removed. There are two tiers:
An instance’s own Icon Image Sequence is dropped when that instance is redacted or has redaction zones applied at export.
Every other nested icon – a thumbnail under Referenced Image Sequence, of a different instance – is dropped when any instance in the store is redacted or a zones rule matches any series in the store. That holds whether or not that instance is in the export.
Retired Curve groups
(50xx)are removed, by the table’s own50xx,xxxxrow. Overlay groups(60xx)are removed whole by60xx,xxxx, a rule the table does not have. The table removes Overlay Data(60xx,3000)and Overlay Comments(60xx,4000). That alone leaves an Overlay Plane module without its Type 1 element (PS3.3 C.9-2), with its free-text Overlay Description and Overlay Label in place. PS3.15 E.1.1 says “If non-pixel data graphics or overlays contain identification, the de-identifier is required to remove them”. The two table rows are folded into the group rule, so"60xx,xxxx": {action: KEEP}keeps a whole, valid overlay.A presentation state’s Bitmap Display Shutter can name an overlay group this rule removes. Shutter Overlay Group
(0018,1623)is kept as written, and then points at a group the file no longer has. PS3.15 Annex E is the authority on what the profile removes. For the overlay group, the authority is E.1.1’s sentence on overlays quoted above. For every other attribute, it is Table E.1-1, which has no row for Shutter Overlay Group. Isocenter does not second-guess either for one object. It neither keeps a group because a shutter names it nor removes the shutter. Removing Overlay Data alone, as the table’s own row does, already left that presentation state without a Type 1 element. Where the presentation state must stay valid, keep the overlays:"60xx,xxxx": {action: KEEP}.
Referenced File ID
(0004,1500)is removed, a rule the table does not have. It is a Directory Record element of the Basic Directory IOD (the DICOMDIR, PS3.3 Annex F), not part of any composite instance. So in an image file it is an anomaly. Its value is a file-set path, which sites build from MRNs, accession numbers or dates. Table E.1-1 has no row for it, so through 1.0.0rc20 an image file carrying one exported it as written (#1133). The rule is on that element alone, wherever it sits, nested items included, and not on group 0004. Referenced SOP Instance UID in File(0004,1511)keeps itsUrow, and the other Directory Structuring elements have no rule. To keep Referenced File ID, give"0004,1500"action: "KEEP".Isocenter’s own redaction note in Derivation Description
(0008,2111)is kept. Any other Derivation Description is removed.Private attributes are the
remove_private_tagssweep, not a rule.
The table removes, empties or replaces attributes research often wants: Patient’s Weight and Size (PET SUV), Patient’s Age, Protocol Name, Contrast/Bolus Agent, ROI Name and Channel Label. Give any of them action: "KEEP" to retain it.
What basic@2026c contains is frozen for every 1.x: the rules 1.0 ships under it, which are the table, this mapping and these departures. The one exception is a row the published 2026c standard shows was transcribed wrongly. A 1.x may correct such a row as a Breaking changelog entry quoting the standard’s row. Any other change is a new name.
A PHI status records the policy it was recorded under. An export() that writes instances whose statuses were recorded under another policy writes one WARNING row naming the policies. The row stays: every later report of the store grades REVIEW_REQUIRED. After reopening a store, load the configuration it was anonymized under before anything else. A store anonymized by a 0.9.x release has statuses of this kind.
Keeping UIDs#
PS3.15’s Retain UIDs Option is KEEP on the U rows. Keep all of them or none. If you keep Study Instance UID while SOP Instance UID is replaced, the export holds references that name nothing in it. The same happens if you keep a Referenced SOP Instance UID while the SOP Instance UID it names is replaced. A kept UID links the export to its source for anyone who can see the source UIDs. A UID that embeds a date carries that date.
phi_tags:
"0000,1001": {action: KEEP} # Requested SOP Instance UID
"0002,0003": {action: KEEP} # Media Storage SOP Instance UID
"0004,1511": {action: KEEP} # Referenced SOP Instance UID in File
"0008,0014": {action: KEEP} # Instance Creator UID
"0008,0017": {action: KEEP} # Acquisition UID
"0008,0018": {action: KEEP} # SOP Instance UID
"0008,0019": {action: KEEP} # Pyramid UID
"0008,0058": {action: KEEP} # Failed SOP Instance UID List
"0008,1155": {action: KEEP} # Referenced SOP Instance UID
"0008,1195": {action: KEEP} # Transaction UID
"0008,3010": {action: KEEP} # Irradiation Event UID
"0018,1002": {action: KEEP} # Device UID
"0018,100b": {action: KEEP} # Manufacturer's Device Class UID
"0018,2042": {action: KEEP} # Target UID
"0020,000d": {action: KEEP} # Study Instance UID
"0020,000e": {action: KEEP} # Series Instance UID
"0020,0052": {action: KEEP} # Frame of Reference UID
"0020,0200": {action: KEEP} # Synchronization Frame of Reference UID
"0020,9161": {action: KEEP} # Concatenation UID
"0020,9164": {action: KEEP} # Dimension Organization UID
"0028,1199": {action: KEEP} # Palette Color Lookup Table UID
"0028,1214": {action: KEEP} # Large Palette Color Lookup Table UID
"003a,0310": {action: KEEP} # Multiplex Group UID
"0040,0554": {action: KEEP} # Specimen UID
"0040,4023": {action: KEEP} # Referenced General Purpose Scheduled Procedure Step Transaction UID
"0040,a124": {action: KEEP} # UID
"0040,a171": {action: KEEP} # Observation UID
"0040,a172": {action: KEEP} # Referenced Observation UID (Trial)
"0040,a402": {action: KEEP} # Observation Subject UID (Trial)
"0040,db0c": {action: KEEP} # Template Extension Organization UID
"0040,db0d": {action: KEEP} # Template Extension Creator UID
"0062,0021": {action: KEEP} # Tracking UID
"0064,0003": {action: KEEP} # Source Frame of Reference UID
"006a,0003": {action: KEEP} # Annotation Group UID
"0070,031a": {action: KEEP} # Fiducial UID
"0070,1101": {action: KEEP} # Presentation Display Collection UID
"0070,1102": {action: KEEP} # Presentation Sequence Collection UID
"0088,0140": {action: KEEP} # Storage Media File-set UID
"0400,0100": {action: KEEP} # Digital Signature UID
"3006,0024": {action: KEEP} # Referenced Frame of Reference UID
"3006,00c2": {action: KEEP} # Related Frame of Reference UID
"300a,0013": {action: KEEP} # Dose Reference UID
"300a,0054": {action: KEEP} # Table Top Position Alignment UID
"300a,0083": {action: KEEP} # Referenced Dose Reference UID
"300a,0609": {action: KEEP} # Treatment Position Group UID
"300a,0650": {action: KEEP} # Patient Setup UID
"300a,0700": {action: KEEP} # Treatment Session UID
"300a,0785": {action: KEEP} # Referenced Treatment Position Group UID
"3010,0006": {action: KEEP} # Conceptual Volume UID
"3010,000b": {action: KEEP} # Referenced Conceptual Volume UID
"3010,0013": {action: KEEP} # Constituent Conceptual Volume UID
"3010,0015": {action: KEEP} # Source Conceptual Volume UID
"3010,0031": {action: KEEP} # Referenced Fiducials UID
"3010,003b": {action: KEEP} # RT Treatment Phase UID
"3010,006e": {action: KEEP} # Dosimetric Objective UID
"3010,006f": {action: KEEP} # Referenced Dosimetric Objective UID
Patient’s Name, Patient ID and Study Date#
These three belong to the patient and the study, and the exporter writes the patient’s and study’s value on every file. Their rule governs that value:
Rule |
Patient’s Name |
Patient ID |
Study Date |
|---|---|---|---|
no rule, or |
|
the keyed |
the per-patient shift |
|
the value |
refused |
the value (a valid DA) |
|
kept |
kept |
kept |
|
zero-length |
refused |
zero-length |
|
zero-length in the file, and removed from the instance’s own copy |
refused |
zero-length in the file, and removed from the instance’s own copy |
|
refused |
refused |
the per-patient shift |
REMOVE still writes the element, at zero length. Patient’s Name and Study Date are both Type 2 in their modules, so a file without them would not conform. A Patient ID rule other than KEEP or REPLACE with no value raises ValueError. The reason is that the ID is what keeps two patients apart, and anonymize() merges patients that share one. On Study Date, the string form ("0008,0020": "Study Date") is REPLACE with no value, and means the shift.
Date Jitter#
Sets the range of the per-patient date shift. Default: {min_days: -365, max_days: -1}.
The shift applies only to tags whose rule is SHIFT or JITTER, and to Study Date when it has no rule or REPLACE with no value. basic@2026c has no SHIFT or JITTER rule. It removes, empties or replaces with a dummy the dates Table E.1-1 names (Study, Series, Acquisition, Content, Instance Creation and the rest). So under basic@2026c alone, date_jitter moves nothing. The floor and the file create_config() writes give Study Date JITTER. To shift another date, give it action: "JITTER". A date tag no rule names is exported as ingested. Under basic or the floor, that is a date the table does not name. Under privacy_profile: none, it is every date your phi_tags leave out. Add a rule for any such date that must not leave the site.
Logic: Isocenter derives each patient’s offset from a secret it generates for the project and keeps inside the session store. The offset is the same for every study and series of that patient, so intervals survive. Without that secret, the offset cannot be computed from the exported pseudonym, or from any other value the derivation uses. That is a statement about the offset. It is not a guarantee that no exported date can be recovered. A date tag no rule shifts is exported as it was, a UID the configuration keeps carries any date it embeds, and a whole-day shift keeps the weekday. The offset is not random per run. It hides absolute dates only from someone who holds neither the store nor the secret. A store and its exports must not travel together, because the store holds the secret and the store’s audit log records each offset. The log file (
isocenter.log) records neither original Patient IDs nor offsets. Offsets and pseudonyms belong to the store, and a secret cannot be carried to another store. See What to keep. Within one store, a later batch for a patient already in it, ingested under its original Patient ID, joins that patient’s studies whenanonymize()gives it the same pseudonym, and its dates land on the same offset. A store de-identified by a release before 0.9.7 used an offset that can be computed from an exported file (advisory GHSA-phg9-vcvc-j4r7).Config:
date_jitter: min_days: -10 max_days: 10
For a fixed shift, give both bounds the same value (
{min_days: -5, max_days: -5}). A bare integer (date_jitter: -5) is refused, and so ismin_daysgreater thanmax_days, which has at least one bound wrong. A range assigned in code (session.configuration.date_jitter = ...) is judged the same way.audit(),anonymize(),configuration.save()andcreate_config()raise the loader’sValueErrorrather than swap the bounds or write a file that does not load (#731).
What an exported file says about itself#
export(format="dicom") writes up to three elements that say how the file was de-identified. They state which software ran and which policy it applied. They do not say whether that policy is enough: that is your configuration’s call.
When. The export writes the markers only on an instance whose patient, study and own PHI status all read REMEDIATED or CLEARED, recorded under one policy. That policy must be the one in force or one this session ran audit() under. That is the condition under which the export writes no “recorded under a policy other than the one in force” notice. The markers are not written on:
an instance never audited
an instance with a finding left open, whether declined, not handed to
anonymize(), or a Series findingan instance whose own attributes were edited after its pass
a patient restored with
recover_patient_identity(restore=True)a store reopened under another policy and not audited again
a store written before 1.0
The markers rest on the same status the report’s grade reads. So any edit after the pass withholds the markers until a scan reads the edit. That covers an instance’s own attributes. It also covers an owner field assigned directly, such as patient.patient_name = ..., a Series field, such as series.series_instance_uid = ..., and a value set inside a nested sequence item.
Attributes, not pixels. YES records that the attribute policy was applied in full and that the file declares no burned-in text. Isocenter does not read the pixels to decide it. PS3.3 defines YES as identity removed from the Pixel Data as well. So a file whose Burned In Annotation (0028,0301) says YES does not get YES. The source’s own (0012,0062), if any, stays, and the De-identification Method value and the temporal marker are still written. Text drawn into the pixels is redact()’s to clear (see Pixel Redaction). redact() writes Burned In Annotation NO on the pixels it clears, and that file then says YES. A (0012,0062) already in the source is kept as the source wrote it, YES included, beside a Burned In Annotation YES. The kept (0012,0062) is the source’s claim, not Isocenter’s, and the hold-back governs only the YES Isocenter writes. The file is read as it is written. So a rule of yours that removes Burned In Annotation removes the declaration too, and the file then says YES: that is your policy’s call.
What.
Patient Identity Removed
(0012,0062):YES. A source value ofNOis replaced, and a sourceYESstays.De-identification Method
(0012,0063)gains one value, after any values the source carried, which are kept in order:isocenter/<version>; <policy>; v1:<8 hex>.<policy>isbasic@2026c,floor over basic@2026cornone. An external profile isexternal profile, never its path.The hex is the first 32 bits of the policy’s fingerprint (
phi_status_policy). It tells two policies under one label apart, such as the floor and the floor with overrides. The fingerprint includes the configuration schema version. So a release that raises that version’s minor moves the hex in every file it writes, under an unchanged configuration.No value is added if the last value is already this one. So re-exporting an ingested Isocenter export under the same policy and release adds nothing.
Longitudinal Temporal Information Modified
(0028,0303), read from the file’s own dates. Every DA and DT element is read, including nested ones and private ones whose VR is recorded. A private element whose VR the source did not state (an Implicit VR source, or an Explicit VR one that saysUN) has no recorded VR, whether or not pydicom’s private dictionary knows its creator. So a date in such an element is not read and does not stopREMOVED. The element is exported asUN, andremove_private_tags(on by default) removes it.MODIFIEDwhen at least one date is a shift this store wrote, whatever the others are. It replaces the source’s value, a sourceUNMODIFIEDincluded. It says that a date in the file was modified, not that every date was: a date beside it may be as it was ingested.REMOVEDwhen no date is shifted and every date is empty or the dummy19000101.Nothing when no date is shifted and any date is as it was ingested. The source’s value, if any, then stays, with one exception.
A source’s
UNMODIFIEDis not carried into such a file when this store’s own record shows that it emptied, removed or wrote the dummy to a top-level date of that instance, and the file still lacks that date. The element is then absent: no enumerated value says “some removed, none shifted, some kept”. A source’sMODIFIEDorREMOVEDstays, and so does anUNMODIFIEDin a file none of whose dates this store took. Three things the record does not show, beside each of which a source’sUNMODIFIEDstill stays: a date removed inside a sequence, a private date removed byremove_private_tags, and a date a rule replaced with a value of its own that is not the dummy. A source that already saysUNMODIFIEDbeside dates an earlier tool emptied is that tool’s claim, and stays too. One limit runs the other way. The record does not say whether a removed element held a value. So aREMOVErule on a top-level date the source left empty counts as a date this store took, and a source’sUNMODIFIEDis withdrawn although no date value changed.EMPTYand a value-lessREPLACEon an empty date record nothing and leave it. These limits are #1044.TM is not read: a time of day beside a shifted date does not place the patient in time. An emptied or removed time does not withdraw a source’s
UNMODIFIEDeither.UNMODIFIEDis never written, because a date kept on purpose cannot be told from one no rule named.
Worked on a CT whose source holds Study Date, Series Date, Acquisition Date, Content Date, Instance Creation Date and an empty Birth Date:
Policy
Study Date
The other dates
(0028,0303)the floor
shifted
empty or
19000101MODIFIEDbasic@2026cempty
empty or
19000101REMOVEDprivacy_profile: noneshifted (the default for Study Date with no rule)
as ingested
MODIFIEDnoneplus0008,0020: KEEPas ingested
as ingested
nothing. A source’s value stays.
the floor plus
0008,0021: KEEPshifted
Series Date as ingested, the rest empty or
19000101MODIFIEDbasic@2026cplus0008,0021: KEEPempty
Series Date as ingested, the rest empty or
19000101nothing. A source’s
MODIFIEDorREMOVEDstays, and a source’sUNMODIFIEDdoes not.De-identification Method Code Sequence
(0012,0064): no code is written (see the departures above). A source’s items pass through.
Your rules decide. Table E.1-1 has no row for any of the three elements. A rule you write on one, of any action, KEEP included, means the export writes no marker to that element: KEEP over a source NO exports NO. The other two markers are still written.
Where not. DicomExporter.write_tree() writes none of them: it is the serializer without the pipeline. A WFDB header has no such field. The markers are never written into the store.
Pixel Redaction (Machines)#
Redacts burned-in text (pixels) on specific devices. Isocenter identifies the machine by the Device Serial Number (0018,1000) of each series. Default: no rules, so no pixels are redacted.
Worked example: Redact burned-in text for one machine.
machines:
- serial_number: "SN-9999"
model_name: "Documentation Only"
redaction_zones:
- [0, 100, 0, 500]
serial_number: one of three forms. A bareserial_number:is null, and is refused as missing.An exact match for
0018,1000.""(quoted) for every series with no Device Serial Number. That includes a series whose files name no manufacturer, no model and no serial (it has no equipment). A series whose files carry a serial and nothing else is matched by that serial, not by""."*"for every series, with a serial or without.
match: select by device instead of serial, for a machine whose files carry no serial number:machines: - match: manufacturer: "FUJI PHOTO FILM CO. LTD." model_name: IRS redaction_zones: - [60, 90, 60, 380]
Give
manufacturer,model_name, or both. Each is compared exactly with Manufacturer(0008,0070)and Manufacturer’s Model Name(0008,1090)as the files spell them, case and spaces included. The rule covers every series of that device whatever its serial, with one or without. A series whose files name neither is never matched. A rule has exactly one selector:serial_numberormatch, never both. Themanufacturerandmodel_namekeys besideserial_numberare still labels, read by nothing, becauseadd_rule()writesUnknownfor both by default.get_rule(),update_rule()anddelete_rule()find a rule by its serial and do not see amatchrule. Write amatchrule in the file, or append it toconfiguration.rules.Every matching rule applies, in
redact()and at export alike: an exact rule, amatchrule, a""rule and a"*"rule, or two rules for one serial, each zero their zones. No rule takes precedence over another for what is zeroed.redact()redacts such an image once, with every matching rule’s zones, and derives its new SOP Instance UID from all of them, whatever order the work runs in (#908). The export applies them whether or notredact()has run.redaction_zones: List of zones to zero out.Format:
[y1, y2, x1, x2](Row Start, Row End, Col Start, Col End), or{"roi": [y1, y2, x1, x2]}, the shape the shipped knowledge base uses andcreate_config()copies for a machine it recognises.Coordinates are 0-indexed.
End must be strictly greater than start on both axes.
load_config()accepts a zone whose start equals its end. Such a zone selects no pixels, andredact()fails every instance the zone applies to withRedactionError.
To find where a machine draws its text, see Zone Discovery.
Burned-in Text#
Reads the images its scope names with OCR and acts on the text it finds, image by image. It is for text that moves from one image to the next, which no zone describes, and for series with no Device Serial Number (#1108, #1121). Default: absent, so nothing is read by OCR and nothing below happens. It needs the ocr extra and the tesseract binary (OCR prerequisites). Under detector: db, it needs the textdetect extra instead, which the free-threaded build cannot install (Detecting text with a model).
burned_in_text:
action: redact # report | redact | withhold (required)
scope: modalities # flagged | modalities | all (required)
modalities: [CR, DX, MG] # required under scope: modalities, refused otherwise
target: [names, dates, ids] # any | a list of kinds; default any
detector: tesseract # tesseract | db; default tesseract
min_confidence: 80 # 0 to 100; default 80
scope(required, spelled exactly): which images the policy reads and gates. Every scope reads only images that hold pixels.flagged: an image whose Burned In Annotation(0028,0301)saysYES(in any letter case, padding ignored, and a value held as bytes is not read), or an image this store has redacted, or one whose record from an earlier read holds a text box. The last two are there because a zone redaction writes Burned In AnnotationNO. Read by the flag alone, an imagewithholdkept out, or an image a zone redacted before the policy was loaded, would leave the scope and be written with its text. A record with no box does not keep an image in scope. So an image read underalland found clean is not read again underflagged. The flag is read from the image as it stands whenredact()runs. Aphi_tagsrule of your own that removes or replaces(0028,0301)takes theYESaway inanonymize(), beforeredact()reads it.flaggedthen does not read that image.modalities: whatflaggedreads, and every image of a series one of whose Modality values is inmodalities.all: every image that holds pixels.An image out of scope is not read, and the export writes it with no row, as it writes an image with no pixels. A pass that selects nothing costs no PASS. The
REDACTIONrow and section 5 of the report say how many images were out of scope. On MIDI-B no file of 53,581 saysYES, soflaggedreads nothing there.modalities: [CR, DX, MG, US]reads 258 of the Validation set’s 23,921 instances, whereallreads about 24,000 (nearly all CT, MR and PET slices).
modalities: a list of Modality values as DICOM writes them: upper case (CR, notcr), letters, digits, underscore and space, at most 16 characters. A repeat is dropped. Required underscope: modalitiesand refused under any other scope. The list itself must be upper case, but a source’s Modality is matched upper-cased: a file that writescrfalls inmodalities: [CR].target(optional, defaultany): which text found is acted on.anyis every box, as described below. A list of kinds,[names, dates, ids]or any of them, acts only on the words read as one of those kinds and leaves the rest of the text in place (Redacting only some kinds of text):names: what spaCy’sen_core_web_smmodel reads as a person (PERSON, not an organisation), on the line as read and title-cased, plus a word holding^between letters (DOE^JANE). It needs thenlpextra and the model:pip install "isocenter[nlp]"thenpython -m spacy download en_core_web_sm. Without them,redact()andexport(check_burned_in=True)raiseNlpUnavailableError(anOcrUnavailableError) before anything.load_config(),save(),create_config()and plainexport()do not need the model. There is no fallback. spaCy publishes no free-threaded wheel, sonamescannot be used on the free-threaded build (3.14t). CI runs this arm’s name finder with the model on every entry that is not free-threaded. Theredact()andexport(check_burned_in=True)paths through it are tested with a stand-in model.dates: three date shapes. The first is day, month and year with one separator (/,.,-or a space) in either day-month order or year first, with a 2- or 4-digit year (1800 to 2199) and a day/month pair that reads as a date. The second isYYYYMMDD. The third is an English month name, full or three letters, beside a day or a year (01 JAN 1970,Jan 1, 1970). OCR’s digit look-alikes (O,I,l,|,S,B) are read as digits inside a candidate. A time of day is not a date.ids: a run of letters and digits (-or_allowed inside) of at least 6 characters holding at least 5 digits:MRN0012345,A1234567,00123456. It does not take120kV,1024,L5-S1or12345.Nothing is compared with the patient’s own values: a burned-in name may be misspelled, and the source is not read again. A narrowed target never redacts a box
anywould not. The kinds are read over the boxesanykeeps, somin_confidenceand the two-letters-or-digits rule mean the same under every target. Only the words a match overlaps are redacted, never the whole line. An image with text left in place gets oneRISKaudit row naming the target’s kinds and the frames. That row does not grade. Spelled exactly:[names], never a barenames, andanyalone, never inside a list.
action(required, spelled exactly):redact:redact()blanks each box OCR finds, on its own frame, widened on every side by 15% of its height (at least 2 pixels). The image takes a new SOP Instance UID, derived from its source UID, the zones and the boxes. The image also takesDERIVEDand the derivation code. Burned In Annotation(0028,0301)is left as the source had it, because OCR alone does not show the image holds no text (see What OCR misses). Each redacted image is read once more, and text still found writes aWARNINGaudit row.report:redact()changes no pixel and writes oneWARNINGrow per image with text. The export writes the image and one moreWARNINGrow for it.withhold:redact()changes no pixel. The export withholds every image with text, with oneWARNINGrow each.
min_confidence: a box is kept when tesseract’s confidence is this or more and its text holds at least two letters or digits. Two (JT,A1,12) are text. One (a,4, a lone side markerL) is not, and punctuation does not count. Every false box measured on MIDI-B was one character, and the rule lost no burned-in text there (#1121). The two is fixed. There is no key for it.detector(optional, spelled exactly, defaulttesseract): what decides “is this text?”.tesseractreads each word, as above.dbis the PP-OCRv3 DB text-detection model shipped with the package, run by OpenCV (thetextdetectextra,pip install "isocenter[textdetect]"), which finds where text is without reading it (#1121). Underdb,min_confidenceis the detector’s box score times 100 (default 80). Underdb, a box whose short side is more than a quarter of the frame’s short side is dropped and counted, so text that tall is not redacted. Undertarget: anytesseract is not needed and the two-letters rule does not apply, so a loneLorRside marker the detector finds is blanked. Under a narrowed target, each box is cut out, levelled and enlarged and read by tesseract as one line, so tesseract is needed too. That reading is classified as the target’s kinds are. A box whose reading holds fewer than two letters or digits cannot be classified, and is redacted, counted as unread.redact()andexport(check_burned_in=True)raiseTextDetectorUnavailableError, anOcrUnavailableError, before anything when OpenCV or the shipped model is unavailable. That is always the case on the free-threaded build. OCR has the measurement and what it misses.null(a bareburned_in_text:) is the same as no key. Ascope: nullis refused as a value, not read as absent. Each of these is also refused when the file loads, with a sentence naming the values:an unknown key or a missing
scopean action or scope spelled any other way
a
modalitieslist where the scope takes none, or a malformed onea
targetthat is notanyor a list of known kindsa
detectorother thantesseractordba
min_confidencethat is not a number from 0 to 100
Side markers. A radiograph’s lead
L/Rmarker is imaged with the patient, and technologist initials on it are text. Underaction: redactthe box over the initials usually blanks theLorRbeside it, which is laterality, clinical information. A loneLorRis one letter and is not a box. AnLread as one word with the initials is a box. See What OCR misses.
redact() reads pixels and records what it read. export(check_burned_in=True) reads them too and records nothing (check_burned_in=True). redact() reads every image in the policy’s scope, serial or not. It reads after zeroing, on a copy, the zones its machine rules hold, so text a zone covers is not found again. On each image, redact() records:
the boxes it found (never the text)
the tesseract version (under
detector: db, the model’s sha256 and the OpenCV version, and the tesseract version beside them under a narrowed target)the detector, threshold, zones, box rule and target it read under. The scope is not in the record: the scope chooses images, not boxes.
Under a narrowed target, the record also holds how many regions were read as each kind and how many were left. Under names, the record also holds the spaCy and model versions. A record another model read is read again by the next redact(), while plain export() takes it as current without loading any model. Under db, likewise, an image read by another OpenCV or model is read again by the next redact(). A plain export() does not compare them, and needs no OpenCV to trust a record. An image already read under the same detector, threshold, zones, box rule and target, whose pixels are still the ones it read, is not read again by OCR. redact(force=True) reads every image again and keeps the boxes recorded before. redact() with this key present and OCR unavailable raises OcrUnavailableError before anything, the zones included. redact_by_machine() does not run it.
The record names the pixels it read. Each image’s record holds a sha256 digest of the pixels the read saw, after the zones (so a zone’s own redaction leaves the record current). The read after redaction moves a redacted image’s digest to its redacted pixels. Pixels set on an image afterwards, by set_pixel_data() or anything else, are pixels no read saw. The export treats such an image as never checked, and the next redact() reads it again without force.
The export reads the record and runs no OCR, unless check_burned_in=True, which reads the pixels with OCR instead (check_burned_in=True). It loads each image’s frame once to check the record’s digest. That check runs one image at a time in the calling process, while the export is planned and before any export worker starts. Under redact and withhold, an image in the policy’s scope that was never read under the policy’s threshold and zones (redact() not called since load_config(), an image it could not read in full, or pixels changed since the read) is withheld, with a WARNING row saying to run redact(). Under report, such an image is not withheld, and the same row is written. Under redact, an image with text is withheld until a redaction carrying its boxes has landed. The EXPORT row counts the images the policy withheld apart from the ones the pre-export scan withheld. An image out of scope, and an image with no pixels (an SR, an RT object, a waveform), is never read, gated or counted. Not seen: an Instance built by hand with only a file_path, never ingested or loaded, reads as holding no pixels.
The grade. A redact pass that blanked text does not cost the PASS by itself. The rows that do are text still found after redaction, images OCR could not read, and images the export gated as unchecked. A scope that selects no image costs nothing either. Each pass writes one REDACTION row with its scope, its target, its counts (the images out of scope among them, and, under a narrowed target, the regions read as each kind and left in place) and the tesseract version (and the spaCy and model versions under names). Section 5 of the report says what the passes of the session did.
The key is not part of the policy fingerprint: adding it moves no (0012,0063) value and no recorded PHI status.
Generating Configuration Templates#
You can generate a starter isocenter_config.yaml from the session’s inventory. If the session has loaded no configuration (the floor), the generated file:
names
basic@2026cgives Study Date
JITTERand keeps Patient’s Sex and Age (the floor’s three research defaults)lists each machine the inventory holds
If the session loaded a configuration, the file names that configuration’s base as save() does (the pinned profile, an external profile’s path, or none). The file then holds every phi_tags rule that differs from the base’s, value and name included, so the file loads to the policy the session holds (#741). The file also copies the session’s current date_jitter, remove_private_tags and machine rules.
A series with no Device Serial Number gets no scaffolded rule. Write serial_number: "" for it yourself. A policy missing a rule its base supplies is refused with save()’s ValueError. A failed write raises its OSError. Each machine’s redaction_zones is empty unless the machine is one Isocenter’s shipped knowledge base recognises. Add the zones yourself. If you do not add them, redact() changes nothing for that machine.
# Inspects data, finds all unique machine serials, and writes a config file
session.create_config("my_new_policy.yaml")
Programmatic Configuration#
Besides YAML files, you can manage the configuration in Python code, through the session.configuration property.
Accessing Configuration#
import isocenter
session = isocenter.Session("my_project.db")
session.load_config("isocenter_config.yaml")
config = session.configuration
print(config.rules) # machine redaction rules
print(config.phi_tags) # the full tag policy in force, floor included
Methods#
These methods change the configuration in memory. They do not write the file load_config() read. The first change after a load or a save prints one line saying the file is unchanged. To write the file, call session.configuration.save(). Or enable auto-save for the session with session.configuration.auto_save = True. After that, every change is written as it is made, to whichever file the session loaded last. If there is no file to write, save() raises ValueError (a session that loaded none: set session.configuration.config_path first). If a write fails, save() raises the error of that write. With auto-save on, a change whose write fails or is refused is undone. With auto-save on and no file to write, each method raises that ValueError before changing anything.
save() writes a new file. It names the profile rather than copying it. It writes privacy_profile: basic@2026c (or the external file’s path, none, or no line for the floor). Under phi_tags, it writes only the rules that differ from the profile’s. Then it writes date_jitter, remove_private_tags and every machine rule. It always writes a version line, "2.0". Comments and layout in the loaded file are not kept. Keep a hand-edited file under version control. If its comments matter, edit it by hand rather than through these methods. save() refuses a policy that has lost a rule its profile supplies (by deleting from phi_tags directly), because the file would restore that rule. Give the tag action: KEEP instead. An external profile is read again when save() runs, so the saved file reloads to what the session holds. If the profile file has gained a rule since the load, save() refuses and asks you to load it again. auto_remediate_config() changes the rules in memory. Call save() afterwards to keep them.
add_rule()#
add_rule(serial_number, manufacturer="Unknown", model_name="Unknown", redaction_zones=None)
Add a new machine redaction rule dynamically.
# Add a rule for a specific ultrasound machine
session.configuration.add_rule(
serial_number="US-5555",
manufacturer="GE",
model_name="Voluson",
redaction_zones=[[0, 50, 0, 800]] # [y1, y2, x1, x2]
)
session.configuration.save() # write it to the loaded file
delete_rule()#
delete_rule(serial_number)
Remove a rule by serial number. Returns True if a rule was removed, False if none had that serial.
removed = session.configuration.delete_rule("US-5555")
update_rule()#
update_rule(serial_number, updates)
Update a rule by serial number. updates is a dict of the rule’s keys and their new values. The serial number itself cannot be changed. If no rule has that serial, update_rule() raises ValueError.
session.configuration.update_rule(
"US-5555",
{"redaction_zones": [[0, 60, 0, 800]], "comment": "banner is taller on v2 firmware"},
)
add_rule() and update_rule() refuse, with ValueError, a rule load_config() would refuse: an unknown key such as redaction_zone, a serial that is not a string, or a malformed zone. They then leave the rules and the file unchanged, so the file save() writes always loads again.
set_phi_tag()#
set_phi_tag(tag, action, value=None, target=None)
Update the policy for a specific DICOM tag. action is one of the actions. value is stored as the rule’s value:, which REPLACE writes. target is stored as the rule’s target:, the kinds SCRUB removes, as a list or tuple kept in its order. SCRUB requires target, and no other action takes it. An unknown action, or a rule Isocenter cannot honour (see PHI Tags), raises ValueError and leaves the policy and its file unchanged.
# Remove Manufacturer's Model Name, which basic@2026c keeps
session.configuration.set_phi_tag("0008,1090", "REMOVE")
# Keep Study Description, which basic@2026c empties
session.configuration.set_phi_tag("0008,1030", "KEEP")
# Keep Series Description, and remove the dates and IDs inside it
session.configuration.set_phi_tag("0008,103e", "SCRUB", target=["dates", "ids"])
What to keep#
A de-identification run depends on three things, and the configuration file is only one of them.
What it decides |
Where it is |
If you lose it |
|
|---|---|---|---|
The configuration file |
Which tags are kept, removed, emptied, replaced or date-shifted. The date-shift range. Whether private tags go. The pixel zones for each machine. |
A YAML file you keep, under version control. |
Nothing you cannot write again. A 1.0 file loads unchanged in every 1.x, and |
The store ( |
Each patient’s |
Two files that belong together: the session file ( |
The pseudonyms, offsets and UIDs it made. The same configuration over a new store gives every patient a new pseudonym and a new offset, and every study, series and instance new UIDs. Files already exported keep theirs. But data exported later will not link to them, and the intervals between a patient’s old and new studies are lost. |
|
Whether original identities written into exported files can be recovered. |
The file |
Recovery. Identities in files exported under that key cannot be recovered by anyone. |
The configuration does not reproduce pseudonyms or date shifts. They belong to the store they were made in. A later batch for the same patients goes into the same store. ingest() adds to the store, and a patient ingested under the same original Patient ID gets the same pseudonym and the same offset.
A project secret cannot be moved to another store. Isocenter has no way to export one or to load one. Every session that opens a store uses that store’s secret. A session on a different store uses a different one.
A copy of the store is the same store, secret included. The store is both files. Copy my_project.db and my_project_pixels.bin together, and keep them under the same basename, because the session finds its sidecar by the .db file’s name. A copy of the .db alone keeps the pseudonyms and offsets. The instances ingested before the copy have no pixels in such a copy, and export fails for them. Isocenter does not detect copies or refuse them. Treat every copy as the project itself. Back it up as you back up isocenter.key, and never send it, or any copy of it, with an export. Whoever holds the store can recover every shifted date, and the store’s audit log records each offset.
Replacement UIDs belong to the store as well. A source UID gets the same replacement in every export from the store and from any copy of it, and a different one from any other store. A redacted instance’s new SOP Instance UID is derived from the same secret, its source UID and the zones of every rule that matches it. So redacting the instance again with the same zones gives the same UID. A store that holds replaced UIDs but has lost its secret refuses audit(), anonymize(), redact() and export(check_burned_in=True). It refuses them because a new secret would not recognise those UIDs and would replace them a second time.
Auto-Discovery of Redaction Zones#
discover_redaction_zones() finds where a machine draws its burned-in text. It runs OCR over a sample of that machine’s images and reports where text was found. It needs the ocr extra and the Tesseract binary. See Burned-in text (OCR).
discover_redaction_zones() returns a DiscoveryResult holding the raw text
candidates, not zones. to_zones() groups them, and each group’s zone entry
is the [y1, y2, x1, x2] list a rule stores. For filtering and tuning the
grouping, see Zone Discovery.
# Discover potential redaction zones for a machine
result = session.discover_redaction_zones(
serial_number="US-12345",
sample_size=50
)
zones = [z["zone"] for z in result.to_zones()]
print(f"Discovered {len(zones)} zones: {zones}")
# Apply these zones to your configuration
if zones:
session.configuration.add_rule(
serial_number="US-12345",
redaction_zones=zones
)