rsatoolbox.data.base module

Base class for Dataset

class rsatoolbox.data.base.DatasetBase(measurements, descriptors=None, obs_descriptors=None, channel_descriptors=None, check_dims=True)[source]

Bases: object

Abstract dataset class. Defines members that every class needs to have, but does not implement any interesting behavior. Inherit from this class to define specific dataset types

Parameters:
  • measurements (numpy.ndarray) – n_obs x n_channel 2d-array,

  • descriptors (dict) – descriptors (metadata)

  • obs_descriptors (dict) – observation descriptors (all are array-like with shape = (n_obs,…))

  • channel_descriptors (dict) – channel descriptors (all are array-like with shape = (n_channel,…))

Returns:

dataset object

copy() DatasetBase[source]

Copy Dataset To be implemented in child class

Raises:

NotImplementedError – raised if not implemented

Returns:

Never returns

Return type:

DatasetBase

save(filename, file_type='hdf5', overwrite=False)[source]

Saves the dataset object to a file

Parameters:
  • filename (String) – path to the file [or opened file]

  • file_type (String) – Type of file to create: hdf5: hdf5 file pkl: pickle file

  • overwrite (Boolean) – overwrites file if it already exists

split_channel(by)[source]

Returns a list Datasets split by channels

Parameters:

by (String) – the descriptor by which the splitting is made

Returns:

list of Datasets, splitted by the selected channel_descriptor

split_obs(by)[source]

Returns a list Datasets split by obs

Parameters:

by (String) – the descriptor by which the splitting is made

Returns:

list of Datasets, splitted by the selected obs_descriptor

subset_channel(by, value)[source]

Returns a subsetted Dataset defined by certain channel value

Parameters:
  • by (String) – the descriptor by which the subset selection is made from channel dimension

  • value – the value by which the subset selection is made from channel dimension

Returns:

Dataset, with subset defined by the selected channel_descriptor

subset_obs(by, value)[source]

Returns a subsetted Dataset defined by certain obs value

Parameters:
  • by (String) – the descriptor by which the subset selection is made from obs dimension

  • value – the value by which the subset selection is made from obs dimension

Returns:

Dataset, with subset defined by the selected obs_descriptor

to_dict()[source]

Generates a dictionary which contains the information to recreate the dataset object. Used for saving to disc

Returns:

dictionary with dataset information

Return type:

data_dict(dict)