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 intervals_dict = defaultdict(list) for tag in tags: if tag.name.startswith('Baseline'): continue curr_comb = tag.metadata["RePro-Info"]["settings"]["object"] repro_pos, = tag.position repro_ext, = tag.extent idx_qry = np.logical_and(repro_pos < comb_pos, comb_pos < (repro_pos + repro_ext)) tag_idx = np.flatnonzero(idx_qry) tag_pos = comb_pos[idx_qry] for idx, position in zip(tag_idx, tag_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])] intervals_dict.update({(tag.name, curr_speed, curr_dir, curr_pos, curr_comb): curr_spikes}) embed() quit()