Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bnicenboim committed Feb 7, 2024
1 parent 20f4751 commit bb916de
Show file tree
Hide file tree
Showing 3 changed files with 293 additions and 218 deletions.
3 changes: 2 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ if (getRversion() >= "2.15.1") {
}
## data.table needs this
.datatable.aware <- TRUE
mne <- NULL

.onLoad <- function(libname, pkgname) {

if(requireNamespace("reticulate", quietly = TRUE)){
reticulate::use_condaenv("r-eeguana", required = FALSE)
mne <<- reticulate::import("mne", delay_load = TRUE)
}
}

#dplyr styff
register_s3_method("dplyr", "group_by", "eeg_lst")
Expand Down
24 changes: 12 additions & 12 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -90,28 +90,28 @@ trigger "s70" was used for faces and "s71" for no faces. We'll segment the data
using these two triggers.

```{r}
faces_segs <- faces %>%
faces_segs <- faces |>
eeg_segment(.description %in% c("s70", "s71"),
.lim = c(-.2, .25)
) %>%
eeg_events_to_NA(.type == "Bad Interval") %>%
) |>
eeg_events_to_NA(.type == "Bad Interval") |>
eeg_baseline()
```


We can also edit the segmentation information and add more descriptive labels. Once the `eeg_lst` is segmented, the segments table includes the relevant columns from the events table (but without the leading dots).

*eeguana* has wrappers for many `dplyr` commands for the EEG data. These commands always return an entire `eeg_lst` object so that they can be piped using `magrittr`'s pipe, `%>%`.
*eeguana* has wrappers for many `dplyr` commands for the EEG data. These commands always return an entire `eeg_lst` object so that they can be piped using `magrittr`'s pipe, `|>`.

```{r}
## To only see the segments table:
segments_tbl(faces_segs)
## We modify the entire object:
faces_segs_some <- faces_segs %>%
faces_segs_some <- faces_segs |>
eeg_mutate(
condition =
ifelse(description == "s70", "faces", "non-faces")
) %>%
) |>
eeg_select(-type)
faces_segs_some
Expand All @@ -121,8 +121,8 @@ With some "regular" `ggplot` skills, we can create customized plots. `ggplot()`

```{r plot, fig.dim = c(10,15), out.width = "100%", results = "hide"}
library(ggplot2)
faces_segs_some %>%
eeg_select(O1, O2, P7, P8) %>%
faces_segs_some |>
eeg_select(O1, O2, P7, P8) |>
ggplot(aes(x = .time, y = .value)) +
geom_line(alpha = .1, aes(group = .id, color = condition)) +
stat_summary(
Expand All @@ -147,10 +147,10 @@ dev.off()
```

```{r topo, fig.dim = c(10,5), out.width = "100%", results = "hide"}
faces_segs_some %>%
eeg_filter(between(as_time(.sample, .unit = "milliseconds"), 100, 200)) %>%
eeg_group_by(condition) %>%
eeg_summarize(across_ch(mean, na.rm = TRUE)) %>%
faces_segs_some |>
eeg_filter(between(as_time(.sample, .unit = "milliseconds"), 100, 200)) |>
eeg_group_by(condition) |>
eeg_summarize(across_ch(mean, na.rm = TRUE)) |>
plot_topo() +
annotate_head() +
geom_contour() +
Expand Down
Loading

0 comments on commit bb916de

Please sign in to comment.