This script is used for training or updating CSP models for each dataset in a directory.
python FBCSP.py --data_dir <path_to_data_directory> --model_file <path_to_save_or_load_model> [--update_existing]--data_dir: Path to the directory containing the input CSV files.--model_file: Path to save or load the CSP models.--update_existing: (Optional) Flag to update existing models if they exist.
This script is used for transforming and printing the data using trained CSP models. It is useful for verifying the transformation process and inspecting the transformed data.
python FBCSP_Simulation.py --data_file <path_to_data_file> --model_file <path_to_trained_model>--data_file: Path to the input CSV file.--model_file: Path to the trained CSP model file.
This script transforms the data using trained CSP models and saves the transformed data into a specified output directory. It also creates cumulative files for each user and one for all users.
python FBCSP_transform.py --input_dir <path_to_input_directory> --output_dir <path_to_output_directory> --model_file <path_to_trained_model>--input_dir: Path to the directory containing the input CSV files.--output_dir: Path to the directory where the transformed CSV files will be saved.--model_file: Path to the trained CSP model file.
The final CSP-transformed CSV files have the following structure:
- Each row corresponds to a data segment.
- Columns are named according to the frequency band, class, and CSP component, e.g.,
delta_LeftHand_comp1,theta_RightHand_comp2, etc. - The last column is
activity, which contains the class label for each segment.
<MainFolder>
│
└───<User1>
│ │
│ └───<User1_Day1>
│ │ │ file1.csv
│ │ │ file2.csv
│ │
│ └───<User1_Day2>
│ │ file1.csv
│ │ file2.csv
│
└───<User2>
│
└───<User2_Day1>
│ │ file1.csv
│ │ file2.csv
│
└───<User2_Day2>
│ file1.csv
│ file2.csv
<OutputFolder>
│
└───<User1>
│ │ User1_cumulative.csv
│ │
│ └───<User1_Day1>
│ │ │ file1.csv
│ │ │ file2.csv
│ │
│ └───<User1_Day2>
│ │ file1.csv
│ │ file2.csv
│
└───<User2>
│ User2_cumulative.csv
│
└───<User2_Day1>
│ │ file1.csv
│ │ file2.csv
│
└───<User2_Day2>
│ file1.csv
│ file2.csv
<OutputFolder>/User1/User1_cumulative.csv: Cumulative data for User1 across all days.<OutputFolder>/User2/User2_cumulative.csv: Cumulative data for User2 across all days.<OutputFolder>/cumulative_all_users.csv: Cumulative data for all users.
The transformed CSP CSV data contains columns representing the CSP components for each frequency band and each class, followed by an 'activity' column which holds the labels. The column names are structured as follows:
- Frequency Bands: The data includes CSP components for 7 frequency bands: delta, theta, alpha, beta_low, beta_mid, beta_high, and gamma.
- Classes: Each frequency band has CSP components for 5 classes: LeftHand, RightHand, Jaw, LeftHandClench, and RightHandClench.
- Components: Each class has 2 CSP components: comp1 and comp2.
- Activity: The last column is 'activity', which holds the labels for the data segments.
The total number of columns is calculated as follows:
- Frequency bands: 7
- Classes per frequency band: 5
- Components per class: 2
- Plus 1 activity column (Default convention is {0:'NO ACTIVITY',1: 'LeftHand', 2: 'RightHand', 3: 'Jaw', 4: 'LeftHandClench', 5: 'RightHandClench'})
This results in a total of 71 columns in the transformed CSP CSV data.
The data from BCI Competition is located on project's google drive. https://drive.google.com/drive/u/1/folders/1yEbw1B5vBvJsIbltqB07WSYyan97SDEf
The data can be interacted with two approaches:
- 1- Each patient separately: A csv file for each patient is provided for subject dependent tasks
- 2- All patients: the file with "all_patients" in it's name contain all patients data with a column specifying the patient number
The events considered in the data are only the 4 target classes (left, right, foot, tongue), other events mentioned in the paper have been discarded for simplicity