Skip to content
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

Get alpha/ctrl modes working again #12

Merged
merged 2 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 32 additions & 17 deletions analysis/actuation_modes/alpha_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,50 @@

"""

from DBSpace.control import proc_dEEG
import DBSpace as dbo
from DBSpace.visualizations import EEG_Viz
from DBSpace.control.TVB_DTI import DTI_support_model, plot_support_model
#%%

from dbspace.control import offline_segments
from dbspace.viz.MM import EEG_Viz
from dbspace.control.DTI_support import DTI_support_model, plot_support_model

import scipy.stats as stats
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_context('paper')
sns.set(font_scale=3)
sns.set_style('white')

import pickle
import cmocean
sns.set_context("paper")
sns.set(font_scale=3)
sns.set_style("white")

pt_list = ['906','907','908']
pt_list = ["906", "907", "908"]
## Basic initialization methods, need to suppress figures from these and clean these up
eFrame = proc_dEEG.proc_dEEG(pts=pt_list,procsteps='conservative',condits=['OnT','OffT'])
eFrame = offline_segments.network_action_dEEG(
pts=pt_list,
procsteps="conservative",
condits=["OnT", "OffT"],
config_file="../../assets/config/targeting_experiment.json",
)
eFrame.standard_pipeline()
#%% Generate the control modes
#eFrame.OnT_ctrl_modes(pt='POOL') #THIS HAS BEEN MOVED TO control_modes.py
# eFrame.OnT_ctrl_modes(pt='POOL') #THIS HAS BEEN MOVED TO control_modes.py

#%% Plot the median response
eFrame.topo_median_response(do_condits=['OnT','OffT'],pt='POOL',band='Alpha',use_maya=True,scale_w_mad=False,avg_func=np.mean)
#eFrame.topo_median_variability(do_condits=['OnT','OffT'],pt='POOL',band='Alpha',use_maya=False)
eFrame.topo_median_response(
do_condits=["OnT", "OffT"],
pt="POOL",
band="Alpha",
use_maya=False,
scale_w_mad=False,
avg_func=np.mean,
)
# eFrame.topo_median_variability(do_condits=['OnT','OffT'],pt='POOL',band='Alpha',use_maya=False)

#%% Plot individual patients
for pp in pt_list:
eFrame.topo_median_response(do_condits=['OnT','OffT'],pt=pp,band='Alpha',use_maya=True,scale_w_mad=False)
#eFrame.topo_median_variability(do_condits=['OnT','OffT'],pt='POOL',band='Alpha',use_maya=False)
eFrame.topo_median_response(
do_condits=["OnT", "OffT"],
pt=pp,
band="Alpha",
use_maya=False,
scale_w_mad=False,
)
# eFrame.topo_median_variability(do_condits=['OnT','OffT'],pt='POOL',band='Alpha',use_maya=False)
28 changes: 0 additions & 28 deletions analysis/actuation_modes/tensor_decomp.py

This file was deleted.

15 changes: 5 additions & 10 deletions analysis/actuation_modes/voltage_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,12 @@
Script to load and characterize Voltage-sweep data; Most likely just from 906
"""

import matplotlib.pyplot as plt
import numpy as np
from dbspace.control.stream_buffers import streamEEG
from dbspace.utils.structures import nestdict

import itertools
from sklearn.metrics import confusion_matrix

import matplotlib.pyplot as plt
import numpy as np

import pickle

from dbspace.viz.MM import EEG_Viz
from sklearn.metrics import confusion_matrix

#%%
#First, let's bring in the timeseries from DBS906 Voltage Sweep Experiment
Expand Down Expand Up @@ -61,6 +55,7 @@
#Need to go into each channel and figure out which ones "GROW" and which ones don't
from scipy.stats import linregress


def isMonotonic(A):

return (all(A[i] <= A[i + 1] for i in range(len(A) - 1)) or
Expand All @@ -74,4 +69,4 @@ def isMonotonic(A):
chann_mono[cc] = (voltage_diff > 0).all()
chann_monoish[cc] = np.sum(voltage_diff > 0) > 4

EEG_Viz.plot_3d_scalp(chann_monoish,unwrap=True)
EEG_Viz.plot_3d_scalp(chann_monoish,unwrap=True)
40 changes: 21 additions & 19 deletions notebooks/net_support/group_network_support.ipynb

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions scripts/pyvista_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from pyvista import examples
mesh = examples.download_st_helens()
warped = mesh.warp_by_scalar('Elevation')
surf = warped.extract_surface().triangulate()
surf = surf.decimate_pro(0.75) # reduce the density of the mesh by 75%
surf.plot(cmap='gist_earth')