contraction_net.annotation

Classes

TimeSeriesAnnotator

Class to annotate contraction intervals in multiple time-series files and save the results.

Functions

split_trace(filepath, output_dir[, chunk_size, p])

Split a time-series trace into smaller chunks and save them to separate files.

Module Contents

class contraction_net.annotation.TimeSeriesAnnotator(file_list, output_dir, figsize=(11, 3.5))[source]

Class to annotate contraction intervals in multiple time-series files and save the results.

This class allows users to interactively annotate the start and end of contractions in time-series data by clicking on the plot. The user can press the left mouse button at the start of a contraction interval and release at the end of the contraction interval. The results are saved to a specified output directory.

Parameters:
  • file_list (list of str) – List of file paths to the time-series data files to be annotated.

  • output_dir (str) – Directory where the output files with annotated contraction intervals will be saved.

  • figsize (tuple, optional) – Figure size in inches.

load_next_file()[source]

Load the next time-series file for annotation.

press_callback(event)[source]

Record the x-coordinate (time) where the mouse button is pressed.

release_callback(event)[source]

Record the x-coordinate (time) where the mouse button is released.

save_and_load_next(event)[source]

Save the current annotations and load the next time-series file.

reset_annotations(event)[source]

Reset the current annotations for the current time-series file.

Notes

In an interactive Jupyter notebook, add the following before running the TimeSeriesAnnotator:

` matplotlib.use('nbagg') %matplotlib notebook `

file_list
output_dir
current_file_index = 0
start_contraction = []
end_contraction = []
save_button
reset_button
load_next_file()[source]

Load the next time-series file for annotation.

press_callback(event)[source]

Record the x-coordinate (time) where the mouse button is pressed.

release_callback(event)[source]

Record the x-coordinate (time) where the mouse button is released.

save_and_load_next(event)[source]

Save the current annotations and load the next time-series file.

reset_annotations(event)[source]

Reset the current annotations for the current time-series file.

contraction_net.annotation.split_trace(filepath, output_dir, chunk_size=512, p=1)[source]

Split a time-series trace into smaller chunks and save them to separate files.

Parameters:
  • filepath (str) – Path to the input time-series data file.

  • output_dir (str) – Directory where the output chunk files will be saved.

  • chunk_size (int, optional) – The size of each chunk, by default 512.

  • p (float, optional) – Probability of saving each chunk, by default 1 (save all chunks).