diff --git a/open_nixio.py b/open_nixio.py index 76b064e..edee585 100644 --- a/open_nixio.py +++ b/open_nixio.py @@ -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 diff --git a/open_nixio_new.py b/open_nixio_new.py new file mode 100644 index 0000000..36acc73 --- /dev/null +++ b/open_nixio_new.py @@ -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])] diff --git a/raster_plot.py b/raster_plot.py index 9a5b000..d57f402 100644 --- a/raster_plot.py +++ b/raster_plot.py @@ -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() \ No newline at end of file + plt.show() + plt.close \ No newline at end of file