neuropercolation/evaluation/4laysign.py
2023-12-14 19:49:44 +00:00

174 lines
6.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 10 07:07:28 2023
@author: timofej
"""
import sys as _sys
from sign import sampling as _samp
from sign import plotting as _plot
from sign import full_stats as _stats
import numpy as _np
import json
from plot import qtplot
import gc as _gc
_dim = 9
_epsilons = _np.linspace(0.005,0.20,40)
_noeffects = list(range(1,41,5))
try:
_exeps = int(_sys.argv[1])
_epses=_epsilons[_exeps-1:_exeps]
_nf = int(_sys.argv[2])
_nfs = _noeffects[_nf-1:_nf]
except:
_epses=_epsilons
_nfs = list(range(1,41,5))
_samplemethod = 'allpos_ei'
_ext = 5000
_dt=40
path='/cloud/Public/_data/neuropercolation/4lay/cons=27-knight_steps=1000100/dim=09/batch=0/'
plotpath = path + _samplemethod + f'_samples={_ext}/'
savepath = path + _samplemethod + f'_samples={_ext}/dt={_dt}/'
meanlist = []
stdlist = []
integrallist = []
cohendlist = []
norm_p_list = []
ttest_p_list = []
sign_p_list = []
resultant_i = []
resultant_c = []
for _eps in _epses[11:21]:
res_evol_i = []
res_evol_c = []
for nf in _nfs:
#_samp(_dim,_eps,_samplemethod,_ext,_dt,noeff=nf)
resultant_i = []
resultant_c = []
for t in range(1,_dt):
res_i, res_c = _stats(_dim,_eps,_samplemethod,_ext,t,noeff=nf,ret='phases')
resultant_i.append(res_i)
resultant_c.append(res_c)
res_evol_i.append(resultant_i)
res_evol_c.append(resultant_c)
# mean,std,integral,cohend,norm_p,ttest_p,sign_p = _stats(_dim,_eps,_samplemethod,_ext,1)
# meanlist.append(mean)
# stdlist.append(std)
# integrallist.append(integral)
# cohendlist.append(-cohend)
# norm_p_list.append(norm_p)
# ttest_p_list.append(ttest_p)
# sign_p_list.append(sign_p)
with open(savepath+f"phasediff_means.txt", 'w', encoding='utf-8') as f:
json.dump(meanlist, f, indent=1)
with open(savepath+f"phasediff_stds.txt", 'w', encoding='utf-8') as f:
json.dump(stdlist, f, indent=1)
with open(savepath+f"phasediff_integrals.txt", 'w', encoding='utf-8') as f:
json.dump(integrallist, f, indent=1)
with open(savepath+f"phasediff_cohends.txt", 'w', encoding='utf-8') as f:
json.dump(cohendlist, f, indent=1)
with open(savepath+f"phasediff_norm_ps.txt", 'w', encoding='utf-8') as f:
json.dump(norm_p_list, f, indent=1)
with open(savepath+f"phasediff_ttest_ps.txt", 'w', encoding='utf-8') as f:
json.dump(ttest_p_list, f, indent=1)
with open(savepath+f"phasediff_sign_ps.txt", 'w', encoding='utf-8') as f:
json.dump(sign_p_list, f, indent=1)
# stdlowlist = [meanlist[eps] - stdlist[eps] for eps in range(len(meanlist))]
# stdhighlist = [meanlist[eps] + stdlist[eps] for eps in range(len(meanlist))]
# norm_conf = [1-p for p in norm_p_list]
# ttest_conf = [1-p for p in ttest_p_list]
# sign_conf = [1-p for p in sign_p_list]
res_tot_i = _np.average(res_evol_i,axis=0)
res_evol_c.append(res_tot_i)
qtplot(f'Resultant reduction disconnect eps={_eps} dim={_dim} with 4 layers',
[list(range(_dt-1))]*(len(_nfs)+1),
res_evol_c,
[f'{nf} disconnected steps' for nf in _nfs]+['connected steps'],
x_tag = 'dt',
y_tag = 'resultant',
export=True,
path=plotpath,
filename=f'Resultant reduction disconnect eps={_eps} dim={_dim} extremes={_ext}.png',
close=True)
qtplot(f'Mean causal phase reduction for dt={_dt} dim={_dim} with 4 layers',
[_epsilons]*3,
[stdlowlist, stdhighlist, meanlist],
['Low standard deviation',
'High standard deviation',
'Mean'],
colors=['r','r','g'],
x_tag = f'noise level {chr(949)}',
y_tag = 'abs phase reduction',
export=True,
path=savepath,
filename=f'Mean phase reduction dim={_dim} extremes={_ext}.png',
close=True)
# qtplot(f'Phase reduction probability for dt={_dt} dim={_dim} with 4 layers',
# [_epsilons],
# [integrallist],
# ['probability of phase reduction'],
# x_tag = f'noise level {chr(949)}',
# y_tag = 'abs phase reduction',
# export=True,
# path=savepath,
# filename=f'Probability of phase reduction dim={_dim} extremes={_ext}.png',
# close=True)
# qtplot(f'Effect size phase reduction for dt={_dt} dim={_dim} with 4 layers',
# [_epsilons],
# [cohendlist],
# ["Absolute Cohen's d (negative)"],
# x_tag = f'noise level {chr(949)}',
# y_tag = 'effect size',
# x_range = (0,0.2),
# # y_range = (0.05,1),
# y_log = True,
# export=True,
# path=savepath,
# filename=f'Effect size phase reduction dim={_dim} extremes={_ext}.png',
# close=False)
# qtplot(f'Test p-values for dt={_dt} dim={_dim} with 4 layers',
# [_epsilons]*5,
# [[0.001 for eps in _epsilons],[0.0001 for eps in _epsilons],
# norm_p_list,ttest_p_list,sign_p_list],
# ['0.001 limit','0.0001 limit',
# 'p-value for normality', 'p-value for mean difference', 'p-value for median'],
# x_tag = f'noise level {chr(949)}',
# y_tag = 'p-value',
# y_range = (0,0.01),
# lw=2,
# export=True,
# path=savepath,
# filename=f'P-values phase reduction dim={_dim} extremes={_ext}.png',
# close=True)
# qtplot(f'Test confidences for dt={_dt} dim={_dim} with 4 layers',
# [_epsilons]*5,
# [[0.999 for eps in _epsilons],[0.9999 for eps in _epsilons],
# norm_conf,ttest_conf,sign_conf],
# ['0.999 limit', '0.999 limit',
# 'confidence for normality', 'confidence for mean difference', 'confidence for median'],
# x_tag = f'noise level {chr(949)}',
# y_tag = 'confidence´',
# y_range = (0.99,1),
# lw=2,
# export=True,
# path=savepath,
# filename=f'Confidences phase reduction dim={_dim} extremes={_ext}.png',
# close=True)