Package oro.dicom. R topics documented: February 15, Version Date Title Rigorous - DICOM Input / Output

Similar documents
The DICOM Package. August 23, Title Import medical imaging data using the DICOM Standard

Working with the DICOM Data Standard in R

dicom2nifti Documentation icometrix

Tools for NIfTI and ANALYZE image (Click LINK HERE for the latest update)

Package getopt. February 16, 2018

Package oro.nifti. March 3, 2013

IDLffAnalyze Class. Ron Kneusel RSI

Technical Publications

Package clipr. June 23, 2018

Processing math: 100% Imaging Packages in R

DICOM Correction Item

addendum for nifti converter plugins Hester Breman and Rainer Goebel

Package abf2. March 4, 2015

Appendix B ANALYZE Coordinate System

Package crossword.r. January 19, 2018

Python Working with files. May 4, 2017

EnableBasic. The Enable Basic language. Modified by Admin on Sep 13, Parent page: Scripting Languages

Package kirby21.base

Package gifti. February 1, 2018

Package rmatio. July 28, 2017

Package narray. January 28, 2018

Package cgh. R topics documented: February 19, 2015

RT_Image v0.2β User s Guide

Package sfc. August 29, 2016

1.6: Streamio library

Technical Publications

DICOM Correction Item

The DICOM Standard. Miloš Šrámek Austrian Academy of Sciences

Package fso. February 19, 2015

PACS and DICOM. Einar Heiberg,

DICOM Conformance Statement

Transform Introduction page 96 Spatial Transforms page 97

Package oasis. February 21, 2018

Notes Lesson 3 4. Positive. Coordinate. lines in the plane can be written in standard form. Horizontal

This document contains confidential information that is proprietary to SonoSite. Neither the document nor the information contained therein should be

Saturn User Manual. Rubén Cárdenes. 29th January 2010 Image Processing Laboratory, University of Valladolid. Abstract

Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100

Package brainr. R topics documented: October 12, Type Package

Package tau. R topics documented: September 27, 2017

DICOM Conformance Statement for Scanner Interface. Release 4.7.1

Technical Publications

Package tibble. August 22, 2017

Package oro.nifti. December 21, 2010

Package seg. February 15, 2013

Package pdfsearch. July 10, 2018

Package SFtools. June 28, 2017

Package gcite. R topics documented: February 2, Type Package Title Google Citation Parser Version Date Author John Muschelli

Package datasets.load

Technical Publication. DICOM Conformance Statement. BrainSUITE NET 1.5. Document Revision 1. March 5, Copyright BrainLAB AG

Package lxb. R topics documented: August 29, 2016

Universal Format Plug-in User s Guide. Version 10g Release 3 (10.3)

Package fastrtext. December 10, 2017

Spatial transformations in BrainVoyager

Manual of IMD. By Zhaohui Wang

Package esabcv. May 29, 2015

Package Mondrian. R topics documented: March 4, Type Package

Package csvread. August 29, 2016

JIV : A 3D Image Data Visualization and Comparison Tool. Chris Cocosco

DICOM 3.0 Conformance Statement

Matrix algebra. Basics

REGIUS CONSOLE CS-2. Revision History. Date Version Description 02/08/2004 Ver This Conformance Statement applies to DICOM3.0 (2000 version).

Package filematrix. R topics documented: February 27, Type Package

Package HMRFBayesHiC

Package datetimeutils

Package adfexplorer. R topics documented: March 5, 2018

DICOM Correction Proposal

HST.583 Functional Magnetic Resonance Imaging: Data Acquisition and Analysis

DICOM Conformance Statement

StellarPACS DICOM Conformance Statement. Version 1.3, August 2008 SoftTeam Solutions

Package Rwinsteps. February 19, 2015

Package EnQuireR. R topics documented: February 19, Type Package Title A package dedicated to questionnaires Version 0.

Package LSDinterface

nstream Version 3.1 DICOM Conformance Statement

Package crochet. January 8, 2018

Data Loading & 3D Visualization

Package iterators. December 12, 2017

Package LaF. November 20, 2017

Package ggsubplot. February 15, 2013

The First Step for Neuroimaging Data Analysis: DICOM to NIfTI conversion

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Stat 579: Objects in R Vectors

Package beast. March 16, 2018

Package microbenchmark

Package qicharts. October 7, 2014

Package darksky. September 20, 2017

Package svd. R topics documented: March 24, Type Package. Title Interfaces to various state-of-art SVD and eigensolvers. Version 0.3.

DICOM Conformance Statement August 23, 2010 Version 1.0 ImageWorks Internal document number:

Digital Imaging and Communications in Medicine (DICOM) Supplement 174: RESTful Rendering

Digital Imaging and Communications in Medicine (DICOM)

Package orthogonalsplinebasis

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

Package RTNduals. R topics documented: March 7, Type Package

Package pairsd3. R topics documented: August 29, Title D3 Scatterplot Matrices Version 0.1.0

Package SSLASSO. August 28, 2018

Path Objects. Introduction. Methods. Data Types. Create, Delete, Validate Methods. Configuration and Information Methods. Relational Methods

Package nonlinearicp

Package slam. February 15, 2013

Package oro.pet. R topics documented: October 6, 2017

Digital Imaging and Communications in Medicine (DICOM) Supplement 174: RESTful Rendering. Public Comment Draft

Type conversion functions

Transcription:

Package oro.dicom February 15, 2013 Version 0.3.7 Date 2012-09-23 Title Rigorous - DICOM Input / Output Author Brandon Whitcher Maintainer Brandon Whitcher <bwhitcher@gmail.com> Depends oro.nifti (>= 0.3.0), R (>= 2.13.0), utils Suggests hwriter Data input/output functions for data that conform to the standard, part of the Rigorous Analytics bundle. License BSD URL http://rigorousanalytics.blogspot.com, http://rig.oro.us.com LazyData yes ZipData no Repository CRAN Date/Publication 2012-12-23 18:23:56 NeedsCompilation no R topics documented: Create............................................ 2 dec2base........................................... 4 DICOM Dictionary..................................... 5 dicom2analyze....................................... 5 dicom2nifti......................................... 6 dicomtable......................................... 8 1

2 Create extractheader........................................ 9 getorientation........................................ 10 header2matrix........................................ 11 JpegComponentInfo..................................... 12 matchheader........................................ 13 nextheader......................................... 14 Orthogonal Planes...................................... 15 readdicom......................................... 16 readdicomfile....................................... 17 str2time........................................... 19 subraw........................................... 20 swapdimension....................................... 22 writeheader......................................... 23 Index 24 Create Create Arrays from DICOM Headers/Images A DICOM list structure is used to produce a multi-dimensional array representing a single acquisition of medical imaging data. create3d(dcm, mode = "integer", transpose = TRUE, pixeldata = TRUE, mosaic = FALSE, mosaicxy = NULL, sequence = FALSE) create4d(dcm, mode = "integer", transpose = TRUE, pixeldata = TRUE, mosaic = FALSE, mosaicxy = NULL, nslices = NULL, ntimes = NULL, instance = TRUE, sequence = FALSE) dcm mode transpose pixeldata mosaic mosaicxy is the DICOM list structure (if pixeldata = TRUE) or the DICOM header information (if pixeldata = FALSE). is a valid character string for storage.mode. is available in order to switch the definition of rows and columns from DICOM (default = TRUE. is a logical variable (default = TRUE) that is associated with the DICOM image data being pre-loaded. is a logical variable (default = FALSE) to denote storage of the data in Siemens Mosaic format. is a vector of length two that provides the (x,y) dimensions of the individual images. Default behavior is to use the AcquisitonMatrix to determine the (x,y) values.

Create 3 sequence nslices ntimes instance is a logical variable (default = FALSE) on whether to look in SequenceItem entries for DICOM header information. is the third dimension of the array. Attempts are made to determine this number from the DICOM data. is the fourth dimension of the array. Attempts are made to determine this number from the DICOM data. is a logical variable (default = TRUE) that determines whether or not to access the InstanceNumber field in the DICOM header to help order the slices. Multi-dimensional array of medical imaging data. array, readdicom, storage.mode Examples ## pixeldata = TRUE ## The DICOM image data are read from readdicom() ## Not run: dcmlist <- readdicom(system.file("hk-40", package="oro.dicom")) ## End(Not run) load(system.file("hk-40/hk40.rdata", package="oro.dicom")) dcmlist <- hk40 dcmimage <- create3d(dcmlist) image(dcmimage[,,1], col=grey(0:64/64), axes=false, xlab="", ylab="", main=paste("first Slice from HK-40")) imagepositionpatient <- attributes(dcmimage)$ipp dsl <- abs(diff(imagepositionpatient[,3])) plot(dsl, ylim=range(range(dsl) * 1.5, 0, 10), xlab="image", ylab="mm", main="difference in Slice Location") ## Not run: ## pixeldata = FALSE ## The DICOM image data are read from create3d() ## This may save on memory for large batches of DICOM data dcmlist <- readdicom(system.file("hk-40", package="oro.dicom"), pixeldata=false) dcmimage <- create3d(dcmlist, pixeldata=false)

4 dec2base image(dcmimage[,,1], col=grey(0:64/64), axes=false, xlab="", ylab="", main=paste("first Slice from HK-40 (again)")) ## End(Not run) ## mosaic = TRUE mosaicfile <- system.file("dcm/mr-sonata-3d-as-tile.dcm", package="oro.dicom") dcm <- readdicomfile(mosaicfile) image(t(dcm$img), col=grey(0:64/64), axes=false, xlab="", ylab="", main="siemens MOSAIC") dcmimage <- create3d(dcm, mode="integer", mosaic=true) z <- trunc(dim(dcmimage)[3]/2) image(dcmimage[,,z], col=grey(0:64/64), axes=false, xlab="", ylab="", main=paste("slice", z, "from Siemens MOSAIC")) 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 Details Length of the character string. This function converts the nonnegative integer n to the specified base, where n must be a nonnegative integer smaller than 2 5 2, base must be an integer between 2 and 36 and len suggests the length of the character string. The returned argument is a string. Examples (x <- dec2base(23, 2))

DICOM Dictionary 5 DICOM Dictionary Lookup Tables for DICOM Header Information Lookup tables for DICOM header information. data(dicom.dic) data(dicom.vr) Source See references. http://en.wikipedia.org/wiki/digital_imaging_and_communications_in_medicine readdicom, readdicomfile. dicom2analyze Convert DICOM Header to Analyze A subset of header information from DICOM is placed into Analyze 7.5 format. dicom2analyze(dcm, datatype = 4, reslice = TRUE, DIM = 3, descrip = "Series",...) dcm DICOM object containing both header and image information. datatype is an integer that denotes the type of data contained in each voxel. See convert.datatype.anlz or the ANALYZE documentation for more details. reslice Logical variable (default = TRUE) indicating if the data volume should be resliced. DIM The dimension of the array to be used (default = 3D). descrip DICOM header field(s) to be included in the descrip... to be passed to anlz

6 dicom2nifti Details See the references. An object of class anlz. Analyze 7.5 http://www.mayo.edu/bir/pdf/analyze75.pdf convert.datatype.anlz, dicom2nifti, anlz Examples ## Not run: dcmlist <- dicomseparate(system.file("hk-40", package="oro.dicom")) require("oro.nifti") dcmanlz <- dicom2analyze(dcmlist, datatype=4, mode="integer") image(dcmanlz) orthographic(dcmanlz) ## End(Not run) dicom2nifti Convert DICOM Header to NIfTI A subset of header information from DICOM is placed into NIfTI-1 format. dicom2nifti(dcm, datatype = 4, units = c("mm","sec"), rescale = FALSE, reslice = TRUE, qform = TRUE, sform = TRUE, DIM = 3, descrip = "Series", aux.file = NULL,...)

dicom2nifti 7 dcm datatype units rescale reslice qform sform DIM descrip aux.file DICOM object containing both header and image information. is an integer that denotes the type of data contained in each voxel. See convert.datatype or the NIfTI documentation for more details. Spatial and temporal units for xyzt Should slope and intercept parameters be extracted from the DICOM headers and saved? Logical variable (default = TRUE) indicating if the data volume should be resliced. Logical variable (default = TRUE) indicating if the 3D image orientation should be used. Logical variable (default = TRUE) indicating if the 3D image orientation should be used. The dimension of the array to be used (default = 3D). DICOM header field(s) to be included in the descrip slot for the nifti class object. Character string to be included in the aux_file slot for the nifti class object.... to be passed to nifti Details See the references. An object of class nifti. NIfTI-1 http://nifti.nimh.nih.gov/nifti-1 convert.datatype, dicom2analyze, nifti

8 dicomtable Examples ## Not run: dcmlist <- dicomseparate(system.file("hk-40", package="oro.dicom")) require("oro.nifti") dcmnifti <- dicom2nifti(dcmlist, datatype=4, mode="integer") qform(dcmnifti) sform(dcmnifti) image(dcmnifti) orthographic(dcmnifti) ## End(Not run) dicomtable Construct Data Frame from DICOM Headers A data frame is created given the valid DICOM fields provided by the user. dicomtable(hdrs, stringsasfactors = FALSE, collapse = "-", colsort = TRUE, verbose = FALSE, debug = FALSE) hdrs List object of DICOM headers. stringsasfactors Logical variable to be passed to data.frame. collapse colsort verbose debug Character string used to paste DICOM group, element and value fields. Logical variable (default = TRUE) to sort column names in the table. Flag to provide text-based progress bar (default = FALSE). Logical variable (default = FALSE) that regulates to display of intermediate processing steps. Data frame where the rows correspond to images and the columns correspond to the UNION of all DICOM fields across all files in the list.

extractheader 9 Whitcher, B., V. J. Schmid and A. Thornton (2011). Working with the DICOM and NIfTI Data Standards in R, Journal of Statistical Software, 44 (6), 1 28. http://www.jstatsoft.org/v44/ i06 extractheader Extract Single Field from DICOM Headers A particular DICOM field is extracted for a collection of DICOM headers. extractheader(hdrs, string, numeric = TRUE, names = FALSE, insequence = TRUE) hdrs string numeric names insequence 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. Logical; whether or not to look into SequenceItem elements. Details The DICOM field is extracted from each DICOM header and placed into a vector. Vector of values from the requested DICOM field. readdicom

10 getorientation Examples x <- readdicomfile(system.file("dcm/abdo.dcm", package="oro.dicom")) (series <- extractheader(x$hdr, "Series", numeric=false)) (IOP <- extractheader(x$hdr, "ImageOrientationPatient", numeric=false)) getorientation Convert Direction Cosines to Anatomical Direction For cross-sectional DICOM images the orientation must be derived from the Image Orientation (Patient) direction cosines. getorientation(xyz, delta = 0.0001) Details xyz is a vector of direction cosines from ImageOrientationPatient (0020,0037). delta is the tolerance around zero for comparisons. C.7.6.2.1.1 Image Position And Image Orientation. The Image Position (0020,0032) specifies the x, y, and z coordinates of the upper left hand corner of the image; it is the center of the first voxel transmitted. Image Orientation (0020,0037) specifies the direction cosines of the first row and the first column with respect to the patient. These Attributes shall be provide as a pair. Row value for the x, y, and z axes respectively followed by the Column value for the x, y, and z axes respectively. The direction of the axes is defined fully by the patient s orientation. The x-axis is increasing to the left hand side of the patient. The y-axis is increasing to the posterior side of the patient. The z-axis is increasing toward the head of the patient. The patient based coordinate system is a right handed system; i.e., the vector cross product of a unit vector along the positive x-axis and a unit vector along the positive y-axis is equal to a unit vector along the positive z-axis. Anatomical direction shall be designated by the capital letters: A P R L H F anterior posterior right left head foot

header2matrix 11 http://www.dclunie.com/medical-image-faq/html/part2.html swapdimension header2matrix Converts DICOM Header Field to a Matrix Converts a vector of DICOM header information, assuming there are multiple entries per element of the vector, into a matrix. header2matrix(hdr, ncol, sep = " ", byrow = TRUE) hdr ncol sep byrow is the result from extracting information from a DICOM header field; e.g., using extractheader. is the number of columns. is the character string required to split entries in the header field. is a logical variable (default = TRUE) telling the routine to populate the matrix by rows then columns. Matrix with length(hdr) rows and ncol columns. extractheader, matrix

12 JpegComponentInfo Examples x <- readdicomfile(system.file("dcm/abdo.dcm", package="oro.dicom")) pixelspacing <- extractheader(x$hdr, "PixelSpacing", numeric=false) psmat <- header2matrix(pixelspacing, ncol=2) IOP <- extractheader(x$hdr, "ImageOrientationPatient", numeric=false) IOPmat <- header2matrix(iop, ncol=6) JpegComponentInfo Constructor for JPEG Component Information The lossless JPEG code in C from Cornell includes "typedef struct JpegComponentInfo" consisting of 4 variables of class "short". In R, these are represented as raw vectors of length 2. JpegComponentInfo(componentID, componentindex, hsampfactor, vsampfactor) Details componentid identifier for this component (0..255) componentindex index in SOF or cpter->compinfo[] (see "jpeg.h" in the LJPG C code). hsampfactor,vsampfactor horizontal and verticalsampling factors Constructor function for an object of class JpegComponentInfo. For details, see Huang and Smith (1994). A list with 4 components matching the arguments of this constructor function, each being a raw vector of length 2. The input arguments must either be of class raw or capable of coersion via as.raw. Spencer Graves Kongji Huang and Brian Smith (1994) "Lossless JPEG Codec", v. 1.0 ftp://ftp.cs.cornell. edu/pub/multimed/ljpg.tar.z

matchheader 13 as.raw Examples jpegci <- JpegComponentInfo(1, 2, 3, 4) jpegci. <- list(componentid=as.raw(1), componentindex=as.raw(2), hsampfactor=as.raw(3), vsampfactor=as.raw(4)) class(jpegci.) <- JpegComponentInfo all.equal(jpegci, jpegci.) matchheader Match String to DICOM Header Field A convenient wrapper function that utilizes internal functions to match character strings with the DICOM header information. matchheader(hdr, string) hdr string is the result from extracting information from a DICOM header field; e.g., using extractheader. is a character string to be matched with the DICOM header. A logical vector of length length(hdr).

14 nextheader extractheader Examples x <- readdicomfile(system.file("dcm/abdo.dcm", package="oro.dicom")) modality <- extractheader(x$hdr, "Modality", numeric=false) matchheader(modality, "mr") # case insensitive by default nextheader Check String Against DICOM Header Field to Produce Error Message or NEXT A function designed to break out of loops given information (or the lackthereof) contained in the DICOM header. nextheader(dcm, string, reference, str.warning, htmlfile = NULL, heading = 3, numeric = FALSE) dcm string reference str.warning htmlfile is the DICOM list structure. is a character string to be matched with the DICOM header. is the scalar/vector of character strings to check against the DICOM header output. is a text string for the warning. is the hwriter object for the HTML file (default = NULL. heading is the HTML tag <H?> (default = 3). numeric is the argument to be passed to matchheader. An expression to be evaluated and HTML content.

Orthogonal Planes 15 extractheader, matchheader Orthogonal Planes Orthogonal Planes Functions to test the orientation for a single slice. is.axial(imageorientationpatient, axial = c("l","r","a","p")) is.coronal(imageorientationpatient, coronal = c("l","r","h","f")) is.sagittal(imageorientationpatient, sagittal = c("a","p","h","f")) imageorientationpatient A vector of length six taken from the DICOM header field ImageOrientation- Patient. axial coronal sagittal Logical value. Characters that are valid in defining an axial slice. Characters that are valid in defining a coronal slice. Characters that are valid in defining a sagittal slice. Brandon Whitcher <<bjw34032@users.sourceforge.net>> getorientation Examples x <- readdicomfile(system.file("dcm/abdo.dcm", package="oro.dicom")) iop <- header2matrix(extractheader(x$hdr, "ImageOrientationPatient", FALSE), 6) is.axial(iop) is.coronal(iop) is.sagittal(iop) x <- readdicomfile(system.file("dcm/spine1.dcm", package="oro.dicom"))

16 readdicom iop <- header2matrix(extractheader(x$hdr, "ImageOrientationPatient", FALSE), 6) is.axial(iop) is.coronal(iop) is.sagittal(iop) readdicom Read All DICOM Files in a Directory All DICOM files are imported and a text file summarizing their content recorded. readdicom(path, recursive = TRUE, exclude = NULL, verbose = FALSE, counter,...) path Path name to the DICOM directory. recursive Search recursively down from the given path name. exclude Exclude file names containing this character string. verbose Flag to provide text-based progress bar. counter Ignored.... to be passed to readdicomfile. Details A for loop is used to process each DICOM file contained in the directory(ies). If only a single file is specified in the path, readdicom will read that file only. A list structure with two major components: img hdr All images associated with the DICOM directory(ies). All header files associated with the DICOM directory(ies).

readdicomfile 17 Whitcher, B., V. J. Schmid and A. Thornton (2011). Working with the DICOM and NIfTI Data Standards in R, Journal of Statistical Software, 44 (6), 1 28. http://www.jstatsoft.org/v44/ i06 readdicomfile Examples ## Not run: dcmimage <- readdicom(system.file("hk-40", package="oro.dicom"), verbose=true) ## End(Not run) readdicomfile Read Single DICOM File All information, both header and image, is read into a list structure from a DICOM file. readdicomfile(fname, endian = "little", flipud = TRUE, skip128 = TRUE, DICM = TRUE, skipsequence = TRUE, pixeldata = TRUE, warn = -1, debug = FALSE) fname endian flipud skip128 DICM skipsequence pixeldata warn debug is the file name of the DICOM image (with suffix). is the endian-ness of the file (default is "little"). is a logical variable for vertical flipping of the image (default is TRUE). is a logical variable to skip the first 128 bytes in the file (default = TRUE). is a logical variable to read in the four bytes "DICM" (default = TRUE). is a logical variable to skip all content contained in SequenceItem tags (default = TRUE). is a logical variable (default = TRUE) on whether or not the PixelData should be read from the DICOM files. is a number to regulate the display of warnings (default = -1). See options for more details. is a logical variable (default = FALSE) that regulates to display of intermediate processing steps.

18 readdicomfile Details A while loop is used to traverse the unknown number of DICOM header fields contained in a single file. Information contained in sequences may be included/excluded according to the logical variable skipsequence (default = TRUE). A list containing two elements: hdr all DICOM header fields (with or without sequence information). img the image information. Whitcher, B., V. J. Schmid and A. Thornton (2011). Working with the DICOM and NIfTI Data Standards in R, Journal of Statistical Software, 44 (6), 1 28. http://www.jstatsoft.org/v44/ i06 http://en.wikipedia.org/wiki/digital_imaging_and_communications_in_medicine readdicom Examples x <- readdicomfile(system.file("dcm/abdo.dcm", package="oro.dicom")) graphics::image(t(x$img), col=grey(0:64/64), axes=false, xlab="", ylab="", main="abdo.dcm") x <- readdicomfile(system.file("dcm/spine1.dcm", package="oro.dicom")) graphics::image(t(x$img), col=grey(0:64/64), axes=false, xlab="", ylab="", main="spine1.dcm") ck <- system.file( jpeg/cervicalkyphosis.dcm, package= oro.dicom ) x.jpeg <- readdicomfile(ck)

str2time 19 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, format.out) str2date(dd, format.in, format.out) tt Details TM field from a DICOM header. dd DA field from a DICOM header. format.in,format.out Appropriate formatting of input or output. 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: 1. 19930822 would represent August 22, 1993.

20 subraw 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. http://en.wikipedia.org/wiki/digital_imaging_and_communications_in_medicine readdicom subraw Pattern Replacement for Raw Vectors subraw searchs for substring pattern within a raw vector x and replaces it if found with replacement. subraw(pattern, replacement, x, offset=1l, ignore.case=false, fixed=true, all=false) pattern replacement x raw vector containing the pattern to be matched and replaced by replacement. This is passed to grepraw, which supports the use of regular expressions in pattern if fixed = FALSE. a replacement for matched pattern. a raw vector where matches are sought, or an object which can be coerced by chartoraw to a raw vector.

subraw 21 offset ignore.case fixed all An integer passed to grepraw specifying the offset from which the search should start. Must be positive. The beginning of line is defined to be at that offset so "^" will match there. If all, offset only applies to the first match. logical passed to grepraw: if FALSE, the pattern matching is _case sensitive_ and if TRUE, case is ignored during matching. logical passed to grepraw: If TRUE, pattern is a pattern to be matched as is. NOTE: The default is TRUE here, even though the default for the fixed argument in grepraw is FALSE. logical. If TRUE all matches are returned, otherwise just the first one. Details 1. found <- grepraw(pattern, x=x, offset=offset, ignore.case=ignore.case, fixed=fixed) 2. if(length(found)>0) find the match and replace x with c(x[1:(start-1)], replace, c[(end+1):length(x)]). Also, if(all) recurse. 3. return(x) a raw vector matching x except with any subsequence of bytes matching pattern replaced by replacement. Spencer Graves array, readdicom, storage.mode Examples ## ## example ## abcdef <- chartoraw( abcdef ) ab. <- subraw(chartoraw( ab ), chartoraw( d ), abcdef) # replace first two bytes all.equal(ab., chartoraw( dcdef ) ) # replace lst two bytes all.equal(subraw(chartoraw( ef ), chartoraw( g ), abcdef), chartoraw( abcdg ) )

22 swapdimension # replace nothing all.equal(subraw(chartoraw( noop ), chartoraw( c ), abcdef), abcdef ) # replace all ababab <- chartoraw( ababab ) ab3 <- subraw(chartoraw( ab ), chartoraw( g ), ababab, all=true) all.equal(ab3, chartoraw( ggg ) ) swapdimension Reslice Data Volume Using DICOM Header Fields The input data volume (assumed to be three-dimensional) is re-sliced so that each slice is in the axial plane. Orientation is preserved so that orthographic viewing is standardized. swapdimension(img, dcm, digits=2) img dcm digits Multidimensional array (assumed to be three-dimensional only). DICOM header/image object associated with the multidimensional array. Number of significant digits used in testing unique-ness of values in DICOM header fields. Multidimensional array with (potentially) permuted dimensions because of the reslicing operation. An additional attribute pixdim is provided in order to facilitate conversion from DICOM to NIFTI/ANALYZE. dicom2nifti, getorientation

writeheader 23 writeheader Write DICOM Table to ASCII File A wrapper to write.table specifically for DICOM tables. writeheader(dtable, filename,...) Details dtable filename The DICOM table. 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.table

Index Topic classes JpegComponentInfo, 12 Topic datasets DICOM Dictionary, 5 Topic file dicom2analyze, 5 dicom2nifti, 6 readdicom, 16 readdicomfile, 17 writeheader, 23 Topic misc dec2base, 4 dicomtable, 8 extractheader, 9 header2matrix, 11 Orthogonal Planes, 15 str2time, 19 swapdimension, 22 anlz, 6 array, 3, 21 as.raw, 12, 13 convert.datatype, 7 convert.datatype.anlz, 6 Create, 2 create3d (Create), 2 create4d (Create), 2 dec2base, 4 dec2hex (dec2base), 4 DICOM Dictionary, 5 dicom.dic (DICOM Dictionary), 5 dicom.vr (DICOM Dictionary), 5 dicom2analyze, 5, 7 dicom2nifti, 6, 6, 22 dicominfo (readdicomfile), 17 dicomseparate (readdicom), 16 dicomtable, 8 getorientation, 10, 15, 22 grepraw, 20 header2matrix, 11 is.axial (Orthogonal Planes), 15 is.coronal (Orthogonal Planes), 15 is.sagittal (Orthogonal Planes), 15 JpegComponentInfo, 12 matchheader, 13, 15 matrix, 11 nextheader, 14 nifti, 7 Orthogonal Planes, 15 readdicom, 3, 5, 9, 16, 18, 20, 21 readdicomfile, 5, 17, 17 storage.mode, 3, 21 str2date (str2time), 19 str2time, 19 subraw, 20 swapdimension, 11, 22 write.table, 23 writeheader, 23 extractheader, 9, 11, 14, 15 24