This function creates the training vectors for a single subject from a probability map, a gold standard mask (normally a manual segmentation), and a brain mask. For a grid of thresholds provided and applied to the probability map the function calculates Sørensen's–Dice coefficient (DSC) between the automatic image and the gold standard image. The function also calculates the volume associated with thresholding at each respective threshold.

tapas_data(thresholds = seq(from = 0, to = 1, by = 0.01), pmap,
  gold_standard, mask, k = 0, subject_id = NULL, verbose = TRUE)



A vector of thresholds to apply to the probability map. The default vector applied is 0 to 1 by 0.01 increments. Threshold values must be between 0 and 1.


A character file path to a probability map image or an object of class nifti.


A character file path to a gold standard image (normally a manual segmentation) or an object of class nifti. The gold standard segmentation is used to compare the thresholded probability map image using Sørensen's–Dice coefficient (DSC).


A character file path to a brain mask image or an object of class nifti.


The minimum number of voxels for a cluster/component. Segmentation clusters of size less than k are removed from the mask, volume estimation, and the Sørensen's–Dice coefficient (DSC) calculation.


A subject ID of class character. By default this is set to NULL but users must provide an ID.


A logical argument to print messages. Set to TRUE by default.


A tibble containing the training data for a single subject. The data contains columns threshold, Sørensen's–Dice coefficient (dsc), and volume.


if (FALSE) {
# Data is provided in the rtapas package as arrays. Below we will convert them to nifti objects.
# Gold standard manual segmentation
gs1 = oro.nifti::nifti(gs1)
# Probability map for subject 1
pmap1 = oro.nifti::nifti(pmap1)
# Brain mask
brain_mask = oro.nifti::nifti(brain_mask)

# Run the tapas_data function for subject 1
data = tapas_data(thresholds = seq(from = 0, to = 1, by = 0.01),
                  pmap = pmap1,
                  gold_standard = gs1,
                  mask = brain_mask,
                  k = 0,
                  subject_id = "subject_1",
                  verbose = TRUE)
# Visualize data returned from the tapas_data function