This article uses
N27 sample files mentioned by the previous vignettes. If you are using this example, please execute the following R code to set up. Alternatively, you can substitute variables
library(threeBrain) subject_code <- "N27" subject_path <- "~/Downloads/N27" brain <- freesurfer_brain2(subject_path, subject_code)
To add electrodes to the brain object, you need a electrode table with least 5 columns:
Label. The column names are case-sensitive.
If you have performed electrode localization (see the previous article) and exported the electrode table, the exported table can be used here once
Electrode is filled out.
For demonstration purposes, this electrode table will be used. Please download this file and place it at
electrode_table <- `~/Downloads/N27/electrodes.csv` brain$set_electrodes(electrode_table) brain$plot()
In iEEG study, various of analyses can be performed on the electrodes. The analysis results are different, including
threeBrain can visualize them all with two lines and one data table.
First, let’s take a look To start, generate a table as follows:
The column names are case-sensitive, and should only contain letters, digits and
Project: (optional) the project name that this experiment belongs to
Subject: (mandatory) the subject code; must be consistent with the brain subject code
Electrode: (mandatory) integers of electrode channel number; correspond to the
Electrodecolumn in the electrode table
Time(optional) numerical time in seconds
cluster): values of the electrodes
Download sample value table from here and save it to
electrode_table <- `~/Downloads/N27/electrodes.csv` value_table <- `~/Downloads/N27/values.csv` brain$set_electrodes(electrode_table) brain$set_electrode_values(value_table) brain$plot()
Data Visualization panel, change
Display Data or use keyboard shortcut
d (make sure the mouse is hovering on the brain) to switch to desired variables.
sine_wave is time series. You can see the animation by toggling
Play/Pause option in the
Data Visualization panel.
In the example above, the p-value legend shows the range is from
0.5. This is because
threeBrain viewer’s default palette is symmetric around zero, and the range is decided by the maximum absolute number. However, the actual p-value should range from
1, and we might be particularly interested in
$p \leq 0.05$. This means both the color palette and value range need to be corrected.
In the following code,
value_ranges is a named list of such value ranges.
"p_value"=c(0,1) suggests that the
p_value variable should range from 0 to 1. All other variables adopt the default ranges.
palettes is a named list of color palettes. In this specific case, variable
pal is a vector of 64 colors.
colorRampPalette is a base-R function to interpolate colors. Please use
help("colorRampPalette") to see the documentation.
pal <- c( colorRampPalette(c("red", "#FFC6C6"))(8), colorRampPalette(c("#FFC6C6", "white"))(56) ) brain$plot( value_ranges = list( "p_value" = c(0, 1) ), palettes = list( "p_value" = pal ) )
threeBrain provides value mapping that allows electrode values to be displayed on the surfaces. To enable this feature, open
Surface Settings panel, and click on
Surface Color, switch to
sync from electrodes, or simply use keyboard shortcut
k (make sure the mouse is hovering over the brain) to change.
You can also hide the electrodes by switching the electrode
hidden in the
Electrodes panel to only show the mapped results.