start_end_array_to_bool_array#
- mobgap.utils.array_handling.start_end_array_to_bool_array( ) ndarray[source]#
Convert a start-end list to a bool array.
- Parameters:
- start_end_arrayarray with shape (n,2)
2d-array indicating start and end values e.g. [[10,20],[20,40],[70,80]]
Warning
We assume that the end index is exclusiv! This is in line with the definitions of stride and roi lists in gaitmap.
- pad_to_length: int
Define the length of the resulting array. If None, the array will have the length of the largest index. Otherwise, the final array will either be padded with False or truncated to the specified length.
- Returns:
- array with shape (n,)
boolean array with True/False elements
Examples
>>> import numpy as np >>> example_array = np.array([[3, 5], [7, 8]]) >>> start_end_array_to_bool_array(example_array, pad_to_length=12) array([False, False, False, True, True, True, False, True, True, False, False, False]) >>> example_array = np.array([[3, 5], [7, 8]]) >>> start_end_array_to_bool_array(example_array, pad_to_length=None) array([False, False, False, True, True, True, False, True, True])