Title: | Get Images Out of DICOM Format Quickly |
---|---|
Description: | Provides tools to sort DICOM-format medical image files, and convert them to NIfTI-1 format. |
Authors: | Jon Clayden [aut, cre] |
Maintainer: | Jon Clayden <[email protected]> |
License: | BSD_3_clause + file LICENCE |
Version: | 1.2.0 |
Built: | 2025-03-05 22:23:02 UTC |
Source: | https://github.com/jonclayden/divest |
This function summarises the capabilities of the package as compiled for the
current machine, analogously to the base
function capabilities()
. It
identifies the support available for various input and output formats.
divest.capabilities(what = NULL)
divest.capabilities(what = NULL)
what |
A character vector of components to extract, or |
A named logical vector, indicating whether plain JPEG, JPEG-LS and
JPEG2000 DICOM transfer syntaxes are supported by the current build of the
package, and also whether zlib
is available to produce compressed NIfTI
output files from convertDicom()
.
Jon Clayden [email protected]
divest.capabilities()
divest.capabilities()
These functions are R wrappers around the DICOM-to-NIfTI conversion routines
provided by dcm2niix
. They scan directories containing DICOM files,
potentially pertaining to more than one image series, read them and/or merge
them into a list of niftiImage
objects.
readDicom(path = ".", subset = NULL, flipY = TRUE, crop = FALSE, forceStack = FALSE, verbosity = 0L, labelFormat = "T%t_N%n_S%s", depth = 5L, interactive = base::interactive(), output = NULL) convertDicom(path = ".", subset = NULL, flipY = TRUE, crop = FALSE, forceStack = FALSE, verbosity = 0L, labelFormat = "T%t_N%n_S%s", depth = 5L, interactive = base::interactive(), output = path) sortDicom(path = ".", forceStack = FALSE, verbosity = 0L, labelFormat = "T%t_N%n_S%s/%b", depth = 5L, nested = NA, keepUnsorted = FALSE, output = path) scanDicom(path = ".", forceStack = FALSE, verbosity = 0L, labelFormat = "T%t_N%n_S%s", depth = 5L)
readDicom(path = ".", subset = NULL, flipY = TRUE, crop = FALSE, forceStack = FALSE, verbosity = 0L, labelFormat = "T%t_N%n_S%s", depth = 5L, interactive = base::interactive(), output = NULL) convertDicom(path = ".", subset = NULL, flipY = TRUE, crop = FALSE, forceStack = FALSE, verbosity = 0L, labelFormat = "T%t_N%n_S%s", depth = 5L, interactive = base::interactive(), output = path) sortDicom(path = ".", forceStack = FALSE, verbosity = 0L, labelFormat = "T%t_N%n_S%s/%b", depth = 5L, nested = NA, keepUnsorted = FALSE, output = path) scanDicom(path = ".", forceStack = FALSE, verbosity = 0L, labelFormat = "T%t_N%n_S%s", depth = 5L)
path |
A character vector of paths to scan for DICOM files. Each will
examined in turn. The default is the current working directory.
|
subset |
If |
flipY |
If |
crop |
If |
forceStack |
If |
verbosity |
Integer value between -2 and 3, controlling the amount of
output generated during the conversion. A value of -1 will suppress all
output from |
labelFormat |
A |
depth |
The maximum subdirectory depth in which to search for DICOM
files, relative to each |
interactive |
If |
output |
The directory to write converted or copied NIfTI files to, or
|
nested |
For |
keepUnsorted |
For |
The scanDicom
function parses directories full of DICOM files and
returns information about the acquisition series they contain.
readDicom
reads these files and converts them to (internal) NIfTI
images (whose pixel data can be extracted using as.array
).
convertDicom
performs the same conversion but writes to NIfTI files
by default, instead of retaining the images in memory. sortDicom
renames the files, but does not convert them.
The labelFormat
argument describes the string format used for image
labels and sorted files. Valid codes, each escaped with a percentage sign,
include a
for coil number, b
for the source file base name,
c
for image comments, d
for series description, e
for
echo number, f
for the source directory, i
for patient ID,
j
for the series instance UID, k
for the study instance UID,
l
for the procedure step description, m
for manufacturer,
n
for patient name, p
for protocol name, q
for
scanning sequence, r
for instance number, s
for series number,
t
for the date and time, u
for acquisition number, v
for vendor, x
for study ID and z
for sequence name. For
sortDicom
the label forms the new file path, and may include one or
more slashes to create subdirectories. A ".dcm" suffix will be added to file
names if no extension is specified.
readDicom
and convertDicom
return a list of
niftiImage
objects if output
is NULL
; otherwise
(invisibly) a vector of paths to NIfTI-1 files created in the target
directory. Returned images typically have attributes containing additional
metadata extracted from the DICOM headers, either in a JSON string or (if
the jsonlite
package is available), in individually parsed
elements. The scanDicom
function returns a data frame containing
information about each DICOM series found. sortDicom
is mostly
called for its side-effect, but also (invisibly) returns a list detailing
source and target paths.
Jon Clayden [email protected]
path <- system.file("extdata", "raw", package="divest") scanDicom(path) readDicom(path, interactive=FALSE)
path <- system.file("extdata", "raw", package="divest") scanDicom(path) readDicom(path, interactive=FALSE)