dattalab / keypoint-moseq

https://keypoint-moseq.readthedocs.io
Other
64 stars 26 forks source link

plot_pcs not working wiht 3d data from SLEAP-Anipose. #60

Closed ab-madabhushi closed 1 year ago

ab-madabhushi commented 1 year ago

Dear all,

I was trying to use keypoint-moseq to analyse 3d coordinate data generated from SLEAP-Anipose. I first used SLEAP to track the keypoints (2d) from multiple camera angles. I then generated a calibration.toml using checkerboard points annotated using DLT and generated coefficients for 3d reconstruction. I then modified this file to make it suitable for SLEAP-Anipose ( following this https://github.com/backyardbiomech/DLCconverterDLT/blob/master/DLTcameraPosition.py) and reconstructed xyz coordinates of the keypoints using the calibration function in SLEAP-anipose (https://github.com/talmolab/sleap-anipose). The resulting file was a .h5 file with tracks of shape (3 x K x 1 x N ) where 3 refers to the 3 coordinates, K is the number of keypoints 1 refers to the single individual tracked and N is the total no. of frames.

However, I now see this error when I try to plot PC's using keypoint-moseq. image

Could you please direct me to what I can do to fix this and what is going wrong here?

Thank you very much!

calebweinreb commented 1 year ago

Hey! Two things:

  1. I discovered a bug in the sleap-anipose loader. Can you try updating to the latest version and see if the problem persists? (BTW, the command switched from kpms.load_keypoints(PATH, 'anipose-sleap') to kpms.load_keypoints(PATH, 'sleap-anipose')
  2. Looking through the sleap-anipose code, it seems like it saves the data in the format (n_frames, n_tracks, n_nodes, 3). This is what keypoint-moseq expects. If your h5 file has shape (3 x K x 1 x N ), why do you think that is? What command exactly did you use for saving it?
ab-madabhushi commented 1 year ago

Hi Dr. Weinreb,

I am not sure why it had a different format. My guess is I 'viewed' the file in MATLAB which apparently has a different way to read matrices compared to python (Transposed). I now generated the triangulation again and it seems to be working now! Thank you so much for your help!


From: Caleb Weinreb @.> Sent: Thursday, June 8, 2023 10:29 AM To: dattalab/keypoint-moseq @.> Cc: Madabhushi, Abhinav (madabhan) @.>; Author @.> Subject: Re: [dattalab/keypoint-moseq] plot_pcs not working wiht 3d data from SLEAP-Anipose. (Issue #60)

External Email: Use Caution

Hey! Two things:

  1. I discovered a bug in the sleap-anipose loader. Can you try updating to the latest versionhttps://keypoint-moseq.readthedocs.io/en/latest/FAQs.html#troubleshooting and see if the problem persists? (BTW, the command switched from kpms.load_keypoints(PATH, 'anipose-sleap') to kpms.load_keypoints(PATH, 'sleap-anipose')
  2. Looking through the sleap-aniposehttps://github.com/talmolab/sleap-anipose/blob/d1a8dbc0754bb087d9bf0c3f7b96cabf9298ecd8/sleap_anipose/triangulation.py#L121 code, it seems like it saves the data in the format (n_frames, n_tracks, n_nodes, 3). This is what keypoint-moseq expects. If your h5 file has shape (3 x K x 1 x N ), why do you think that is? What command exactly did you use for saving it?

— Reply to this email directly, view it on GitHubhttps://github.com/dattalab/keypoint-moseq/issues/60#issuecomment-1582690797, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A32COT7W6RDGDOUVCSGIPBLXKHOWFANCNFSM6AAAAAAY4UQXKA. You are receiving this because you authored the thread.Message ID: @.***>

calebweinreb commented 1 year ago

Great!