EEG-ExPy
EEG-ExPy copied to clipboard
Implement ExperimentSpec to reduce redundancy
A lot of the code/experiments needs access to static information such as:
- device name
- experiment name
- subject id
- session id
- data directory
- record duration
It would probably be a good idea to add a dataclass for this, that'll be easier to pass around without having to repeat the same set of arguments every time.
The idea would be that once you've constructed a ExperimentSpec, you can:
- Run the experiment:
expspec.run() - Get an
EEGinstance:expspec.device(generated from input arguments at initialization) - Generate a savefile:
expspec.generate_output_file()(see #74) - Write new experiments by simply having their
presentfunctions accept the single argumentspecwhich contains all metadata possibly needed by the experiment.
Essentially:
@dataclass
class ExperimentSpec:
device_name: str
experiment_name: str
subject_id: int
session_id: int
device_options: dict = field(default_factory=dict, ...)
def __post_init__(self):
self.device = EEG(self.device_name, **self.device_options)
def run() -> None:
...
def get_output_file() -> Path:
...
This can maybe be implemented with a simple configuration files instead of starting a whole new dataclass but perhaps being able to do things like expspec.run() might be useful so I will play around with this.