From 784fcadbe87c137e09df021e30e76b21442d1e86 Mon Sep 17 00:00:00 2001 From: Gregor Lenz Date: Tue, 11 Jul 2023 01:13:50 +0200 Subject: [PATCH] use numpy struct to unstruct function for timesurface generation --- tonic/functional/to_timesurface.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tonic/functional/to_timesurface.py b/tonic/functional/to_timesurface.py index da87ea31..19075fe2 100644 --- a/tonic/functional/to_timesurface.py +++ b/tonic/functional/to_timesurface.py @@ -1,6 +1,7 @@ from typing import Tuple import numpy as np +from numpy.lib import recfunctions as rfn from tonic.slicers import slice_events_by_time @@ -41,7 +42,7 @@ def to_timesurface_numpy( start_t = event_slices[0][0][t_index] for i, slice in enumerate(event_slices): # structured to unstructured in order to access the indices - slice = slice.view((int, len(slice.dtype.names))) + slice = rfn.structured_to_unstructured(slice, dtype=int) indices = slice[:, [p_index, y_index, x_index]].T timestamps = slice[:, t_index] memory[tuple(indices)] = timestamps