-
Notifications
You must be signed in to change notification settings - Fork 76
The Data Class
IDTxl uses its own class to handle data.
from idtxl.data import Data
import numpy as np
The Data class holds up to 3D data, where one dimension represents processes, one dimension represents samples, and one dimension represents replications. For example, in a neuroscience setting, processes would correspond to EEG channels, samples to time steps, and replications to trials (repetitions of the same experiment).
To import your own data set, create a Data object passing a 1D, 2D, or 3D numpy array. To specify which axis of the numpy array represents which dimension of the data, pass a one to three-letter string as dim_order
, where 'p' stands for processes, 's' for samples, and 'r' for replications.
Example: 3D numpy array
# Initialise a data object holding data with 50000 samples,
# 10 processes, and 5 replications.
mydata = np.arange(50000).reshape((1000, 10, 5))
dat = Data(mydata, dim_order='spr')
Example: 2D numpy array
# Initialise a data object holding data with 5 processes and
# 5000 samples
mydata = np.arange(5000).reshape((5, 1000))
dat = Data(mydata, dim_order='ps')
Example: 1D numpy array
# Initialise a data object holding data with 1 process and
# 1000 samples
mydata = np.arange(1000)
dat = Data(mydata, dim_order='s')
Example: pandas data frame
import pandas as pd
df = pd.DataFrame(
{'col1': np.random.rand(100), 'col2': np.random.rand(100)})
data = Data(df, dim_order='sp')
# Adding data with properties: 2 processes, 100 samples, 1 replications
# overwriting existing data
IDTxl also provides the functionality to generate synthetic test data.