library(ieegio)
nifti_file <- "nifti/rnifti_example.nii.gz"
nifti_rgbfile <- "nifti/rnifti_example_rgb.nii.gz"
# Use
# `ieegio_sample_data(nifti_file)`
# and
# `ieegio_sample_data(nifti_rgbfile)`
# to download sample data
if(
ieegio_sample_data(nifti_file, test = TRUE) &&
ieegio_sample_data(nifti_rgbfile, test = TRUE)
) {
# ---- NIfTI examples ---------------------------------------------
underlay_path <- ieegio_sample_data(nifti_file)
overlay_path <- ieegio_sample_data(nifti_rgbfile)
# basic read
underlay <- read_volume(underlay_path)
overlay <- read_volume(overlay_path)
par(mfrow = c(1, 3), mar = c(0, 0, 3.1, 0))
ras_position <- c(50, -10, 15)
ras_str <- paste(sprintf("%.0f", ras_position), collapse = ",")
for(which in c("coronal", "axial", "sagittal")) {
plot(x = underlay, position = ras_position, crosshair_gap = 10,
crosshair_lty = 2, zoom = 3, which = which,
main = sprintf("%s T1RAS=[%s]", which, ras_str))
plot(x = overlay, position = ras_position,
crosshair_gap = 10, label_col = NA,
add = TRUE, alpha = 0.9, zoom = 5, which = which)
}
}
Run the code above in your browser using DataLab