Title: | Rigorous - DICOM Input / Output |
---|---|
Description: | Data input/output functions for data that conform to the Digital Imaging and Communications in Medicine (DICOM) standard, part of the Rigorous Analytics bundle. |
Authors: | Brandon Whitcher [aut, cre] |
Maintainer: | Brandon Whitcher <[email protected]> |
License: | BSD_3_clause + file LICENSE |
Version: | 0.5.5 |
Built: | 2024-12-05 04:11:52 UTC |
Source: | https://github.com/bjw34032/oro.dicom |
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, boffset = NULL ) create4D( dcm, mode = "integer", transpose = TRUE, pixelData = TRUE, mosaic = FALSE, mosaicXY = NULL, nslices = NULL, ntimes = NULL, instance = TRUE, sequence = FALSE )
create3D( dcm, mode = "integer", transpose = TRUE, pixelData = TRUE, mosaic = FALSE, mosaicXY = NULL, sequence = FALSE, boffset = NULL ) create4D( dcm, mode = "integer", transpose = TRUE, pixelData = TRUE, mosaic = FALSE, mosaicXY = NULL, nslices = NULL, ntimes = NULL, instance = TRUE, sequence = FALSE )
dcm |
is the DICOM list structure (if |
mode |
is a valid character string for |
transpose |
is available in order to switch the definition of rows and
columns from DICOM (default = |
pixelData |
is a logical variable (default = |
mosaic |
is a logical variable (default = |
mosaicXY |
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. |
sequence |
is a logical variable (default = |
boffset |
is the number of bytes to skip at the beginning of the DICOM
file (default = |
nslices |
is the third dimension of the array. Attempts are made to determine this number from the DICOM data. |
ntimes |
is the fourth dimension of the array. Attempts are made to determine this number from the DICOM data. |
instance |
is a logical variable (default = |
Multi-dimensional array of medical imaging data.
Brandon Whitcher [email protected]
Digital Imaging and Communications in Medicine (DICOM)
https://www.dicomstandard.org
array
, readDICOM
,
storage.mode
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) 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"))
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) 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"))
This function converts the nonnegative integer to the specified base.
dec2base(n, base, len = 0) dec2hex(n, len = 0)
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, where n
must be a nonnegative integer smaller than ,
base
must be an integer between 2 and 36 and len
suggests the
length of the character string.
The returned argument is a string.
Brandon Whitcher [email protected]
x <- dec2base(23, 2)
x <- dec2base(23, 2)
Lookup Tables for DICOM Header Information
data(dicom.dic)
data(dicom.dic)
An object of class data.frame
with 4188 rows and 5 columns.
See references.
Digital Imaging and Communications in Medicine (DICOM)
https://www.dicomstandard.org
https://en.wikipedia.org/wiki/DICOM
A subset of header information from DICOM is placed into Analyze 7.5 format.
dicom2analyze( dcm, datatype = 4, reslice = TRUE, DIM = 3, descrip = "SeriesDescription", digits = 2, ... )
dicom2analyze( dcm, datatype = 4, reslice = TRUE, DIM = 3, descrip = "SeriesDescription", digits = 2, ... )
dcm |
DICOM object containing both header and image information. |
datatype |
is an integer that denotes the type of data contained in
each voxel. See |
reslice |
Logical variable (default = |
DIM |
The dimension of the array to be used (default = 3D). |
descrip |
DICOM header field(s) to be included in the |
digits |
Number of digits to use when rounding in |
... |
Arguments to be passed to |
See the references.
An object of class anlz
.
Brandon Whitcher [email protected]
Analyze 7.5
https//eeg.sourceforge.net//ANALYZE75.pdf
Digital Imaging and Communications in Medicine (DICOM)
https://www.dicomstandard.org
convert.datatype.anlz
,
dicom2nifti
, anlz
## 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)
## 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)
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 = "SeriesDescription", aux.file = NULL, digits = 2, ... )
dicom2nifti( dcm, datatype = 4, units = c("mm", "sec"), rescale = FALSE, reslice = TRUE, qform = TRUE, sform = TRUE, DIM = 3, descrip = "SeriesDescription", aux.file = NULL, digits = 2, ... )
dcm |
DICOM object containing both header and image information. |
datatype |
is an integer that denotes the type of data contained in
each voxel. See |
units |
Spatial and temporal units for |
rescale |
Should slope and intercept parameters be extracted from the DICOM headers and saved? |
reslice |
Logical variable (default = |
qform |
Logical variable (default = |
sform |
Logical variable (default = |
DIM |
The dimension of the array to be used (default = 3D). |
descrip |
DICOM header field(s) to be included in the |
aux.file |
Character string to be included in the |
digits |
Number of digits to use when rounding in |
... |
Arguments to be passed to |
See the references.
An object of class nifti
.
Brandon Whitcher [email protected]
Digital Imaging and Communications in Medicine (DICOM)
https://www.dicomstandard.org
NIfTI-1
http://nifti.nimh.nih.gov/nifti-1
convert.datatype
,
dicom2analyze
, nifti
## 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)
## 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)
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 )
dicomTable( hdrs, stringsAsFactors = FALSE, collapse = "-", colSort = TRUE, verbose = FALSE, debug = FALSE )
hdrs |
List object of DICOM headers. |
stringsAsFactors |
Logical variable to be passed to |
collapse |
Character string used to |
colSort |
Logical variable (default = |
verbose |
Flag to provide text-based progress bar (default =
|
debug |
Logical variable (default = |
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.
Brandon Whitcher [email protected]
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.
Digital Imaging and Communications in Medicine (DICOM)
https://www.dicomstandard.org
A particular DICOM field is extracted for a collection of DICOM headers.
extractHeader(hdrs, string, numeric = TRUE, names = FALSE, inSequence = TRUE)
extractHeader(hdrs, string, numeric = TRUE, names = FALSE, inSequence = TRUE)
hdrs |
List object of DICOM headers. |
string |
DICOM field name. |
numeric |
Logical; values are converted to numbers when |
names |
Logical; file names are kept with elements of the vector. |
inSequence |
Logical; whether or not to look into SequenceItem elements. |
The DICOM field is extracted from each DICOM header and placed into a vector.
Vector of values from the requested DICOM field.
Brandon Whitcher [email protected]
Digital Imaging and Communications in Medicine (DICOM)
https://www.dicomstandard.org
x <- readDICOMFile(system.file("dcm/Abdo.dcm", package="oro.dicom")) seriesDescription <- extractHeader(x$hdr, "SeriesDescription", numeric=FALSE) IOP <- extractHeader(x$hdr, "ImageOrientationPatient", numeric=FALSE)
x <- readDICOMFile(system.file("dcm/Abdo.dcm", package="oro.dicom")) seriesDescription <- extractHeader(x$hdr, "SeriesDescription", numeric=FALSE) IOP <- extractHeader(x$hdr, "ImageOrientationPatient", numeric=FALSE)
For cross-sectional DICOM images the orientation must be derived from the Image Orientation (Patient) direction cosines.
getOrientation(xyz, delta = 0.0001)
getOrientation(xyz, delta = 0.0001)
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 |
anterior |
P |
posterior |
R |
right |
L |
left |
H |
head |
F |
foot |
Brandon Whitcher [email protected]
http://www.dclunie.com/medical-image-faq/html/part2.html
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)
header2matrix(hdr, ncol, sep = " ", byrow = TRUE)
hdr |
is the result from extracting information from a DICOM header
field; e.g., using |
ncol |
is the number of columns. |
sep |
is the character string required to split entries in the header field. |
byrow |
is a logical variable (default = |
Matrix with length(hdr)
rows and ncol
columns.
Brandon Whitcher [email protected]
Digital Imaging and Communications in Medicine (DICOM)
https://www.dicomstandard.org
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)
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)
A convenient wrapper function that utilizes internal functions to match character strings with the DICOM header information.
matchHeader(hdr, string)
matchHeader(hdr, string)
hdr |
is the result from extracting information from a DICOM header
field; e.g., using |
string |
is a character string to be matched with the DICOM header. |
A logical vector of length length(hdr)
.
Brandon Whitcher [email protected]
Digital Imaging and Communications in Medicine (DICOM)
https://www.dicomstandard.org
x <- readDICOMFile(system.file("dcm/Abdo.dcm", package="oro.dicom")) modality <- extractHeader(x$hdr, "Modality", numeric=FALSE) matchHeader(modality, "mr") # case insensitive by default
x <- readDICOMFile(system.file("dcm/Abdo.dcm", package="oro.dicom")) modality <- extractHeader(x$hdr, "Modality", numeric=FALSE) matchHeader(modality, "mr") # case insensitive by default
A function designed to break
out of loops given information (or the
lack thereof) contained in the DICOM header.
nextHeader( dcm, string, reference, str.warning, htmlfile = NULL, heading = 3, numeric = FALSE )
nextHeader( dcm, string, reference, str.warning, htmlfile = NULL, heading = 3, numeric = FALSE )
dcm |
is the DICOM list structure. |
string |
is a character string to be matched with the DICOM header. |
reference |
is the scalar/vector of character strings to check against the DICOM header output. |
str.warning |
is a text string for the warning. |
htmlfile |
is the hwriter object for the HTML file (default =
|
heading |
is the HTML tag <H?> (default = |
numeric |
is the argument to be passed to |
An expression to be evaluated and HTML content.
Brandon Whitcher [email protected]
Digital Imaging and Communications in Medicine (DICOM)
https://www.dicomstandard.org
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"))
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 “ImageOrientationPatient”. |
axial |
Characters that are valid in defining an ‘axial’ slice. |
coronal |
Characters that are valid in defining a ‘coronal’ slice. |
sagittal |
Characters that are valid in defining a ‘sagittal’ slice. |
Logical value.
Brandon Whitcher [email protected]
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")) iop <- header2matrix(extractHeader(x$hdr, "ImageOrientationPatient", FALSE), 6) is.axial(iop) is.coronal(iop) is.sagittal(iop)
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")) iop <- header2matrix(extractHeader(x$hdr, "ImageOrientationPatient", FALSE), 6) is.axial(iop) is.coronal(iop) is.sagittal(iop)
These subroutines process the information contained after the DICOM header and process this information into an image (2D or 3D) or complex-valued vector.
parsePixelData(rawString, hdr, endian = "little", flipupdown = TRUE) parseSpectroscopyData(rawString, hdr, endian = "little")
parsePixelData(rawString, hdr, endian = "little", flipupdown = TRUE) parseSpectroscopyData(rawString, hdr, endian = "little")
rawString |
is a vector of |
hdr |
is the list object of DICOM header information. |
endian |
is the endian-ness of the file (default is |
flipupdown |
is a logical variable for vertical flipping of the image
(default is |
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 recursive implementation of the code breaks the DICOM file into segments and calls itself to parse each segment.
A list containing two elements:
all DICOM header fields (with or without “sequence” information).
the ‘image’ information.
Brandon Whitcher [email protected]
See references.
Digital Imaging and Communications in Medicine (DICOM)
https://www.dicomstandard.org
https://en.wikipedia.org/wiki/DICOM
parseDICOMHeader
, readDICOMFile
.
All DICOM files are imported and a text file summarizing their content recorded.
readDICOM( path, recursive = TRUE, exclude = NULL, verbose = FALSE, counter, ... )
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. |
... |
Arguments to be passed to |
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 |
All images associated with the DICOM directory(ies). |
hdr |
All header files associated with the DICOM directory(ies). |
Brandon Whitcher [email protected]
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.
Digital Imaging and Communications in Medicine (DICOM)
https://www.dicomstandard.org
## pixelData = TRUE ## The DICOM image data are read from readDICOM() ## Not run: dcmSphere <- readDICOM(system.file("sphere3", package="oro.dicom"), verbose=TRUE) ## End(Not run)
## pixelData = TRUE ## The DICOM image data are read from readDICOM() ## Not run: dcmSphere <- readDICOM(system.file("sphere3", package="oro.dicom"), verbose=TRUE) ## End(Not run)
All information, both header and image, is read into a list structure from a DICOM file.
readDICOMFile( fname, boffset = NULL, endian = "little", flipud = TRUE, skipSequence = FALSE, pixelData = TRUE, warn = -1, debug = FALSE ) parseDICOMHeader(rawString, sq.txt = "", endian = "little", verbose = FALSE)
readDICOMFile( fname, boffset = NULL, endian = "little", flipud = TRUE, skipSequence = FALSE, pixelData = TRUE, warn = -1, debug = FALSE ) parseDICOMHeader(rawString, sq.txt = "", endian = "little", verbose = FALSE)
fname |
is the file name of the DICOM image (with suffix). |
boffset |
is the number of bytes to skip at the beginning of the DICOM
file (default = |
endian |
is the endian-ness of the file (default is |
flipud |
is a logical variable for vertical flipping of the image
(default is |
skipSequence |
is a logical variable to skip all content contained in
SequenceItem tags (default = |
pixelData |
is a logical variable (default = |
warn |
is a number to regulate the display of warnings (default = -1).
See |
debug |
is a logical variable (default = |
rawString |
is a vector of |
sq.txt |
is an character string (default = “”) that indicates if the DICOM header field is embedded within a sequence. |
verbose |
is a logical variable (default = |
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 resursive implementation of the code breaks the DICOM file into segments and calls itself to parse each segment.
Strict adherence to the DICOM standard is not required. Specifically, content is allowed to start at the first byte and the four characters ‘DICM’ are not required at bytes 129-132.
A list containing two elements:
all DICOM header fields (with or without “sequence” information).
the ‘image’ information.
Brandon Whitcher [email protected]
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.
Digital Imaging and Communications in Medicine (DICOM)
https://www.dicomstandard.org
https://en.wikipedia.org/wiki/DICOM
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")
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")
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 = "%02i:%02i:%08.5f") str2date(dd, format.in = "%Y%m%d", format.out = "%d %b %Y")
str2time(tt, format.out = "%02i:%02i:%08.5f") str2date(dd, format.in = "%Y%m%d", format.out = "%d %b %Y")
tt |
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:
070907.0705 represents a time of 7 hours, 9 minutes and 7.0705 seconds.
1010 represents a time of 10 hours, and 10 minutes.
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:
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 |
A text version of the time where colons have been inserted for readability. |
time |
Time in seconds from midnight. |
for “DA”, a simple character string.
Brandon Whitcher [email protected]
Digital Imaging and Communications in Medicine (DICOM)
https://www.dicomstandard.org
https://en.wikipedia.org/wiki/DICOM
str2date("19930822") str2time("112308")
str2date("19930822") str2time("112308")
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)
swapDimension(img, dcm, digits = 2)
img |
Multidimensional array (assumed to be three-dimensional only). |
dcm |
DICOM header/image object associated with the multidimensional array. |
digits |
Number of significant digits used in testing
|
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.
Brandon Whitcher [email protected]
A wrapper to write.table
specifically for DICOM tables.
writeHeader(dtable, filename, ...)
writeHeader(dtable, filename, ...)
dtable |
The DICOM table. |
filename |
Name of the file to be created. |
... |
Additional parameters to be passed to |
This function is a straightforward wrapper to write.table
.
None.
Brandon Whitcher [email protected]
Digital Imaging and Communications in Medicine (DICOM)
https://www.dicomstandard.org