Get all trans and limits we need.
(pos, start, stop)
| 939 | |
| 940 | |
| 941 | def _trans_lims(pos, start, stop): |
| 942 | """Get all trans and limits we need.""" |
| 943 | pos_idx = np.arange(*np.searchsorted(pos[1], [start, stop])) |
| 944 | used = np.zeros(stop - start, bool) |
| 945 | quats = np.empty((9, stop - start)) |
| 946 | n_positions = len(pos_idx) |
| 947 | for ti in range(-1, len(pos_idx)): |
| 948 | # first iteration for this block of data |
| 949 | if ti < 0: |
| 950 | rel_start = 0 |
| 951 | rel_stop = pos[1][pos_idx[0]] if len(pos_idx) > 0 else stop |
| 952 | rel_stop = rel_stop - start |
| 953 | if rel_start == rel_stop: |
| 954 | continue # our first pos occurs on first time sample |
| 955 | this_quat = pos[2][max(pos_idx[0] - 1 if len(pos_idx) else 0, 0)] |
| 956 | n_positions += 1 |
| 957 | else: |
| 958 | rel_start = pos[1][pos_idx[ti]] - start |
| 959 | if ti == len(pos_idx) - 1: |
| 960 | rel_stop = stop - start |
| 961 | else: |
| 962 | rel_stop = pos[1][pos_idx[ti + 1]] - start |
| 963 | this_quat = pos[2][pos_idx[ti]] |
| 964 | quats[:, rel_start:rel_stop] = this_quat[:, np.newaxis] |
| 965 | assert 0 <= rel_start |
| 966 | assert rel_start < rel_stop |
| 967 | assert rel_stop <= stop - start |
| 968 | assert not used[rel_start:rel_stop].any() |
| 969 | used[rel_start:rel_stop] = True |
| 970 | assert used.all() |
| 971 | quats = np.array(quats) |
| 972 | avg_quat = _average_quats(quats[:3].T) |
| 973 | avg_t = np.mean(quats[3:6], axis=1) |
| 974 | avg_quat = np.concatenate([avg_quat, avg_t]) |
| 975 | return quats, n_positions, avg_quat |
| 976 | |
| 977 | |
| 978 | def _get_coil_scale(meg_picks, mag_picks, grad_picks, mag_scale, info): |
no test coverage detected