Compare commits
3 Commits
fd62d9d556
...
d9ff5efd5d
Author | SHA1 | Date | |
---|---|---|---|
d9ff5efd5d | |||
2742b8e760 | |||
62edec5a5b |
69
code/plot_functions.py
Normal file
69
code/plot_functions.py
Normal file
@ -0,0 +1,69 @@
|
||||
'''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
|
@ -120,7 +120,7 @@ def power_spectrum(stimulus):
|
||||
Parameters
|
||||
----------
|
||||
stimulus : Stimulus object or rlxnix.base.repro module
|
||||
The stimulus from which the data is needed.
|
||||
The stimulus for which the data is needed.
|
||||
|
||||
Returns
|
||||
-------
|
||||
@ -244,13 +244,13 @@ def spike_times(stim):
|
||||
|
||||
"""
|
||||
# reads out the spike times
|
||||
spike_times, _ = stim.trace_data('Spikes-1')
|
||||
spikes, _ = stim.trace_data('Spikes-1')
|
||||
# reads out the duration
|
||||
stim_dur = stim.duration
|
||||
# get the stimulus interval
|
||||
ti = stim.trace_info("V-1")
|
||||
dt = ti.sampling_interval
|
||||
return spike_times, stim_dur, dt
|
||||
return spikes, stim_dur, dt # se changed spike_times to spikes so its not the same as name of function
|
||||
|
||||
'''TODO: AM-freq plot:
|
||||
meaning of am peak in spectrum? why is it there how does it change with stim intensity?
|
||||
|
Loading…
Reference in New Issue
Block a user