Skip to main content

vame.util.data_manipulation

get_pose_data_from_nwb_file

def get_pose_data_from_nwb_file(
nwbfile: NWBFile, path_to_pose_nwb_series_data: str) -> LabelledDict

Get pose data from nwb file using a inside path to the nwb data.

Arguments:

  • nwbfile NWBFile - NWB file object.
  • path_to_pose_nwb_series_data str - Path to the pose data inside the nwb file.

Returns:

  • LabelledDict - Pose data.

consecutive

def consecutive(data: np.ndarray, stepsize: int = 1) -> List[np.ndarray]

Find consecutive sequences in the data array.

Arguments:

  • data np.ndarray - Input array.
  • stepsize int, optional - Step size. Defaults to 1.

Returns:

  • List[np.ndarray] - List of consecutive sequences.

nan_helper

def nan_helper(y: np.ndarray) -> Tuple

Identifies indices of NaN values in an array and provides a function to convert them to non-NaN indices.

Arguments:

  • y np.ndarray - Input array containing NaN values.

Returns:

Tuple[np.ndarray, Union[np.ndarray, None]]: A tuple containing two elements:

  • An array of boolean values indicating the positions of NaN values.
  • A lambda function to convert NaN indices to non-NaN indices.

interpol_all_nans

def interpol_all_nans(arr: np.ndarray) -> np.ndarray

Interpolates all NaN values in the given array.

Arguments:

  • arr np.ndarray - Input array containing NaN values.

Returns:

  • np.ndarray - Array with NaN values replaced by interpolated values.

interpol_first_rows_nans

def interpol_first_rows_nans(arr: np.ndarray) -> np.ndarray

Interpolates NaN values in the given array.

Arguments:

  • arr np.ndarray - Input array with NaN values.

Returns:

  • np.ndarray - Array with interpolated NaN values.

crop_and_flip

def crop_and_flip(
rect: Tuple, src: np.ndarray, points: List[np.ndarray],
ref_index: Tuple[int, int]) -> Tuple[np.ndarray, List[np.ndarray]]

Crop and flip the image based on the given rectangle and points.

Arguments:

  • rect Tuple - Rectangle coordinates (center, size, theta).
  • src np.ndarray - Source image.
  • points List[np.ndarray] - List of points.
  • ref_index Tuple[int, int] - Reference indices for alignment.

Returns:

Tuple[np.ndarray, List[np.ndarray]]: Cropped and flipped image, and shifted points.

background

def background(path_to_file: str,
filename: str,
file_format: str = '.mp4',
num_frames: int = 1000,
save_background: bool = True) -> np.ndarray

Compute background image from fixed camera.

Arguments:

  • path_to_file str - Path to the directory containing the video files.
  • filename str - Name of the video file.
  • file_format str, optional - Format of the video file. Defaults to '.mp4'.
  • num_frames int, optional - Number of frames to use for background computation. Defaults to 1000.

Returns:

  • np.ndarray - Background image.