Performs SPM12 realignment estimation and reslicing on an Image

build_spm12_realign(filename, time_points = NULL, fwhm = 5,
  quality = 0.9, separation = 4, register_to = c("first", "mean"),
  est_interp = c("bspline2", "trilinear", paste0("bspline", 3:7)),
  wrap_x = FALSE, wrap_y = FALSE, wrap_z = FALSE,
  weight_image = NULL, reslice = c("all+mean", "all", "2:n", "mean"),
  reslice_interp = c("bspline4", "nearestneighbor", "trilinear",
  paste0("bspline", 2:3), paste0("bspline", 5:7), "fourier"),
  mask = FALSE, prefix = "r", verbose = TRUE, ...)

spm12_realign(..., add_spm_dir = TRUE, spmdir = spm_dir(verbose =
  verbose, install_dir = install_dir), clean = TRUE, retimg = FALSE,
  reorient = FALSE, verbose = TRUE, outdir = NULL,
  install_dir = NULL)

Arguments

filename

Files to be realigned and resliced

time_points

A vector of time points to run realignment, If filename is a 4D file, then will do all the time points. Otherwise, filename must be a character vector of 3D files or a list of 3D nifti objects.

fwhm

Full-Width Half Max to smooth. Gaussian smoothing to apply to the 256x256 joint histogram.

quality

Quality versus speed trade-off. Highest quality (1) gives most precise results, whereas lower qualities gives faster realignment.

separation

The average distance between sampled points (in mm). Can be a vector to allow a coarse registration followed by increasingly fine

register_to

Should the files be registered to the first or the mean

est_interp

Interpolator for estimation

wrap_x

wrap in x-direction

wrap_y

wrap in y-direction

wrap_z

wrap in z-direction

weight_image

weighting image to weight each voxel of the reference image during estimation. The weights are proportional to the inverses of the standard deviations. May be used when there is a lot of motion.

reslice

Options for reslicing all - all images in filename, 2:n - all images in filename 2:length(filename), all+mean - all images and the mean, mean - mean only

reslice_interp

Interpolator for reslicing

mask

Mask the data. With masking enabled, the program searches through the whole time series looking for voxels which need to be sampled from outside the original images. Where this occurs, that voxel is set to zero for the whole set of images

prefix

Prefix to append to front of image filename

verbose

Print diagnostic messages

...

Arguments passed to run_spm12_script

add_spm_dir

Add SPM12 directory from this package

spmdir

SPM dir to add, will use package default directory

clean

Remove scripts from temporary directory after running

retimg

(logical) return image of class nifti

reorient

(logical) If retimg, should file be reoriented when read in?

outdir

Directory to copy results. If full filename given, then results will be in dirname(filename)

install_dir

directory to download SPM12

Value

List of output files, the matlabbatch object, and the script

Examples

dims = rep(10, 4)
temp_nii = array(rnorm(prod(dims)), dim = dims)
temp_nii = oro.nifti::nifti(temp_nii)
res = build_spm12_realign(temp_nii)
#> # Getting Number of Time Points
#> # Reslice is all+mean