stimuli figures

This commit is contained in:
Lisa 2019-08-20 16:45:13 +02:00
parent b14fc1a294
commit 18c6550f2a
5 changed files with 59 additions and 22 deletions

BIN
contrast_sweep.dat.pdf Normal file

Binary file not shown.

View File

@ -2,6 +2,8 @@ import os
import numpy as np
import matplotlib.pyplot as plt
import nixio as nix
import glob
import os
from IPython import embed
def analyze_sams(filename):
@ -13,37 +15,39 @@ def analyze_sams(filename):
for g in b.groups:
if 'sam' in g.name.lower(): # go through loop, until 'sam' is found
break
rtag_data = g.tags[0]
rtag_data.metadata.pprint(max_depth=-1)
# print(40*'*')
stim_tag = g.multi_tags[0]
stim_pos = stim_tag.positions[:] # beginnings of stimulations
stim_extent = stim_tag.extents[:] # duration of stimulations
for r in rtag_data.references:
print(r.name, r.type)
# embed()
# exit()
voltage_trace = rtag_data.references['V-1']
rtag_data = g.tags[0]
rtag_data.metadata.pprint(max_depth=-1)
# print(40*'*')
stim_tag = g.multi_tags[0]
stim_pos = stim_tag.positions[:] # beginnings of stimulations
stim_extent = stim_tag.extents[:] # duration of stimulations
# embed()
# exit()
for r in rtag_data.references:
print(r.name, r.type)
# embed()
# exit()
voltage_trace = rtag_data.references['V-1']
spike_data = []
spike_data = []
for idx in range(len(stim_pos)):
spike_data.append(stim_tag.retrieve_data(idx, 'Spikes-1')[:])
for idx in range(len(stim_pos)):
spike_data.append(stim_tag.retrieve_data(idx, 'Spikes-1')[:])
# embed()
# exit()
dims = voltage_trace.dimensions[0].axis(len(voltage_trace))
# embed()
# exit()
dims = voltage_trace.dimensions[0].axis(len(voltage_trace))
# # f.close()
# embed()
# # f.close()
# embed()
# exit()
return stim_pos, stim_extent, spike_data, voltage_trace, dims
if __name__ == '__main__':
data_dir = '/home/lisa/data'
data_set = '2019-06-24-aa-invivo-1'
os.chdir(data_dir)
data_set = glob.glob('2019-*')
stim_pos, stim_extent, spike_data, voltage_trace, dims = analyze_sams(os.path.join(data_dir, data_set,
data_set + '.nix'))
print(len(spike_data))
@ -59,5 +63,5 @@ if __name__ == '__main__':
for k in range(len(spike_data[j])):
print('current spike time is: ', spike_data[j][k])
plt.plot(spike_data[j][k], -40, 'o', color='k')
plt.ylim([-100, -30])
# plt.ylim([-45, 0])
plt.show()

BIN
phase_sweep.dat.pdf Normal file

Binary file not shown.

33
stimuli_figures.py Normal file
View File

@ -0,0 +1,33 @@
import glob
import matplotlib.pyplot as plt
filenames = glob.glob('*.dat')
for i in range(len(filenames)):
with open(filenames[i], 'r') as f:
lines = f.readlines()
time = []
amplitude = []
for l in lines:
if len(l.strip()) > 0 and '#' not in l:
l = l.strip().split()
time.append(float(l[0]))
amplitude.append(float(l[1]))
plt.figure(figsize=(20/2.54, 12/2.54), facecolor='white', edgecolor='white')
ax = plt.subplot(111)
ax.spines["top"].set_visible(False)
# ax.spines["bottom"].set_visible(False)
ax.spines["right"].set_visible(False)
# ax.spines["left"].set_visible(False)
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
if filenames[i] == 'zap.dat':
ax.set_xlim([0, 1])
else:
ax.set_xlim([0, .2])
ax.set_title(filenames[i])
ax.set_xlabel('time')
ax.set_ylabel('amplitude')
ax.plot(time, amplitude)
plt.savefig(filenames[i]+'.pdf')
plt.show()

BIN
zap.dat.pdf Normal file

Binary file not shown.