Syncing to home.
This commit is contained in:
parent
b1fcd0121b
commit
9701ef1a4d
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,2 @@
|
||||
data/*
|
||||
data/*
|
||||
./_pycache_/
|
||||
60
python/fig_pathway_stages.py
Normal file
60
python/fig_pathway_stages.py
Normal file
@ -0,0 +1,60 @@
|
||||
import glob
|
||||
import plotstyle_plt
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from thunderhopper.modeltools import load_data
|
||||
from IPython import embed
|
||||
|
||||
# GENERAL SETTINGS:
|
||||
data_paths = glob.glob('../data/*.npz')
|
||||
channel = 0
|
||||
stages_pre = ['raw', 'filt', 'env', 'log', 'inv']
|
||||
stages_feat = ['conv', 'bi', 'feat', 'norm']
|
||||
|
||||
# PLOT SETTINGS:
|
||||
fig_kwargs = dict(
|
||||
figsize = np.array([16, 9]) * 0.75,
|
||||
layout = 'constrained',
|
||||
sharex = 'col',
|
||||
sharey = 'row'
|
||||
)
|
||||
zoom_rel = np.array([0.4, 0.6])
|
||||
colors_pre = ['k' for _ in range(len(stages_pre))]
|
||||
colors_feat = ['k' for _ in range(len(stages_feat))]
|
||||
|
||||
for data_path in data_paths:
|
||||
# Load overall data:
|
||||
data, config = load_data(data_path)
|
||||
t_full = np.arange(data['raw'].shape[0]) / config['rate']
|
||||
|
||||
# Establish zoom frame:
|
||||
zoom_abs = zoom_rel * t_full[-1]
|
||||
zoom_mask = (t_full >= zoom_abs[0]) & (t_full <= zoom_abs[1])
|
||||
t_zoom = t_full[zoom_mask]
|
||||
|
||||
# PART I: PREPROCESSING STAGE
|
||||
fig, axes = plt.subplots(len(stages_pre), 2, **fig_kwargs)
|
||||
|
||||
for i, stage in enumerate(stages_pre):
|
||||
signal = data[stage][:, channel]
|
||||
ax_full, ax_zoom = axes[i, :]
|
||||
ax_full.plot(t_full, signal, c=colors_pre[i])
|
||||
ax_full.set_ylim(signal.min(), signal.max())
|
||||
|
||||
ax_zoom.plot(t_zoom, signal[zoom_mask], c=colors_pre[i])
|
||||
ax_full.set_xlim(t_full[0], t_full[-1])
|
||||
|
||||
# PART II: FEATURE EXTRACTION STAGE:
|
||||
fig, axes = plt.subplots(len(stages_feat), 2, **fig_kwargs)
|
||||
|
||||
for i, stage in enumerate(stages_feat):
|
||||
signal = data[stage][:, ..., channel]
|
||||
ax_full, ax_zoom = axes[i, :]
|
||||
ax_full.plot(t_full, signal, c=colors_feat[i])
|
||||
ax_full.set_ylim(signal.min(), signal.max())
|
||||
|
||||
ax_zoom.plot(t_zoom, signal[zoom_mask, ...], c=colors_feat[i])
|
||||
ax_full.set_xlim(t_full[0], t_full[-1])
|
||||
plt.show()
|
||||
|
||||
|
||||
48
python/plotstyle_plt.py
Normal file
48
python/plotstyle_plt.py
Normal file
@ -0,0 +1,48 @@
|
||||
import matplotlib as mpl
|
||||
|
||||
# Latex rendering disabled:
|
||||
mpl.rcParams['text.usetex'] = False
|
||||
|
||||
# Font style:
|
||||
mpl.rcParams['font.style'] = 'normal'
|
||||
mpl.rcParams['font.family'] = 'serif'
|
||||
mpl.rcParams['mathtext.fontset'] = 'cm'
|
||||
mpl.rcParams['mathtext.default'] = 'regular'
|
||||
# Font sizes:
|
||||
mpl.rcParams['font.size'] = 14
|
||||
mpl.rcParams['figure.titlesize'] = 15
|
||||
mpl.rcParams['axes.labelsize'] = 14
|
||||
mpl.rcParams['axes.titlesize'] = 14
|
||||
mpl.rcParams['xtick.labelsize'] = 13
|
||||
mpl.rcParams['ytick.labelsize'] = 13
|
||||
mpl.rcParams['legend.fontsize'] = 14
|
||||
mpl.rcParams['legend.title_fontsize'] = 14
|
||||
# Font weights:
|
||||
single_weight = ['normal', 'bold'][0]
|
||||
mpl.rcParams['font.weight'] = single_weight
|
||||
mpl.rcParams['axes.labelweight'] = single_weight
|
||||
mpl.rcParams['axes.titleweight'] = single_weight
|
||||
mpl.rcParams['figure.titleweight'] = single_weight
|
||||
|
||||
# Figure parameters:
|
||||
mpl.rcParams['figure.figsize'] = (16/2.54, 9/2.54)
|
||||
mpl.rcParams['figure.autolayout'] = False
|
||||
mpl.rcParams['figure.raise_window'] = True
|
||||
# mpl.rcParams['figure.dpi'] = 100
|
||||
# mpl.rcParams['savefig.dpi'] = 500
|
||||
|
||||
# Axes parameters:
|
||||
mpl.rcParams['axes.spines.top'] = False
|
||||
mpl.rcParams['axes.spines.right'] = False
|
||||
mpl.rcParams['axes.xmargin'] = 0
|
||||
mpl.rcParams['axes.ymargin'] = 0
|
||||
mpl.rcParams['axes.autolimit_mode'] = 'round_numbers'
|
||||
mpl.rcParams['axes.labelpad'] = 3
|
||||
|
||||
# Tick parameters:
|
||||
mpl.rcParams['xtick.major.pad'] = 5
|
||||
mpl.rcParams['ytick.major.pad'] = 5
|
||||
|
||||
# Legend parameters:
|
||||
mpl.rcParams['legend.frameon'] = False
|
||||
mpl.rcParams['legend.scatterpoints'] = 3
|
||||
Loading…
Reference in New Issue
Block a user