Welcome to the Swarm-Contrastive Decomposition project! This repository contains the code of our research paper on decomposition of Neurophysiological Time Series signals. The primary goal of this project is to provide an open-source implementation for fostering further research in this area.
Make sure you have the following software and libraries installed:
- Python 3.10 🐍
- NumPy 📦
- PyTorch 🔥
Follow these steps to set up the project locally:
- Clone the repository:
git clone https://github.com/AgneGris/swarm-contrastive-decomposition
- Navigate to the project directory:
cd swarm-contrastive-decomposition
- Create the conda environment from the
decomposition.yml
file:conda env create -f decomposition.yml
- Activate the environment:
conda activate decomposition
-
Upload Your Input Data:
- Place your input data files in the
data/input
folder.
- Place your input data files in the
-
Modify Data Loading:
- Depending on your data structure, you may need to adjust the data loading logic in
main.py
(lines 41-53).
- Depending on your data structure, you may need to adjust the data loading logic in
-
Configure the Parameters:
- Customize the configuration settings in
main.py
according to your needs:device
: Set to"cuda"
for GPU or"cpu"
for CPU.acceptance_silhouette
: Define the acceptance threshold for source quality.extension_factor
: This factor typically equals1000 / number of channels
. A higher value may improve results.low_pass_cutoff
: Define the cutoff frequency for the low-pass filter.high_pass_cutoff
: Define the cutoff frequency for the high-pass filter.start_time
: Set the start time for signal trimming. Use0
to include the entire signal from the beginning.end_time
: Set the end time for signal trimming. Use-1
to include the entire signal until the end.max_iterations
: Specify the maximum number of iterations for the decomposition process.sampling_frequency
: Indicate the sampling frequency of your signal.peel_off_window_size
: Define the size of the window (in ms) for the spike-triggered average of the source.output_final_source_plot
: Set toTrue
to generate a plot of the final source, orFalse
to skip plotting.use_coeff_var_fitness
: Set toTrue
if consistent activity is expected in discharge times (recommended for most EMGs); set toFalse
for other types of data (e.g., intracortical).remove_bad_fr
: Set toTrue
to filter out sources with firing rates below 2 Hz or above 100 Hz. You can adjust these thresholds inmodels\scd.py
if needed.
- Other configuration parameters are found in
config\structures
.
- Customize the configuration settings in
-
Run the Decomposition:
- Once your data is properly loaded and configured, run the following command to start the decomposition process:
python main.py
- Once the decomposition process has terminated, the output data will be saved in the
data/output
folder.
- Once your data is properly loaded and configured, run the following command to start the decomposition process:
We welcome contributions! Here’s how you can contribute:
- Fork the repository.
- Create a feature branch (git checkout -b feature/newfeature).
- Commit your changes (git commit -m 'Add some newfeature').
- Push to the branch (git push origin feature/newfeature).
- Open a pull request.
This project is licensed under the CC BY-NC 4.0 License.
If you use this code in your research, please cite our paper:
@article{10643350,
author={Grison, Agnese and Clarke, Alexander Kenneth and Muceli, Silvia and Ibáñez, Jaime and Kundu, Aritra and Farina, Dario},
journal={IEEE Transactions on Biomedical Engineering},
title={A Particle Swarm Optimised Independence Estimator for Blind Source Separation of Neurophysiological Time Series},
year={2024},
volume={},
number={},
pages={1-11},
keywords={Recording;Time series analysis;Sorting;Vectors;Measurement;Electrodes;Probes;Independent component analysis;particle swarm optimisation;blind source separation;intramuscular electromyography;intracortical recording},
doi={10.1109/TBME.2024.3446806}}
For any questions or inquiries, please contact us at:
Agnese Grison
[email protected]