dattalab / keypoint-moseq

https://keypoint-moseq.readthedocs.io
Other
77 stars 28 forks source link

Trajectory Plots not Displaying Properly #112

Closed Bojun-Feng closed 11 months ago

Bojun-Feng commented 12 months ago

Problem Description

What could have possibly caused this? I expected both graphs to be of approximately the same size, but the problem seems to exist in Trajectory Plots only. I did some debugging but was unable to identify what caused the resolution inconsistency. This is not a huge issue since I can manually update the plotting code, but I couldn't help wondering if there is some simple setting that I missed.

This is my first time using keypoint-moseq, so any advice would be appreciated.

Screenshots

Screenshot 2023-11-16 at 10 12 52 AM Screenshot 2023-11-16 at 10 12 33 AM

Config

The config for the project was generated through importing DeepLabCut config.yaml file.

config info ``` #==================== ANATOMY =====================# # used to access columns in the keypoint data bodyparts: - head - neck - rear - tail # determines the subset of bodyparts to use for modeling and the order in which they are represented use_bodyparts: - head - neck - rear - tail # used for visualization only skeleton: - - head - neck - - neck - rear - - rear - tail # used to initialize heading anterior_bodyparts: - head # used to initialize heading posterior_bodyparts: - tail #==================== FITTING =====================# # upper bound of uniform noise added to the data during initial AR-HMM fitting; this is used to regularize the model added_noise_level: 0.1 # number of frames used to fit the PCA model during initialization PCA_fitting_num_frames: 1000000 # used to define outliers for interpolation when the model is initialized conf_threshold: 0.5 #================== HYPER PARAMS ==================# # parameters to convert neural net likelihoods to error size priors error_estimator: intercept: 0.25 slope: -0.5 # keypoint observation hyperparameters obs_hypparams: nu_s: 5 nu_sigma: 100000.0 sigmasq_0: 0.1 sigmasq_C: 0.1 # autoregressive hyperparameters ar_hypparams: K_0_scale: 10.0 S_0_scale: 0.01 latent_dim: 4 nlags: 3 # transition hyperparameters trans_hypparams: alpha: 5.7 gamma: 1000.0 kappa: 1000000.0 num_states: 100 # centroid movement hyperparameters cen_hypparams: sigmasq_loc: 0.5 #===================== OTHER ======================# # suffix used to match videos to recording names; this can usually be left empty (see `util.find_matching_videos` for details) recording_name_suffix: '' # whether to print progress messages during fitting verbose: false # pseudocount used regularize neural network confidences conf_pseudocount: 0.001 # directory with videos from which keypoints were derived (used for crowd movies) video_dir: videos/ # colormap used for visualization; see `matplotlib.cm.get_cmap` for options keypoint_colormap: autumn # whether to whiten principal components; used to initialize the latent pose trajectory `x` whiten: true # whether to keep the heading angle fixed; this should only be True if the pose is constrained to a narrow range of angles, e.g. a headfixed mouse. fix_heading: false # data are broken up into segments to parallelize fitting seg_length: 10000 ```
calebweinreb commented 12 months ago

Weird! Would you be willing to send me the results.h5 file and files containing keypoint coordinates? calebsw@gmail.com

Bojun-Feng commented 11 months ago

Hello @calebweinreb,

Apologies for the late reply; we encountered a formatting issue with our input CSV file, which was the root of our earlier problem. Thankfully, this was resolved once we switched to using an unaltered H5 file.

This change corrected the syllables. However, I've noticed a minor issue with the layout. The titles in the plots seem to be cramped and lack adequate space. Could you consider adding some additional padding around the plots? This would help in separating the titles from the plots more clearly. In most cases, the current setup works well, but when the syllables are either flat or small, the title tends to overlap with the plot.

Example Bad Case: All syllables were flat and the title overlaps with the plot: unnamed

Example Good Case: One syllable moves up/down and takes up additional space, so the title does not overlap with the plot: unnamed (1)

This also relates to the original issue, the input CSV file had a different metric of length and resulted in really small plots. However, no paddings were given and titles were simply overlapped on the top, resulting in an unreadable figure.

calebweinreb commented 11 months ago

Hello,

There is a padding argument in generate_trajectory_plots that you could adjust. The default value is {'left':0.1, 'right':0.1, 'top':0.2, 'bottom':0.2}, so you could increase the amount of padding for the top.

Bojun-Feng commented 11 months ago

Awesome! This solves the problem. Should we close the issue?

calebweinreb commented 11 months ago

Indeed!