[242173]: / R / ich_candidate_voxels.R

Download this file

47 lines (40 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
40
41
42
43
44
45
#' @title Create ICH Segmentation Candidate Voxesl
#' @description Takes estimated cutoffs from paper from training data
#' and creates a logical candidate vector
#' @param df \code{data.frame} of image from \code{\link{make_predictors}}
#' @param cutoffs a set of cutoffs/quantiles, with the names of
#' columns of \code{df}
#'
#' @return Logical vector
#' @export
ich_candidate_voxels = function(df, cutoffs = ichseg::est.cutoffs){
# fname = file.path(outdir,
# paste0("Reseg_Aggregate_data_cutoffs",
# adder, ".Rda"))
#
# load(file = fname)
# data(est.cutoffs)
#
# med.ztemp = median(df$zscore_template[keep.ind])
#
# df$gr_medztemp = (df$zscore_template >
# med.ztemp)
keepnames = c("zscore3", "zscore2",
"pct_thresh", "zscore_template")
for (icut in keepnames) {
qcuts = cutoffs[, icut]
colname = paste0(icut, ".cutoff")
df[, colname] =
df[, icut] >= qcuts[1] &
df[, icut] <= qcuts[2]
}
df$include = df$value >= 30 &
df$value <= 100
df$zval = df[, "zscore3.cutoff"] &
df$include &
df$pct_thresh.cutoff
df$zval2 = df[, "zscore2.cutoff"] &
df$zval
candidate = df$zval2
return(candidate)
}