|
7 | 7 | import ibllib.atlas as atlas |
8 | 8 | from ibllib.ephys.neuropixel import SITES_COORDINATES |
9 | 9 | from ibllib.pipes.ephys_alignment import EphysAlignment |
10 | | -from ibllib.plots import wiggle |
| 10 | +from ibllib.plots import wiggle, color_cycle |
11 | 11 |
|
12 | 12 | brain_atlas = atlas.AllenAtlas() |
13 | 13 | # Instantiate brain atlas and one |
14 | 14 |
|
15 | 15 |
|
16 | | -def show_psd(data, fs): |
| 16 | +def show_psd(data, fs, ax=None): |
17 | 17 | psd = np.zeros((data.shape[0], 129)) |
18 | 18 | for tr in np.arange(data.shape[0]): |
19 | 19 | f, psd[tr, :] = scipy.signal.welch(data[tr, :], fs=fs) |
20 | 20 |
|
21 | | - plt.figure() |
22 | | - plt.plot(f, 10 * np.log10(psd.T), color='gray', alpha=0.1) |
23 | | - plt.plot(f, 10 * np.log10(np.mean(psd, axis=0).T), color='red') |
24 | | - plt.xlabel('Frequency (Hz)') |
25 | | - plt.ylabel('PSD (dB rel V/Hz)') |
26 | | - plt.gca() |
27 | | - plt.gca().set_ylim(-150, -110) |
28 | | - plt.gca().set_xlim(0, fs / 2) |
| 21 | + if ax is None: |
| 22 | + fig, ax = plt.subplots() |
| 23 | + ax.plot(f, 10 * np.log10(psd.T), color='gray', alpha=0.1) |
| 24 | + ax.plot(f, 10 * np.log10(np.mean(psd, axis=0).T), color='red') |
| 25 | + ax.set_xlabel('Frequency (Hz)') |
| 26 | + ax.set_ylabel('PSD (dB rel V/Hz)') |
| 27 | + ax.set_ylim(-150, -110) |
| 28 | + ax.set_xlim(0, fs / 2) |
29 | 29 | plt.show() |
30 | 30 |
|
31 | 31 |
|
@@ -146,7 +146,11 @@ def overlay_spikes(self, spikes, clusters, channels): |
146 | 146 | sc = self.layers['default']['layer'] |
147 | 147 | sc.setSize(8) |
148 | 148 | sc.setSymbol('x') |
149 | | - sc.setPen(pg.mkPen((0, 255, 0, 155), width=1)) |
| 149 | + # sc.setPen(pg.mkPen((0, 255, 0, 155), width=1)) |
| 150 | + rgbs = [list((rgb * 255).astype(np.uint8)) for rgb in color_cycle(spikes['clusters'][ifirst:ilast])] |
| 151 | + sc.setBrush([pg.mkBrush(rgb) for rgb in rgbs]) |
| 152 | + sc.setPen([pg.mkPen(rgb) for rgb in rgbs]) |
| 153 | + return sc |
150 | 154 |
|
151 | 155 | # sc.setData(x=xspi, y=tspi, brush=pg.mkBrush((255, 0, 0))) |
152 | 156 | def callback(sc, points, evt): |
|
0 commit comments