first file
This commit is contained in:
parent
18cfff0292
commit
62740c692a
52
ephys_analysis.py
Normal file
52
ephys_analysis.py
Normal file
@ -0,0 +1,52 @@
|
||||
import os
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import nixio as nix
|
||||
from IPython import embed
|
||||
|
||||
def analyze_sams(filename):
|
||||
print(filename)
|
||||
f = nix.File.open(filename, nix.FileMode.ReadOnly)
|
||||
b = f.blocks[0]
|
||||
b.metadata.pprint(max_depth=-1) # max_depth=-1: alles rausschreiben
|
||||
print(b.groups)
|
||||
for g in b.groups:
|
||||
if 'sam' in g.name.lower():
|
||||
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[:]
|
||||
stim_extent = stim_tag.extents[:]
|
||||
|
||||
for r in rtag_data.references:
|
||||
print(r.name, r.type)
|
||||
|
||||
voltage_trace = rtag_data.references['V-1']
|
||||
|
||||
spike_data = []
|
||||
|
||||
for i in range(len(stim_pos)):
|
||||
spike_data.append(stim_tag.retrieve_data(i, 'Spikes-1')[:])
|
||||
|
||||
|
||||
dims = [[]] * len(voltage_trace)
|
||||
for j in range(len(spike_data)):
|
||||
dims[j] = voltage_trace.dimensions[j]
|
||||
print(spike_data, len(spike_data))
|
||||
f.close()
|
||||
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'
|
||||
stim_pos, stim_extent, spike_data, voltage_trace, dims = analyze_sams(os.path.join(data_dir, data_set, data_set + '.nix'))
|
||||
for i in range(len(stim_pos)):
|
||||
plt.eventplot(dims[i], spike_data[i])
|
||||
plt.show()
|
||||
# spikes = stim_tag.retrieve_data(i, 'Spikes-1')[:]
|
||||
# print(spikes)
|
||||
# embed()
|
||||
# exit()
|
Loading…
Reference in New Issue
Block a user