description argument to BaseDataset and WindowsDataset is now optional and can be either None, a dict, or a pandas.Series
@@ -24,7 +24,7 @@ class BaseDataset(Dataset):
Parameters
----------
raw: mne.io.Raw
- description: dict | pandas.Series
+ description: dict | pandas.Series | None
holds additional description about the continuous signal / subject
target_name: str | None
name of the index in `description` that should be use to provide the
@@ -32,7 +32,12 @@ class BaseDataset(Dataset):
"""
def __init__(self, raw, description=None, target_name=None):
self.raw = raw
- if description is not None and isinstance(description, pd.Series):
+ if description is not None:
+ if (not isinstance(description, pd.Series)
+ and not isinstance(description, dict)):
+ raise ValueError(
+ f"'{description}' has to be either a pandas.Series or a dict")
+ if isinstance(description, dict):
description = pd.Series(description)
self.description = description
@@ -58,12 +63,17 @@ class WindowsDataset(BaseDataset):
windows: mne.Epochs
windows/supercrops obtained through the application of a windower to a
BaseDataset
- description: dict | pandas.Series
+ description: dict | pandas.Series | None
holds additional info about the windows
"""
def __init__(self, windows, description=None):
self.windows = windows
- if description is not None and not isinstance(description, pd.Series):
+ if description is not None:
+ if (not isinstance(description, pd.Series)
+ and not isinstance(description, dict)):
+ raise ValueError(
+ f"'{description}' has to be either a pandas.Series or a dict")
+ if isinstance(description, dict):
description = pd.Series(description)
self.description = description
self.y = np.array(self.windows.metadata.loc[:,'target'])
