Learn R Programming

espadon (version 1.11.3)

bin.from.roi: Creation of a binary volume according to RoI

Description

The bin.from.roi function creates a "volume" class object, of modality "binary" or "weight", by selecting the voxels defined by the RoI.

Usage

bin.from.roi(
  vol,
  struct,
  roi.name = NULL,
  roi.sname = NULL,
  roi.idx = NULL,
  T.MAT = NULL,
  within = TRUE,
  alias = "",
  description = NULL,
  modality = c("binary", "weight"),
  ...
)

Value

Returns a "volume" class object of "binary" or "weight" modality (see espadon.class for class definitions), with the same grid as vol.

  • In the “binary” modality, voxels with 50 percent of their volume within the ROI are set to TRUE.

  • In the “weight” modality, the value of each voxel is its volume fraction included in the ROI.

Arguments

vol

"volume" class object.

struct

"struct" class object.

roi.name

Vector of exact names of the RoI in the struct object. By default roi.name = NULL. See Details.

roi.sname

Vector of names or parts of names of the RoI in the struct object. By default roi.sname = NULL. See Details.

roi.idx

Vector of indices of the RoI that belong to the struct object. By default roi.idx = NULL. See Details.

T.MAT

"t.mat" class object, created by load.patient.from.Rdcm or load.T.MAT. If T.MAT = NULL, struct$ref.pseudo must be equal to vol$ref.pseudo.

within

Boolean, defaults to TRUE. If within = TRUE, the contours included in a RoI are managed, depending on their $level field. If within = FALSE, only the $level = 0 fields of the RoI are used (i.e. only the external outlines).

alias

Character string, $alias of the created object.

description

Character string, describing the created object. If description = NULL (default value), it will be set to struct$roi.info$roi.pseudo[roi.idx].

modality

modality ("binary" or "weight") of the generated object.

...

additional argument.

Details

roi.name, roi.sname, and roi.idx must select only one RoI.

See Also

bin.from.vol.

Examples

Run this code
# loading of toy-patient objects (decrease dxyz for better result)
step <- 5
patient <- toy.load.patient (modality = c("ct", "rtstruct"), 
                             roi.name =  c("eye", "optical nerve", "brain"), 
                             dxyz = rep (step, 3))
CT <- patient$ct[[1]]
S <- patient$rtstruct[[1]]

# "optical nerve" binary, with  modality "binary" and "weight"
binl <- bin.from.roi (CT, struct = S, roi.sname = "left optical",
                      alias = "left_optical_nerve", verbose = FALSE,
                      modality = "binary")
binr <- bin.from.roi (CT, struct = S, roi.sname = "right optical",
                      alias = "right_optical_nerve", verbose = FALSE,
                      modality = "weight")

view.coord <- S$roi.info[S$roi.info$roi.pseudo == "leftopticalnerve",]$Gz
palette <- grey.colors(100, start = 0, end = 1, 
                       alpha = c(0, rep(1,99)))
plot(S, view.coord = view.coord, main ="optical nerves")
plot(binl, view.coord = view.coord, col = palette, 
    cut.interpolate = FALSE, add = TRUE)
plot(binr, view.coord = view.coord, col =palette, 
      cut.interpolate = FALSE, add = TRUE)
plot(S, view.coord = view.coord, lwd = 2, add= TRUE)

if (FALSE) {
# with a smaller step
step <- 1
patient <- toy.load.patient (modality = c("ct", "rtstruct"), 
                             roi.name =  c("eye", "optical nerve", "brain"), 
                             dxyz = rep (step, 3))
CT <- patient$ct[[1]]
S <- patient$rtstruct[[1]]
#' view.coord <- S$roi.info[S$roi.info$roi.pseudo == "leftopticalnerve",]$Gz

# "optical nerve" binary without inclusions management
bin <- bin.from.roi (CT, struct = S, roi.sname = "left optical", 
                     alias = "left_optical_nerve", within = FALSE,
                     verbose = FALSE)
display.plane (CT, top = bin, struct = S, view.coord = view.coord, 
               legend.shift = -80, interpolate = FALSE, main = "Left nerve")

# "optical nerve" binary with inclusions management
bin <- bin.from.roi (CT, struct = S, roi.sname = "left optical", 
                     alias = "left_optical_nerve", within = TRUE,
                     verbose = FALSE)
display.plane (CT, top = bin, struct = S, view.coord = view.coord, 
               legend.shift = -80, interpolate = FALSE, main = "Left nerve") 
}

Run the code above in your browser using DataLab