Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SBI MEA Model
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Doorn, Nina (UT-TNW)
SBI MEA Model
Commits
f3d30446
Commit
f3d30446
authored
10 months ago
by
Doorn, Nina (UT-TNW)
Browse files
Options
Downloads
Patches
Plain Diff
Update FindPosteriors.py
parent
f2599634
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
FindPosteriors.py
+6
-9
6 additions, 9 deletions
FindPosteriors.py
with
6 additions
and
9 deletions
FindPosteriors.py
+
6
−
9
View file @
f3d30446
...
...
@@ -3,12 +3,9 @@ import pickle
from
brian2
import
*
from
sbi
import
utils
as
utils
from
sbi
import
analysis
as
analysis
from
sbi.inference
import
SNPE
import
matplotlib.pyplot
as
plt
from
Simulator
import
MEAnetSimulate
,
ComputeFeatures
from
MakeFigures
import
rasterplot
,
Marginaldiffplot
import
importlib
import
os
from
scipy.stats
import
ks_2samp
numstats
=
15
# Number of summary statistics
...
...
@@ -25,7 +22,7 @@ SSlabels = ['MFR', 'NBR', 'NBD', 'PSIB', '#FBs', 'CVIBI', 'mean CC', 'sd CC', 'm
## LOAD YOUR OWN EXPERIMENTAL DATA TO OBTAIN POSTERIOR
# Load your own experimental data as APs (first column electrode number, second column AP timestamps):
# location of your experimental files
exp_fileloc
=
'
/home/
Nina/Documents/SBI_project/Output/Paper_Figures_ver1/APs_Fig_5_CACNClonesb3_sim0.csv
'
exp_fileloc
=
'
/home/
yourlocation
'
APs_obs
=
numpy
.
loadtxt
(
exp_fileloc
,
delimiter
=
"
,
"
,
dtype
=
'
int
'
)
recordtime
=
165
*
second
# how long the recording was
fs
=
10000
# sampling frequency used for the recording
...
...
@@ -61,20 +58,20 @@ rasterplot(APs_sim, "simulation", 1/fs, transient, simtime, 'black')
## COMPARE TWO POSTERIORS
# calculate or define the MEA features of your two observations
observation1
=
torch
.
tensor
(
torch
.
load
(
'
/home/Nina/Documents/SBI_project/Analyzed_experimental/
SCN_WTC_2410.pt
'
))
observation1
=
torch
.
tensor
(
torch
.
load
(
'
SCN_WTC_2410.pt
'
))
posterior
.
set_default_x
(
observation1
)
# find the maxima of the posterior
obs1_samples
=
posterior
.
sample
((
1000
,))
observation2
=
torch
.
tensor
(
torch
.
load
(
'
/home/Nina/Documents/SBI_project/Analyzed_experimental/
SCN_GEFS_2410.pt
'
))
observation2
=
torch
.
tensor
(
torch
.
load
(
'
SCN_GEFS_2410.pt
'
))
posterior
.
set_default_x
(
observation2
)
# find the maxima of the posterior
obs2_samples
=
posterior
.
sample
((
1000
,))
Marginaldiffplot
(
obs1_samples
,
obs2_samples
,
numparams
,
priorlimits
,
parlabels
,
'
WTC_GEFS_diff
'
)
#Perform Kolmogorov-Smirnov test to test differences between marginals
observation1
=
torch
.
tensor
(
torch
.
load
(
'
/home/Nina/Documents/SBI_project/Analyzed_experimental/
SCN_WTC_2410.pt
'
))
observation1
=
torch
.
tensor
(
torch
.
load
(
'
SCN_WTC_2410.pt
'
))
posterior
.
set_default_x
(
observation1
)
# find the maxima of the posterior
obs1_samples
=
posterior
.
sample
((
50
,))
observation2
=
torch
.
tensor
(
torch
.
load
(
'
/home/Nina/Documents/SBI_project/Analyzed_experimental/
SCN_GEFS_2410.pt
'
))
observation2
=
torch
.
tensor
(
torch
.
load
(
'
SCN_GEFS_2410.pt
'
))
posterior
.
set_default_x
(
observation2
)
# find the maxima of the posterior
obs2_samples
=
posterior
.
sample
((
50
,))
...
...
@@ -89,7 +86,7 @@ for i in range(numparams):
## FIND CONDITIONAL DISTRIBUTIONS AND PEARSON CORRELATIONS
# show a conditional posterior distribution with one sample from the posterior
observation
=
torch
.
tensor
(
torch
.
load
(
'
/home/Nina/Documents/SBI_project/Analyzed_experimental/
SCN_DS_2410.pt
'
))
observation
=
torch
.
tensor
(
torch
.
load
(
'
SCN_DS_2410.pt
'
))
posterior
.
set_default_x
(
observation
)
condition
=
posterior
.
sample
((
1
,))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment