-
Notifications
You must be signed in to change notification settings - Fork 34
Robinson structure folder and files in models #199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sbastiaens
wants to merge
18
commits into
GriffithsLab:main
Choose a base branch
from
sbastiaens:robinson_struct
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
4b5e8c6
Folder and files for robinson
sbastiaens 47782ca
Create __init__.py
sbastiaens d03fc18
Update robinson_lin.py
sbastiaens 50e0cf1
Create README.md
sbastiaens 72b1e15
Merge branch 'GriffithsLab:main' into robinson_struct
sbastiaens 5b462bc
Update robinson_lin.py
sbastiaens 8cec7bf
Update robinson_lin.py
sbastiaens c48d641
Update __init__.py
sbastiaens 1e737cd
Forward function Robinson Linear example
sbastiaens 3f1c5a1
Merge branch 'robinson_struct' of https://github.com/sbastiaens/whobp…
sbastiaens 19b1387
Update robinson_lin_forward.py
sbastiaens bbfa048
Sphinx gallery line
sbastiaens 4dd2cbf
Update robinson_lin_forward.py
sbastiaens ea5bb57
Updated version
sbastiaens b984da3
Merge branch 'robinson_struct' of https://github.com/sbastiaens/whobp…
sbastiaens faa883b
Update __init__.py
sbastiaens e84b2bf
Update index.rst
sbastiaens 1e851df
Update and rename robinson_lin_forward.py to eg__robinson_lin_forward.py
sbastiaens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,213 @@ | ||
| """ | ||
| .. _ex-robinson_lin: | ||
|
|
||
| ======================================================== | ||
| Testing forward function of Linear Robinson model | ||
| ======================================================== | ||
|
|
||
| This example runs a minimal example for running the forward function of the Linear Robinson based on | ||
|
|
||
| R.G. Abeysuriya, C.J. Rennie, P.A. Robinson (2015) | ||
| "Physiologically based arousal state estimation and dynamics" | ||
|
|
||
|
|
||
| The code includes data fetching, model fitting, and result visualization based on the methods presented in the paper. | ||
|
|
||
| """ | ||
|
|
||
| # Reproducing Abeysuriya 2015 outputs and BrainTrak equations with the forward function | ||
|
|
||
| # sphinx_gallery_thumbnail_number = 2 | ||
| # Importage: | ||
|
|
||
| # os stuff | ||
| import os | ||
| import sys | ||
| sys.path.append('..') | ||
|
|
||
| # whobpyt stuff | ||
| import whobpyt | ||
| from whobpyt.datatypes import Parameter as par | ||
| from whobpyt.models.robinson import RobinsonLinModel, RobinsonLinParams | ||
|
|
||
| # python stuff | ||
| import numpy as np | ||
| import pandas as pd | ||
| import scipy.io | ||
| import pickle | ||
| import warnings | ||
| warnings.filterwarnings('ignore') | ||
| import math | ||
| import numpy as np | ||
| #neuroimaging packages | ||
| import mne | ||
|
|
||
| # viz stuff | ||
| import matplotlib.pyplot as plt | ||
|
|
||
| def parameter_set(pars): | ||
| if pars == 'EC': | ||
| # Eyes closed | ||
| params = RobinsonLinParams( Gei = par(-4.11), | ||
| Gee = par(2.070), | ||
| Ges = par(0.77), | ||
| Gsn = par(8.10), | ||
| Gse = par(7.77), | ||
| Gsr = par(-3.3), | ||
| Grs = par(0.2), | ||
| Gre = par(0.66), | ||
| alpha = par(83), | ||
| beta = par(769), | ||
| gammae = par(116), | ||
| t0 = par(0.085), | ||
| re = par(0.086), | ||
| phin = par(1e-5), | ||
| EMG = par(0), | ||
| kmax = par(4), | ||
| k0 = par(10), | ||
| Lx = par(0.5) | ||
| ) | ||
|
|
||
| if pars == 'EO': | ||
| # Eyes open | ||
| params = RobinsonLinParams( Gei = par(-13.22), | ||
| Gee = par(10.50), | ||
| Ges = par(1.21), | ||
| Gsn = par(14.23), | ||
| Gse = par(5.78), | ||
| Gsr = par(-2.83), | ||
| Grs = par(0.25), | ||
| Gre = par(0.85), | ||
| alpha = par(83), | ||
| beta = par(769), | ||
| gammae = par(116), | ||
| t0 = par(0.085), | ||
| re = par(0.086), | ||
| phin = par(1e-5), | ||
| EMG = par(0), | ||
| kmax = par(4), | ||
| k0 = par(10), | ||
| Lx = par(0.5) | ||
| ) | ||
| if pars == 'REM': | ||
| # REM | ||
| params = RobinsonLinParams( Gei = par(-6.61), | ||
| Gee = par(5.87), | ||
| Ges = par(0.21), | ||
| Gsn = par(0.68), | ||
| Gse = par(0.66), | ||
| Gsr = par(-0.28), | ||
| Grs = par(4.59), | ||
| Gre = par(2.08), | ||
| alpha = par(45), | ||
| beta = par(185), | ||
| gammae = par(116), | ||
| t0 = par(0.085), | ||
| re = par(0.086), | ||
| phin = par(1e-5), | ||
| EMG = par(0), | ||
| kmax = par(4), | ||
| k0 = par(10), | ||
| Lx = par(0.5) | ||
| ) | ||
| if pars == 'S1': | ||
| # S1 | ||
| params = RobinsonLinParams( Gei = par(-8.30), | ||
| Gee = par(7.45), | ||
| Ges = par(0.31), | ||
| Gsn = par(3.90), | ||
| Gse = par(1.67), | ||
| Gsr = par(-0.40), | ||
| Grs = par(4.44), | ||
| Gre = par(7.47), | ||
| alpha = par(45), | ||
| beta = par(185), | ||
| gammae = par(116), | ||
| t0 = par(0.085), | ||
| re = par(0.086), | ||
| phin = par(1e-5), | ||
| EMG = par(0), | ||
| kmax = par(4), | ||
| k0 = par(10), | ||
| Lx = par(0.5) | ||
| ) | ||
| if pars == 'S2': | ||
| # S2 | ||
| params = RobinsonLinParams( Gei = par(-17.93), | ||
| Gee = par(16.8), | ||
| Ges = par(3.89), | ||
| Gsn = par(2.38), | ||
| Gse = par(0.07), | ||
| Gsr = par(-0.14), | ||
| Grs = par(8.33), | ||
| Gre = par(4.96), | ||
| alpha = par(45), | ||
| beta = par(185), | ||
| gammae = par(116), | ||
| t0 = par(0.085), | ||
| re = par(0.086), | ||
| phin = par(1e-5), | ||
| EMG = par(0), | ||
| kmax = par(4), | ||
| k0 = par(10), | ||
| Lx = par(0.5) | ||
| ) | ||
| if pars == 'SWS': | ||
| # SWS | ||
| params = RobinsonLinParams( Gei = par(-19.74), | ||
| Gee = par(19.52), | ||
| Ges = par(5.30), | ||
| Gsn = par(1.70), | ||
| Gse = par(0.22), | ||
| Gsr = par(-0.22), | ||
| Grs = par(1.35), | ||
| Gre = par(1.90), | ||
| alpha = par(45), | ||
| beta = par(185), | ||
| gammae = par(116), | ||
| t0 = par(0.085), | ||
| re = par(0.086), | ||
| phin = par(1e-5), | ||
| EMG = par(0), | ||
| kmax = par(4), | ||
| k0 = par(10), | ||
| Lx = par(0.5) | ||
| ) | ||
| if pars == 'Spindles': | ||
| # Spindles | ||
| params = RobinsonLinParams( Gei = par(-18.96), | ||
| Gee = par(18.52), | ||
| Ges = par(2.55), | ||
| Gsn = par(2.78), | ||
| Gse = par(0.73), | ||
| Gsr = par(-0.26), | ||
| Grs = par(16.92), | ||
| Gre = par(4.67), | ||
| alpha = par(45), | ||
| beta = par(185), | ||
| gammae = par(116), | ||
| t0 = par(0.085), | ||
| re = par(0.086), | ||
| phin = par(1e-5), | ||
| EMG = par(0), | ||
| kmax = par(4), | ||
| k0 = par(10), | ||
| Lx = par(0.5) | ||
| ) | ||
| return params | ||
| # %% | ||
| # Plot | ||
| freq = np.linspace(1,60,200) | ||
| w1 = 2*math.pi*freq | ||
| options = ['EC','EO', 'REM', 'S1', 'S2', 'SWS', 'Spindles'] | ||
| for option in options: | ||
| params = parameter_set(option) | ||
| model = RobinsonLinModel(params) | ||
| P = model.forward(external=0, w1=w1) | ||
| plt.plot(freq,P/sum(P)) | ||
| plt.yscale("log") | ||
| plt.xscale("log") | ||
| plt.ylabel('Normalized Power (A.U.)') | ||
| plt.xlabel('Frequency (Hz)') | ||
| plt.legend(options) | ||
| plt.title('Power spectra for different parameter sets') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| NEEDS TO BE DEVELOPED | ||
| # Robinson Model | ||
|
|
||
| ## Robinson Linear model | ||
|
|
||
| ### Equations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from .robinson_lin import RobinsonLinModel, RobinsonLinParams |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge conflict here that needs to be resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok thanks resolved