remove_neck: Remove Neck from Image

View source: R/remove_neck.R

remove_neckR Documentation

Remove Neck from Image

Description

Removes the neck from axially acquired scan so skull stripping can be done.

Usage

remove_neck(
  file,
  template.file,
  template.mask = NULL,
  ret_mask = FALSE,
  typeofTransform = "Rigid",
  rep.value = 0,
  swapdim = TRUE,
  verbose = TRUE,
  ...
)

Arguments

file

File for neck removal - either filename or class nifti

template.file

Template to warp to original image space

template.mask

Mask of template to use as rough brain mask. If template.file is specified, but template.mask is not, then fslbin(file=template.file) is performed.

ret_mask

Return mask of slices to keep

typeofTransform

Transformation for template to image, passed to ants_regwrite.

rep.value

Value to replace neck slices with

swapdim

Should the dimensions be swapped before registration, and then reset after

verbose

Print out diagnostic messages

...

Additional arguments passed to ants_regwrite

Value

Object of class nifti or vector of indices

Examples

if (fslr::have.fsl()){
  print(fslr::fsl_version())
  in_ci <- function() {
    nzchar(Sys.getenv("CI"))
  }
  if (in_ci()) {
    destfile = tempfile(fileext = ".nii.gz")
    dl = download.file(paste0(
      "https://github.com/muschellij2/",
      "Neurohacking/files/3454385/113-01-MPRAGE2.nii.gz"),
      destfile = destfile)
    tfile = fslr::mni_fname(brain = TRUE)
    if (file.exists(tfile)) {
      res = remove_neck(
        destfile, 
        template.file = tfile,
        template.mask = fslr::mni_fname(brain = TRUE, mask = TRUE)
      )
    }
  }
}

muschellij2/extrantsr documentation built on June 3, 2024, 7:04 p.m.