def _plot_default(self): # Create the plot index_mapper = LinearMapper(range=DataRange1D(low=0, high=0.0012)) value_mapper = LinearMapper(range=DataRange1D(low=-0.00025, high=0.00025)) plot = SnippetChannelPlot(history=20, source=self.channels[self.channel-1], value_mapper=value_mapper, index_mapper=index_mapper, bgcolor='white', padding=[60, 5, 5, 20]) add_default_grids(plot, major_index=1e-3, minor_index=1e-4, major_value=1e-3, minor_value=1e-4) # Add the axes labels axis = PlotAxis(orientation='left', component=plot, tick_label_formatter=scale_formatter, title='Signal (mV)') plot.overlays.append(axis) axis = PlotAxis(orientation='bottom', component=plot, tick_label_formatter=scale_formatter) plot.overlays.append(axis) # Add the tools zoom = ZoomTool(plot, drag_button=None, axis="value") plot.overlays.append(zoom) self.tool = WindowTool(component=plot) plot.overlays.append(self.tool) # Whenever we draw a window, the settings should immediately be updated! self.sync_trait('windows', self.tool) return plot
def _add_default_axes_and_grids(self, plot, value): value_trait = self.data.trait(value) axis = PlotAxis(plot, orientation='left', title=value_trait.label) plot.overlays.append(axis) index_title = self.paradigm.get_parameter_label(self.data.parameters[-1]) axis = PlotAxis(plot, orientation='bottom', title=index_title) plot.overlays.append(axis) minor, major = value_trait.suggested_grid add_default_grids(plot, minor_value=minor, major_value=major)
def _update_experiment_plot(self): index_range = ChannelDataRange(trig_delay=0) index_range.sources = [self.data.contact_digital] index_mapper = LinearMapper(range=index_range) container = OverlayPlotContainer(padding=[20, 20, 50, 5]) self._add_experiment_plots(index_mapper, container) # Add axes and grids to the first plot plot = container.components[0] add_default_grids(plot, minor_index=0.25, major_index=1) add_time_axis(plot, orientation='top') self.experiment_plot = container
def _generate_experiment_plot(self): index_range = ChannelDataRange(trig_delay=0) index_range.sources = [self.data.spout_TTL] index_mapper = LinearMapper(range=index_range) self.index_range = index_range container = OverlayPlotContainer(padding=[20, 20, 50, 5]) self._add_experiment_plots(index_mapper, container, 0.5) plot = container.components[0] add_default_grids(plot, major_index=1, minor_index=0.25) add_time_axis(plot, orientation='top') self.experiment_plot = container
def _data_changed(self): index_range = ChannelDataRange(trig_delay=0) index_range.add(self.data.spout_TTL) index_mapper = LinearMapper(range=index_range) value_range = DataRange1D(low_setting=-0, high_setting=1) value_mapper = LinearMapper(range=value_range) container = OverlayPlotContainer(bgcolor='white', fill_padding=True, padding=50, spacing=50) # SIGNAL plot = TTLPlot(source=self.data.signal_TTL, index_mapper=index_mapper, value_mapper=value_mapper, fill_color=(0, 1, 0, 0.5), rect_height=0.2, rect_center=0.9) container.add(plot) # PUMP plot = TTLPlot(source=self.data.pump_TTL, index_mapper=index_mapper, value_mapper=value_mapper, fill_color=(0, 0, 1, 0.5), rect_height=0.2, rect_center=0.7) container.add(plot) # SPOUT plot = TTLPlot(source=self.data.spout_TTL, reference=0, index_mapper=index_mapper, value_mapper=value_mapper, fill_color=(1, 1, 1, 0.5), rect_height=0.2, rect_center=0.5) container.add(plot) # OVERRIDE plot = TTLPlot(source=self.data.override_TTL, reference=0, index_mapper=index_mapper, value_mapper=value_mapper, fill_color=(1, 0, 0, 0.5), rect_height=0.2, rect_center=0.3) container.add(plot) # FREE RUN plot = TTLPlot(source=self.data.free_run_TTL, reference=0, index_mapper=index_mapper, value_mapper=value_mapper, fill_color=(1, 0, 0, 0.5), rect_height=0.2, rect_center=0.1) container.add(plot) # Add the axes and grids grid = PlotGrid(mapper=plot.index_mapper, component=plot, orientation='vertical', line_color='lightgray', line_style='dot', grid_interval=0.25) plot.underlays.append(grid) grid = PlotGrid(mapper=plot.index_mapper, component=plot, orientation='vertical', line_color='lightgray', line_style='solid', grid_interval=1) plot.underlays.append(grid) add_time_axis(plot) add_default_grids(plot, major_index=1, minor_index=0.25) # set up microphone plot value_range = DataRange1D(low_setting=0, high_setting=80) value_mapper = LinearMapper(range=value_range) plot = RMSChannelPlot(source=self.data.microphone, index_mapper=index_mapper, value_mapper=value_mapper, line_color=(0, 0, 0, 0.25)) self.microphone_plot = plot container.add(plot) self.contact_plot = container
def _generate_physiology_plot(self): # NOTE THAT ORDER IS IMPORTANT. First plots added are at bottom of # z-stack, so the physiology must be last so it appears on top. # Padding is in left, right, top, bottom order container = OverlayPlotContainer(padding=[50, 20, 20, 50]) # Create the index range shared by all the plot components self.physiology_index_range = ChannelDataRange(span=5, trig_delay=1, timeseries=self.data.ts, sources=[self.data.processed]) # Create the TTL plot index_mapper = LinearMapper(range=self.physiology_index_range) value_mapper = LinearMapper(range=DataRange1D(low=0, high=1)) plot = TTLPlot(source=self.data.sweep, index_mapper=index_mapper, value_mapper=value_mapper, reference=0, fill_color=(0.25, 0.41, 0.88, 0.1), line_color='transparent', rect_center=0.5, rect_height=1.0) container.add(plot) # Create the epoch plot plot = EpochPlot(source=self.data.epoch, marker='diamond', marker_color=(.5, .5, .5, 1.0), marker_height=0.9, marker_size=10, index_mapper=index_mapper, value_mapper=value_mapper) container.add(plot) add_default_grids(plot, major_index=1, minor_index=0.25) # Hack alert. Can we separate this out into a separate function? if self.parent is not None: try: self.parent._add_experiment_plots(index_mapper, container) except AttributeError: pass # Create the neural plots value_mapper = LinearMapper(range=self.physiology_value_range) plot = ExtremesMultiChannelPlot(source=self.data.processed, index_mapper=index_mapper, value_mapper=value_mapper) self.settings.sync_trait('visible_channels', plot, 'channel_visible', mutual=False) overlay = ChannelNumberOverlay(plot=plot) self.sync_trait('show_channel_number', overlay, 'visible') plot.overlays.append(overlay) container.add(plot) add_default_grids(plot, major_index=1, minor_index=0.25, major_value=1e-3, minor_value=1e-4) axis = PlotAxis(component=plot, orientation='left', tick_label_formatter=scale_formatter, title='Volts (mV)') plot.underlays.append(axis) add_time_axis(plot, 'bottom', fraction=True) self.physiology_plot = plot tool = MultiChannelRangeTool(component=plot) plot.tools.append(tool) overlay = SpikeOverlay(plot=plot, spikes=self.data.spikes) self.sync_trait('visualize_spikes', overlay, 'visible') plot.overlays.append(overlay) self.spike_overlay = overlay # Create the threshold overlay plot overlay = ThresholdOverlay(plot=plot, visible=False) self.sync_trait('visualize_thresholds', overlay, 'visible') self.settings.sync_trait('spike_thresholds', overlay, 'sort_thresholds', mutual=False) self.settings.sync_trait('spike_signs', overlay, 'sort_signs', mutual=False) self.sync_trait('channel_sort', overlay, 'sort_channels', mutual=False) plot.overlays.append(overlay) self.threshold_overlay = overlay self.physiology_container = container