diff --git a/contrast_sweep.dat.pdf b/contrast_sweep.dat.pdf new file mode 100644 index 0000000..aec55b5 Binary files /dev/null and b/contrast_sweep.dat.pdf differ diff --git a/ephys_analysis.py b/ephys_analysis.py index d627a3f..13d6aa4 100644 --- a/ephys_analysis.py +++ b/ephys_analysis.py @@ -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() \ No newline at end of file diff --git a/phase_sweep.dat.pdf b/phase_sweep.dat.pdf new file mode 100644 index 0000000..7fbd83c Binary files /dev/null and b/phase_sweep.dat.pdf differ diff --git a/stimuli_figures.py b/stimuli_figures.py new file mode 100644 index 0000000..46d7d18 --- /dev/null +++ b/stimuli_figures.py @@ -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() \ No newline at end of file diff --git a/zap.dat.pdf b/zap.dat.pdf new file mode 100644 index 0000000..1661966 Binary files /dev/null and b/zap.dat.pdf differ