(self)
| 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() |
no test coverage detected