library("rplatypus")
spec <- platypus_spec(... )
channels <- predict(fit, "brats", split = "test", type = "probability")
save_class_masks(channels, "predictions", classes = c("whole tumour", "core", "enhancing"))Write overlapping classes, one file per class
Description
regions gives a channel per named class and a sigmoid per channel, so a pixel may be in several classes at once - that is the point of it. A colour map cannot hold that: one pixel gets one colour. save_masks() therefore refuses such a prediction, and this is what it refuses it in favour of - one binary picture per class, named after the class.
Usage
save_class_masks(
masks,
dir,
classes,
names = NULL,
suffix = "",
threshold = 0.5
)
Arguments
masks
|
Channel probabilities from image x height x width has the same rank as one image’s height x width x class, exactly as save_masks() cannot tell a stack of volumes from a stack of images - so that one is read as one image with eight channels and caught by classes not having eight names.
|
dir
|
Directory to write into; created if it does not exist. |
classes
|
One name per channel, in channel order, which is the order the regions were written in and the order every per-class score is reported in. inspect_masks() names them the same way. Called classes and not names because names in this family is the files - see below.
|
names
|
File name stems, one per image, or the source image paths to take them from. Defaults to mask_0001 and so on. The engine’s own function calls this cases; in R it is names, matching save_masks() and save_volumes(), and classes carries what the engine calls names.
|
suffix
|
Added before the class, so predictions from different models can sit in one directory without overwriting each other. |
threshold
|
A class is written where its channel reaches this. 0.5 is what every metric in the engine thresholds a channel at, so a different number here writes pictures that disagree with the scores printed beside them. |
Details
Each file is <name><suffix><class>.png, black and white, so it opens in anything and thresholds back to exactly what was written. A class name becomes a filename by replacing anything outside letters, digits, dot, dash and underscore with , so whole tumour is whole_tumour on disk; two class names that become the same filename are refused rather than written, because one file would hold the second class with the first silently gone.
A class nothing reaches is written as an empty picture rather than skipped. A missing file reads as this run did not produce that class and an empty one as it did and the answer was nothing, which are different findings and only one of them is true.
Value
The paths written, invisibly, image by image and within an image class by class.
See Also
save_masks() for exclusive classes as one colour picture, save_volumes() for volumes as NIfTI.