Creates a `segmentation` object from an array or a `NIfTI` file
seg_draw(
nifti_file = NULL,
nrrd_file = NULL,
array = NULL,
molten_array = NULL,
ontology = NULL,
ontology_file = NULL,
outliers = NULL,
verbose = TRUE,
directions_from = "RAS",
directions_to = "RAS",
planes = "all",
subset_structures = NULL,
draw_outline = TRUE,
subset_sagittal = NULL,
subset_coronal = NULL,
subset_axial = NULL,
reference_space = NULL,
citation = NULL,
parallel = FALSE
)
a character string pointing to the NIfTI file address. Default is NULL
a character string pointing to the NRRD file address. Default is NULL
a 3D array containing structure annotations (optional if nifti_file
and molten_array
are not specified). Default is NULL
an array in molten form, such as the result of reshape2::melt()
(optional if nifti_file
and array
are not specified). Default is NULL
an object containing the segmentation ontology (e.g. from another segmentation). Default is NULL
a character string pointing to the ontology .csv or .txt file address. Default is NULL
a numeric vector indicating outlier points to be eliminated before drawing polygons. Default is NULL
logical, should messages on the process be displayed? Default is TRUE
character, indicates the original orientation of the array. Default is "RAS"
(Left to Right, Posterior to Anterior, Inferior to Superior).
character, indicates the final orientation of the array. The array is rotated only if it is different from directions_from
. Default is "RAS"
, which results in the proper assignment of axis labels.
character, either "all"
(default) or any subset of "sagittal"
, "coronal"
, and "axial"
. Determines along which axes the array wil be sliced.
character vector, structures to be subset for the segmentation. Default is NULL
logical, should the outline of the whole array be drawn? Default is TRUE
numeric vector, indicates a subset of slices along the sagittal plane that will be drawn. Default is NULL
numeric vector, indicates a subset of slices along the coronal plane that will be drawn. Default is NULL
numeric vector, indicates a subset of slices along the axial plane that will be drawn. Default is NULL
character, what reference space does this segmentation use, e.g. "MNI152"
, "CCFv3"
, "JFRC2010"
. Default is NULL
list of character strings, what is the citation for this segmentation? Default is NULL
.
logical, should the polygons be drawn using parallel processing? Uses future.apply::future_lapply()
, so the proper setup must be done beforehand. Default is FALSE
.
a segmentation
S4 object.
This function takes a volume file such as a NIfTI, NRRD or 3D array and performs all the slicing and contour drawing operations, loading metadata, subsetting structures, etc.
The output of this function is a segmentation
object that can be passed to plotting functions and can be accessed with
several auxiliary methods.
Ideally, the user only needs to run this function once, and save the resulting object (as a RDS file, for example) for distribution and future usage. All the operations performed by this function assume the orientation of the volume is RAS.
Additional arguments such as
directions_from
and directions_to
can be supplied to rotate
the volume if its native orientation is different from RAS. Outlier points
can be removed by specifying the index in the volume array in the outliers
argument.
The user can choose to limit the final segmentation
object
to a subset of either structures, planes, or specific slices (indexed by plane).
array_cubes <- dummy_cubes(10)
ontology <- dummy_ontology()
seg <- seg_draw(
array = array_cubes,
ontology = ontology,
verbose = FALSE
)
# Keeping only the sagittal plane
seg_sagittal <- seg_draw(
array = array_cubes,
ontology = ontology,
planes = "sagittal",
verbose = FALSE
)
# Keeping only a subset of structures
seg_sub <- seg_draw(
array = array_cubes,
ontology = ontology,
subset_structures = c("A", "B"),
verbose = FALSE
)