MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / quality

Function quality

python_package/examples/enophone/enotools.py:100–125  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

98
99
100def 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
128def referencing(data, mode):

Callers

nothing calls this directly

Calls 1

calc_fftFunction · 0.85

Tested by

no test coverage detected