示例#1
0
    def update_specgram_settings(self):
        # load specgram settings
        settings = QtCore.QSettings(_organization, _application_name)

        settings.beginGroup("specgram_settings")
        self.specgram_windowlen = int(
            settings.value('window_len',
                           settingsdialog.SPECGRAM_WINDOW_LENGTHS[4]))
        self.specgram_noverlap = int(
            settings.value('noverlap', self.specgram_windowlen / 2))
        self.specgram_window = settings.value('window',
                                              plotting.SPECGRAM_WINDOWS[2])
        settings.endGroup()

        if self.data_loaded:
            # Plot espectrogram
            self.specgram_ax.images = []
            # Save x-axis limits
            limits = self.signal_ax.get_xlim()
            # Draw spectrogram
            plotting.plot_specgram(self.specgram_ax,
                                   self.signal,
                                   self.fs,
                                   nfft=self.specgram_windowlen,
                                   noverlap=self.specgram_noverlap,
                                   window=self.specgram_window)
            # Restore x-axis limits
            self.signal_ax.set_xlim(*limits)
示例#2
0
 def set_record(self, document, step=120.0):
     self.document = document
     self.fs = self.document.record.fs
     self.signal = self.document.record.signal
     self.envelope = env.envelope(self.signal)
     self.cf = self.document.record.cf
     self.time = np.linspace(0,
                             len(self.signal) / self.fs,
                             num=len(self.signal),
                             endpoint=False)
     self.xmax = self.time[-1]
     # Draw minimap
     self.minimap.set_record(self.document.record, step)
     # Plot signal
     self._signal_data = self.signal_ax.plot(self.time,
                                             self.signal,
                                             color='black',
                                             rasterized=True)[0]
     # Plot envelope
     self._envelope_data = self.signal_ax.plot(self.time,
                                               self.envelope,
                                               color='red',
                                               rasterized=True)[0]
     plotting.adjust_axes_height(self.signal_ax)
     # Plot CF
     cf_loaded = (self.cf.size != 0)
     self.set_cf_visible(cf_loaded)
     self.CF_loaded.emit(cf_loaded)
     self._cf_data = self.cf_ax.plot(self.time[:len(self.cf)],
                                     self.cf,
                                     color='black',
                                     rasterized=True)[0]
     plotting.adjust_axes_height(self.signal_ax)
     self.thresholdMarker = ThresholdMarker(self.cf_ax)
     # Plot espectrogram
     plotting.plot_specgram(self.specgram_ax,
                            self.signal,
                            self.fs,
                            nfft=self.specgram_windowlen,
                            noverlap=self.specgram_noverlap,
                            window=self.specgram_window)
     # Set the span selector
     self.selector.fs = self.fs
     self.selector.set_active(False)
     self.selector.set_selection_limits(self.xmin, self.xmax)
     # Set the playback marker
     self.playback_marker = PlayBackMarker(self.fig, self)
     # Set the initial xlimits
     self.set_xlim(0, step)
     self.subplots_adjust()
示例#3
0
 def set_record(self, document, step=120.0):
     self.document = document
     self.fs = self.document.record.fs
     self.signal = self.document.record.signal
     self.envelope = env.envelope(self.signal)
     self.cf = self.document.record.cf
     self.time = np.linspace(0, len(self.signal) / self.fs, num=len(self.signal), endpoint=False)
     self.xmax = self.time[-1]
     # Draw minimap
     self.minimap.set_record(self.document.record, step)
     # Plot signal
     self._signal_data = self.signal_ax.plot(self.time,
                                               self.signal,
                                               color='black',
                                               rasterized=True)[0]
     # Plot envelope
     self._envelope_data = self.signal_ax.plot(self.time,
                                                 self.envelope,
                                                 color='red',
                                                 rasterized=True)[0]
     plotting.adjust_axes_height(self.signal_ax)
     # Plot CF
     cf_loaded = (self.cf.size != 0)
     self.set_cf_visible(cf_loaded)
     self.CF_loaded.emit(cf_loaded)
     self._cf_data = self.cf_ax.plot(self.time[:len(self.cf)],
                                           self.cf,
                                           color='black', rasterized=True)[0]
     plotting.adjust_axes_height(self.signal_ax)
     self.thresholdMarker = ThresholdMarker(self.cf_ax)
     # Plot espectrogram
     plotting.plot_specgram(self.specgram_ax, self.signal, self.fs,
                            nfft=self.specgram_windowlen,
                            noverlap=self.specgram_noverlap,
                            window=self.specgram_window)
     # Set the span selector
     self.selector.fs = self.fs
     self.selector.set_active(False)
     self.selector.set_selection_limits(self.xmin, self.xmax)
     # Set the playback marker
     self.playback_marker = PlayBackMarker(self.fig, self)
     # Set the initial xlimits
     self.set_xlim(0, step)
     self.subplots_adjust()
示例#4
0
    def update_specgram_settings(self):
        # load specgram settings
        settings = QtCore.QSettings(_organization, _application_name)

        settings.beginGroup("specgram_settings")
        self.specgram_windowlen = int(settings.value('window_len', settingsdialog.SPECGRAM_WINDOW_LENGTHS[4]))
        self.specgram_noverlap = int(settings.value('noverlap', self.specgram_windowlen / 2))
        self.specgram_window = settings.value('window', plotting.SPECGRAM_WINDOWS[2])
        settings.endGroup()

        if self.data_loaded:
            # Plot espectrogram
            self.specgram_ax.images = []
            # Save x-axis limits
            limits = self.signal_ax.get_xlim()
            # Draw spectrogram
            plotting.plot_specgram(self.specgram_ax, self.signal, self.fs,
                                   nfft=self.specgram_windowlen,
                                   noverlap=self.specgram_noverlap,
                                   window=self.specgram_window)
            # Restore x-axis limits
            self.signal_ax.set_xlim(*limits)
示例#5
0
 def set_record(self, document, step=120.0):
     self.document = document
     self.fs = self.document.record.fs
     self.signal = self.document.record.signal
     self.envelope = env.envelope(self.signal)
     self.cf = self.document.record.cf
     self.time = np.linspace(0,
                             len(self.signal) / self.fs,
                             num=len(self.signal),
                             endpoint=False)
     self.xmax = self.time[-1]
     # Draw minimap
     self.minimap.minimapSelector.set(
         visible=False)  # Hide minimap selector while loading
     self.minimap.set_record(self.document.record, step)
     # Plot signal
     step_samples = step * self.fs
     self._signal_data = self.signal_ax.plot(self.time[:step_samples],
                                             self.signal[:step_samples],
                                             color='black',
                                             rasterized=True)[0]
     # Plot envelope
     self._envelope_data = self.signal_ax.plot(self.time[:step_samples],
                                               self.envelope[:step_samples],
                                               color='red',
                                               rasterized=True)[0]
     # Adjust y axis for signal plot
     signal_yaxis_max_value = max(np.max(self.signal),
                                  np.max(self.envelope))
     signal_yaxis_min_value = np.min(self.signal)
     plotting.adjust_axes_height(self.signal_ax,
                                 max_value=signal_yaxis_max_value,
                                 min_value=signal_yaxis_min_value)
     # Plot CF
     cf_loaded = (self.cf.size != 0)
     self.set_cf_visible(cf_loaded)
     self.CF_loaded.emit(cf_loaded)
     cf_step_samples = min(step_samples, len(self.cf))
     self._cf_data = self.cf_ax.plot(self.time[:cf_step_samples],
                                     self.cf[:cf_step_samples],
                                     color='black',
                                     rasterized=True)[0]
     # Adjust y axis for CF plot
     if cf_loaded:
         plotting.adjust_axes_height(self.cf_ax,
                                     max_value=np.max(self.cf),
                                     min_value=np.min(self.cf))
     self.thresholdMarker = ThresholdMarker(self.cf_ax)
     # Plot espectrogram
     plotting.plot_specgram(self.specgram_ax,
                            self.signal,
                            self.fs,
                            nfft=self.specgram_windowlen,
                            noverlap=self.specgram_noverlap,
                            window=self.specgram_window)
     # Set the span selector
     self.selector.fs = self.fs
     self.selector.set_active(False)
     self.selector.set_selection_limits(self.xmin, self.xmax)
     # Set the playback marker
     self.playback_marker = PlayBackMarker(self.fig, self)
     # Set the initial xlimits
     self.set_xlim(0, step)
     self.subplots_adjust()
     # Set event markers
     self.eventMarkers = {}
     for event in self.document.record.events:
         self.create_event(event)
     # Now activate selector again on minimap
     self.minimap.minimapSelector.set(visible=True)
     self.minimap.draw()
示例#6
0
 def set_record(self, document, step=120.0):
     self.document = document
     self.fs = self.document.record.fs
     self.signal = self.document.record.signal
     self.envelope = env.envelope(self.signal)
     self.cf = self.document.record.cf
     self.time = np.linspace(0, len(self.signal) / self.fs, num=len(self.signal), endpoint=False)
     self.xmax = self.time[-1]
     # Draw minimap
     self.minimap.minimapSelector.set(visible=False)  # Hide minimap selector while loading
     self.minimap.set_record(self.document.record, step)
     # Plot signal
     step_samples = step * self.fs
     self._signal_data = self.signal_ax.plot(self.time[:step_samples],
                                               self.signal[:step_samples],
                                               color='black',
                                               rasterized=True)[0]
     # Plot envelope
     self._envelope_data = self.signal_ax.plot(self.time[:step_samples],
                                                 self.envelope[:step_samples],
                                                 color='red',
                                                 rasterized=True)[0]
     # Adjust y axis for signal plot
     signal_yaxis_max_value = max(np.max(self.signal), np.max(self.envelope))
     signal_yaxis_min_value = np.min(self.signal)
     plotting.adjust_axes_height(self.signal_ax,
                                 max_value=signal_yaxis_max_value,
                                 min_value=signal_yaxis_min_value)
     # Plot CF
     cf_loaded = (self.cf.size != 0)
     self.set_cf_visible(cf_loaded)
     self.CF_loaded.emit(cf_loaded)
     cf_step_samples = min(step_samples,len(self.cf))
     self._cf_data = self.cf_ax.plot(self.time[:cf_step_samples],
                                     self.cf[:cf_step_samples],
                                     color='black',
                                     rasterized=True)[0]
     # Adjust y axis for CF plot
     if cf_loaded:
         plotting.adjust_axes_height(self.cf_ax,
                                     max_value=np.max(self.cf),
                                     min_value=np.min(self.cf))
     self.thresholdMarker = ThresholdMarker(self.cf_ax)
     # Plot espectrogram
     plotting.plot_specgram(self.specgram_ax, self.signal, self.fs,
                            nfft=self.specgram_windowlen,
                            noverlap=self.specgram_noverlap,
                            window=self.specgram_window)
     # Set the span selector
     self.selector.fs = self.fs
     self.selector.set_active(False)
     self.selector.set_selection_limits(self.xmin, self.xmax)
     # Set the playback marker
     self.playback_marker = PlayBackMarker(self.fig, self)
     # Set the initial xlimits
     self.set_xlim(0, step)
     self.subplots_adjust()
     # Set event markers
     self.eventMarkers = {}
     for event in self.document.record.events:
         self.create_event(event)
     # Now activate selector again on minimap
     self.minimap.minimapSelector.set(visible=True)
     self.minimap.draw()