Skip to content

Commit

Permalink
Merge pull request #6 from ramintoosi/v2-server
Browse files Browse the repository at this point in the history
V2 server
  • Loading branch information
ramintoosi committed Jul 5, 2023
2 parents 72f4c12 + 2380c0a commit eb31bcd
Show file tree
Hide file tree
Showing 41 changed files with 1,555 additions and 1,667 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ross-test.yml
@@ -0,0 +1,31 @@
name: ROSS Test

on:
push:
branches-ignore:
- master
pull_request:
branches:
- v2

jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
max-parallel: 5
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: '3.9'
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Install dependencies
run: |
conda env update --file environment.yml --name base
- name: Test with pytest
run: |
python -m pytest -q -rf --tb=short --cov-report term-missing --cov=./
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -407,3 +407,7 @@ compile_commands.json
data
/ross_backend/data.db
/ross_ui/ross_data/
ross_backend/ross_data/
ross_ui/.tmp
*.mat
*.pickle
85 changes: 60 additions & 25 deletions README.md
@@ -1,72 +1,107 @@
# ROSS v2

![image](./images/Ross_Color.png)

ROSS v2 (beta) is the Python version of offline spike sorting software implemented based on the methods described in the paper entitled [An automatic spike sorting algorithm based on adaptive spike detection and a mixture of skew-t distributions](https://www.nature.com/articles/s41598-021-93088-w). (Official Python Implementation)
![ROSS Test](https://github.com/ramintoosi/ROSS/actions/workflows/ross-test.yml/badge.svg)

ROSS v2 (alpha) is the Python version of offline spike sorting software implemented based on the methods described in the
paper
entitled [An automatic spike sorting algorithm based on adaptive spike detection and a mixture of skew-t distributions](https://www.nature.com/articles/s41598-021-93088-w). (
Official Python Implementation)

### Important Note on ROSS v2
ROSS v2 is implemented based on the client-server architecture. In the beta version, the GUI and processing units are completely separated and their connection is based on Restful APIs. However, at this moment, it only works on one machine and we try to find a good way to optimize the data transfer between the client and the server. In our final release, you would be able to run the light GUI on a simple machine while the data and algorithms would be executed on a separate server in your lab.

ROSS v2 is implemented based on the client-server architecture. In the alpha version, the GUI and processing units are
completely separated and their connection is based on Restful APIs. Now, you are able to run the light GUI on a simple machine while the data and algorithms would be executed on a
separate server in your lab. Please carefully read the docs and check our tutorial videos.

## Requirements
- All the requirement packages are listed at enviroments.yml file in root path

- All the requirement packages are listed at environment.yml file in root path

## How to install

1. Git Clone this repository to your local path ```git clone https://github.com/ramintoosi/ROSS```
2. Checkout to v2 ```git checkout v2```
2. Checkout to v2 ```git checkout v2```
3. Create a conda enviroment by command : ```conda env create -f environment.yml```
4. Activate conda environment ```conda activate ross```

## How to run

1. Run the backend by typing ```python ./ross_backend/app.py``` in the terminal.
2. Run the UI by typing ```python ./ross_ui/main.py``` in the terminal.

**Note:** If you have a separate server, run ```step 1``` in your server and ```step 2``` in your personal computer.
3. The first time you want to use the software, you must define a user as follows:

- In opened window, click on ```Options``` ---> ```Sign In/Up``` , enter the desired username and password, click on ```Sign Up```.
- In opened window, click on ```Options``` ---> ```Sign In/Up``` , enter the desired username and password, click
on ```Sign Up```.

4. The next time you want to use the software, just click on ```Options``` ---> ```Sign In/Up``` and enter your username and password, click on ```Sign In``` .
4. The next time you want to use the software, just click on ```Options``` ---> ```Sign In/Up``` and enter your username
and password, click on ```Sign In``` .

5. Import your "Raw Data" as follows :
5. Import your "Raw Data" as follows :

- In opened window, click on ```File``` ---> ```Import``` ---> ```Raw Data``` , select the data file from your system, then, select the variable containing raw-data ```(Spike)``` and click on ```OK```.
- In opened window, click on ```File``` ---> ```Import``` ---> ```Raw Data``` , select the data file from your system,
then, select the variable containing raw-data ```(Spike)``` and click on ```OK```.

6. Now you can Go on and enjoy the Software.
6. Enjoy the Software!

For more instructions and samples please visit ROSS documentation at (link), or demo video at (link).

## Usage

ROSS v2, same as v1, provides useful tools for spike detection, automatic and manual sorting.
ROSS v2, same as v1, provides useful tools for spike detection, automatic and manual sorting.

- Detection

You can load raw extracellular data and adjust the provided settings for filtering and thresholding. Then by pushing **Start Detection** button the detection results appear in a PCA plot:

You can load raw extracellular data and adjust the provided settings for filtering and thresholding. Then by pushing *
*Start Detection** button the detection results appear in a PCA plot:

![image](./images/detection.png)


- Automatic Sorting

Automatic sorting is implemented based on five different methods: skew-t and t distributions, GMM, k-means and template matching. Several options are provided for configurations in the algorithm. Automatic sorting results will appear in PCA and waveform plots:

![image](./images/sort.png)
Automatic sorting is implemented based on five different methods: skew-t and t distributions, GMM, k-means and
template matching. Several options are provided for configurations in the algorithm. Automatic sorting results will
appear in PCA and waveform plots:

![image](./images/sort.png)

- Manual Sorting

Manual sorting tool is used for manual modifications on automatic results by the researcher. These tools include: Merge, Delete, Resort and Manual grouping or deleting samples in PCA domain:

Manual sorting tool is used for manual modifications on automatic results by the researcher. These tools include:
Merge, Delete, Resort and Manual grouping or deleting samples in PCA domain:

![image](./images/sort2.png)


- Visualization
- Several visualization tools are provided such as: 3D plot

- Several visualization tools are provided such as: 3D plot

![image](./images/vis1.png)

- Also, inter spike interval, neuron live time and Cluster Waveforms

![image](./images/vis2.png)


- Also, inter spike interval, neuron live time and Cluster Waveforms

![image](./images/vis2.png)

# Citation
If ROSS helps your research, please cite our paper in your publications.

```
@article{Toosi_2021,
doi = {10.1038/s41598-021-93088-w},
url = {https://doi.org/10.1038%2Fs41598-021-93088-w},
year = 2021,
month = {jul},
publisher = {Springer Science and Business Media {LLC}},
volume = {11},
number = {1},
author = {Ramin Toosi and Mohammad Ali Akhaee and Mohammad-Reza A. Dehaqani},
title = {An automatic spike sorting algorithm based on adaptive spike detection and a mixture of skew-t distributions},
journal = {Scientific Reports}
}
```

94 changes: 55 additions & 39 deletions environment.yml
Expand Up @@ -46,42 +46,58 @@ dependencies:
- xz=5.2.5=h7b6447c_0
- zlib=1.2.11=h7f8727e_4
- pip:
- aniso8601==9.0.1
- cffi==1.15.1
- charset-normalizer==2.0.10
- colour==0.1.5
- cryptography==39.0.0
- cycler==0.11.0
- flask-jwt==0.3.2
- flask-jwt-extended==3.0.0
- flask-restful==0.3.8
- flask-sqlalchemy==2.5.1
- greenlet==1.1.2
- h5py==3.6.0
- idna==3.3
- joblib==1.1.0
- kiwisolver==1.3.2
- matplotlib==3.4.3
- nptdms==1.4.0
- numpy==1.22.1
- opencv-python==4.6.0.66
- pillow==9.0.0
- pycparser==2.21
- pyjwt==1.4.2
- pyopengl==3.1.5
- pyopenssl==23.0.0
- pyparsing==3.0.6
- pyqt5==5.15.6
- pyqt5-qt5==5.15.2
- pyqt5-sip==12.9.0
- pyqtgraph==0.13.1
- pytz==2021.3
- pywavelets==1.2.0
- pyyawt==0.1.1
- requests==2.26.0
- scikit-learn==1.0.1
- scipy==1.7.1
- sip==6.5.0
- sqlalchemy==1.4.29
- threadpoolctl==3.0.0
- urllib3==1.26.8
- aniso8601==9.0.1
- astroid==2.15.3
- cffi==1.15.1
- charset-normalizer==2.0.10
- colour==0.1.5
- coverage==7.2.7
- cryptography==39.0.0
- cycler==0.11.0
- dill==0.3.6
- exceptiongroup==1.1.1
- flask-jwt==0.3.2
- flask-jwt-extended==3.0.0
- flask-restful==0.3.8
- flask-sqlalchemy==2.5.1
- greenlet==1.1.2
- h5py==3.6.0
- idna==3.3
- iniconfig==2.0.0
- isort==5.12.0
- joblib==1.1.0
- kiwisolver==1.3.2
- lazy-object-proxy==1.9.0
- matplotlib==3.4.3
- mccabe==0.7.0
- nptdms==1.4.0
- numpy==1.22.1
- opencv-python==4.6.0.66
- pillow==9.0.0
- platformdirs==3.2.0
- pluggy==1.0.0
- pycparser==2.21
- pyjwt==1.4.2
- pyopengl==3.1.5
- pyopenssl==23.0.0
- pyparsing==3.0.6
- pyqt5==5.15.6
- pyqt5-qt5==5.15.2
- pyqt5-sip==12.9.0
- pyqtgraph==0.13.1
- pytest==7.3.2
- pytest-cov==4.1.0
- pytz==2021.3
- pywavelets==1.2.0
- pyyawt==0.1.1
- requests==2.26.0
- scikit-learn==1.0.1
- scipy==1.7.1
- sip==6.5.0
- sqlalchemy==1.4.29
- threadpoolctl==3.0.0
- tomli==2.0.1
- tomlkit==0.11.7
- typing-extensions==4.5.0
- urllib3==1.26.8
- wrapt==1.15.0
21 changes: 11 additions & 10 deletions ross_backend/app.py
Expand Up @@ -7,13 +7,14 @@
from blacklist import BLACKLIST
from flask import Flask, jsonify
from flask_jwt_extended import JWTManager
from resources.sort import SortDefault, Sort
from resources.project import Project, Projects
from resources.data import RawData, RawDataDefault
from resources.detect import Detect, DetectDefault
from resources.sort import SortDefault
from resources.project import Projects
from resources.data import RawDataDefault
from resources.detect import DetectDefault
from resources.sorting_result import SortingResultDefault
from resources.detection_result import DetectionResultDefault
from resources.detection_result import DetectionResult, DetectionResultSpikeMat
from resources.user import UserRegister, UserLogin, User, TokenRefresh, UserLogout
from resources.browse import Browse

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///data.db' # 'sqlite:///:memory:' # 'sqlite:///data.db'
Expand Down Expand Up @@ -87,19 +88,19 @@ def revoked_token_callback():
api.add_resource(UserLogout, '/logout')
api.add_resource(User, '/user/<int:user_id>')

# api.add_resource(RawData, '/raw/<string:name>')
api.add_resource(RawDataDefault, '/raw')
api.add_resource(DetectDefault, '/detect')
# api.add_resource(Detect, '/detect/<string:name>')
api.add_resource(SortDefault, '/sort')
# api.add_resource(Sort, '/sort/<string:name>')

api.add_resource(DetectionResultDefault, '/detection_result')
api.add_resource(DetectionResult, '/detection_result')
api.add_resource(DetectionResultSpikeMat, '/detection_result_waveform')
api.add_resource(SortingResultDefault, '/sorting_result')

api.add_resource(Projects, '/projects')
# api.add_resource(Project, '/project/<string:name>')

api.add_resource(Browse, '/browse')

if __name__ == '__main__':
db.init_app(app)
app.run(port=5000, debug=False)
app.run(host='0.0.0.0', port=5000, debug=False)

0 comments on commit eb31bcd

Please sign in to comment.