PhysioCore: using the data model through the compatibility layer

What this package is

PhysioCore is a compatibility package. The shared data model it used to implement – the PhysioExperiment S4 class and the containers for multiple streams, repeated sessions and cohorts – now lives in the PhysioExperiment package. PhysioCore re-exports that public interface unchanged, so that existing code written against it keeps working, including S4 objects that were saved while the classes were defined here.

Everything shown below therefore works identically whether you attach PhysioCore (as here) or PhysioExperiment. New code should depend on PhysioExperiment directly; this vignette exists so that users of the older package name can see the core workflow in one place.

library(PhysioCore)
#> Loading required package: PhysioExperiment

Build a PhysioExperiment

A PhysioExperiment holds one or more assays shaped as time x channels, plus a sampling rate. We create a small synthetic three-channel recording – no files, no downloads.

set.seed(1)
sig <- matrix(rnorm(500 * 3), nrow = 500, ncol = 3)   # 500 samples, 3 channels
pe <- PhysioExperiment(assays = list(raw = sig), samplingRate = 250)
pe
#> class: PhysioExperiment
#> dim: 500 x 3 
#> assays(1): raw
#> samplingRate: 250 Hz
#> channels(3): Ch1, Ch2, Ch3

Core accessors

The fundamental properties are reached through accessor functions rather than slots:

samplingRate(pe)   # Hz
#> [1] 250
nChannels(pe)      # number of channels
#> [1] 3
duration(pe)       # seconds
#> [1] 2
head(timeIndex(pe)) # time vector for the samples
#> [1] 0.000 0.004 0.008 0.012 0.016 0.020
channelNames(pe)    # auto-generated names, until you set your own
#> [1] "Ch1" "Ch2" "Ch3"

Channels are named Ch1, Ch2, … by default. Rename them with the replacement form of channelNames():

channelNames(pe) <- c("Fz", "Cz", "Pz")
channelNames(pe)
#> [1] "Fz" "Cz" "Pz"

Channel management

Select or drop channels by name; the returned object is a PhysioExperiment:

front <- pickChannels(pe, c("Fz", "Cz"))
channelNames(front)
#> [1] "Fz" "Cz"

no_pz <- dropChannels(pe, "Pz")
channelNames(no_pz)
#> [1] "Fz" "Cz"

Events

Experimental markers (stimuli, responses, …) are attached with addEvents() and read back with getEvents():

pe <- addEvents(pe, onset = c(0.5, 1.2, 1.9), duration = 0.1, type = "stimulus")
nEvents(pe)
#> [1] 3
getEvents(pe)
#> PhysioEvents with 3 events
#> Event types: stimulus 
#>   onset duration     type value
#> 1   0.5      0.1 stimulus      
#> 2   1.2      0.1 stimulus      
#> 3   1.9      0.1 stimulus

Extract a time window

extractWindow() cuts a segment by time in seconds:

seg <- extractWindow(pe, tmin = 0, tmax = 0.5)
dim(seg)
#> [1] 126   3

Summarize and check for gaps

summary(pe)
#>   channel       min      max         mean       sd      median
#> 1      Fz -3.008049 3.810277  0.022644089 1.011928 -0.03677830
#> 2      Cz -2.996949 3.055742 -0.045940373 1.057304 -0.02125687
#> 3      Pz -3.253220 3.639574 -0.002988453 1.009642 -0.05359054
naSummary(pe)
#>   assay n_na n_total pct_na
#> 1   raw    0    1500      0

Where to go next

PhysioCore adds nothing beyond this re-exported surface. For the full data model – including the multi-stream, longitudinal and cohort containers – and for signal I/O, preprocessing and analysis, see the dedicated packages:

Package Purpose
PhysioExperiment the data model (depend on this in new code)
PhysioIO reading/writing files and databases
PhysioPreprocess filtering, referencing, resampling, ICA
PhysioAnalysis spectral/time-frequency analysis, statistics, plots
#> R version 4.6.1 (2026-06-24)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 26.04.1 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.32.so;  LAPACK version 3.12.0
#> 
#> 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       
#> 
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] PhysioCore_1.0.1       PhysioExperiment_2.3.1 rmarkdown_2.32        
#> 
#> loaded via a namespace (and not attached):
#>  [1] cli_3.6.6                   knitr_1.52                 
#>  [3] rlang_1.3.0                 xfun_0.61                  
#>  [5] otel_0.2.0                  generics_0.1.4             
#>  [7] DelayedArray_0.39.8         jsonlite_2.0.0             
#>  [9] S4Vectors_0.51.10           SummarizedExperiment_1.43.0
#> [11] buildtools_1.0.0            htmltools_0.5.9            
#> [13] maketools_1.3.2             sys_3.4.3                  
#> [15] sass_0.4.10                 stats4_4.6.1               
#> [17] MatrixGenerics_1.25.0       Biobase_2.73.2             
#> [19] grid_4.6.1                  Seqinfo_1.3.2              
#> [21] abind_1.4-8                 evaluate_1.0.5             
#> [23] jquerylib_0.1.4             fastmap_1.2.0              
#> [25] IRanges_2.47.5              yaml_2.3.12                
#> [27] lifecycle_1.0.5             compiler_4.6.1             
#> [29] XVector_0.53.0              lattice_0.23-1             
#> [31] digest_0.6.39               R6_2.6.1                   
#> [33] SparseArray_1.13.4          GenomicRanges_1.65.4       
#> [35] Matrix_1.7-6                bslib_0.12.0               
#> [37] tools_4.6.1                 matrixStats_1.5.0          
#> [39] S4Arrays_1.13.2             BiocGenerics_0.59.12       
#> [41] cachem_1.1.0