- Timestamp:
- 2021-02-26T19:39:51+13:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/cpan/Image/ExifTool/DICOM.pm
r24107 r34921 21 21 use Image::ExifTool qw(:DataAccess :Utils); 22 22 23 $VERSION = '1. 11';23 $VERSION = '1.22'; 24 24 25 25 # DICOM VR (Value Representation) format conversions … … 50 50 %Image::ExifTool::DICOM::Main = ( 51 51 GROUPS => { 2 => 'Image' }, 52 PROCESS_PROC => 0, # set this to zero toomit tags from lookup (way too many!)52 VARS => { NO_LOOKUP => 1 }, # omit tags from lookup (way too many!) 53 53 NOTES => q{ 54 54 The DICOM format is based on the ACR-NEMA specification, but adds a file … … 58 58 L<http://medical.nema.org/>). The table below contains tags from the DICOM 59 59 2009 and earlier specifications plus some vendor-specific private tags. 60 61 Note that DICOM information may be saved in other file formats using the 62 L<XMP DICOM Tags|Image::ExifTool::TagNames/XMP DICOM Tags>. 60 63 }, 61 64 # file meta information group (names end with VR) … … 2341 2344 '0072,0514' => { VR => 'FD', Name => 'ReformattingInterval' }, 2342 2345 '0072,0516' => { VR => 'CS', Name => 'ReformattingOpInitialViewDir' }, 2343 '0072,0520' => { VR => 'CS', Name => ' 3DRenderingType' },2346 '0072,0520' => { VR => 'CS', Name => 'RenderingType3D' }, 2344 2347 '0072,0600' => { VR => 'SQ', Name => 'SortingOperationsSequence' }, 2345 2348 '0072,0602' => { VR => 'CS', Name => 'SortByCategory' }, … … 3405 3408 '1.2.840.10008.5.1.4.1.1.13.1.1' => 'X-Ray 3D Angiographic Image Storage', 3406 3409 '1.2.840.10008.5.1.4.1.1.13.1.2' => 'X-Ray 3D Craniofacial Image Storage', 3410 '1.2.840.10008.5.1.4.1.1.13.1.3' => 'Breast Tomosynthesis Image Storage', 3411 '1.2.840.10008.5.1.4.1.1.14.1' => 'Intravascular Optical Coherence Tomography Image Storage - For Presentation', 3412 '1.2.840.10008.5.1.4.1.1.14.2' => 'Intravascular Optical Coherence Tomography Image Storage - For Processing', 3407 3413 '1.2.840.10008.5.1.4.1.1.20' => 'Nuclear Medicine Image Storage', 3408 3414 '1.2.840.10008.5.1.4.1.1.66' => 'Raw Data Storage', … … 3425 3431 '1.2.840.10008.5.1.4.1.1.77.1.5.3' => 'Stereometric Relationship Storage', 3426 3432 '1.2.840.10008.5.1.4.1.1.77.1.5.4' => 'Ophthalmic Tomography Image Storage', 3433 '1.2.840.10008.5.1.4.1.1.77.1.6' => 'VL Whole Slide Microscopy Image Storage', 3434 '1.2.840.10008.5.1.4.1.1.78.1' => 'Lensometry Measurements Storage', 3435 '1.2.840.10008.5.1.4.1.1.78.2' => 'Autorefraction Measurements Storage', 3436 '1.2.840.10008.5.1.4.1.1.78.3' => 'Keratometry Measurements Storage', 3437 '1.2.840.10008.5.1.4.1.1.78.4' => 'Subjective Refraction Measurements Storage', 3438 '1.2.840.10008.5.1.4.1.1.78.5' => 'Visual Acuity Measurements Storage', 3439 '1.2.840.10008.5.1.4.1.1.78.6' => 'Spectacle Prescription Report Storage', 3440 '1.2.840.10008.5.1.4.1.1.78.7' => 'Ophthalmic Axial Measurements Storage', 3441 '1.2.840.10008.5.1.4.1.1.78.8' => 'Intraocular Lens Calculations Storage', 3442 '1.2.840.10008.5.1.4.1.1.79.1' => 'Macular Grid Thickness and Volume Report Storage SOP Class', 3443 '1.2.840.10008.5.1.4.1.1.80.1' => 'Ophthalmic Visual Field Static Perimetry Measurements Storage', 3427 3444 '1.2.840.10008.5.1.4.1.1.88.1' => 'Text SR Storage - Trial (Retired)', 3428 3445 '1.2.840.10008.5.1.4.1.1.88.2' => 'Audio SR Storage - Trial (Retired)', … … 3437 3454 '1.2.840.10008.5.1.4.1.1.88.65' => 'Chest CAD SR', 3438 3455 '1.2.840.10008.5.1.4.1.1.88.67' => 'X-Ray Radiation Dose SR Storage', 3456 '1.2.840.10008.5.1.4.1.1.88.69' => 'Colon CAD SR', 3457 '1.2.840.10008.5.1.4.1.1.88.70' => 'Implantation Plan SR Document Storage', 3439 3458 '1.2.840.10008.5.1.4.1.1.104.1' => 'Encapsulated PDF Storage', 3440 3459 '1.2.840.10008.5.1.4.1.1.104.2' => 'Encapsulated CDA Storage', … … 3474 3493 '1.2.840.10008.5.1.4.34.4.4' => 'Unified Procedure Step - Event SOP Class', 3475 3494 '1.2.840.10008.5.1.4.34.5' => 'Unified Worklist and Procedure Step SOP Instance', 3495 '1.2.840.10008.5.1.4.34.6.1' => 'Unified Procedure Step - Push SOP Class', 3496 '1.2.840.10008.5.1.4.34.6.2' => 'Unified Procedure Step - Watch SOP Class', 3497 '1.2.840.10008.5.1.4.34.6.3' => 'Unified Procedure Step - Pull SOP Class', 3498 '1.2.840.10008.5.1.4.34.6.4' => 'Unified Procedure Step - Event SOP Class', 3499 '1.2.840.10008.5.1.4.34.7' => 'RT Beams Delivery Instruction Storage', 3500 '1.2.840.10008.5.1.4.34.8' => 'RT Conventional Machine Verification', 3501 '1.2.840.10008.5.1.4.34.9' => 'RT Ion Machine Verification', 3476 3502 '1.2.840.10008.5.1.4.37.1' => 'General Relevant Patient Information Query', 3477 3503 '1.2.840.10008.5.1.4.37.2' => 'Breast Imaging Relevant Patient Information Query', … … 3480 3506 '1.2.840.10008.5.1.4.38.2' => 'Hanging Protocol Information Model - FIND', 3481 3507 '1.2.840.10008.5.1.4.38.3' => 'Hanging Protocol Information Model - MOVE', 3508 '1.2.840.10008.5.1.4.39.1' => 'Color Palette Storage', 3509 '1.2.840.10008.5.1.4.39.2' => 'Color Palette Information Model - FIND', 3510 '1.2.840.10008.5.1.4.39.3' => 'Color Palette Information Model - MOVE', 3511 '1.2.840.10008.5.1.4.39.4' => 'Color Palette Information Model - GET', 3482 3512 '1.2.840.10008.5.1.4.41' => 'Product Characteristics Query SOP Class', 3483 3513 '1.2.840.10008.5.1.4.42' => 'Substance Approval Query SOP Class', 3514 '1.2.840.10008.5.1.4.43.1' => 'Generic Implant Template Storage', 3515 '1.2.840.10008.5.1.4.43.2' => 'Generic Implant Template Information Model - FIND', 3516 '1.2.840.10008.5.1.4.43.3' => 'Generic Implant Template Information Model - MOVE', 3517 '1.2.840.10008.5.1.4.43.4' => 'Generic Implant Template Information Model - GET', 3518 '1.2.840.10008.5.1.4.44.1' => 'Implant Assembly Template Storage', 3519 '1.2.840.10008.5.1.4.44.2' => 'Implant Assembly Template Information Model - FIND', 3520 '1.2.840.10008.5.1.4.44.3' => 'Implant Assembly Template Information Model - MOVE', 3521 '1.2.840.10008.5.1.4.44.4' => 'Implant Assembly Template Information Model - GET', 3522 '1.2.840.10008.5.1.4.45.1' => 'Implant Template Group Storage', 3523 '1.2.840.10008.5.1.4.45.2' => 'Implant Template Group Information Model - FIND', 3524 '1.2.840.10008.5.1.4.45.3' => 'Implant Template Group Information Model - MOVE', 3525 '1.2.840.10008.5.1.4.45.4' => 'Implant Template Group Information Model - GET', 3484 3526 '1.2.840.10008.15.0.3.1' => 'dicomDeviceName', 3485 3527 '1.2.840.10008.15.0.3.2' => 'dicomDescription', … … 3527 3569 # Inputs: 0) ExifTool object reference, 1) DirInfo reference 3528 3570 # Returns: 1 on success, 0 if this wasn't a valid DICOM file 3529 sub ProcessDIC M($$)3571 sub ProcessDICOM($$) 3530 3572 { 3531 my ($e xifTool, $dirInfo) = @_;3573 my ($et, $dirInfo) = @_; 3532 3574 my $raf = $$dirInfo{RAF}; 3533 my $unknown = $e xifTool->Options('Unknown');3534 my $verbose = $e xifTool->Options('Verbose');3575 my $unknown = $et->Options('Unknown'); 3576 my $verbose = $et->Options('Verbose'); 3535 3577 my ($hdr, $buff, $implicit, $vr, $len); 3536 3578 # … … 3543 3585 # file meta information transfer syntax is explicit little endian 3544 3586 SetByteOrder('II'); 3545 $e xifTool->SetFileType('DICOM');3587 $et->SetFileType('DICOM'); 3546 3588 } else { 3547 3589 # test for a RAW DCM image (ACR-NEMA format, ie. no header) … … 3573 3615 } 3574 3616 $raf->Seek(0, 0) or return 0; # rewind to start of file 3575 $e xifTool->SetFileType('ACR');3617 $et->SetFileType('ACR'); 3576 3618 } 3577 3619 # … … 3595 3637 # 1.2.840.10008.1.2.1.99 = deflated 3596 3638 unless ($transferSyntax =~ /^1\.2\.840\.10008\.1\.2(\.\d+)?(\.\d+)?/) { 3597 $e xifTool->Warn("Unrecognized transfer syntax $transferSyntax");3639 $et->Warn("Unrecognized transfer syntax $transferSyntax"); 3598 3640 last; 3599 3641 } … … 3605 3647 } elsif ($1 eq '.1' and $2 and $2 eq '.99') { 3606 3648 # inflate compressed data stream 3607 if (eval 'require Compress::Zlib') {3649 if (eval { require Compress::Zlib }) { 3608 3650 # must use undocumented zlib feature to disable zlib header information 3609 3651 # because DICOM deflated data doesn't have the zlib header (ref 3) … … 3621 3663 last if $stat == Compress::Zlib::Z_STREAM_END(); 3622 3664 } else { 3623 $e xifTool->Warn('Error inflating compressed data stream');3665 $et->Warn('Error inflating compressed data stream'); 3624 3666 return 1; 3625 3667 } … … 3632 3674 $group = Get16u(\$buff, 0); 3633 3675 } else { 3634 $e xifTool->Warn('Error initializing inflation');3676 $et->Warn('Error initializing inflation'); 3635 3677 return 1; 3636 3678 } 3637 3679 } else { 3638 $e xifTool->Warn('Install Compress::Zlib to decode compressed data stream');3680 $et->Warn('Install Compress::Zlib to decode compressed data stream'); 3639 3681 return 1; 3640 3682 } … … 3667 3709 if ($verbose) { 3668 3710 # start list of items in verbose output 3669 $e xifTool->VPrint(0, "$exifTool->{INDENT}+ [List of items]\n");3670 $ exifTool->{INDENT} .= '| ';3711 $et->VPrint(0, "$$et{INDENT}+ [List of items]\n"); 3712 $$et{INDENT} .= '| '; 3671 3713 } 3672 3714 } … … 3707 3749 } 3708 3750 $$tagInfo{Unknown} = 1; 3709 Image::ExifTool::AddTagToTable($tagTablePtr, $tag, $tagInfo);3751 AddTagToTable($tagTablePtr, $tag, $tagInfo); 3710 3752 } 3711 3753 } … … 3718 3760 my $val; 3719 3761 my $format = $dicomFormat{$vr}; 3762 # remove trailing space used to pad to an even number of characters 3763 $buff =~ s/ $// unless $format or length($buff) & 0x01; 3720 3764 if ($len > 1024) { 3721 3765 # treat large data elements as binary data 3722 3766 my $binData; 3723 if ($exifTool->Options('Binary') or ($tagInfo and 3724 $exifTool->{REQ_TAG_LOOKUP}->{lc($$tagInfo{Name})})) 3767 my $lcTag = $tagInfo ? lc($$tagInfo{Name}) : 'unknown'; 3768 if ($$et{REQ_TAG_LOOKUP}{$lcTag} or 3769 ($$et{OPTIONS}{Binary} and not $$et{EXCL_TAG_LOOKUP}{$lcTag})) 3725 3770 { 3726 3771 $binData = $buff; # must make a copy … … 3736 3781 if ($vr eq 'DA') { 3737 3782 # format date values 3738 $val =~ s/^ (\d{4})(\d{2})(\d{2})/$1:$2:$3/;3783 $val =~ s/^ *(\d{4})(\d{2})(\d{2})/$1:$2:$3/; 3739 3784 } elsif ($vr eq 'TM') { 3740 3785 # format time values 3741 $val =~ s/^ (\d{2})(\d{2})(\d{2}.*)/$1:$2:$3/;3786 $val =~ s/^ *(\d{2})(\d{2})(\d{2}[^ ]*)/$1:$2:$3/; 3742 3787 } elsif ($vr eq 'DT') { 3743 3788 # format date/time values 3744 $val =~ s/^ (\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2}.*)/$1:$2:$3 $4:$5:$6/;3789 $val =~ s/^ *(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2}[^ ]*)/$1:$2:$3 $4:$5:$6/; 3745 3790 } elsif ($vr eq 'AT' and $len == 4) { 3746 3791 # convert attribute tag ID to hex format … … 3749 3794 } elsif ($vr eq 'UI') { 3750 3795 # add PrintConv to translate registered UID's 3751 $val =~ s/\0.*// ; # truncate at null3796 $val =~ s/\0.*//s; # truncate at null 3752 3797 $$tagInfo{PrintConv} = \%uid if $uid{$val} and $tagInfo; 3798 } elsif ($vr =~ /^(AE|CS|DS|IS|LO|PN|SH)$/) { 3799 $val =~ s/ +$//; # leading/trailing spaces not significant 3800 $val =~ s/^ +//; 3801 } elsif ($vr =~ /^(LT|ST|UT)$/) { 3802 $val =~ s/ +$//; # trailing spaces not significant 3753 3803 } 3754 3804 } … … 3760 3810 3761 3811 # handle the new tag information 3762 $e xifTool->HandleTag($tagTablePtr, $tag, $val,3812 $et->HandleTag($tagTablePtr, $tag, $val, 3763 3813 DataPt => \$buff, 3764 3814 DataPos => $pos - $len, … … 3770 3820 3771 3821 # stop indenting for list if we reached EndOfItems tag 3772 $ exifTool->{INDENT} =~ s/..$// if $verbose and $tag eq 'FFFE,E00D';3822 $$et{INDENT} =~ s/..$// if $verbose and $tag eq 'FFFE,E00D'; 3773 3823 } 3774 $err and $e xifTool->Warn('Error reading DICOM file (corrupted?)');3824 $err and $et->Warn('Error reading DICOM file (corrupted?)'); 3775 3825 return 1; 3776 3826 } … … 3804 3854 =head1 AUTHOR 3805 3855 3806 Copyright 2003-20 11, Phil Harvey (phil at owl.phy.queensu.ca)3856 Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com) 3807 3857 3808 3858 This library is free software; you can redistribute it and/or modify it
Note:
See TracChangeset
for help on using the changeset viewer.