Configuration API
A session's configuration is session.configuration, an
IsocenterConfiguration. load_config() fills it from a YAML file;
the methods below change it in memory and write it back with save().
The file format is on Configuration. The class,
its fields and these six methods are frozen at 1.0
(API stability).
IsocenterConfiguration
dataclass
The configuration a session applies, reached as session.configuration.
load_config() fills it from a file; the methods below change it in
memory, and save() writes it.
Attributes:
| Name | Type | Description |
|---|---|---|
rules |
List[Dict[str, Any]]
|
List of machine redaction rules. |
phi_tags |
Dict[str, Any]
|
PHI tag policies, keyed by lowercase
|
date_jitter |
Dict[str, int]
|
The range the per-patient date
offset is derived within, in days, both ends included:
|
remove_private_tags |
bool
|
Global flag to strip private tags. |
config_path |
Optional[str]
|
The file |
auto_save |
bool
|
Write |
privacy_profile |
Optional[str]
|
The pinned name of the built-in
profile whose rules were merged into |
save()
Write the configuration to config_path as YAML.
The file names the profile rather than copying it:
privacy_profile is the pinned name (basic@2026c), the external
profile's path, none, or no line at all for the floor, and
phi_tags holds only the rules that differ from that base's. Then
date_jitter, remove_private_tags and every machine rule, each
key kept (comment: as data). version is always written, as this
library's configuration version. A file this writes loads to the
configuration it was written from.
Comments and layout in an existing file are not kept: this writes a new file.
Raises:
| Type | Description |
|---|---|
ValueError
|
With no |
OSError
|
The write's own error, unchanged. |
add_rule(serial_number, manufacturer='Unknown', model_name='Unknown', redaction_zones=None)
Add a machine redaction rule.
Replaces any existing rule for the same serial number. Changes
memory; writes config_path only when auto_save is on. The
keywords are spelled as the rule's keys in a machines: file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
serial_number
|
str
|
The device serial number. |
required |
manufacturer
|
str
|
Metadata for reference. |
'Unknown'
|
model_name
|
str
|
Metadata for reference. |
'Unknown'
|
redaction_zones
|
List[Any]
|
The zones to set to zero,
each |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
For a rule |
OSError
|
Under |
update_rule(serial_number, updates)
Update the rule for serial_number.
Changes memory; writes config_path only when auto_save is on.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
serial_number
|
str
|
The target rule's serial number. |
required |
updates
|
Dict[str, Any]
|
Dictionary of fields to update. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no rule is found, if the update changes the
serial number, or if the updated rule is one |
OSError
|
Under |
delete_rule(serial_number)
Remove the rule for a serial number.
Changes memory; writes config_path only when auto_save is on
and a rule was removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
serial_number
|
str
|
The serial number to remove. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if a rule was found and removed, False otherwise. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Under |
OSError
|
Under |
set_phi_tag(tag, action, value=None)
Set or replace the PHI rule for one tag.
Changes memory; writes config_path only when auto_save is on.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str
|
The DICOM tag to target (e.g. "0010,0010"), stored lowercase. |
required |
action
|
str
|
One of |
required |
value
|
str
|
The value |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
For an unknown action, and for a rule the pipeline
cannot honour: a Patient ID rule other than KEEP or REPLACE
with no value, a |
OSError
|
Under |
get_rule(serial_number)
Return the rule for a serial number: the rule dictionary itself, not a copy.
Exact spelling, first match. Redaction does not use this: redact()
and the export apply every matching rule, "*" included.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
serial_number
|
str
|
The serial number to find. |
required |
Returns:
| Type | Description |
|---|---|
Optional[Dict[str, Any]]
|
The rule dictionary if found, else None. |