bnicenboim / eeguana

A package for manipulating EEG data in R.
https://bnicenboim.github.io/eeguana/
Other
21 stars 9 forks source link

could not find function "across." #236

Closed prattems closed 6 months ago

prattems commented 6 months ago

Several functions throw this error including eeg_rereference() and eeg_filt_band_pass(). I'm loading eeguana (version 0.1.10.9001) followed by dplyr (version 1.1.4). It looks like mutate.() is defined internally, but I'm not sure where across.() should be coming from.

Thanks so much, for the help and this package! I've only started using it but it's going to be terribly helpful (if I can learn dplyr).

Mike

bnicenboim commented 6 months ago

Hi, thanks for reporting this. Could you send me reproducible example? if you install, reprex (https://reprex.tidyverse.org/), you can use the Addins menu in Rstudio and do Reprex selection. I want to know the order of loading packages and what exactly you're doing with the functions.

Also paste the output of sessionInfo()

prattems commented 6 months ago

Thanks so much,

In the example below I use your builtin data and code from the help files. The call to eeg_segment works but the subsequent call to eeg_reference gives the error regarding across.() not being found. I find the same error if dplyr is loaded before eeguana.

library(eeguana)
#> eeguana version 0.1.10.9001
#> An introduction to the package can be found in https://bruno.nicenboim.me/eeguana/articles/intro.html
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:eeguana':
#> 
#>     across, between, c_across
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

data_faces_10_trials %>% eeg_segment(.description %in% c("s70", "s71"),
                                     .lim = c(-5, 1))
#> # Total of 9 segments found.
#> # Object size in memory 7.3 Mb after segmentation.
#> # EEG data:
#> 
#> # Signal table:
#> Key: <.id, .sample>
#>          .id      .sample           Fp1           Fpz           Fp2
#>        <int> <sample_int> <channel_dbl> <channel_dbl> <channel_dbl>
#>     1:     1        -2499    -21.109169    -28.948433   -25.2941818
#>     2:     1        -2498    -26.754496    -31.574997   -29.3033142
#>     3:     1        -2497    -28.524906    -30.061056   -29.8119774
#>     4:     1        -2496    -19.430933    -21.690756   -22.9545746
#>     5:     1        -2495     -5.725405    -12.675667   -14.1778440
#>    ---                                                             
#> 27005:     9          497     -8.819434    -10.321518    -4.1491461
#> 27006:     9          498     -6.959885    -10.197778    -3.9415770
#> 27007:     9          499     -1.756994     -7.125042    -1.8327932
#> 27008:     9          500      3.828817     -3.076797     0.1685476
#> 27009:     9          501      6.447233     -1.101932     0.8303175
#>                   F7            F3            Fz            F4            F8
#>        <channel_dbl> <channel_dbl> <channel_dbl> <channel_dbl> <channel_dbl>
#>     1:  -10.91393471    -7.5658569    -8.7408314     -8.170362    -6.2060385
#>     2:  -15.56297112    -8.5204601    -8.6705694     -7.897309    -6.2139606
#>     3:  -18.79760742   -10.9199018    -8.0307159     -6.302173    -7.0704432
#>     4:  -14.15851784   -11.1185970    -5.9641218     -3.515551    -9.4960175
#>     5:   -2.97854924    -7.5502534    -3.7647977     -1.728970   -11.8486443
#>    ---                                                                      
#> 27005:   -0.04505777    -3.4396243    -0.3492746      1.448371    -0.9764605
#> 27006:   -0.39633083    -5.2603526    -0.5973411      2.423673    -1.4587488
#> 27007:    1.76945877    -4.0067720     0.8627796      3.911339    -2.3904738
#> 27008:    5.14945936    -1.2876422     2.6780972      4.573048    -3.9883673
#> 27009:    7.85265970     0.7570639     3.2915244      3.903461    -5.8100514
#>                  FC5           FC1           FC2           FC6            M1
#>        <channel_dbl> <channel_dbl> <channel_dbl> <channel_dbl> <channel_dbl>
#>     1:   -10.3604956     -8.741921    -11.687920    -3.2395220   -1.33440495
#>     2:    -8.3586874     -9.393848    -11.007945    -2.0159216   -0.40914702
#>     3:    -6.6766038    -10.921223     -9.508024     0.6382501   -0.02219653
#>     4:    -5.3997726    -11.370429     -8.181183     2.3170936   -0.15380359
#>     5:    -1.5244772    -10.140000     -8.618706     0.1669424   -0.42611933
#>    ---                                                                      
#> 27005:    -3.1192555      7.583683      4.683777     2.0146487   -0.75850582
#> 27006:    -5.0121384      7.003987      5.093409     2.6218574   -0.48889470
#> 27007:    -3.8819036      8.010637      6.655658     2.4396117    0.37114978
#> 27008:     0.2056897      9.351544      7.915032     1.1819088    0.79920685
#> 27009:     3.5806384      9.694896      7.764079    -0.7410481    0.47170472
#>                   T7            C3            Cz            C4            T8
#>        <channel_dbl> <channel_dbl> <channel_dbl> <channel_dbl> <channel_dbl>
#>     1:    -10.026085     -9.994508     -9.713416    -11.545010     -5.506052
#>     2:    -10.864231    -11.186291    -10.363641    -10.096234    -13.692937
#>     3:    -10.305115    -14.071175    -11.175298     -7.532410    -18.642357
#>     4:     -6.952291    -15.679218    -11.470225     -5.610895    -15.585937
#>     5:     -1.514339    -14.149639    -11.411907     -7.089185     -5.756573
#>    ---                                                                      
#> 27005:     -2.933141      1.959429      5.739326      3.235288      7.357582
#> 27006:     -3.713117      1.318202      5.491092      3.290012      7.295595
#> 27007:     -2.321592      1.811074      6.128494      3.688938      5.087297
#> 27008:      1.119921      2.753958      6.793680      3.092779      3.427744
#> 27009:      3.754653      3.358357      6.357634      1.617870      3.171353
#>                   M2           CP5           CP1           CP2           CP6
#>        <channel_dbl> <channel_dbl> <channel_dbl> <channel_dbl> <channel_dbl>
#>     1:    1.33440495    -10.124557    -21.182615     -8.225979      1.352515
#>     2:    0.40914702    -10.541845    -22.123146     -8.299847      2.918134
#>     3:    0.02219653    -10.097946    -22.904871     -7.499836      6.240794
#>     4:    0.15380359     -7.715628    -22.575096     -6.102085      8.873845
#>     5:    0.42611933     -3.972811    -21.122660     -5.780276      7.216280
#>    ---                                                                      
#> 27005:    0.75850582      2.440120      9.009402      2.962071      2.134945
#> 27006:    0.48889470      2.300604      8.520119      3.144351      2.515271
#> 27007:   -0.37114978      2.277759      8.711225      3.692545      2.287699
#> 27008:   -0.79920685      2.035310      8.742649      3.526225     -0.904506
#> 27009:   -0.47170472      2.071527      8.072234      2.323087     -4.643136
#>                   P7            P3            Pz            P4            P8
#>        <channel_dbl> <channel_dbl> <channel_dbl> <channel_dbl> <channel_dbl>
#>     1:    -12.080380    -10.113933     -8.703011   -4.20130539      3.195775
#>     2:    -11.193981    -10.194810     -9.080425   -4.14209843      2.318590
#>     3:     -7.487033     -9.285007     -8.754600   -2.61196470      3.541405
#>     4:     -1.335482     -7.199755     -7.912488   -0.50822496      6.676203
#>     5:      4.918743     -4.848968     -7.416552   -0.01726842      8.177627
#>    ---                                                                      
#> 27005:     -5.362492      3.755604      7.436291    0.44716191     -3.323942
#> 27006:     -5.735914      3.123381      7.172704    0.63476968     -2.597961
#> 27007:     -5.450908      3.175655      7.514575    0.96244740     -2.774142
#> 27008:     -4.410063      3.246389      7.394914    0.24067569     -3.957345
#> 27009:     -2.809917      2.920698      6.190672   -1.19312561     -4.774019
#>                  POz            O1            Oz            O2          EOGV
#>        <channel_dbl> <channel_dbl> <channel_dbl> <channel_dbl> <channel_dbl>
#>     1:     -8.369589    -8.4397917    -3.8788650    -0.1158402    -19.684998
#>     2:     -9.067577    -8.5709276    -4.3982387    -0.5201874    -16.109802
#>     3:     -7.452994    -5.2471170    -1.8378611     1.8578585    -11.800674
#>     4:     -4.108239     1.1644255     3.2520020     6.4933400     -7.483185
#>     5:     -1.417105     7.4992466     8.0737114    10.8989525     -6.017853
#>    ---                                                                      
#> 27005:      5.305985    -2.0515025    -0.6655829    -1.8001112     -6.660660
#> 27006:      5.463353    -1.7843865    -0.1968485    -1.1158936     -5.629734
#> 27007:      5.724925    -0.8298787     0.3083435    -0.6791936     -5.186114
#> 27008:      5.367867     0.6219659     0.7365036    -0.5318193     -4.111660
#> 27009:      4.392406     2.3162208     1.4108977     0.1259224     -2.589244
#>                 EOGH
#>        <channel_dbl>
#>     1:    -54.449097
#>     2:    -68.097107
#>     3:    -83.815216
#>     4:   -100.941864
#>     5:   -118.664459
#>    ---              
#> 27005:      6.173569
#> 27006:      4.975996
#> 27007:      3.522355
#> 27008:      2.911364
#> 27009:      3.616112
#> 
#> # Events table:
#>        .id        .type .description     .initial       .final .channel
#>      <int>       <char>       <char> <sample_int> <sample_int>   <char>
#>   1:     1 Bad Interval  Bad Min-Max        -2499        -1905      Fp1
#>   2:     1 Bad Interval  Bad Min-Max        -2499        -1906      Fpz
#>   3:     1 Bad Interval  Bad Min-Max        -2499        -1905      Fp2
#>   4:     1 Bad Interval  Bad Min-Max        -2499        -1980       F7
#>   5:     1 Bad Interval  Bad Min-Max        -2499        -1939       Fz
#>  ---                                                                   
#> 150:     9 Bad Interval  Bad Min-Max        -1691        -1349      Fpz
#> 151:     8 Bad Interval  Bad Min-Max          277          501       F8
#> 152:     9 Bad Interval  Bad Min-Max        -1672        -1435       F8
#> 153:     9     Stimulus         s130         -369         -369     <NA>
#> 154:     9     Stimulus          s70            1            1     <NA>
#> 
#> # Segments table:
#> Key: <.id>
#>      .id .recording segment     type description
#>    <int>     <char>   <int>   <char>      <char>
#> 1:     1 faces.vhdr       1 Stimulus         s70
#> 2:     2 faces.vhdr       2 Stimulus         s71
#> 3:     3 faces.vhdr       3 Stimulus         s71
#> 4:     4 faces.vhdr       4 Stimulus         s71
#> 5:     5 faces.vhdr       5 Stimulus         s70
#> 6:     6 faces.vhdr       6 Stimulus         s71
#> 7:     7 faces.vhdr       7 Stimulus         s71
#> 8:     8 faces.vhdr       8 Stimulus         s70
#> 9:     9 faces.vhdr       9 Stimulus         s70

data_faces_ERPs_M1 <- data_faces_ERPs %>%
  eeg_rereference(-EOGV, -EOGH, .ref = M1)
#> Error in across.(tidyselect::all_of(c(Fp1 = "Fp1", Fpz = "Fpz", Fp2 = "Fp2", : could not find function "across."

############# sessionInfo() Output ##################
sessionInfo()
#> R version 4.1.2 (2021-11-01)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 22.04.4 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] dplyr_1.1.4         eeguana_0.1.10.9001
#> 
#> loaded via a namespace (and not attached):
#>  [1] rstudioapi_0.14   knitr_1.42        magrittr_2.0.3    munsell_0.5.0    
#>  [5] tidyselect_1.2.0  colorspace_2.1-0  R6_2.5.1          rlang_1.1.3      
#>  [9] fastmap_1.1.1     fansi_1.0.6       tools_4.1.2       grid_4.1.2       
#> [13] tidytable_0.11.0  gtable_0.3.4      data.table_1.15.2 xfun_0.42        
#> [17] utf8_1.2.4        cli_3.6.2         withr_3.0.0       htmltools_0.5.4  
#> [21] yaml_2.3.7        digest_0.6.31     tibble_3.2.1      lifecycle_1.0.4  
#> [25] purrr_1.0.2       ggplot2_3.5.0     vctrs_0.6.5       fs_1.6.0         
#> [29] glue_1.7.0        evaluate_0.20     rmarkdown_2.20    reprex_2.1.0     
#> [33] compiler_4.1.2    pillar_1.9.0      scales_1.3.0      generics_0.1.3   
#> [37] pkgconfig_2.0.3

Created on 2024-03-11 with reprex v2.1.0

bnicenboim commented 6 months ago

thanks, this is fixed now.

Feel free to use https://github.com/bnicenboim/eeguana/discussions if you have general questions