convertDicom: Convert dicom files into jpeg files

View source: R/manageXray.R

convertDicomR Documentation

Convert dicom files into jpeg files

Description

This uses calls to the command line to convert dicom files into jpegs. It takes in a directory and converts all dicom files in that directory (minus any files specified in the argument 'ignore'), converts them to jpegs using imageMagick and stores the resulting jpegs in the specified directory 'out.dir'.

Usage

convertDicom(
  dcm.dir = "I:/departments/research/EchinaceaXray/ace_xray",
  quality = "80%",
  convert = "magick.exe",
  out.dir,
  ignore = NULL,
  moreMagickArgs = NULL
)

Arguments

dcm.dir

a directory housing dicom images. The default is the location on the I drive where volunteers are instructed to save CG scans. Don't incldue spaces in the directory

quality

character string indicating quality of converted image, a percent, such as "80%"

convert

notation for converting dicoms to jpegs, "convert" or "magick.exe" or "magick convert"

out.dir

a destination directory for the jpeg images

ignore

files to ignore when converting. Specify by file name.

moreMagickArgs

additional ImageMagick convert arguments to use in processing

Details

The line sent to the command line is "convert -define dcm:display-range=reset <dicom file> -normalize -transpose -quality 60 Because this file calls the command line directly through the command "shell()", it is finicky and won't take paths or file names that have spaces in them. Make sure you are only entering paths or file names with no spaces! Otherwise it throws an error. Use the argument "moreMagickArgs" to use additional commands associated with imagemagick convert. Note that this function relies on the dicom images being saved with a certain format – "<year>_<number>.dcm" e.g., 2015_4001.dcm. Using a different format will scew up the conversion or processing.

Value

none

Examples

## Not run: 
convertDicom(dcm.dir = "I:/departments/research/EchinaceaXray/ace_xray",
            out.dir = "C:/users/snordstrom/dropbox/remData/160_xray/xray2016/xtremeRem",
            ignore = "Thumbs.db", moreMagickArgs = "-brightness-contrast 0x50")
## End(Not run)

stuartWagenius/echinaceaLab documentation built on April 13, 2025, 5:22 a.m.