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
subject_code
and subject_path
accordingly.
library(threeBrain)
<- "N27"
subject_code <- "~/Downloads/N27"
subject_path <- freesurfer_brain2(subject_path, subject_code) brain
To add electrodes to the brain object, you need a electrode table
with least 5 columns: Subject
, Coord_x
,
Coord_y
, Coord_z
, 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
~/Downloads/N27/electrodes.csv
<- `~/Downloads/N27/electrodes.csv`
electrode_table $set_electrodes(electrode_table)
brain$plot() brain
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:
Project | Subject | Electrode | Time | sine_wave | p_value | z_score | cluster |
---|---|---|---|---|---|---|---|
demo | N27 | 1 | 0.00 | 0.20 | 0.05 | 1.96 | A |
demo | N27 | 1 | 0.50 | 0.88 | 0.05 | 1.96 | A |
demo | N27 | 1 | 1.00 | 0.98 | 0.05 | 1.96 | A |
demo | N27 | 2 | 0.00 | 0.38 | 0.01 | 2.58 | A |
demo | N27 | 2 | 0.44 | 0.89 | 0.01 | 2.58 | A |
demo | N27 | 2 | 0.89 | 0.98 | 0.01 | 2.58 | A |
demo | N27 | 3 | 0.00 | 0.56 | 0.28 | 1.09 | A |
demo | N27 | 3 | 0.11 | 0.69 | 0.28 | 1.09 | A |
… |
The column names are case-sensitive, and should only contain letters,
digits and _
.
Project
: (optional) the project name that this
experiment belongs toSubject
: (mandatory) the subject code; must be
consistent with the brain subject codeElectrode
: (mandatory) integers of electrode channel
number; correspond to the Electrode
column in the electrode
tableTime
(optional) numerical time in secondssine_wave
, p_value
,
z_score
, and cluster
): values of the
electrodesDownload sample value table from here
and save it to ~/Downloads/N27/values.csv
<- `~/Downloads/N27/electrodes.csv`
electrode_table <- `~/Downloads/N27/values.csv`
value_table $set_electrodes(electrode_table)
brain$set_electrode_values(value_table)
brain$plot() brain
Open 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.
The 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
to 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 0
to 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.
<- c(
pal colorRampPalette(c("red", "#FFC6C6"))(8),
colorRampPalette(c("#FFC6C6", "white"))(56)
)$plot(
brainvalue_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
Visibility
to hidden
in the
Electrodes
panel to only show the mapped results.