|
a |
|
b/R/biometric_mask.R |
|
|
1 |
#' @title Estimate Biometric Masks |
|
|
2 |
#' @description Estimates biometric masks for anonymization, such as the face and |
|
|
3 |
#' ears. |
|
|
4 |
#' |
|
|
5 |
#' @param file Filename (or nifti) of image |
|
|
6 |
#' @param type character of \code{ct} for CT images or \code{mri} for magnetic |
|
|
7 |
#' resonance images |
|
|
8 |
#' @param ... arguments to pass to \code{ct/mri_ear_mask} and |
|
|
9 |
#' \code{ct/mri_face_mask} |
|
|
10 |
#' |
|
|
11 |
#' @return Object of class nifti |
|
|
12 |
#' @export |
|
|
13 |
#' @examples \dontrun{ |
|
|
14 |
#' file = "~/Desktop/Desktop/scratch/100-318_20070723_0957_CT_3_CT_Head-.nii.gz" |
|
|
15 |
#' mask = NULL |
|
|
16 |
#' robust = FALSE |
|
|
17 |
#' mask = ct_biometric_mask( |
|
|
18 |
#' file = file, |
|
|
19 |
#' robust = FALSE |
|
|
20 |
#' ) |
|
|
21 |
#' img = readnii(file) |
|
|
22 |
#' rimg = randomize_mask(img, mask = face) |
|
|
23 |
#' } |
|
|
24 |
#' |
|
|
25 |
biometric_mask = function( |
|
|
26 |
file, |
|
|
27 |
type = c("ct", "mri"), |
|
|
28 |
...) { |
|
|
29 |
type = match.arg(type) |
|
|
30 |
|
|
|
31 |
args = list(...) |
|
|
32 |
args$file = file |
|
|
33 |
|
|
|
34 |
func = paste0(type, "_ear_mask") |
|
|
35 |
ears = do.call(what = func, args = args) |
|
|
36 |
|
|
|
37 |
func = paste0(type, "_face_mask") |
|
|
38 |
face = do.call(what = func, args = args) |
|
|
39 |
mask = ears | face |
|
|
40 |
return(mask) |
|
|
41 |
} |
|
|
42 |
|
|
|
43 |
#' @export |
|
|
44 |
#' @rdname biometric_mask |
|
|
45 |
ct_biometric_mask = function( |
|
|
46 |
file, |
|
|
47 |
...) { |
|
|
48 |
|
|
|
49 |
args = list(...) |
|
|
50 |
args$type = "ct" |
|
|
51 |
args$file = file |
|
|
52 |
|
|
|
53 |
mask = do.call("biometric_mask", args = args) |
|
|
54 |
return(mask) |
|
|
55 |
} |
|
|
56 |
|
|
|
57 |
#' @export |
|
|
58 |
#' @rdname biometric_mask |
|
|
59 |
mri_biometric_mask = function( |
|
|
60 |
file, |
|
|
61 |
...) { |
|
|
62 |
|
|
|
63 |
args = list(...) |
|
|
64 |
args$type = "mri" |
|
|
65 |
args$file = file |
|
|
66 |
|
|
|
67 |
mask = do.call("biometric_mask", args = args) |
|
|
68 |
return(mask) |
|
|
69 |
} |