Skip to content

Add feature to find indices in a time axis #452

Description

@psomhorst

We decided to store e.g. Breaths using the time, not an index. This is useful when e.g. using sources with different time axes, or when applying interpolation. Storing indices would be very error-prone.

However, this results in the need to find the index of a timepoint in a time array often. This can be slow, and verbose. Therefore, we should introduce a feature that does this quickly and easily. An example could be:

@np.vectorize
def get_breath_times(b):
    return (
        (b.start_time, b.middle_time) if isinstance(b, Breath) else (None, None)
    )

breath_times = np.asarray(get_breath_times(pixel_breaths.values)).astype(float)
breath_indices = np.searchsorted(filtered_regional.time, breath_times).astype(
    float
)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions