changed for multiple repros

This commit is contained in:
Carolin Sachgau 2018-11-20 16:35:31 +01:00
parent 01320b8458
commit 1ab2daa258
3 changed files with 46 additions and 5 deletions

View File

@ -22,7 +22,6 @@ def open_nixio(nix_file, avg_opt):
feature_dict = {}
for feat in mt.features:
feature_dict.update({feat.data.name[16:]: mt.features[feat.data.name].data[:]})
# Spike data in intervals of comb position + speed
intervals_dict = defaultdict(list)
for idx, position in enumerate(comb_pos):
@ -40,5 +39,6 @@ def open_nixio(nix_file, avg_opt):
# Spike data at baseline
# comb_baseline = spikes[(spikes < comb_pos[0])]
embed()
quit()
return curr_comb, intervals_dict

40
open_nixio_new.py Normal file
View File

@ -0,0 +1,40 @@
import nixio as nix
from IPython import embed
from collections import defaultdict
import numpy as np
nix_file = '/home/sachgau/Documents/combproject/comb_data/2018-11-16-ag/2018-11-16-ag.nix'
f = nix.File.open(nix_file, nix.FileMode.ReadOnly)
b = f.blocks[0] # first block
mt = b.multi_tags['moving object-1']
comb_pos = mt.positions[:]
comb_ext = np.array(mt.extents[:])
spikes = b.data_arrays["Spikes-1"][:]
feature_dict = {}
for feat in mt.features:
feature_dict.update({feat.data.name[16:]: mt.features[feat.data.name].data[:]})
tags = b.tags
for tag in tags:
if tag.name.startswith('Baseline'):
continue
repro_pos, = tag.position
repro_ext, = tag.extent
tag_idx = np.where(np.logical_and(repro_pos < comb_pos, comb_pos < (repro_pos+repro_ext)))
embed()
quit()
tag_idx_pos = comb_pos[np.logical_and(repro_pos < comb_pos, comb_pos < (repro_pos + repro_ext))]
intervals_dict = defaultdict(list)
for idx, position in enumerate(comb_pos):
if idx == (len(comb_pos)-1):
break
curr_speed = feature_dict['speed'][idx]
curr_pos = comb_pos[idx]
curr_dir = feature_dict['direction'][idx]
curr_spikes = spikes[(spikes < comb_pos[idx + 1]) & (spikes > comb_pos[idx])]

View File

@ -31,10 +31,10 @@ cell_name = sys.argv[1].split('/')[-2]
curr_comb, intervals_dict = open_nixio(sys.argv[1], sys.argv[2])
spike_repeats = []
for (speed, direct, comb) in intervals_dict:
s_trials = intervals_dict[(speed, direct, comb)]
spike_repeats = []
for trial in intervals_dict[(speed, direct, comb)]:
spike_train = trial[1]
spike_train = spike_train - spike_train[0] # changing spike train to start at 0 (subtracting baseline)
@ -45,4 +45,5 @@ for (speed, direct, comb) in intervals_dict:
ax.set_title('Raster Plot of ' + str((speed, direct)) + ' comb = ' + str(comb) + '\n')
ax.set_xlabel('Time (s)')
ax.set_ylabel('Trials')
plt.show()
plt.show()
plt.close