Skip to content
Snippets Groups Projects
Commit f3d30446 authored by Doorn, Nina (UT-TNW)'s avatar Doorn, Nina (UT-TNW)
Browse files

Update FindPosteriors.py

parent f2599634
No related branches found
No related tags found
No related merge requests found
......@@ -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,))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment