NAME
PDL::IO::Dcm - Reads dicom files, sorts them and stores the result into piddles with headers
VERSION
Version 0.9
SYNOPSIS
This is inteded to read and sort dicom images created by medical imaging devices.
Either use something like the following from within your module/application
# loads all dicom files in this directory
# $id is a code reference returning e.g. the Series Number
my $dcms=load_dcm_dir($dir,$id);
die "no data!" unless (keys %$dcms);
print "Read data; ProtIDs: ",join ', ',keys %$dcms,"\n";
# sort all individual dicoms into a hash of piddles.
my $data=parse_dcms($dcms);
or use the read_dcm.pl script to convert dicom files in a directory to serealised piddles (PDL::IO::Sereal) or NIFTI files with separate text headers (PDL::IO::Nifti).
This software is tailored to Siemens MRI data based on the author's needs. For general usage, the read_dcm function should and probably will be moved to vendor/modality specific plugin modules in future releases.
Some notes on Dicom fields and how they are stored/treated
The image data field is stored as the piddle, the other dicom elements are stored in the header under the raw_dicom key.
The Siemens protocol ASCCONV part is stored in the ascconv key.
Key 0029,1010 is the Siemens specific field that contains the ICE miniheaders with dimension information - and position in matrix 0029,1020 is deleted from the header, it is big, containing the whole protocol. The important part is parsed into ascconv.
Keys are parsed into a hash under the dicom key using the DicomPack module(s) to unpack.
The header fields IceDims and IcePos are used for sorting datasets. The field Dimensions lists the sorted names of dimensions.
Piddles are created for each lProtID or Series Number value.
SUBROUTINES/METHODS
read_text_hdr
parses the ASCCONV part of Siemens data header into the ascconv field of the piddle header. All special characters except [a-z0-9]i are converted to _ -- no quoting of hash keys required!
load_dcm_dir
reads all dicom files in a dicrectory and returns a hash of piddles containing sorted N-D data sets. Uses a code reference to access the field by which to split. See read_dcm.pl for details. Currently, the ascconv field lProtID or dicom Series Number are used as keys.
parse_dcms
Parses and sorts a hash of hashes of dicoms (such as returned by load_dcm_dir) based on lProtID and the ICE_Dims field in 0029_1010. Returns a hash of piddles (lProtID).
unpack_field
unpacks dicom fields and walks subfield structures recursively.
read_dcm
reads a dicom file and creates a piddle-with-header structure.
TODO
write tests!
Generalise to other modalities. This will be done based on request or as needed.
LICENSE AND COPYRIGHT
Copyright 2016 Albrecht Ingo Schmid.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.