dcm2nii: Simple run of DICOM 2 NIfTI Converter

Description Usage Arguments Value Examples

View source: R/dcm2nii.R

Description

Uses Chris Rorden's dcm2nii from http://www.mccauslandcenter.sc.edu/mricro/mricron/dcm2nii.html to convert DICOM files to NIfTI format. Should Need run install_dcm2nii before running.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
dcm2nii(basedir = ".", copy_files = TRUE,
  progdir = system.file(package = "dcm2niir"), verbose = TRUE,
  dcm2niicmd = c("dcm2niix", "dcm2nii_2009", "dcm2nii"),
  merge_files = FALSE, ignore_derived = FALSE, opts = paste0("-9 ",
  ifelse(ignore_derived, "-i y ", ""), ifelse(merge_files, " -m y ", ""),
  "-z y -f %p_%t_%s"), ...)

dcm2nii_par_rec(file = list.files(pattern = "[.](par|PAR)"),
  copy_files = TRUE, verbose = TRUE, ...)

dcm2nii_bids_sidecar(basedir, progdir = system.file(package =
  "dcm2niir"), dcm2niicmd = c("dcm2niix", "dcm2nii_2009", "dcm2nii"),
  ...)

fix_sidecar(file)

Arguments

basedir

(character) directory to get files

copy_files

(logical) Should files be copied to a temporary directory?

progdir

(character) directory of bash scripts, no user input needed unless binaries were installed elsewhere. Passed to dcm2nii_bin.

verbose

(logical) print diagnostic printouts

dcm2niicmd

(character) either "dcm2niix", "dcm2nii", or "dcm2nii_2009", which are different versions of dcm2nii. Passed to dcm2nii_bin.

merge_files

Should files be merged, passed do dcm2nii options

ignore_derived

Should derived images be ignored, passed do dcm2nii options

opts

list of arguments to pass to dcm2nii.

...

arguments to be passed to system

file

A Par/REC file

Value

List of result of system command, names of files before and after conversion

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
library(utils)
install_dir = tempdir()
install_dcm2nii(progdir = install_dir)
## dcm_file = paste0("ftp://medical.nema.org/medical/Dicom/", 
## "DataSets/WG30/MGH/MR/MouseBrainSiemens15T_20150410/", 
## "Converted/DICOM/mghmousetoenhancedmr_T1w_pre.dcm")
dcm_file = paste0("http://johnmuschelli.com/dcm2niir/", 
"mghmousetoenhancedmr_T1w_pre.dcm")
tdir = tempfile()
dir.create(tdir)
destfile = tempfile(fileext = ".dcm", tmpdir = tdir)
ci = Sys.getenv("CI")
method = ifelse(ci == "", "auto", "curl")
dl = download.file(url = dcm_file, method = method, destfile = destfile)
dl == 0
stopifnot(file.exists(destfile))
dcm2niir::install_dcm2nii()
res = dcm2niir::dcm2nii(basedir = tdir)
stopifnot(res$result == 0)

muschellij2/dcm2niir documentation built on Nov. 9, 2018, 5:03 a.m.