[3b2327]: / R / reduce_scan.R

Download this file

39 lines (33 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#' @title Reduction of Scan Dimensions from Mask
#' @description Reduces the dimensions of a scan based on extent of
#' a mask. Combines
#' \code{\link{getEmptyImageDimensions}} and
#' \code{\link{applyEmptyImageDimensions}}.
#'
#' @param img Image to reduce
#' @param mask Mask to reduce image by
#'
#' @return List of antsImage objects for reduced image and mask
#' @export
#'
#' @import methods
#' @importFrom extrantsr check_ants
#' @importFrom neurobase mask_img
#' @importFrom neurobase getEmptyImageDimensions applyEmptyImageDimensions
reduce_scan = function(img, mask) {
img = check_ants(img)
mask = check_ants(mask)
# mask = as.array(mask)
inds = getEmptyImageDimensions(mask)
drop_img = applyEmptyImageDimensions(img = img,
inds = inds)
drop_mask = applyEmptyImageDimensions(img = mask, inds = inds)
# drop_img = as.antsImage(drop_img)
# drop_img = antsCopyImageInfo(img, drop_img)
# drop_mask = as.antsImage(drop_mask)
# drop_mask = antsCopyImageInfo(img, drop_mask)
drop_img = mask_img(drop_img, drop_mask)
L = list(img = drop_img,
mask = drop_mask)
return(L)
}