MCPcopy Create free account
hub / github.com/vispy/vispy / _calculate_spectrogram

Method _calculate_spectrogram

vispy/visuals/spectrogram.py:147–162  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

145 self._update_image()
146
147 def _calculate_spectrogram(self):
148 if self._x is not None:
149 x = self._x
150 nan_mean = np.nanmean(x)
151 idx = np.isnan(x)
152 x[idx] = nan_mean
153 data = stft(x, self._n_fft, self._step, self._fs, self._window)
154 data = np.abs(data)
155 data = 20 * np.log10(data) if self._color_scale == 'log' else data
156 if self._normalize:
157 for i in range(data.shape[0]):
158 data[i, :] -= np.mean(data[i, :])
159 data[i, :] /= np.std(data[i, :])
160 return data.astype(np.float32) # ImageVisual will warn if 64-bit
161 else:
162 return None
163
164 def _update_image(self):
165 data = self._calculate_spectrogram()

Callers 2

__init__Method · 0.95
_update_imageMethod · 0.95

Calls 1

stftFunction · 0.85

Tested by

no test coverage detected