Learn R Programming

espadon (version 1.11.3)

dicom.to.Rdcm.converter: Conversion of DICOM object into files that can be interpreted by the espadon package

Description

The dicom.to.Rdcm.converter function creates, for each DICOM object, a *.Rdcm file usefull for using espadon package. Each Rdcm file created is referenced by the date of acquisition of the object (if it is not available, its creation date), the patient's PIN, a reference number, an object number in this reference system, and the object modality (mr, ct, rtstruct...).

Usage

dicom.to.Rdcm.converter(
  dcm.files,
  pat.dest.dir,
  update = TRUE,
  ignore.duplicates = FALSE,
  tag.dictionary = dicom.tag.dictionary(),
  verbose = TRUE
)

Value

Returns the list of basenames of the created files.

Returns NULL if there are no DICOM files in dcm.files

Arguments

dcm.files

String vector, representing the list of the full names of the DICOM files of the same patient, or its directory.

pat.dest.dir

Character string representing the full name of the patient's directory, which will contain files converted into Rdcm objects.

update

Boolean. If set to TRUE, and if pat.dest.dir contains previously converted files, these files are updated,even if they are duplicated. They retain the same espadon reference frame assignment.

ignore.duplicates

Boolean. If TRUE, the function ignores duplicated objects.

tag.dictionary

Dataframe, by default equal to dicom.tag.dictionary, whose structure it must keep. This dataframe is used to parse DICOM files.

verbose

Boolean. If TRUE, a progress bar indicates the progress of the conversion.

Examples

Run this code
# First, save toy.dicom.raw () raw data to a temporary file for testing.
pat.src.dir <- file.path (tempdir(), "PM_dcm") 
dir.create (pat.src.dir, recursive = TRUE) 
dcm.filename <- tempfile (pattern = "PM_rtplan", tmpdir = pat.src.dir,
                          fileext = ".dcm")
zz <- file (dcm.filename, "wb")
writeBin (toy.dicom.raw (), zz, size = 1)
close (zz)

# Create a temporary destination directory where the *.Rdcm file will be saved
pat.dest.dir <- file.path (tempdir(), "PM_Rdcm")

dicom.to.Rdcm.converter (pat.src.dir, pat.dest.dir, update = TRUE)
# or
dicom.to.Rdcm.converter (dcm.filename, pat.dest.dir, update = TRUE)

list.files (pat.dest.dir)

# Cleaning  temporary directories
unlink (pat.src.dir, recursive = TRUE)
unlink (pat.dest.dir, recursive = TRUE)

Run the code above in your browser using DataLab