The DICOM Package August 23, 2005 Version 0.12 Date 2005-8-23 Title Import medical imaging data using the DICOM Standard Author Brandon Whitcher <brandon.j.whitcher@gsk.com> Maintainer Brandon Whitcher <brandon.j.whitcher@gsk.com> Depends R (>= 2.0.0) ZipData no This package provides functions to import and manipulate medical imaging data via the Digital Imaging and Communications in Medicine (DICOM) Standard. License GPL version 2 or later URL http://medical.nema.org R topics documented: dec2base........................................... 2 DICOM Lookup Tables................................... 2 dicom.info.......................................... 3 dicom.separate....................................... 4 dicom.table......................................... 5 dicom2analyze....................................... 5 extract.hdr.......................................... 6 str2time........................................... 7 write.dicom.hdr....................................... 8 Index 10 1
2 DICOM Lookup Tables dec2base Convert Decimal to Base N Number in String This function converts the nonnegative integer to the specified base. dec2base(n, base, len=0) dec2hex(n, len=0) n Non-negative integer. base Number between 2 and 36. len Length of the character string. This function converts the nonnegative integer n to the specified base. n must be a nonnegative integer smaller than 2 5 2, base must be an integer between 2 and 36 and len suggests the lengt of the character string. The returned argument is a string. B. Whitcher Examples x <- dec2base(23, 2) print(x) DICOM Lookup Tables Lookup Tables for DICOM Header Information data(dicom.vrfields) data(dicom.fields)
dicom.info 3 Format Source See references. http://en.wikipedia.org/wiki/digital_imaging_and_communications_in_ Medicine dicom.info, dicom.separate. dicom.info Read Single DICOM File All information, both header and image, is read into a list structure from a DICOM file. dicom.info(fname, endian="little", flipud=true) fname endian flipud File name Binary encoding; default is "little". Flip image vertically; default is TRUE. Brandon Whitcher http://en.wikipedia.org/wiki/digital_imaging_and_communications_in_ Medicine
4 dicom.separate dicom.separate Examples x <- dicom.info(system.file("dcm/abdo.dcm", package="dicom")[1]) image(x$img, col=grey(0:127/128), axes=false, xlab="", ylab="") x <- dicom.info(system.file("dcm/spine1.dcm", package="dicom")[1]) image(x$img, col=grey(0:127/128), axes=false, xlab="", ylab="") dicom.separate Read All DICOM Files in a Directory All DICOM files are imported and a text file summarizing their content recorded. dicom.separate(path, debug=true) path debug Path name to the DICOM directory. Flag to provide limited progress information. Brandon Whitcher dicom.info
dicom.table 5 dicom.table Construct Data Frame from DICOM Headers A data frame is created given the valid DICOM fields provided by the user. dicom.table(hdrs, fields, numeric=rep(true,length(fields))) hdrs fields numeric List object of DICOM headers. Vector of character strings; i.e., valid DICOM field names. Logical vector; each field is converted to numeric when TRUE. The function extract.hdr is called for each DICOM field and the resulting vectors are rearranged into a convenient matrix. Data frame where the rows correspond to images and the columns to DICOM fields. B. Whitcher extract.hdr dicom2analyze Convert DICOM Header to Analyze A subset of header information from DICOM is placed into Analyze 7.5 format. dicom2analyze(hdr, img)
6 extract.hdr hdr img DICOM header 4D data volume See the references. A list containing Analyze header information. Brandon Whitcher Analyze 7.5 http://www.mayo.edu/bir/pdf/analyze75.pdf extract.hdr Extract Single Field from DICOM Headers A particular DICOM field is extracted for a collection of DICOM headers. extract.hdr(hdrs, string, numeric=true, names=false) hdrs string numeric names List object of DICOM headers. DICOM field name. Logical; values are converted to numbers when TRUE. Logical; file names are kept with elements of the vector. The DICOM field is extracted from each DICOM header and placed into a vector. Vector of values from the requested DICOM field.
str2time 7 B. Whitcher dicom.info str2time Convert DICOM Time/Date Entry The DICOM time entry (TM) is converted into two alternative formats: a text version of the original format and a number in seconds. The DICOM date entry (DA) is converted into a simple alternative format. str2time(tt) str2date(dd) tt dd TM field from a DICOM header. DA field from a DICOM header. DICOM "TM" format consists of a string of characters of the format hhmmss.frac; where hh contains hours (range "00" - "23"), mm contains minutes (range "00" - "59"), ss contains seconds (range "00" - "59"), and frac contains a fractional part of a second as small as 1 millionth of a second (range 000000-999999). A 24 hour clock is assumed. Midnight can be represented by only 0000 since 2400 would violate the hour range. The string may be padded with trailing spaces. Leading and embedded spaces are not allowed. One or more of the components mm, ss, or frac may be unspecified as long as every component to the right of an unspecified component is also unspecified. If frac is unspecified the preceding "." may not be included. Frac shall be held to six decimal places or less to ensure its format conforms to the ANSI HISPP MSDS Time common data type. Examples: 1. 070907.0705 represents a time of 7 hours, 9 minutes and 7.0705 seconds. 2. 1010 represents a time of 10 hours, and 10 minutes. 3. 021 is an invalid value. Notes: For reasons of backward compatibility with versions of this standard prior to V3.0, it is recommended that implementations also support a string of characters of the format hh:mm:ss.frac for this VR. DICOM "DA" format A string of characters of the format yyyymmdd; where yyyy shall contain year, mm shall contain the month, and dd shall contain the day. This conforms to the ANSI HISPP MSDS Date common data type. Example:
8 write.dicom.hdr 1. 19930822 would represent August 22, 1993. Notes: For reasons of backward compatibility with versions of this standard prior to V3.0, it is recommended that implementations also support a string of characters of the format yyyy.mm.dd for this VR. For "TM", a list structure containing two fields txt time A text version of the time where colons have been inserted for readability. Time in seconds from midnight. for "DA", a simple character string. B. Whitcher http://en.wikipedia.org/wiki/digital_imaging_and_communications_in_ Medicine dicom.info write.dicom.hdr Write DICOM Table to ASCII File A wrapper to write.table specifically for DICOM tables. write.dicom.hdr(dtable, filename,...) dtable The DICOM table. filename Name of the file to be created.... Additional parameters to be passed to write.table. This function is a straightforward wrapper to write.table. None.
write.dicom.hdr 9 B. Whitcher write.table
Index Topic datasets DICOM Lookup Tables, 2 Topic file dicom.info, 3 dicom.separate, 4 dicom2analyze, 5 write.dicom.hdr, 8 Topic misc dec2base, 1 dicom.table, 4 extract.hdr, 6 str2time, 7 dec2base, 1 dec2hex (dec2base), 1 DICOM Lookup Tables, 2 dicom.fields (DICOM Lookup Tables), 2 dicom.info, 2, 3, 4, 6, 8 dicom.separate, 2, 3, 4 dicom.table, 4 dicom.vrfields (DICOM Lookup Tables), 2 dicom2analyze, 5 extract.hdr, 5, 6 str2date (str2time), 7 str2time, 7 write.dicom.hdr, 8 write.table, 9 10