def __init__(self, canvas, analog_data, spike_data): super().__init__() self.canvas = canvas self.analog_data = analog_data self.spike_data = mea.MEASpikeDict(spike_data) prespikes = spike_data.copy() prespikes.electrode = prespikes.electrode.str.split('.').str.get(0) self.condensed_spike_data = mea.MEASpikeDict(prespikes) self._t0 = 0 self._dt = 20 self.mouse_t = 0 self.electrode = '' self._time_window = 20 # in milliseconds self._scale = (5, 150) self.extra_text = '' self._selected_electrodes = [] self.program = gloo.Program(self.VERTEX_SHADER, self.FRAGMENT_SHADER) self.program['u_scale'] = self._scale self.program['a_position'] = [[0, 0, 0, 0]] self.program['a_color'] = [[0, 0, 0, 0]] self.program['u_width'] = 100 self.program['u_rows'] = self.canvas.layout.rows self.program['u_columns'] = self.canvas.layout.columns self.grid = LineCollection() self.create_grid() self.sample_rate = 1.0 / (self.analog_data.index[1] - self.analog_data.index[0]) self.measuring = False self.measure_start = (0, 0) self.measure_line = visuals.LineVisual(np.array(((0, 0), (0, 0))), Theme.yellow, method='agg') self.configure_transforms()
def __init__(self, canvas, spike_data): self.canvas = canvas # Load data self.spike_data = mea.MEASpikeDict(spike_data) self.spike_data.sort() self.program = gloo.Program(RasterPlotVisualization.VERTEX_SHADER, RasterPlotVisualization.FRAGMENT_SHADER) self._t0 = 0 self._dt = self.spike_data.max_time() self.electrode = '' self.program['u_pan'] = self._t0 self.program['u_y_scale'] = self._dt / 2 self.program['u_top_margin'] = 20.0 * 2.0 / canvas.size[1] self._row_count = 120 self._display_selected = False self._unselected_row_count = 120 self.selected_electrodes = [] self.row_count = len(self.spike_data) self.resample() self.margin = {} self.margin['top'] = 20 self.velocity = 0 self.tick_separtion = 50 self.tick_labels = [ visuals.TextVisual('', font_size=10, color='w') for x in range(18) ] self.tick_marks = LineCollection() self.mouse_t = 0 self.extra_text = ''
def __init__(self, canvas, spike_data): super().__init__() self.canvas = canvas if 'conductance' not in spike_data.columns: spike_data['conductance'] = False self.spike_data = mea.MEASpikeDict(spike_data) self.spike_data.sort() self.program = gloo.Program(RasterPlotVisualization.VERTEX_SHADER, RasterPlotVisualization.FRAGMENT_SHADER) self._t0 = 0 self._dt = self.spike_data.max_time() self.electrode = '' self.program['u_pan'] = self._t0 self.program['u_y_scale'] = self._dt / 2 self.program['u_top_margin'] = 20.0 * 2.0 / canvas.size[1] self._row_count = 120 self._display_selected = False self.selected_electrodes = [] self.row_count = len(self.spike_data) self._unselected_row_count = self.row_count self._dim_conductance = False self.resample() self.margin = {'top': 20} self.velocity = 0 self.tick_separtion = 50 self.tick_labels = [visuals.TextVisual('', font_size=10, color='w') for x in range(14)] self.tick_marks = LineCollection() self.mouse_t = 0 self.extra_text = '' self.measuring = False self.measure_start = (0, 0) self.measure_line = visuals.LineVisual(np.array(((0, 0), (100, 100))), Theme.yellow)
def __init__(self, canvas, analog_data, spike_data): super().__init__() self.canvas = canvas self.analog_data = analog_data self.raw_data = spike_data self.spike_data = mea.MEASpikeDict(spike_data) self.show_spikes = False self._dim_conductance = False self._t0 = 0 self._dt = 20 self._y_scale = 150 self._pan = 0 self._scale = 1 self.mouse_t = 0 self.electrode = '' self.selected_electrodes = ['h11'] # l5, m5 self.strip_program = gloo.Program(self.STRIP_VERTEX_SHADER, self.STRIP_FRAGMENT_SHADER) self.strip_program['u_color'] = Theme.blue self.point_program = gloo.Program(self.POINT_VERTEX_SHADER, self.POINT_FRAGMENT_SHADER) self.pan = self._t0 self.scale = (2.0 / self._dt, 1 / self._y_scale) self.velocity = 0 self.measuring = False self.measure_start = (0, 0) self.measure_line = visuals.LineVisual(np.array(((0, 0), (100, 100))), Theme.yellow) self.scale_bar = visuals.LineVisual(np.array(((10, 10), (200, 10))), Theme.black, width=10, method='agg') self.scale_label = visuals.TextVisual('', font_size=8) self.configure_transforms() self.extra_text = '' self._filtered = False self._filter_cutoff = [200, 4000] self.all_spike_colors = [] self.propagation_spike_colors = [] self.resample() self.background_color = Theme.background
def __init__(self, canvas, analog_data, spike_data): self.canvas = canvas self.analog_data = analog_data self.spike_data = mea.MEASpikeDict(spike_data) self.show_spikes = False self._t0 = 0 self._dt = 20 self._y_scale = 150 self._pan = 0 self._scale = 1 self.mouse_t = 0 self.electrode = '' self.electrodes = ['h11'] # l5, m5 self.strip_program = gloo.Program(self.STRIP_VERTEX_SHADER, self.STRIP_FRAGMENT_SHADER) self.strip_program['u_color'] = Theme.blue self.point_program = gloo.Program(self.POINT_VERTEX_SHADER, self.POINT_FRAGMENT_SHADER) self.point_program['u_color'] = Theme.yellow self.pan = self._t0 self.scale = (2.0 / self._dt, 1 / self._y_scale) self.velocity = 0 self.measuring = False self.measure_start = (0, 0) self.measure_line = visuals.LineVisual(np.array(((0, 0), (100, 100))), Theme.grid_line) self.extra_text = '' self._filtered = False self._filter_cutoff = [200, 4000] self.resample() self.background_color = Theme.background
def tag_cond(args): if len(args.FILES) < 2: print('Must specify src and dest files.') return src = args.FILES[-1] if len(args.FILES) == 2: files = [ f for f in glob.glob(args.FILES[0]) if f.endswith('.csv') and os.path.exists(f) ] else: files = [f for f in args.FILES[:-1] if f.endswith('.csv')] seqs = [] with open(src, 'r') as f: for line in f: seqs.append([s.lower().strip() for s in line.split(',')]) import pymea as mea for i, f in enumerate(files): conductance_locs = [] df = pd.read_csv(f) spikes = mea.MEASpikeDict(df) for seq in seqs: e_keep = seq[0] sub_df = pd.concat([spikes[tag] for tag in seq]) cofiring = pd.concat(mea.cofiring_events(sub_df, 0.0007)) conductance_locs.extend( list(cofiring[cofiring.electrode != e_keep].index.values)) df['conductance'] = False df.ix[conductance_locs, 'conductance'] = True df.to_csv(f, index=False) print('%d of %d exported.' % (i + 1, len(files)))