(data)
| 98 | |
| 99 | |
| 100 | def quality(data): |
| 101 | # Should only be used on raw, unreferenced signal. |
| 102 | fft, freqs = calc_fft(data) |
| 103 | |
| 104 | quality = np.zeros(fft.shape[1]) |
| 105 | power = np.zeros(fft.shape[1]) |
| 106 | |
| 107 | ix_power = np.logical_and(freqs >= 10, freqs < 40) |
| 108 | |
| 109 | for i in range(0, fft.shape[1]): |
| 110 | chan_fft = fft[:, i].copy() |
| 111 | power[i] = np.sum(chan_fft[ix_power]) |
| 112 | |
| 113 | # Using A1 or A2 as reference for "best contact" |
| 114 | # The quality metric will only be relevant as long as one of A1 or A2 touches |
| 115 | ref = np.max(power[0:2]) |
| 116 | |
| 117 | for i in range(0, fft.shape[1]): |
| 118 | quality[i] = 1 - abs(1 - power[i] / ref) |
| 119 | |
| 120 | if quality[0] > quality[1]: |
| 121 | quality[0] = np.max(quality[1:]) |
| 122 | else: |
| 123 | quality[1] = np.max(quality[(0, 2, 3), None]) |
| 124 | |
| 125 | return np.round(quality * 100, 1) |
| 126 | |
| 127 | |
| 128 | def referencing(data, mode): |
nothing calls this directly
no test coverage detected