flexconn_predict: Predict from FLEXCONN model

Description Usage Arguments Value Note Examples

View source: R/flexconn_predict.R

Description

Predict from FLEXCONN model

Usage

 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
46
47
48
flexconn_predict_patch(
  model,
  t1,
  flair,
  t2 = NULL,
  mask = NULL,
  patchsize,
  verbose = TRUE,
  ...,
  batch_size = 1
)

flexconn_predict(
  model,
  t1,
  flair,
  t2 = NULL,
  mask = NULL,
  type = c("volume", "patch"),
  patchsize,
  verbose = TRUE,
  normalize = TRUE,
  ...,
  batch_size = 1
)

flexconn_predict_with_patches(
  model,
  t1,
  flair,
  t2 = NULL,
  mask = NULL,
  patchsize,
  verbose = TRUE,
  ...,
  batch_size = 1
)

flexconn_predict_with_volume(
  model,
  t1,
  flair,
  t2 = NULL,
  verbose = TRUE,
  normalize = TRUE,
  ...,
  batch_size = 1
)

Arguments

model

A keras model object trained

t1

3D array or nifti image

flair

3D array or nifti image

t2

3D array or nifti image, optional if model has this

mask

binary 3D array or nifti image, but of the whole area of prediction, not the ground truth

patchsize

Vector of length 2 (or more)

verbose

print diagnostic messages

...

additional arguments to get_patches

batch_size

Size of batches for prediction. Integer. Passed to predict.keras.engine.training.Model.

type

type of prediction to use, patch-based or slice/volume based

normalize

Run normalize_image on the image before prediction

Value

A vector of predictions, based on the indices of the mask

Note

If mask = NULL, a mask will be generated for t1 > 0.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
model_file = tempfile(fileext = ".h5")
base_url = paste0("https://github.com/muschellij2/flexconnr",
"/raw/master/inst/extdata/")
model_url = paste0(base_url, "21atlases/",
"atlas_with_mask1/FLEXCONNmodel2D_35x35_17-10-2017_21-53-35.h5")
download.file(model_url, destfile = model_file)

t1_file = tempfile(fileext = ".nii.gz")
download.file(paste0(base_url, "T1.nii.gz"), destfile = t1_file)

flair_file = tempfile(fileext = ".nii.gz")
download.file(paste0(base_url, "FLAIR.nii.gz"), destfile = flair_file)

model = keras::load_model_hdf5(model_file)
res = flexconn_predict(model,
t1 = t1_file,
flair = flair_file)

## End(Not run)

neuroconductor/flexconn documentation built on Sept. 25, 2020, 10:51 a.m.