Apply an average transformation over the next interval.
(self, *, start, stop)
| 880 | self.last_avg_quat = np.nan * np.ones(6) |
| 881 | |
| 882 | def get_avg_op(self, *, start, stop): |
| 883 | """Apply an average transformation over the next interval.""" |
| 884 | n_positions, avg_quat = _trans_lims(self.pos, start, stop)[1:] |
| 885 | if not np.allclose(avg_quat, self.last_avg_quat, atol=1e-7): |
| 886 | self.last_avg_quat = avg_quat |
| 887 | avg_trans = np.vstack( |
| 888 | [ |
| 889 | np.hstack([quat_to_rot(avg_quat[:3]), avg_quat[3:][:, np.newaxis]]), |
| 890 | [[0.0, 0.0, 0.0, 1.0]], |
| 891 | ] |
| 892 | ) |
| 893 | S_decomp_st, _, pS_decomp_st, _, n_use_in_st = self.get_decomp( |
| 894 | avg_trans, t=start / self.sfreq |
| 895 | ) |
| 896 | self.op_in_avg = np.dot( |
| 897 | S_decomp_st[:, :n_use_in_st], pS_decomp_st[:n_use_in_st] |
| 898 | ) |
| 899 | self.op_resid_avg = ( |
| 900 | np.eye(len(self.op_in_avg)) |
| 901 | - self.op_in_avg |
| 902 | - np.dot(S_decomp_st[:, n_use_in_st:], pS_decomp_st[n_use_in_st:]) |
| 903 | ) |
| 904 | return self.op_in_avg, self.op_resid_avg, n_positions |
| 905 | |
| 906 | def feed(self, data, good_mask, st_only): |
| 907 | n_samp = data.shape[1] |
no test coverage detected