still struggling
This commit is contained in:
parent
646eaccb9b
commit
9150263bdd
@ -5,24 +5,25 @@ import nixio as nix
|
|||||||
from IPython import embed
|
from IPython import embed
|
||||||
|
|
||||||
def analyze_sams(filename):
|
def analyze_sams(filename):
|
||||||
print(filename)
|
# print(filename)
|
||||||
f = nix.File.open(filename, nix.FileMode.ReadOnly)
|
f = nix.File.open(filename, nix.FileMode.ReadOnly)
|
||||||
b = f.blocks[0]
|
b = f.blocks[0]
|
||||||
b.metadata.pprint(max_depth=-1) # max_depth=-1: alles rausschreiben
|
b.metadata.pprint(max_depth=-1) # max_depth=-1: alles rausschreiben
|
||||||
print(b.groups)
|
# print(b.groups)
|
||||||
for g in b.groups:
|
for g in b.groups:
|
||||||
if 'sam' in g.name.lower():
|
if 'sam' in g.name.lower(): # go through loop, until 'sam' is found
|
||||||
break
|
break
|
||||||
rtag_data = g.tags[0]
|
rtag_data = g.tags[0]
|
||||||
rtag_data.metadata.pprint(max_depth=-1)
|
rtag_data.metadata.pprint(max_depth=-1)
|
||||||
print(40*'*')
|
# print(40*'*')
|
||||||
stim_tag = g.multi_tags[0]
|
stim_tag = g.multi_tags[0]
|
||||||
stim_pos = stim_tag.positions[:] # beginnings of stimulations
|
stim_pos = stim_tag.positions[:] # beginnings of stimulations
|
||||||
stim_extent = stim_tag.extents[:] # duration of stimulations
|
stim_extent = stim_tag.extents[:] # duration of stimulations
|
||||||
|
|
||||||
for r in rtag_data.references:
|
for r in rtag_data.references:
|
||||||
print(r.name, r.type)
|
print(r.name, r.type)
|
||||||
|
# embed()
|
||||||
|
# exit()
|
||||||
voltage_trace = rtag_data.references['V-1']
|
voltage_trace = rtag_data.references['V-1']
|
||||||
|
|
||||||
spike_data = []
|
spike_data = []
|
||||||
@ -30,25 +31,26 @@ def analyze_sams(filename):
|
|||||||
for idx in range(len(stim_pos)):
|
for idx in range(len(stim_pos)):
|
||||||
spike_data.append(stim_tag.retrieve_data(idx, 'Spikes-1')[:])
|
spike_data.append(stim_tag.retrieve_data(idx, 'Spikes-1')[:])
|
||||||
|
|
||||||
|
# embed()
|
||||||
|
# exit()
|
||||||
|
dims = voltage_trace.dimensions[0].axis(len(voltage_trace))
|
||||||
|
|
||||||
# dims = [[]] * len(spike_data)
|
# # f.close()
|
||||||
# for j in range(len(spike_data)):
|
|
||||||
# dims[j] = spike_data.dimensions[j]
|
|
||||||
# print(spike_data, len(spike_data))
|
|
||||||
# embed()
|
# embed()
|
||||||
# exit()
|
# exit()
|
||||||
f.close()
|
return stim_pos, stim_extent, spike_data, voltage_trace, dims
|
||||||
return stim_pos, stim_extent, spike_data, voltage_trace
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
data_dir = '/home/lisa/data'
|
data_dir = '/home/lisa/data'
|
||||||
data_set = '2019-06-24-aa-invivo-1'
|
data_set = '2019-06-24-aa-invivo-1'
|
||||||
stim_pos, stim_extent, spike_data, voltage_trace = analyze_sams(os.path.join(data_dir, data_set, data_set + '.nix'))
|
stim_pos, stim_extent, spike_data, voltage_trace, dims = analyze_sams(os.path.join(data_dir, data_set,
|
||||||
for i in range(len(stim_pos)):
|
data_set + '.nix'))
|
||||||
plt.scatter(voltage_trace.dimensions[i].axis(1000), spike_data[i][:1000])
|
print(len(spike_data))
|
||||||
plt.show()
|
stims = []
|
||||||
# spikes = stim_tag.retrieve_data(i, 'Spikes-1')[:]
|
# for i in range(len(stim_pos)):
|
||||||
# print(spikes)
|
|
||||||
# embed()
|
# embed()
|
||||||
# exit()
|
# plt.plot(stim_pos)
|
||||||
|
plt.plot(dims[:-1], voltage_trace[:-1])
|
||||||
|
plt.scatter(spike_data[:-1], np.ones(len(spike_data)-1)*np.max(voltage_trace))
|
||||||
|
plt.show()
|
Loading…
Reference in New Issue
Block a user