69 lines
1.9 KiB
Python
69 lines
1.9 KiB
Python
'''This script contains all functions for various plots that could be relevant
|
|
for the presentation or protocol of the Grewe GP 2024'''
|
|
|
|
import os
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
import rlxnix as rlx
|
|
from useful_functions import power_spectrum
|
|
|
|
'''IMPORT DATA'''
|
|
datafolder = '../data' #./ wo ich gerade bin; ../ eine ebene höher; ../../ zwei ebenen höher
|
|
example_file = os.path.join('..', 'data', '2024-10-16-ac-invivo-1.nix')
|
|
|
|
'''EXTRACT DATA'''
|
|
dataset = rlx.Dataset(example_file)
|
|
|
|
# get sams
|
|
sams = dataset.repro_runs('SAM')
|
|
sam = sams[2]
|
|
|
|
# get stims
|
|
stimulus = sam.stimuli[-1]
|
|
stim_count = sam.stimulus_count
|
|
|
|
'''PLOTS'''
|
|
# create colormap
|
|
colors = plt.cm.prism(np.linspace(0, 1, stim_count))
|
|
|
|
# plot timeline of whole rec
|
|
dataset.plot_timeline()
|
|
|
|
# plot voltage over time for whole trace
|
|
def plot_vt_spikes(t, v, spike_t):
|
|
fig = plt.figure(figsize=(5, 2.5))
|
|
# alternative to ax = axs[0]
|
|
ax = fig.add_subplot()
|
|
# plot vt diagram
|
|
ax.plot(t[t<0.1], v[t<0.1])
|
|
# plot spikes into vt diagram, at max V
|
|
ax.scatter(spike_t[spike_t<0.1], np.ones_like(spike_t[spike_t<0.1]) * np.max(v))
|
|
plt.show()
|
|
|
|
# plot scatter plot for one sam with all 3 stims
|
|
def scatter_plot(colormap, stimuli_list, stimulus_count):
|
|
fig = plt.figure()
|
|
ax = fig.add_subplot()
|
|
|
|
ax.eventplot(stimuli_list, colors=colormap)
|
|
ax.set_xlabel('Spike Times [ms]')
|
|
ax.set_ylabel('Loop #')
|
|
ax.set_yticks(range(stimulus_count))
|
|
ax.set_title('Spikes of SAM 3')
|
|
plt.show()
|
|
|
|
# calculate power spectrum
|
|
freq, power = power_spectrum(stimulus)
|
|
|
|
# plot power spectrum
|
|
def power_spectrum_plot(f, p):
|
|
# plot power spectrum
|
|
fig = plt.figure()
|
|
ax = fig.add_subplot()
|
|
ax.plot(freq, power)
|
|
ax.set_xlabel('Frequency [Hz]')
|
|
ax.set_ylabel('Power [1/Hz]')
|
|
ax.set_xlim(0, 1000)
|
|
plt.show()
|
|
|
|
####### ADD DIANAS POWER SPECTRUM PLOT |