pub struct ConfigBuilder(/* private fields */);
Expand description
A builder for Config
to configure DICOM de-identification settings.
The builder provides methods to customize various aspects of de-identification, including:
- Setting the UID root prefix for generating UIDs
- Configuring actions for specific DICOM tags
- Setting policies for private tags, curves, and overlays
§Example
use dicom_anonymization::config::ConfigBuilder;
use dicom_anonymization::actions::Action;
use dicom_dictionary_std::tags;
let config = ConfigBuilder::new()
.uid_root("1.2.840.123".parse().unwrap())
.tag_action(tags::PATIENT_NAME, Action::Empty)
.tag_action(tags::PATIENT_ID, Action::Hash(None))
.remove_private_tags(true)
.build();
Implementations§
Source§impl ConfigBuilder
impl ConfigBuilder
pub fn new() -> Self
Sourcepub fn uid_root(self, uid_root: UidRoot) -> Self
pub fn uid_root(self, uid_root: UidRoot) -> Self
Sets the UID root for the configuration.
The UidRoot
provides the prefix that will be used when creating new UIDs with Action::HashUID
.
It must follow DICOM UID format rules: start with a digit 1-9 and contain only numbers and dots.
It must also have no more than 32 characters.
Setting it is optional. In that case, no specific UID prefix will be used when creating new UIDs.
§Example
use dicom_anonymization::config::ConfigBuilder;
let config = ConfigBuilder::new()
.uid_root("1.2.840.123".parse().unwrap())
.build();
Sourcepub fn tag_action(self, tag: Tag, action: Action) -> Self
pub fn tag_action(self, tag: Tag, action: Action) -> Self
Sets the action to take for a specific DICOM tag.
The action determines how the tag value will be handled during de-identification.
§Arguments
tag
- The DICOM tag to apply the action toaction
- TheAction
to take
§Examples
use dicom_anonymization::actions::{Action, HashLength};
use dicom_anonymization::config::ConfigBuilder;
use dicom_dictionary_std::tags;
let mut config_builder = ConfigBuilder::new();
// Keep the tag value unchanged
config_builder = config_builder.tag_action(tags::MODALITY, Action::Keep);
// Remove the tag completely
config_builder = config_builder.tag_action(tags::SERIES_DATE, Action::Remove);
// Replace with empty value
config_builder = config_builder.tag_action(tags::PATIENT_SEX, Action::Empty);
// Hash the value with specified length
config_builder = config_builder.tag_action(tags::PATIENT_ID, Action::Hash(Some(HashLength::new(10).unwrap())));
// Hash a UID
config_builder = config_builder.tag_action(tags::STUDY_INSTANCE_UID, Action::HashUID);
// Replace a date with another date using a hash of another tag value to determine the offset
config_builder = config_builder.tag_action(tags::STUDY_DATE, Action::HashDate(tags::PATIENT_ID));
// Replace with specific value
config_builder = config_builder.tag_action(tags::DEIDENTIFICATION_METHOD, Action::Replace("MYAPP".into()));
// No specific tag action
//
// Mainly for documentation purposes to show that certain tags were considered, but
// that no specific tag actions are applied to those.
config_builder = config_builder.tag_action(tags::IMAGE_TYPE, Action::None);
Controls whether private DICOM tags will be removed during de-identification.
Private DICOM tags are those with odd group numbers. This function configures whether these tags should be removed or preserved.
By default (i.e. if not explicitly set to false
) all private tags will be removed. If enabled,
individual private tags can still be kept by setting a specific tag Action
for those
(except Action::None
).
§Arguments
remove
- Iftrue
, all private tags will be removed. Iffalse
, they will be kept.
§Examples
use dicom_anonymization::config::ConfigBuilder;
// Remove private tags (default)
let config = ConfigBuilder::new()
.remove_private_tags(true)
.build();
// Keep private tags
let config = ConfigBuilder::new()
.remove_private_tags(false)
.build();
Sourcepub fn remove_curves(self, remove: bool) -> Self
pub fn remove_curves(self, remove: bool) -> Self
Controls whether DICOM curve tags (from groups 0x5000-0x50FF
) will be removed during de-identification.
By default (i.e. if not explicitly set to false
) all curve tags will be removed. If enabled,
individual curve tags can still be kept by setting a specific tag Action
for those
(except Action::None
).
§Arguments
remove
- Iftrue
, all curve tags will be removed. Iffalse
, they will be kept.
§Examples
use dicom_anonymization::config::ConfigBuilder;
// Remove curve tags (default)
let config = ConfigBuilder::new()
.remove_curves(true)
.build();
// Keep curve tags
let config = ConfigBuilder::new()
.remove_curves(false)
.build();
Sourcepub fn remove_overlays(self, remove: bool) -> Self
pub fn remove_overlays(self, remove: bool) -> Self
Controls whether DICOM overlay tags (from groups 0x6000-0x60FF
) will be removed during de-identification.
By default (i.e. if not explicitly set to false
) all overlay tags will be removed. If enabled,
individual overlay tags can still be kept by setting a specific tag Action
for those
(except Action::None
).
§Arguments
remove
- Iftrue
, all overlay tags will be removed. Iffalse
, they will be kept.
§Examples
use dicom_anonymization::config::ConfigBuilder;
// Remove overlay tags (default)
let config = ConfigBuilder::new()
.remove_overlays(true)
.build();
// Keep overlay tags
let config = ConfigBuilder::new()
.remove_overlays(false)
.build();
Sourcepub fn build(self) -> Config
pub fn build(self) -> Config
Transforms the ConfigBuilder
into a Config
with all configured options.
§Example
use dicom_anonymization::config::ConfigBuilder;
use dicom_anonymization::actions::Action;
use dicom_core::Tag;
use dicom_dictionary_std::tags;
let config = ConfigBuilder::new()
.uid_root("1.2.840.123".parse().unwrap())
.tag_action(tags::SOP_INSTANCE_UID, Action::HashUID)
.tag_action(tags::PATIENT_NAME, Action::Empty)
.tag_action(Tag(0x0033, 0x0010), Action::Keep)
.build();
Trait Implementations§
Source§impl Default for ConfigBuilder
impl Default for ConfigBuilder
Source§fn default() -> Self
fn default() -> Self
Creates a new ConfigBuilder
with the default configuration.
The default configuration includes a standard set of tag actions for DICOM de-identification,
as well as default settings for removing private tags, curves, and overlays. Also, a default
UidRoot
value is used (i.e. "9999"
).
Returns a ConfigBuilder
initialized with these default settings, which can be further customized
if needed before building the final Config
.
Auto Trait Implementations§
impl Freeze for ConfigBuilder
impl RefUnwindSafe for ConfigBuilder
impl Send for ConfigBuilder
impl Sync for ConfigBuilder
impl Unpin for ConfigBuilder
impl UnwindSafe for ConfigBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more