📄 anonymizer__define.pro
字号:
for i = 0, ns-1 do $
if st_default[i] then $
(*self.static_tags)[i].value = self -> $
get_default_vr_value((*self.static_tags)[i].tag)
; Set any dynamic tags that were using the default:
if nd gt 0 then $
if total(dy_default gt 0) then $
for i = 0, nd-1 do $
if dy_default[i] then $
(*self.dynamic_tags)[i].value = self -> $
get_default_vr_value((*self.dynamic_tags)[i].tag)
end
;*********************************************************************
; Anonymizer::SetProperty
;+
;
; Sets the current value of an object property.
;
; @keyword AGE_STRING {in}{type=string} Sets the default
; value for Age String value representation.
; @keyword APPLICATION_ENTITY {in}{type=string} Sets the default
; value for Application Entity value representation.
; @keyword ATTRIBUTE_TAG {in}{type=string} Sets the default
; value for Attribute Tag value representation.
; @keyword ATTRIBUTE_VALUES {in}{type=structure} Sets the default
; value for Attribute Values value representation.
; @keyword CODE_STRING{in}{type=ulong} Sets the default
; value for Code String value representation.
; @keyword DATE {in}{type=string} Sets the default
; value for Date value representation.
; @keyword DECIMAL_STRING {in}{type=string} Sets the default
; value for Decimal String value representation.
; @keyword DATE_TIME {in}{type=string} Sets the default
; value for DateTime value representation.
; @keyword SINGLE_FLOATING_POINT {in}{type=float} Sets the default
; value for Single Floating Point value representation.
; @keyword DOUBLE_FLOATING_POINT {in}{type=double} Sets the default
; value for Double Floating Point value representation.
; @keyword FILE {in}{type=string} Sets the name of the DICOM file to be
; anonymized
; @keyword INTEGER_STRING {in}{type=string} Sets the default
; value for Integer String value representation.
; @keyword LONG_STRING {in}{type=string} Sets the default
; value for Long String value representation.
; @keyword LONG_TEXT {in}{type=string} Sets the default
; value for Long Text value representation.
; @keyword NO_BLOCK Sets the blocking status of the Anonymizer wizard.
; @keyword OTHER_BYTE_STRING {in}{type=byte} Sets the default
; value for Other Byte String value representation.
; @keyword OTHER_FLOAT_STRING {in}{type=float} Sets the default
; value for Other Float String value representation.
; @keyword OTHER_WORD_STRING {in}{type=int} Sets the default
; value for Other Word String value representation.
; @keyword OUTPUT_DIRECTORY {in}{type=string} Sets the directory to which
; the anonymized files will be written.
; @keyword OUTFILE_EXTENSION {in}{type=string} Sets the anonymized files
; filename extension.
; @keyword OUTFILE_PREFIX {in}{type=string} Sets the anonymized files
; filename prefix.
; @keyword PERSON_NAME {in}{type=string} Sets the default
; value for Person Name value representation.
; @keyword SHORT_STRING {in}{type=string} Sets the default
; value for Short String value representation.
; @keyword SIGNED_LONG {in}{type=long} Sets the default
; value for Signed Long value representation.
; @keyword SEQUENCE_OF_ITEMS {in}{type=long} Sets the default
; value for Sequence of Items value representation.
; @keyword SIGNED_SHORT {in}{type=int} Sets the default
; value for Signed Short value representation.
; @keyword SHORT_TEXT {in}{type=string} Sets the default
; value for Short Text value representation.
; @keyword TIME {in}{type=string} Sets the default
; value for Time value representation.
; @keyword UNIQUE_IDENTIFIER {in}{type=string} Sets the default
; value for Unique Identifier value representation.
; @keyword UNSIGNED_LONG {in}{type=ulong} Sets the default
; value for Unsigned Long value representation.
; @keyword UNKNOWN {in}{type=byte} Sets the default
; value for Unknown value representation.
; @keyword UNSIGNED_SHORT {in}{type=uint} Sets the default
; value for Unsigned Short value representation.
; @keyword UNLIMITED_TEXT {in}{type=string} Sets the default
; value for Unlimited Text value representation.
; @keyword VALUE_ONLY {in}{type=boolean} Sets the VALUE_ONLY field.
; If VALUE_ONLY is set to 1 only attribute tags that exist and
; are defined in the original file are written to the anonymized
; file. If VALUE_ONLY is set to 0, then all tags that exist in
; the orignal file are written to the anonymized file.
;
;-
pro anonymizer::setproperty, $
file = file, $
output_directory = od, $
wizard_cont = cont, $
no_block = nb, $
value_only = val_only, $
outfile_extension = ofe, $
outfile_prefix = ofp, $
attribute_values = av, $
application_entity = ae, $
age_string = as, $
attribute_tag = at, $
code_string = cs, $
date = da, $
decimal_string = ds, $
date_time = dt, $
single_floating_point = fl, $
double_floating_point = fd, $
integer_string = is, $
long_string = lo, $
long_text = _lt, $
other_byte_string = ob, $
other_float_string = _of, $
other_word_string = ow, $
person_name = pn, $
short_string = sh, $
signed_long = sl, $
sequence_of_items = sq, $
signed_short = ss, $
short_text = st, $
time = tm, $
unique_identifier = ui, $
unsigned_long = ul, $
unknown = un, $
unsigned_short = us, $
unlimited_text = ut
; Setting default attribute values per VR:...
if (n_elements(ae) gt 0) then $
self -> set_vr_value, application_entity = ae
if (n_elements(as) gt 0) then $
self -> set_vr_value, age_string = as
if (n_elements(at) gt 0) then $
self -> set_vr_value, attribute_tag = at
if (n_elements(cs) gt 0) then $
self -> set_vr_value, code_string = cs
if (n_elements(da) gt 0) then $
self -> set_vr_value, date = da
if (n_elements(ds) gt 0) then $
self -> set_vr_value, decomal_string = ds
if (n_elements(dt) gt 0) then $
self -> set_vr_value, date_time = dt
if (n_elements(fl) gt 0) then $
self -> set_vr_value, single_floating_point = fl
if (n_elements(fd) gt 0) then $
self -> set_vr_value, double_floating_point = fd
if (n_elements(is) gt 0) then $
self -> set_vr_value, integer_string = is
if (n_elements(lo) gt 0) then $
self -> set_vr_value, long_string = lo
if (n_elements(_lt) gt 0) then $
self -> set_vr_value, long_text = _lt
if (n_elements(ob) gt 0) then $
self -> set_vr_value, other_byte_string = ob
if (n_elements(_of) gt 0) then $
self -> set_vr_value, other_float_string = _of
if (n_elements(ow) gt 0) then $
self -> set_vr_value, other_word_string = ow
if (n_elements(pn) gt 0) then $
self -> set_vr_value, person_name = pn
if (n_elements(sh) gt 0) then $
self -> set_vr_value, short_string = sh
if (n_elements(sl) gt 0) then $
self -> set_vr_value, signed_long = sl
if (n_elements(sq) gt 0) then $
self -> set_vr_value, sequence_of_items = sq
if (n_elements(ss) gt 0) then $
self -> set_vr_value, signed_short = ss
if (n_elements(st) gt 0) then $
self -> set_vr_value, short_text = st
if (n_elements(tm) gt 0) then $
self -> set_vr_value, time = tm
if (n_elements(ui) gt 0) then $
self -> set_vr_value, unique_identifier = ui
if (n_elements(ul) gt 0) then $
self -> set_vr_value, unsigned_long = ul
if (n_elements(un) gt 0) then $
self -> set_vr_value, unknown = un
if (n_elements(us) gt 0) then $
self -> set_vr_value, unsigned_short = us
if (n_elements(ut) gt 0) then $
self -> set_vr_value, unlimited_text = ut
if n_elements(av) gt 0 then $
self -> set_vr_value, attribute_values = av
if n_elements(val_only) gt 0 then $
self.value_only = keyword_set(val_only)
if n_elements(cont) gt 0 then $
self.wizard_cont = cont[0]
if n_elements(od) gt 0 then $
self.outdir = od[0]
if n_elements(nb) gt 0 then begin
xx = keyword_set(nb)
self.no_block = xx
self.wizard -> setproperty, no_block = xx
endif
if n_elements(ofe) gt 0 then begin
if strmid(ofe,0,1) ne '.' then $
ofe = '.' + ofe
self.outfile_extension = ofe[0]
endif
if n_elements(ofp) gt 0 then $
self.outfile_prefix = ofp[0]
if n_elements(file) gt 0 then begin
if ~self.wizard->query_wizard_dialog() then begin
; Catch error
err = 0
catch, err
if err ne 0 then begin
message, 'Invalid Dicom file ' + file, /continue
return
endif
; Generate temporary file.
ind = 0
str = 'anonymous'
tempfile = str + '0.dcm'
while (file_test(tempfile)) do begin
ind++
tempfile = str + strtrim(ind,2) + '.dcm'
endwhile
self.tempfile = tempfile
o = obj_new('idlffdicomex', self.tempfile, $
clone = file)
self.file = file
obj_destroy, self.odicom
self.odicom = o
catch, /cancel
if n_elements(*self.static_tags) gt 0 then $
self -> define_tags, *self.static_tags $
else $
self -> reset, /static
if n_elements(*self.dynamic_tags) gt 0 then $
self -> define_tags, *self.dynamic_tags
endif
endif
end
;*********************************************************************
; Anonymizer::Wizard
;+
;
; Launches the Anonymizer Wizard.
;
; @keyword FROM_ANONYMIZER {in}{type=boolean} Internal keyword letting Wizard know
; it has been launched from the Anonymizer::Anonymize method.
;
;-
pro anonymizer::wizard, from_anonymize = fa
if ~file_test(self.file) then $
return
if n_elements(*self.static_tags) eq 0 then $
return
self.wizard -> launch_wizard, $
static = *self.static_tags, $
dynamic = *self.dynamic_tags, $
value_only = self.value_only, $
from_application = keyword_set(fa)
end
;*********************************************************************
; Anonymizer__Define
;+
; Define the class structure
;
; @field odicom Instance of the IDLffDicomEx object.
; @field dynamic_tags A structure array containing a list of DICOM
; attribute tags to be anonymized. The structures are of the
; form {desc:'', tag:'', value:'', flag:0b}
; This array can be modified by the user.
; @field static_tags Structure array of predefined DICOM attribute tags
; to be anonymized. The structures are of the
; form {desc:'', tag:'', value:'', flag:0b}
; Items can not be added or removed from this array.
; @field wizard AWizard Object Class for Anonymizer wizard.
; @field wizard_cont Used internally.
; @field no_block Sets the blocking status of the Anonymizer Wizard.
; @field value_only Determines what attibutes are written to the anonymized
; file.If VALUE_ONLY is set to 1 only attribute tags that exist and
; are defined in the original file are written to the anonymized file.
; If VALUE_ONLY is set to 0, then all tags that exist in the orignal
; file are written to the anonymized file.
; @field file A string containing the name of the DICOM file to be anonymized.
; @field outdir Sets the output directory for the anonymized DICOM file.
; @field outfile_extension Sets the extension for the anonymized filename.
; @field outfile_prefix Sets the prefix for the anonymized filename.
; @field attribute_values A structure containing the default attributes
; being used.
; @field default_att_values A structure containing the Anonymizer's default
; attributes
; @field tempfile Internal field used for storing the temporary filename to
; which the anonymized file is written.
; @field pref_file Internal field containing the name of the user preference
; file.
;
; @history Written June, 2005 : Daryl Atencio
;-
pro anonymizer__define
; Structure for holding default attribute values:
attribute_values = {attribute_values, $
ae:'Anonymous', $ ; Application Entity
as:'00', $ ; Age String
at:[0u,0], $ ; Attribute Tag
cs:'ANONYMOUS', $ ; Code String
da:'19000101', $ ; Date
ds:'----------------', $ ; Decimal String
dt:'19000101000000', $ ; Date-Time
fl:!values.f_nan, $ ; Floating Point (Single)
fd:!values.d_nan, $ ; Floating Point (Double)
is:'------------', $ ; Integer String
lo:'Anonymous', $ ; Long String
_lt:'Anonymous', $ ; Long Text
ob:0b, $ ; Other Byte String
_of:!values.f_nan, $ ; Other Float String
ow:0, $ ; Other Word String
pn:'Anonymous', $ ; Person Name
sh:'Anonymous', $ ; Short String
sl:0l, $ ; Signed Long
; sq: <-----------------< ; Sequence of Items
ss:0, $ ; Signed Short
st:'Anonymous', $ ; Short Text
tm:'000000', $ ; Time
; ui: <-----------------< ; Unique Identifier
ul:0ul, $ ; Unsigned Long
un:0b, $ ; Unknown
us:0u, $ ; Unsigned Short
ut:'Anonymous'} ; Unlimited Text
void = {anonymizer, $ ; IDLffDicomEx object
odicom:obj_new(), $ ; IDLffDicom Object.
dynamic_tags:ptr_new(), $
static_tags:ptr_new(), $
wizard:obj_new(), $
wizard_cont:1, $
no_block:0b, $
value_only:0b, $
pref_file:'', $
file:'', $
tempfile:'', $
outdir:'', $
outfile_extension:'', $
outfile_prefix:'', $
attribute_values:attribute_values, $
default_att_values:attribute_values}
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -