| 1 | ############################################################################## | ||||||||||
| 2 | # DicomAnonymizer.pm -- a module to anonymize Dicom files | ||||||||||
| 3 | # | ||||||||||
| 4 | # Copyright (c) 2010 Baoshe Zhang. All rights reserved. | ||||||||||
| 5 | # This file is part of "DicomPack". DicomReader is free software. You can | ||||||||||
| 6 | # redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||
| 7 | ############################################################################## | ||||||||||
| 8 | |||||||||||
| 9 | package DicomPack::Util::DicomAnonymizer; | ||||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 1 | ▶ | use DicomPack::IO::DicomReader; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | ▶ | use DicomPack::IO::DicomWriter; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | 1 | our $VERSION = '0.95'; | |||||||||
| 18 | |||||||||||
| 19 | sub new | ||||||||||
| 20 | 0 | ▶ | { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 21 | 0 | my $classname = shift; | |||||||||
| 22 | 0 | my $self = {}; | |||||||||
| 23 | 0 | bless $self, $classname; | |||||||||
| 24 | 0 | return $self; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | # get dicom fields from DICOM data file | ||||||||||
| 28 | sub anonymize | ||||||||||
| 29 | 0 | ▶ | { | ||||||||
|
Subroutine
anonymize: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 30 | 0 | my $self = shift; | |||||||||
| 31 | |||||||||||
| 32 | 0 | my $infile = shift; | |||||||||
| 33 | 0 | my $outfile = shift; | |||||||||
| 34 | |||||||||||
| 35 | 0 | my $anonymizedFieldList = shift; | |||||||||
| 36 | |||||||||||
| 37 | 0 | my $reader = DicomPack::IO::DicomReader->new($infile); | |||||||||
| 38 | 0 | my $dicomFields = $reader->getDicomField(); | |||||||||
| 39 | |||||||||||
| 40 | 0 | my $writer = DicomPack::IO::DicomWriter->new($dicomFields); | |||||||||
| 41 | 0 | ▶ | while(my ($tagPath, $tagValue) = each(%$anonymizedFieldList)) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | { | ||||||||||
| 43 | 0 | ▶ | if(my ($value,$vr) = $reader->getValue($tagPath)) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | { | ||||||||||
| 45 | 0 | $writer->setValue($tagPath, $tagValue, $vr); | |||||||||
| 46 | } | ||||||||||
| 47 | else | ||||||||||
| 48 | { | ||||||||||
| 49 | 0 | print $tagPath." : does not exists in $infile!!!\n"; | |||||||||
| 50 | } | ||||||||||
| 51 | } | ||||||||||
| 52 | 0 | $writer->flush($outfile); | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | 1 | 1; | |||||||||
| 56 | |||||||||||
| 57 | __END__ | ||||||||||