Define an electrophysiological dataset using Xarray#

This example illustrates how to define a dataset using Xarray. If you don’t know this library, we can simplify by saying that it provides containers that accept arrays but you can also labelize your dimensions. Another way of seeing it, pandas is mostly made for tables (i.e 2D arrays) while Xarray provide almost the same functionalities but for multi-dimensional arrays.

import numpy as np
import pandas as pd

from xarray import DataArray
from frites.dataset import DatasetEphy
from frites import set_mpl_style

import matplotlib.pyplot as plt
set_mpl_style()

Create artificial data#

We start by creating some random data for several subjects. To do that, each subject is going have a 3 dimensional array of shape (n_epochs, n_channels, n_times). Then, all of the arrays are grouped together in a list of length (n_subjects,)

n_subjects = 5
n_epochs = 10
n_channels = 5
n_times = 100
sf = 512

x, ch = [], []
for k in range(n_subjects):
    # generate single subject data
    x_suj = np.random.rand(n_epochs, n_channels, n_times)
    # generate some random channel names
    ch_suj = np.array([f"ch_{r}" for r in range(n_channels)])
    # concatenate in a list
    x.append(x_suj)
    ch.append(ch_suj)
# finally lets create a time vector
times = np.arange(n_times) / sf
epochs = np.arange(n_epochs)

Xarray conversion to DataArray#

Here, we convert the NumPy arrays to xarray.DataArray

x_xr = []
for k in range(n_subjects):
    # DataArray conversion
    arr_xr = DataArray(x[k], dims=('epochs', 'channels', 'times'),
                       coords=(epochs, ch[k], times))
    # finally, replace it in the original list
    x_xr.append(arr_xr)
print(x_xr[0])
<xarray.DataArray (epochs: 10, channels: 5, times: 100)> Size: 40kB
array([[[4.30008581e-01, 4.15619327e-01, 8.97145491e-01, ...,
         8.55757189e-01, 7.59507621e-01, 6.01747707e-01],
        [4.02573102e-01, 1.97828239e-01, 5.37139008e-01, ...,
         7.22666646e-01, 9.64066936e-02, 9.28621072e-02],
        [4.49673129e-01, 2.16219113e-03, 7.54797779e-01, ...,
         5.84479083e-02, 7.13079108e-01, 9.06147441e-01],
        [5.51751917e-02, 6.86199079e-01, 5.83072825e-01, ...,
         4.32877614e-01, 3.04843236e-01, 9.90082998e-02],
        [7.10332224e-01, 1.66541040e-01, 4.79279965e-01, ...,
         4.02772711e-01, 5.79732869e-01, 4.55569592e-01]],

       [[4.42653653e-02, 6.25589536e-01, 5.42576396e-01, ...,
         3.63802376e-01, 3.60585380e-01, 1.48582786e-01],
        [1.69032542e-01, 7.05612502e-01, 2.68142230e-01, ...,
         1.87627439e-01, 3.43634152e-01, 9.07068918e-01],
        [1.33953239e-01, 7.25917385e-02, 9.79412500e-01, ...,
         8.84689139e-04, 1.68531356e-01, 6.95919895e-01],
        [9.74397033e-01, 5.62802608e-01, 8.99226653e-01, ...,
         6.07992950e-01, 9.96455361e-01, 5.26676247e-01],
        [3.18727564e-01, 5.45024319e-01, 8.47879462e-01, ...,
...
        [2.71233272e-01, 2.42853502e-01, 4.28530018e-01, ...,
         3.37794144e-02, 8.39410105e-02, 3.97082427e-01],
        [7.11755955e-01, 8.27479920e-01, 4.23932500e-01, ...,
         5.32398555e-01, 4.05543934e-02, 1.77295659e-01],
        [4.75732969e-01, 5.30331741e-02, 4.49995004e-01, ...,
         8.18620214e-02, 6.39047089e-01, 8.78680437e-01],
        [1.23442276e-01, 5.43527659e-01, 2.42839586e-02, ...,
         5.09528262e-01, 7.31521327e-01, 9.86438075e-01]],

       [[1.81666507e-02, 1.13056264e-01, 4.09512525e-01, ...,
         1.36661335e-01, 1.56284832e-01, 9.49422564e-01],
        [6.60434418e-02, 3.53363148e-01, 5.15162443e-01, ...,
         9.11941959e-01, 2.97756640e-01, 1.33746518e-01],
        [3.54040444e-01, 3.04852266e-01, 1.96269968e-01, ...,
         7.63964864e-01, 6.96044342e-01, 2.63218272e-01],
        [8.28104642e-01, 4.62469735e-01, 6.10613807e-01, ...,
         4.81611330e-01, 4.72313149e-01, 2.53627297e-01],
        [2.44161830e-01, 4.55406466e-01, 2.79696627e-01, ...,
         9.38663277e-01, 3.84363188e-01, 7.05822369e-01]]],
      shape=(10, 5, 100))
Coordinates:
  * epochs    (epochs) int64 80B 0 1 2 3 4 5 6 7 8 9
  * channels  (channels) <U4 80B 'ch_0' 'ch_1' 'ch_2' 'ch_3' 'ch_4'
  * times     (times) float64 800B 0.0 0.001953 0.003906 ... 0.1914 0.1934

Build the dataset#

Finally, we pass the data to the frites.dataset.DatasetEphy class in order to create the dataset

# here, we specify to the DatasetEphy class that the roi dimension is actually
# called 'channels' in the DataArray and the times dimension is called 'times'
dt = DatasetEphy(x_xr, roi='channels', times='times')
print(dt)

print('Time vector : ', dt.times)
print('ROI\n: ', dt.df_rs)
<xarray.DataArray 'subject_0' (trials: 10, roi: 5, times: 100)> Size: 40kB
array([[[4.30008581e-01, 4.15619327e-01, 8.97145491e-01, ...,
         8.55757189e-01, 7.59507621e-01, 6.01747707e-01],
        [4.02573102e-01, 1.97828239e-01, 5.37139008e-01, ...,
         7.22666646e-01, 9.64066936e-02, 9.28621072e-02],
        [4.49673129e-01, 2.16219113e-03, 7.54797779e-01, ...,
         5.84479083e-02, 7.13079108e-01, 9.06147441e-01],
        [5.51751917e-02, 6.86199079e-01, 5.83072825e-01, ...,
         4.32877614e-01, 3.04843236e-01, 9.90082998e-02],
        [7.10332224e-01, 1.66541040e-01, 4.79279965e-01, ...,
         4.02772711e-01, 5.79732869e-01, 4.55569592e-01]],

       [[4.42653653e-02, 6.25589536e-01, 5.42576396e-01, ...,
         3.63802376e-01, 3.60585380e-01, 1.48582786e-01],
        [1.69032542e-01, 7.05612502e-01, 2.68142230e-01, ...,
         1.87627439e-01, 3.43634152e-01, 9.07068918e-01],
        [1.33953239e-01, 7.25917385e-02, 9.79412500e-01, ...,
         8.84689139e-04, 1.68531356e-01, 6.95919895e-01],
        [9.74397033e-01, 5.62802608e-01, 8.99226653e-01, ...,
         6.07992950e-01, 9.96455361e-01, 5.26676247e-01],
        [3.18727564e-01, 5.45024319e-01, 8.47879462e-01, ...,
...
        [2.71233272e-01, 2.42853502e-01, 4.28530018e-01, ...,
         3.37794144e-02, 8.39410105e-02, 3.97082427e-01],
        [7.11755955e-01, 8.27479920e-01, 4.23932500e-01, ...,
         5.32398555e-01, 4.05543934e-02, 1.77295659e-01],
        [4.75732969e-01, 5.30331741e-02, 4.49995004e-01, ...,
         8.18620214e-02, 6.39047089e-01, 8.78680437e-01],
        [1.23442276e-01, 5.43527659e-01, 2.42839586e-02, ...,
         5.09528262e-01, 7.31521327e-01, 9.86438075e-01]],

       [[1.81666507e-02, 1.13056264e-01, 4.09512525e-01, ...,
         1.36661335e-01, 1.56284832e-01, 9.49422564e-01],
        [6.60434418e-02, 3.53363148e-01, 5.15162443e-01, ...,
         9.11941959e-01, 2.97756640e-01, 1.33746518e-01],
        [3.54040444e-01, 3.04852266e-01, 1.96269968e-01, ...,
         7.63964864e-01, 6.96044342e-01, 2.63218272e-01],
        [8.28104642e-01, 4.62469735e-01, 6.10613807e-01, ...,
         4.81611330e-01, 4.72313149e-01, 2.53627297e-01],
        [2.44161830e-01, 4.55406466e-01, 2.79696627e-01, ...,
         9.38663277e-01, 3.84363188e-01, 7.05822369e-01]]],
      shape=(10, 5, 100))
Coordinates:
  * trials   (trials) int64 80B 0 1 2 3 4 5 6 7 8 9
    subject  (trials) int64 80B 0 0 0 0 0 0 0 0 0 0
  * roi      (roi) <U4 80B 'ch_0' 'ch_1' 'ch_2' 'ch_3' 'ch_4'
    agg_ch   (roi) int64 40B 0 0 0 0 0
  * times    (times) float64 800B 0.0 0.001953 0.003906 ... 0.1895 0.1914 0.1934
Attributes:
    __version__:   0.4.6
    modality:      electrophysiology
    dtype:         SubjectEphy
    y_dtype:       none
    z_dtype:       none
    mi_type:       none
    mi_repr:       none
    sfreq:         512.0
    agg_ch:        1
    multivariate:  0
<xarray.DataArray 'subject_1' (trials: 10, roi: 5, times: 100)> Size: 40kB
array([[[0.11928999, 0.52618525, 0.1269329 , ..., 0.43542025,
         0.01777982, 0.86024913],
        [0.04195896, 0.76269211, 0.07286539, ..., 0.47600079,
         0.7127555 , 0.8185346 ],
        [0.75214272, 0.39270629, 0.57258749, ..., 0.85279663,
         0.27334737, 0.5835292 ],
        [0.31117365, 0.80379896, 0.39240379, ..., 0.56765811,
         0.65457514, 0.79160714],
        [0.84410288, 0.05874125, 0.35772784, ..., 0.24846727,
         0.86705291, 0.11126956]],

       [[0.56571765, 0.31572435, 0.00228454, ..., 0.65429404,
         0.78269457, 0.91066937],
        [0.68297909, 0.51570707, 0.15465983, ..., 0.99604268,
         0.77917695, 0.85680089],
        [0.36828647, 0.16288634, 0.31779514, ..., 0.45992761,
         0.96891307, 0.94530682],
        [0.67823772, 0.75737861, 0.9682205 , ..., 0.2577613 ,
         0.26592108, 0.3656392 ],
        [0.68707087, 0.40793532, 0.85120588, ..., 0.42044553,
...
         0.99267846, 0.87307804],
        [0.3715323 , 0.33442063, 0.61211934, ..., 0.81183621,
         0.26675029, 0.05376418],
        [0.07408775, 0.46635269, 0.84369904, ..., 0.75604235,
         0.12462772, 0.62275252],
        [0.52300034, 0.52183708, 0.71067454, ..., 0.55096305,
         0.30933686, 0.10933034],
        [0.48531365, 0.50578056, 0.68892731, ..., 0.62669821,
         0.28354695, 0.63785965]],

       [[0.11784489, 0.27841905, 0.86564685, ..., 0.93935605,
         0.57069434, 0.87304802],
        [0.27614432, 0.05458362, 0.20360945, ..., 0.59174349,
         0.27716257, 0.62411018],
        [0.26398572, 0.8130729 , 0.11523605, ..., 0.50230037,
         0.55251583, 0.43443558],
        [0.4158952 , 0.95302152, 0.91040658, ..., 0.83558555,
         0.4134908 , 0.95575555],
        [0.35729684, 0.82486333, 0.71743575, ..., 0.83589958,
         0.64293541, 0.07556001]]], shape=(10, 5, 100))
Coordinates:
  * trials   (trials) int64 80B 0 1 2 3 4 5 6 7 8 9
    subject  (trials) int64 80B 1 1 1 1 1 1 1 1 1 1
  * roi      (roi) <U4 80B 'ch_0' 'ch_1' 'ch_2' 'ch_3' 'ch_4'
    agg_ch   (roi) int64 40B 0 0 0 0 0
  * times    (times) float64 800B 0.0 0.001953 0.003906 ... 0.1895 0.1914 0.1934
Attributes:
    __version__:   0.4.6
    modality:      electrophysiology
    dtype:         SubjectEphy
    y_dtype:       none
    z_dtype:       none
    mi_type:       none
    mi_repr:       none
    sfreq:         512.0
    agg_ch:        1
    multivariate:  0
<xarray.DataArray 'subject_2' (trials: 10, roi: 5, times: 100)> Size: 40kB
array([[[0.91948695, 0.87979538, 0.79281291, ..., 0.82263166,
         0.92349852, 0.64741517],
        [0.74029803, 0.68089148, 0.23847544, ..., 0.96049495,
         0.91139698, 0.0852222 ],
        [0.06195706, 0.50751781, 0.02717379, ..., 0.96101482,
         0.67725388, 0.98765984],
        [0.27896102, 0.34642859, 0.12684912, ..., 0.78485668,
         0.36077026, 0.23479245],
        [0.78552317, 0.1281671 , 0.80580504, ..., 0.61991236,
         0.08161449, 0.07320001]],

       [[0.29114134, 0.26134147, 0.68072373, ..., 0.79293835,
         0.76346626, 0.6600864 ],
        [0.2380412 , 0.55981534, 0.82065207, ..., 0.63367644,
         0.10015319, 0.35899084],
        [0.37397522, 0.83304634, 0.52126711, ..., 0.20324482,
         0.37542584, 0.997347  ],
        [0.83454822, 0.16800315, 0.64732877, ..., 0.18370469,
         0.0258599 , 0.4788021 ],
        [0.61807283, 0.6953434 , 0.30728251, ..., 0.19432944,
...
         0.9224637 , 0.63125157],
        [0.55708516, 0.87784986, 0.37966677, ..., 0.9632567 ,
         0.21915866, 0.00457697],
        [0.49752683, 0.17981057, 0.57013578, ..., 0.45255511,
         0.725804  , 0.1114034 ],
        [0.83133338, 0.09896551, 0.11999966, ..., 0.28314694,
         0.58339661, 0.33079066],
        [0.11909597, 0.34758649, 0.10550889, ..., 0.97560088,
         0.5777897 , 0.42748875]],

       [[0.03267569, 0.61950707, 0.64991809, ..., 0.71811551,
         0.3099583 , 0.52742885],
        [0.11269014, 0.44404203, 0.07050745, ..., 0.73059958,
         0.21967989, 0.03593816],
        [0.64056715, 0.26810605, 0.19728428, ..., 0.77406934,
         0.8526119 , 0.90081977],
        [0.77515231, 0.86759694, 0.63609906, ..., 0.79314501,
         0.9176867 , 0.37723888],
        [0.31401674, 0.41066661, 0.4381768 , ..., 0.41852247,
         0.31735248, 0.79469672]]], shape=(10, 5, 100))
Coordinates:
  * trials   (trials) int64 80B 0 1 2 3 4 5 6 7 8 9
    subject  (trials) int64 80B 2 2 2 2 2 2 2 2 2 2
  * roi      (roi) <U4 80B 'ch_0' 'ch_1' 'ch_2' 'ch_3' 'ch_4'
    agg_ch   (roi) int64 40B 0 0 0 0 0
  * times    (times) float64 800B 0.0 0.001953 0.003906 ... 0.1895 0.1914 0.1934
Attributes:
    __version__:   0.4.6
    modality:      electrophysiology
    dtype:         SubjectEphy
    y_dtype:       none
    z_dtype:       none
    mi_type:       none
    mi_repr:       none
    sfreq:         512.0
    agg_ch:        1
    multivariate:  0
<xarray.DataArray 'subject_3' (trials: 10, roi: 5, times: 100)> Size: 40kB
array([[[0.43004538, 0.65614089, 0.13284507, ..., 0.16816806,
         0.33979741, 0.37546796],
        [0.70255806, 0.78549951, 0.08647421, ..., 0.36036255,
         0.00245529, 0.55037426],
        [0.50360901, 0.84320302, 0.69687019, ..., 0.08969652,
         0.95284688, 0.39686039],
        [0.18588025, 0.25937333, 0.22517591, ..., 0.08456359,
         0.29593196, 0.97353069],
        [0.64624918, 0.05814698, 0.21607716, ..., 0.70918007,
         0.76225478, 0.66491777]],

       [[0.46265872, 0.35913096, 0.16493715, ..., 0.84188051,
         0.93837826, 0.86643623],
        [0.95134456, 0.09031157, 0.75450837, ..., 0.06485132,
         0.2687475 , 0.96743844],
        [0.17654793, 0.44472352, 0.91355439, ..., 0.58816824,
         0.02522253, 0.28955094],
        [0.7819593 , 0.7743504 , 0.94428168, ..., 0.77961091,
         0.65580837, 0.55473179],
        [0.63224248, 0.40365546, 0.74860973, ..., 0.75569197,
...
         0.34429112, 0.02805752],
        [0.7131015 , 0.04315035, 0.87821316, ..., 0.61443466,
         0.81192817, 0.54860817],
        [0.79701442, 0.70784575, 0.36757337, ..., 0.91409791,
         0.00200909, 0.71946715],
        [0.37660624, 0.60205987, 0.90814293, ..., 0.87080868,
         0.1424463 , 0.90913818],
        [0.94780456, 0.63795864, 0.14539284, ..., 0.53113956,
         0.82708304, 0.8529294 ]],

       [[0.57654435, 0.03810384, 0.86381878, ..., 0.58978081,
         0.50967147, 0.62782527],
        [0.40155199, 0.88181222, 0.09689691, ..., 0.81137492,
         0.37524963, 0.91177733],
        [0.4087309 , 0.98467908, 0.94713449, ..., 0.68061051,
         0.6589184 , 0.03143535],
        [0.58335109, 0.61492765, 0.72611378, ..., 0.52935148,
         0.67717479, 0.08073243],
        [0.4694373 , 0.71561275, 0.29705791, ..., 0.51541419,
         0.2558448 , 0.17006528]]], shape=(10, 5, 100))
Coordinates:
  * trials   (trials) int64 80B 0 1 2 3 4 5 6 7 8 9
    subject  (trials) int64 80B 3 3 3 3 3 3 3 3 3 3
  * roi      (roi) <U4 80B 'ch_0' 'ch_1' 'ch_2' 'ch_3' 'ch_4'
    agg_ch   (roi) int64 40B 0 0 0 0 0
  * times    (times) float64 800B 0.0 0.001953 0.003906 ... 0.1895 0.1914 0.1934
Attributes:
    __version__:   0.4.6
    modality:      electrophysiology
    dtype:         SubjectEphy
    y_dtype:       none
    z_dtype:       none
    mi_type:       none
    mi_repr:       none
    sfreq:         512.0
    agg_ch:        1
    multivariate:  0
<xarray.DataArray 'subject_4' (trials: 10, roi: 5, times: 100)> Size: 40kB
array([[[0.81060687, 0.06395865, 0.93834251, ..., 0.38458425,
         0.33503571, 0.35213913],
        [0.9728364 , 0.22333399, 0.51167532, ..., 0.23949269,
         0.12319338, 0.67722901],
        [0.65227237, 0.63854027, 0.20061244, ..., 0.32318281,
         0.96644307, 0.37664041],
        [0.25948739, 0.00694006, 0.29042107, ..., 0.78536757,
         0.37503725, 0.72966275],
        [0.32831335, 0.71420023, 0.89184502, ..., 0.2454904 ,
         0.04527967, 0.35549081]],

       [[0.67116019, 0.88330395, 0.79450572, ..., 0.67184612,
         0.05460093, 0.14406935],
        [0.38628614, 0.42851805, 0.74168145, ..., 0.08240887,
         0.9857575 , 0.77432535],
        [0.14615664, 0.37525907, 0.46117555, ..., 0.85307356,
         0.85050297, 0.34925627],
        [0.30121031, 0.92883483, 0.04915563, ..., 0.94363192,
         0.83600807, 0.97264693],
        [0.61594377, 0.56711937, 0.07108376, ..., 0.32221322,
...
         0.40183786, 0.17538522],
        [0.79461588, 0.94227847, 0.24801076, ..., 0.74271852,
         0.52351185, 0.31655994],
        [0.51511617, 0.16578703, 0.51492142, ..., 0.65666036,
         0.51381209, 0.21136769],
        [0.62106923, 0.90611925, 0.58828558, ..., 0.56307889,
         0.6740868 , 0.49002678],
        [0.10904393, 0.19411827, 0.21737293, ..., 0.13419232,
         0.62989886, 0.19977215]],

       [[0.52818457, 0.61406642, 0.48828433, ..., 0.99444816,
         0.40827414, 0.95696391],
        [0.94988824, 0.86420457, 0.64538879, ..., 0.59625007,
         0.10451909, 0.97635364],
        [0.48001973, 0.03687578, 0.80113744, ..., 0.98693827,
         0.80515945, 0.2371893 ],
        [0.98858328, 0.8495341 , 0.486449  , ..., 0.54092701,
         0.9243252 , 0.06330291],
        [0.66754356, 0.48554682, 0.72044128, ..., 0.31882968,
         0.90538804, 0.72165753]]], shape=(10, 5, 100))
Coordinates:
  * trials   (trials) int64 80B 0 1 2 3 4 5 6 7 8 9
    subject  (trials) int64 80B 4 4 4 4 4 4 4 4 4 4
  * roi      (roi) <U4 80B 'ch_0' 'ch_1' 'ch_2' 'ch_3' 'ch_4'
    agg_ch   (roi) int64 40B 0 0 0 0 0
  * times    (times) float64 800B 0.0 0.001953 0.003906 ... 0.1895 0.1914 0.1934
Attributes:
    __version__:   0.4.6
    modality:      electrophysiology
    dtype:         SubjectEphy
    y_dtype:       none
    z_dtype:       none
    mi_type:       none
    mi_repr:       none
    sfreq:         512.0
    agg_ch:        1
    multivariate:  0
Time vector :  [0.         0.00195312 0.00390625 0.00585938 0.0078125  0.00976562
 0.01171875 0.01367188 0.015625   0.01757812 0.01953125 0.02148438
 0.0234375  0.02539062 0.02734375 0.02929688 0.03125    0.03320312
 0.03515625 0.03710938 0.0390625  0.04101562 0.04296875 0.04492188
 0.046875   0.04882812 0.05078125 0.05273438 0.0546875  0.05664062
 0.05859375 0.06054688 0.0625     0.06445312 0.06640625 0.06835938
 0.0703125  0.07226562 0.07421875 0.07617188 0.078125   0.08007812
 0.08203125 0.08398438 0.0859375  0.08789062 0.08984375 0.09179688
 0.09375    0.09570312 0.09765625 0.09960938 0.1015625  0.10351562
 0.10546875 0.10742188 0.109375   0.11132812 0.11328125 0.11523438
 0.1171875  0.11914062 0.12109375 0.12304688 0.125      0.12695312
 0.12890625 0.13085938 0.1328125  0.13476562 0.13671875 0.13867188
 0.140625   0.14257812 0.14453125 0.14648438 0.1484375  0.15039062
 0.15234375 0.15429688 0.15625    0.15820312 0.16015625 0.16210938
 0.1640625  0.16601562 0.16796875 0.16992188 0.171875   0.17382812
 0.17578125 0.17773438 0.1796875  0.18164062 0.18359375 0.18554688
 0.1875     0.18945312 0.19140625 0.19335938]
ROI
:        #subjects         subjects  keep
roi
ch_0          5  [0, 1, 2, 3, 4]  True
ch_1          5  [0, 1, 2, 3, 4]  True
ch_2          5  [0, 1, 2, 3, 4]  True
ch_3          5  [0, 1, 2, 3, 4]  True
ch_4          5  [0, 1, 2, 3, 4]  True

MultiIndex support#

DataArray also supports multi-indexing of a single dimension.

# create a continuous regressor (prediction error, delta P etc.)
dp = np.random.uniform(-1, 1, (n_epochs,))
# create a discret variable (e.g experimental conditions)
cond = np.array([0] * 5 + [1] * 5)

# now, create a multi-index using pandas
midx = pd.MultiIndex.from_arrays((dp, cond), names=('dp', 'blocks'))

# convert again the original arrays but this time, the epoch dimension is going
# to be a multi-index
x_xr = []
for k in range(n_subjects):
    # DataArray conversion
    arr_xr = DataArray(x[k], dims=('epochs', 'channels', 'times'),
                       coords=(midx, ch[k], times))
    # finally, replace it in the original list
    x_xr.append(arr_xr)
print(x_xr[0])

# finally, when you create your dataset you can also specify the y and z inputs
# by providing their names in the DataArray
dt = DatasetEphy(x_xr, roi='channels', times='times', y='dp', z='blocks')
print(dt)
<xarray.DataArray (epochs: 10, channels: 5, times: 100)> Size: 40kB
array([[[4.30008581e-01, 4.15619327e-01, 8.97145491e-01, ...,
         8.55757189e-01, 7.59507621e-01, 6.01747707e-01],
        [4.02573102e-01, 1.97828239e-01, 5.37139008e-01, ...,
         7.22666646e-01, 9.64066936e-02, 9.28621072e-02],
        [4.49673129e-01, 2.16219113e-03, 7.54797779e-01, ...,
         5.84479083e-02, 7.13079108e-01, 9.06147441e-01],
        [5.51751917e-02, 6.86199079e-01, 5.83072825e-01, ...,
         4.32877614e-01, 3.04843236e-01, 9.90082998e-02],
        [7.10332224e-01, 1.66541040e-01, 4.79279965e-01, ...,
         4.02772711e-01, 5.79732869e-01, 4.55569592e-01]],

       [[4.42653653e-02, 6.25589536e-01, 5.42576396e-01, ...,
         3.63802376e-01, 3.60585380e-01, 1.48582786e-01],
        [1.69032542e-01, 7.05612502e-01, 2.68142230e-01, ...,
         1.87627439e-01, 3.43634152e-01, 9.07068918e-01],
        [1.33953239e-01, 7.25917385e-02, 9.79412500e-01, ...,
         8.84689139e-04, 1.68531356e-01, 6.95919895e-01],
        [9.74397033e-01, 5.62802608e-01, 8.99226653e-01, ...,
         6.07992950e-01, 9.96455361e-01, 5.26676247e-01],
        [3.18727564e-01, 5.45024319e-01, 8.47879462e-01, ...,
...
        [2.71233272e-01, 2.42853502e-01, 4.28530018e-01, ...,
         3.37794144e-02, 8.39410105e-02, 3.97082427e-01],
        [7.11755955e-01, 8.27479920e-01, 4.23932500e-01, ...,
         5.32398555e-01, 4.05543934e-02, 1.77295659e-01],
        [4.75732969e-01, 5.30331741e-02, 4.49995004e-01, ...,
         8.18620214e-02, 6.39047089e-01, 8.78680437e-01],
        [1.23442276e-01, 5.43527659e-01, 2.42839586e-02, ...,
         5.09528262e-01, 7.31521327e-01, 9.86438075e-01]],

       [[1.81666507e-02, 1.13056264e-01, 4.09512525e-01, ...,
         1.36661335e-01, 1.56284832e-01, 9.49422564e-01],
        [6.60434418e-02, 3.53363148e-01, 5.15162443e-01, ...,
         9.11941959e-01, 2.97756640e-01, 1.33746518e-01],
        [3.54040444e-01, 3.04852266e-01, 1.96269968e-01, ...,
         7.63964864e-01, 6.96044342e-01, 2.63218272e-01],
        [8.28104642e-01, 4.62469735e-01, 6.10613807e-01, ...,
         4.81611330e-01, 4.72313149e-01, 2.53627297e-01],
        [2.44161830e-01, 4.55406466e-01, 2.79696627e-01, ...,
         9.38663277e-01, 3.84363188e-01, 7.05822369e-01]]],
      shape=(10, 5, 100))
Coordinates:
  * epochs    (epochs) object 80B MultiIndex
  * dp        (epochs) float64 80B 0.3657 -0.9241 -0.7556 ... 0.3517 -0.8852
  * blocks    (epochs) int64 80B 0 0 0 0 0 1 1 1 1 1
  * channels  (channels) <U4 80B 'ch_0' 'ch_1' 'ch_2' 'ch_3' 'ch_4'
  * times     (times) float64 800B 0.0 0.001953 0.003906 ... 0.1914 0.1934
<xarray.DataArray 'subject_0' (trials: 10, roi: 5, times: 100)> Size: 40kB
array([[[4.30008581e-01, 4.15619327e-01, 8.97145491e-01, ...,
         8.55757189e-01, 7.59507621e-01, 6.01747707e-01],
        [4.02573102e-01, 1.97828239e-01, 5.37139008e-01, ...,
         7.22666646e-01, 9.64066936e-02, 9.28621072e-02],
        [4.49673129e-01, 2.16219113e-03, 7.54797779e-01, ...,
         5.84479083e-02, 7.13079108e-01, 9.06147441e-01],
        [5.51751917e-02, 6.86199079e-01, 5.83072825e-01, ...,
         4.32877614e-01, 3.04843236e-01, 9.90082998e-02],
        [7.10332224e-01, 1.66541040e-01, 4.79279965e-01, ...,
         4.02772711e-01, 5.79732869e-01, 4.55569592e-01]],

       [[4.42653653e-02, 6.25589536e-01, 5.42576396e-01, ...,
         3.63802376e-01, 3.60585380e-01, 1.48582786e-01],
        [1.69032542e-01, 7.05612502e-01, 2.68142230e-01, ...,
         1.87627439e-01, 3.43634152e-01, 9.07068918e-01],
        [1.33953239e-01, 7.25917385e-02, 9.79412500e-01, ...,
         8.84689139e-04, 1.68531356e-01, 6.95919895e-01],
        [9.74397033e-01, 5.62802608e-01, 8.99226653e-01, ...,
         6.07992950e-01, 9.96455361e-01, 5.26676247e-01],
        [3.18727564e-01, 5.45024319e-01, 8.47879462e-01, ...,
...
        [2.71233272e-01, 2.42853502e-01, 4.28530018e-01, ...,
         3.37794144e-02, 8.39410105e-02, 3.97082427e-01],
        [7.11755955e-01, 8.27479920e-01, 4.23932500e-01, ...,
         5.32398555e-01, 4.05543934e-02, 1.77295659e-01],
        [4.75732969e-01, 5.30331741e-02, 4.49995004e-01, ...,
         8.18620214e-02, 6.39047089e-01, 8.78680437e-01],
        [1.23442276e-01, 5.43527659e-01, 2.42839586e-02, ...,
         5.09528262e-01, 7.31521327e-01, 9.86438075e-01]],

       [[1.81666507e-02, 1.13056264e-01, 4.09512525e-01, ...,
         1.36661335e-01, 1.56284832e-01, 9.49422564e-01],
        [6.60434418e-02, 3.53363148e-01, 5.15162443e-01, ...,
         9.11941959e-01, 2.97756640e-01, 1.33746518e-01],
        [3.54040444e-01, 3.04852266e-01, 1.96269968e-01, ...,
         7.63964864e-01, 6.96044342e-01, 2.63218272e-01],
        [8.28104642e-01, 4.62469735e-01, 6.10613807e-01, ...,
         4.81611330e-01, 4.72313149e-01, 2.53627297e-01],
        [2.44161830e-01, 4.55406466e-01, 2.79696627e-01, ...,
         9.38663277e-01, 3.84363188e-01, 7.05822369e-01]]],
      shape=(10, 5, 100))
Coordinates:
  * trials   (trials) int64 80B 0 1 2 3 4 5 6 7 8 9
    y        (trials) float64 80B 0.3657 -0.9241 -0.7556 ... 0.3517 -0.8852
    z        (trials) int64 80B 0 0 0 0 0 1 1 1 1 1
    subject  (trials) int64 80B 0 0 0 0 0 0 0 0 0 0
  * roi      (roi) <U4 80B 'ch_0' 'ch_1' 'ch_2' 'ch_3' 'ch_4'
    agg_ch   (roi) int64 40B 0 0 0 0 0
  * times    (times) float64 800B 0.0 0.001953 0.003906 ... 0.1895 0.1914 0.1934
Attributes:
    __version__:   0.4.6
    modality:      electrophysiology
    dtype:         SubjectEphy
    y_dtype:       float
    z_dtype:       int
    mi_type:       ccd
    mi_repr:       I(x; y (continuous)) | z (discret)
    sfreq:         512.0
    agg_ch:        1
    multivariate:  0
<xarray.DataArray 'subject_1' (trials: 10, roi: 5, times: 100)> Size: 40kB
array([[[0.11928999, 0.52618525, 0.1269329 , ..., 0.43542025,
         0.01777982, 0.86024913],
        [0.04195896, 0.76269211, 0.07286539, ..., 0.47600079,
         0.7127555 , 0.8185346 ],
        [0.75214272, 0.39270629, 0.57258749, ..., 0.85279663,
         0.27334737, 0.5835292 ],
        [0.31117365, 0.80379896, 0.39240379, ..., 0.56765811,
         0.65457514, 0.79160714],
        [0.84410288, 0.05874125, 0.35772784, ..., 0.24846727,
         0.86705291, 0.11126956]],

       [[0.56571765, 0.31572435, 0.00228454, ..., 0.65429404,
         0.78269457, 0.91066937],
        [0.68297909, 0.51570707, 0.15465983, ..., 0.99604268,
         0.77917695, 0.85680089],
        [0.36828647, 0.16288634, 0.31779514, ..., 0.45992761,
         0.96891307, 0.94530682],
        [0.67823772, 0.75737861, 0.9682205 , ..., 0.2577613 ,
         0.26592108, 0.3656392 ],
        [0.68707087, 0.40793532, 0.85120588, ..., 0.42044553,
...
         0.99267846, 0.87307804],
        [0.3715323 , 0.33442063, 0.61211934, ..., 0.81183621,
         0.26675029, 0.05376418],
        [0.07408775, 0.46635269, 0.84369904, ..., 0.75604235,
         0.12462772, 0.62275252],
        [0.52300034, 0.52183708, 0.71067454, ..., 0.55096305,
         0.30933686, 0.10933034],
        [0.48531365, 0.50578056, 0.68892731, ..., 0.62669821,
         0.28354695, 0.63785965]],

       [[0.11784489, 0.27841905, 0.86564685, ..., 0.93935605,
         0.57069434, 0.87304802],
        [0.27614432, 0.05458362, 0.20360945, ..., 0.59174349,
         0.27716257, 0.62411018],
        [0.26398572, 0.8130729 , 0.11523605, ..., 0.50230037,
         0.55251583, 0.43443558],
        [0.4158952 , 0.95302152, 0.91040658, ..., 0.83558555,
         0.4134908 , 0.95575555],
        [0.35729684, 0.82486333, 0.71743575, ..., 0.83589958,
         0.64293541, 0.07556001]]], shape=(10, 5, 100))
Coordinates:
  * trials   (trials) int64 80B 0 1 2 3 4 5 6 7 8 9
    y        (trials) float64 80B 0.3657 -0.9241 -0.7556 ... 0.3517 -0.8852
    z        (trials) int64 80B 0 0 0 0 0 1 1 1 1 1
    subject  (trials) int64 80B 1 1 1 1 1 1 1 1 1 1
  * roi      (roi) <U4 80B 'ch_0' 'ch_1' 'ch_2' 'ch_3' 'ch_4'
    agg_ch   (roi) int64 40B 0 0 0 0 0
  * times    (times) float64 800B 0.0 0.001953 0.003906 ... 0.1895 0.1914 0.1934
Attributes:
    __version__:   0.4.6
    modality:      electrophysiology
    dtype:         SubjectEphy
    y_dtype:       float
    z_dtype:       int
    mi_type:       ccd
    mi_repr:       I(x; y (continuous)) | z (discret)
    sfreq:         512.0
    agg_ch:        1
    multivariate:  0
<xarray.DataArray 'subject_2' (trials: 10, roi: 5, times: 100)> Size: 40kB
array([[[0.91948695, 0.87979538, 0.79281291, ..., 0.82263166,
         0.92349852, 0.64741517],
        [0.74029803, 0.68089148, 0.23847544, ..., 0.96049495,
         0.91139698, 0.0852222 ],
        [0.06195706, 0.50751781, 0.02717379, ..., 0.96101482,
         0.67725388, 0.98765984],
        [0.27896102, 0.34642859, 0.12684912, ..., 0.78485668,
         0.36077026, 0.23479245],
        [0.78552317, 0.1281671 , 0.80580504, ..., 0.61991236,
         0.08161449, 0.07320001]],

       [[0.29114134, 0.26134147, 0.68072373, ..., 0.79293835,
         0.76346626, 0.6600864 ],
        [0.2380412 , 0.55981534, 0.82065207, ..., 0.63367644,
         0.10015319, 0.35899084],
        [0.37397522, 0.83304634, 0.52126711, ..., 0.20324482,
         0.37542584, 0.997347  ],
        [0.83454822, 0.16800315, 0.64732877, ..., 0.18370469,
         0.0258599 , 0.4788021 ],
        [0.61807283, 0.6953434 , 0.30728251, ..., 0.19432944,
...
         0.9224637 , 0.63125157],
        [0.55708516, 0.87784986, 0.37966677, ..., 0.9632567 ,
         0.21915866, 0.00457697],
        [0.49752683, 0.17981057, 0.57013578, ..., 0.45255511,
         0.725804  , 0.1114034 ],
        [0.83133338, 0.09896551, 0.11999966, ..., 0.28314694,
         0.58339661, 0.33079066],
        [0.11909597, 0.34758649, 0.10550889, ..., 0.97560088,
         0.5777897 , 0.42748875]],

       [[0.03267569, 0.61950707, 0.64991809, ..., 0.71811551,
         0.3099583 , 0.52742885],
        [0.11269014, 0.44404203, 0.07050745, ..., 0.73059958,
         0.21967989, 0.03593816],
        [0.64056715, 0.26810605, 0.19728428, ..., 0.77406934,
         0.8526119 , 0.90081977],
        [0.77515231, 0.86759694, 0.63609906, ..., 0.79314501,
         0.9176867 , 0.37723888],
        [0.31401674, 0.41066661, 0.4381768 , ..., 0.41852247,
         0.31735248, 0.79469672]]], shape=(10, 5, 100))
Coordinates:
  * trials   (trials) int64 80B 0 1 2 3 4 5 6 7 8 9
    y        (trials) float64 80B 0.3657 -0.9241 -0.7556 ... 0.3517 -0.8852
    z        (trials) int64 80B 0 0 0 0 0 1 1 1 1 1
    subject  (trials) int64 80B 2 2 2 2 2 2 2 2 2 2
  * roi      (roi) <U4 80B 'ch_0' 'ch_1' 'ch_2' 'ch_3' 'ch_4'
    agg_ch   (roi) int64 40B 0 0 0 0 0
  * times    (times) float64 800B 0.0 0.001953 0.003906 ... 0.1895 0.1914 0.1934
Attributes:
    __version__:   0.4.6
    modality:      electrophysiology
    dtype:         SubjectEphy
    y_dtype:       float
    z_dtype:       int
    mi_type:       ccd
    mi_repr:       I(x; y (continuous)) | z (discret)
    sfreq:         512.0
    agg_ch:        1
    multivariate:  0
<xarray.DataArray 'subject_3' (trials: 10, roi: 5, times: 100)> Size: 40kB
array([[[0.43004538, 0.65614089, 0.13284507, ..., 0.16816806,
         0.33979741, 0.37546796],
        [0.70255806, 0.78549951, 0.08647421, ..., 0.36036255,
         0.00245529, 0.55037426],
        [0.50360901, 0.84320302, 0.69687019, ..., 0.08969652,
         0.95284688, 0.39686039],
        [0.18588025, 0.25937333, 0.22517591, ..., 0.08456359,
         0.29593196, 0.97353069],
        [0.64624918, 0.05814698, 0.21607716, ..., 0.70918007,
         0.76225478, 0.66491777]],

       [[0.46265872, 0.35913096, 0.16493715, ..., 0.84188051,
         0.93837826, 0.86643623],
        [0.95134456, 0.09031157, 0.75450837, ..., 0.06485132,
         0.2687475 , 0.96743844],
        [0.17654793, 0.44472352, 0.91355439, ..., 0.58816824,
         0.02522253, 0.28955094],
        [0.7819593 , 0.7743504 , 0.94428168, ..., 0.77961091,
         0.65580837, 0.55473179],
        [0.63224248, 0.40365546, 0.74860973, ..., 0.75569197,
...
         0.34429112, 0.02805752],
        [0.7131015 , 0.04315035, 0.87821316, ..., 0.61443466,
         0.81192817, 0.54860817],
        [0.79701442, 0.70784575, 0.36757337, ..., 0.91409791,
         0.00200909, 0.71946715],
        [0.37660624, 0.60205987, 0.90814293, ..., 0.87080868,
         0.1424463 , 0.90913818],
        [0.94780456, 0.63795864, 0.14539284, ..., 0.53113956,
         0.82708304, 0.8529294 ]],

       [[0.57654435, 0.03810384, 0.86381878, ..., 0.58978081,
         0.50967147, 0.62782527],
        [0.40155199, 0.88181222, 0.09689691, ..., 0.81137492,
         0.37524963, 0.91177733],
        [0.4087309 , 0.98467908, 0.94713449, ..., 0.68061051,
         0.6589184 , 0.03143535],
        [0.58335109, 0.61492765, 0.72611378, ..., 0.52935148,
         0.67717479, 0.08073243],
        [0.4694373 , 0.71561275, 0.29705791, ..., 0.51541419,
         0.2558448 , 0.17006528]]], shape=(10, 5, 100))
Coordinates:
  * trials   (trials) int64 80B 0 1 2 3 4 5 6 7 8 9
    y        (trials) float64 80B 0.3657 -0.9241 -0.7556 ... 0.3517 -0.8852
    z        (trials) int64 80B 0 0 0 0 0 1 1 1 1 1
    subject  (trials) int64 80B 3 3 3 3 3 3 3 3 3 3
  * roi      (roi) <U4 80B 'ch_0' 'ch_1' 'ch_2' 'ch_3' 'ch_4'
    agg_ch   (roi) int64 40B 0 0 0 0 0
  * times    (times) float64 800B 0.0 0.001953 0.003906 ... 0.1895 0.1914 0.1934
Attributes:
    __version__:   0.4.6
    modality:      electrophysiology
    dtype:         SubjectEphy
    y_dtype:       float
    z_dtype:       int
    mi_type:       ccd
    mi_repr:       I(x; y (continuous)) | z (discret)
    sfreq:         512.0
    agg_ch:        1
    multivariate:  0
<xarray.DataArray 'subject_4' (trials: 10, roi: 5, times: 100)> Size: 40kB
array([[[0.81060687, 0.06395865, 0.93834251, ..., 0.38458425,
         0.33503571, 0.35213913],
        [0.9728364 , 0.22333399, 0.51167532, ..., 0.23949269,
         0.12319338, 0.67722901],
        [0.65227237, 0.63854027, 0.20061244, ..., 0.32318281,
         0.96644307, 0.37664041],
        [0.25948739, 0.00694006, 0.29042107, ..., 0.78536757,
         0.37503725, 0.72966275],
        [0.32831335, 0.71420023, 0.89184502, ..., 0.2454904 ,
         0.04527967, 0.35549081]],

       [[0.67116019, 0.88330395, 0.79450572, ..., 0.67184612,
         0.05460093, 0.14406935],
        [0.38628614, 0.42851805, 0.74168145, ..., 0.08240887,
         0.9857575 , 0.77432535],
        [0.14615664, 0.37525907, 0.46117555, ..., 0.85307356,
         0.85050297, 0.34925627],
        [0.30121031, 0.92883483, 0.04915563, ..., 0.94363192,
         0.83600807, 0.97264693],
        [0.61594377, 0.56711937, 0.07108376, ..., 0.32221322,
...
         0.40183786, 0.17538522],
        [0.79461588, 0.94227847, 0.24801076, ..., 0.74271852,
         0.52351185, 0.31655994],
        [0.51511617, 0.16578703, 0.51492142, ..., 0.65666036,
         0.51381209, 0.21136769],
        [0.62106923, 0.90611925, 0.58828558, ..., 0.56307889,
         0.6740868 , 0.49002678],
        [0.10904393, 0.19411827, 0.21737293, ..., 0.13419232,
         0.62989886, 0.19977215]],

       [[0.52818457, 0.61406642, 0.48828433, ..., 0.99444816,
         0.40827414, 0.95696391],
        [0.94988824, 0.86420457, 0.64538879, ..., 0.59625007,
         0.10451909, 0.97635364],
        [0.48001973, 0.03687578, 0.80113744, ..., 0.98693827,
         0.80515945, 0.2371893 ],
        [0.98858328, 0.8495341 , 0.486449  , ..., 0.54092701,
         0.9243252 , 0.06330291],
        [0.66754356, 0.48554682, 0.72044128, ..., 0.31882968,
         0.90538804, 0.72165753]]], shape=(10, 5, 100))
Coordinates:
  * trials   (trials) int64 80B 0 1 2 3 4 5 6 7 8 9
    y        (trials) float64 80B 0.3657 -0.9241 -0.7556 ... 0.3517 -0.8852
    z        (trials) int64 80B 0 0 0 0 0 1 1 1 1 1
    subject  (trials) int64 80B 4 4 4 4 4 4 4 4 4 4
  * roi      (roi) <U4 80B 'ch_0' 'ch_1' 'ch_2' 'ch_3' 'ch_4'
    agg_ch   (roi) int64 40B 0 0 0 0 0
  * times    (times) float64 800B 0.0 0.001953 0.003906 ... 0.1895 0.1914 0.1934
Attributes:
    __version__:   0.4.6
    modality:      electrophysiology
    dtype:         SubjectEphy
    y_dtype:       float
    z_dtype:       int
    mi_type:       ccd
    mi_repr:       I(x; y (continuous)) | z (discret)
    sfreq:         512.0
    agg_ch:        1
    multivariate:  0

Total running time of the script: (0 minutes 1.159 seconds)

Estimated memory usage: 435 MB

Gallery generated by Sphinx-Gallery