SarcGraphTools Utility Class
- class sarcgraph.sg_tools.SarcGraphTools(input_dir='test-run', quality=300, include_eps=False, save_results=True)[source]
Bases:
objectTools for post processing analysis on detected sarcomeres.
- Parameters:
input_dir (str) –
- Should be the same as the output_dir in sarcgraph.sg.Sarcgraph(),
by default “test-run”
quality (int) – dpi of saved figures in png format, by default 300
include_eps (bool) – save eps format of figures, by default False
save_results (bool) – save the results of post processing analysis, by default True
Submodules
- class sarcgraph.sg_tools.SarcGraphTools.TimeSeries(sg_tools)
Bases:
objectProvides the tools to apply Gaussian Process Regression (GPR) on timeseries of detected sarcomere
- sarcomeres_gpr()
Applies Gaussian Process Regression (GPR) on the output of the sarcomere detection algorithm to reduce the noise and fill in missing data.
- Return type:
pd.DataFrame
Notes
For more information on GPR check https://scikit-learn.org/stable/modules/gaussian_process.html
- class sarcgraph.sg_tools.SarcGraphTools.Visualization(sg_tools)
Bases:
objectProvides tools to visualize the results of post-processing analysis on detected sarcomeres.
- F()
Plot recovered deformation gradient.
- F_eigenval_animation(no_anim=False)
Visualize the eigenvalues of F over all frames
- J()
Plot recovered deformation jacobian.
- OOP()
Plot recovered Orientational Order Parameter.
- contraction()
Visualize all detected sarcomeres in every frame according to normalized fraction length and save as a gif file.
- dendrogram(dist_func='dtw')
Cluster timeseries and plot a dendrogram that shows clusters.
- Parameters:
dist_func (str, optional, by default "dtw") – Choose between “euclidean” or “dtw”
- normalized_sarcs_length()
Plot normalized length of all detected sarcomeres vs frame number.
- spatial_graph()
Visualizes the spatial graph
- timeseries_params()
Visualize time series parameters.
- tracked_vs_untracked(file_path, start_frame=0, stop_frame=inf)
Visualize metrics to compare the effect of tracking sarcomeres in a video vs only detecting sarcomeres in each frame without tracking
- Parameters:
file_path (str) – address to the original video file
start_frame (int, optional, by default 0)
stop_frame (int, optional, by default np.inf)
- zdiscs_and_sarcs(frame_num=0)
Visualize and save the plot of segmented zdiscs and detected sarcomeres in the chosen frame
- Parameters:
frame_num (int, by default 0)
- class sarcgraph.sg_tools.SarcGraphTools.Analysis(sg_tools)
Bases:
objectProvides tools for post processing analysis of detected sarcomeres.
- compute_F_J(adjust_reference=False)
Compute the average deformation gradient (F) and its jacobian (J) for the whole movie.
- Parameters:
adjust_reference (bool, by default False) – The refrence frame by default is the first frame of the movie, if this variable is set to
Truethe function will run twice and the refrence frame on the second run will be the most contracted frame- Returns:
The average deformation gradient (F), shape=(num_frames, 2, 2) The jacobian of F, shape=(num_frames)
- Return type:
Tuple(np.ndarray, np.ndarray)
- compute_OOP()
Computes Orientation Order Parameter (OOP) for the whole movie.
- Returns:
OOP for all frames, shape=(num_frames) OOP vector for all frames, shape=(num_frames, 2)
- Return type:
Tuple[np.ndarray, np.ndarray]
- compute_metrics(frame=None)
This function computes the following metrics as defind in the paper: {OOP, C_iso, C_OOP, s_til, s_avg}.
- Parameters:
frame (int, optional) – By default is set to the frame with maximum contraction
Notes
See the paper for more information: https://arxiv.org/abs/2102.02412
- Return type:
dict
- compute_ts_params()
Compute and save timeseries time constants (contraction time, relaxation time, flat time, period, offset, etc.).
- Return type:
pd.DataFrame
- create_spatial_graph(file_path=None, tracked_zdiscs=None)
Generates and saves a spatial graph of tracked zdiscs where edges indicate sarcomeres and edge weights indicates the ratio of the frames in which that sarcomere is detected
- Parameters:
file_path (str) – The address of an image or a video file to be loaded
tracked_zdiscs (pd.DataFrame) – Information of all detected and tracked zdiscs in every frame.