Skip to content

Commit

Permalink
use numpy struct to unstruct function for timesurface generation
Browse files Browse the repository at this point in the history
  • Loading branch information
biphasic committed Jul 10, 2023
1 parent 142d3b4 commit 784fcad
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tonic/functional/to_timesurface.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 784fcad

Please sign in to comment.