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])]