def decode_location(likelihood, pos_centers, time_centers):
"""Finds the decoded location based on the centers of the position bins.
Parameters
----------
likelihood : np.array
With shape(n_timebins, n_positionbins)
pos_centers : np.array
time_centers : np.array
Returns
-------
decoded : nept.Position
Estimate of decoded position.
"""
prob_rows = np.sum(np.isnan(likelihood), axis=1) < likelihood.shape[1]
max_decoded_idx = np.nanargmax(likelihood[prob_rows], axis=1)
prob_decoded = pos_centers[max_decoded_idx]
decoded_pos = np.empty((likelihood.shape[0], pos_centers.shape[1])) * np.nan
decoded_pos[prob_rows] = prob_decoded
decoded_pos = np.squeeze(decoded_pos)
return nept.Position(decoded_pos, time_centers)
评论列表
文章目录