## Semesterproject of the lecture "Semesterproject Signal processing and Analysis of human brain potentials (eeg)" WS 2020/21

This repository holds the code of the semesterproject as well as the report, created by Julius Voggesberger.
As the dataset for the project, the N170-dataset was chosen.
As the three subjects, to be manually pre-processed, the subjects 001, 003 and 014 were chosen.
The rest of the subjects were pre-processed with provided pre-processing information.

### Structure
```
├── Dataset: The dataset of the project as well as the manually selected bad segments are stored here. 
|   ├── n170: Store the dataset here. 
|   └── preprocessed: Bad segments are stored here. 
├── cached_data: Data that is generated in the analysis part is stored here. 
|   ├── decoding_data: Results of the classifiers. 
|   ├── erp_peaks: ERP peaks needed for the ERP analysis. 
|   └── tf_data: Time-frequency data needed for the tf-analysis. 
├── test: Contains unittests and one visual check. 
├── utils: Contains helper methods 
|   ├── ccs_eeg_semesterproject: Methods given in the lecture. 
|   ├── ccs_eeg_utils_reduced: Method for reading in BIDS. 
|   ├── file_utils.py: Methods for reading in files and getting epochs. 
|   └── plot_utils.py: Methods for manually created plots. 
├── preprocessing_and_cleaning.py: The preprocessing pipeline. 
├── erp_analysis.py: The ERP-Analysis and computation of ERP peaks.
├── decoding_tf_analysis.py: Decoding and time-frequency analysis.
└── semesterproject_report_voggesberger: The report of the project.
```

### Running the project
To run the project python 3.7 is required and anaconda recommended.\
To ensure reproducability, randomstates were used for methods which are non-deterministic.
The randomstates used are either '123' or '1234'.\
The following libraries are needed:
- Matplotlib 3.3.3
- MNE 0.22.0
- MNE-Bids 0.6
- Numpy 1.19.4
- Scikit-Learn 0.23.2
- Pandas 1.2.0
- Scipy 1.5.4

For the code to work, the N170 dataset needs to be provided and put into the folder 'Dataset/n170/', so that the file structure 'Dataset/n170/sub-001', etc. exists.
The pre-processed raw objects are saved in their respective subject folder, in 'Dataset/n170/'.
When first running the analysis, it may take a while. 
After running it one time the data is cached, so that it can be reused if the analysis should be executed again at a later time.
For the cached data to be used, a boolean parameter has to be set in the respective analysis method.

It may be necessary to set the parent directory 'semesterproject_lecture_eeg' as 'Sources Root' for the project, if pycharm is used as an IDE.

### Parameters
Parameters have to be changed manually in the code, if different settings want to be tried.

### Visualisation
The visualisation methods that were used to generate the visualisations in the report, are contained in the code, if they were created manually.
If a visualisation method from mne was used to create the visualisation, it may exist in the code or not.