dattalab / keypoint-moseq

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

Error when creating trajectory plots: ValueError: need at least one array to concatenate #19

Closed juliagorman closed 1 year ago

juliagorman commented 1 year ago

I have been working through the tutorial and I keep running into the same issue when running this line:

kpms.generate_trajectory_plots(coordinates=coordinates, name=name, project_dir=project_dir, **config())

This is the error I get.:

### ValueError                                Traceback (most recent call last)
[<ipython-input-40-07fec078becb>](https://localhost:8080/#) in <cell line: 1>()
----> 1 `kpms.generate_trajectory_plots(coordinates=coordinates,` name=name, project_dir=project_dir, **config())

4 frames
[/usr/local/lib/python3.9/dist-packages/keypoint_moseq/viz.py](https://localhost:8080/#) in generate_trajectory_plots(coordinates, results, output_dir, name, project_dir, results_path, pre, post, min_frequency, min_duration, use_reindexed, use_estimated_coords, skeleton, bodyparts, use_bodyparts, num_samples, keypoint_colormap, plot_options, sampling_options, padding, save_individually, save_gifs, save_mp4s, fps, projection_planes, **kwargs)
   1062 
   1063     sampling_options['n_neighbors'] = num_samples
-> 1064     sampled_instances = sample_instances(
   1065         syllable_instances, num_samples, coordinates=coordinates,
   1066         centroids=centroids, headings=headings, **sampling_options)

[/usr/local/lib/python3.9/dist-packages/keypoint_moseq/util.py](https://localhost:8080/#) in sample_instances(syllable_instances, num_samples, mode, pca_samples, pca_dim, n_neighbors, coordinates, pre, post, centroids, headings, filter_size)
    719             centroids=centroids, headings=headings, filter_size=filter_size
    720             ) for syllable,instances in syllable_instances.items()}
--> 721         X = np.vstack(list(trajectories.values()))
    722 
    723         if X.shape[0]>pca_samples:

/usr/local/lib/python3.9/dist-packages/numpy/core/overrides.py in vstack(*args, **kwargs)

[/usr/local/lib/python3.9/dist-packages/numpy/core/shape_base.py](https://localhost:8080/#) in vstack(tup)
    280     if not isinstance(arrs, list):
    281         arrs = [arrs]
--> 282     return _nx.concatenate(arrs, 0)
    283 
    284 

/usr/local/lib/python3.9/dist-packages/numpy/core/overrides.py in concatenate(*args, **kwargs)

ValueError: need at least one array to concatenate

I am not certain what it means.

calebweinreb commented 1 year ago

Are you using the sample data or your own data? If your own would you be willing to share the results.h5 file?

juliagorman commented 1 year ago

This is the file I am using

Get Outlook for iOShttps://aka.ms/o0ukef


From: Caleb Weinreb @.> Sent: Sunday, April 16, 2023 2:36:41 PM To: dattalab/keypoint-moseq @.> Cc: Gorman, Julia @.>; Author @.> Subject: Re: [dattalab/keypoint-moseq] Error when creating trajectory plots: ValueError: need at least one array to concatenate (Issue #19)

Are you using the sample data or your own data? If your own would you be willing to share the results.h5 file?

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

calebweinreb commented 1 year ago

I'm not sure its possible to send files through issue comments. Can you email the file directly to calebsw@gmail.com?

calebweinreb commented 1 year ago

This bug occurred because all frames were assigned to a single syllable, which itself probably occurred because of NaNs during fitting. These issues are addressed in release 0.0.4. Also see https://keypoint-moseq.readthedocs.io/en/latest/troubleshooting.html

juliagorman commented 1 year ago

Does this version automatically update or do I need to re-install keypoint moseq?

JC Gorman PhD student | Millerhttps://millerlab.ucsd.edu/ lab Neurosciences Graduate Program | UCSD


From: Caleb Weinreb @.> Sent: Tuesday, April 25, 2023 6:15 AM To: dattalab/keypoint-moseq @.> Cc: Julia C Gorman @.>; Author @.> Subject: Re: [dattalab/keypoint-moseq] Error when creating trajectory plots: ValueError: need at least one array to concatenate (Issue #19)

This bug occurred because all frames were assigned to a single syllable, which itself probably occurred because of NaNs during fitting. These issues are addressed in release 0.0.4https://urldefense.com/v3/__https://github.com/dattalab/keypoint-moseq/releases/tag/0.0.4__;!!Mih3wA!BFiQPdmgJ37k8GZOcBrJZAngI_pYXflQ7gJxBxmc2anavhccJsAj-yQ_CdrS_gEyA2BaaMyYNSGXEJSNS9VJhXyxXQ$. Also see https://keypoint-moseq.readthedocs.io/en/latest/troubleshooting.htmlhttps://urldefense.com/v3/__https://keypoint-moseq.readthedocs.io/en/latest/troubleshooting.html__;!!Mih3wA!BFiQPdmgJ37k8GZOcBrJZAngI_pYXflQ7gJxBxmc2anavhccJsAj-yQ_CdrS_gEyA2BaaMyYNSGXEJSNS9UKDE6W8w$

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/dattalab/keypoint-moseq/issues/19*issuecomment-1521773038__;Iw!!Mih3wA!BFiQPdmgJ37k8GZOcBrJZAngI_pYXflQ7gJxBxmc2anavhccJsAj-yQ_CdrS_gEyA2BaaMyYNSGXEJSNS9WOF47Ntw$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AHXPYCKSZ2DDL6POYH5C4ETXC7E6JANCNFSM6AAAAAAXAMB73Q__;!!Mih3wA!BFiQPdmgJ37k8GZOcBrJZAngI_pYXflQ7gJxBxmc2anavhccJsAj-yQ_CdrS_gEyA2BaaMyYNSGXEJSNS9XItrqEYg$. You are receiving this because you authored the thread.Message ID: @.***>

juliagorman commented 1 year ago

Also, sorry for the double email, but would you know why its assigning all the frames to a single variable? I see in the plots of the fitting that its finding like 20-40 syllables?

JC Gorman PhD student | Millerhttps://millerlab.ucsd.edu/ lab Neurosciences Graduate Program | UCSD


From: Caleb Weinreb @.> Sent: Tuesday, April 25, 2023 6:15 AM To: dattalab/keypoint-moseq @.> Cc: Julia C Gorman @.>; Author @.> Subject: Re: [dattalab/keypoint-moseq] Error when creating trajectory plots: ValueError: need at least one array to concatenate (Issue #19)

This bug occurred because all frames were assigned to a single syllable, which itself probably occurred because of NaNs during fitting. These issues are addressed in release 0.0.4https://urldefense.com/v3/__https://github.com/dattalab/keypoint-moseq/releases/tag/0.0.4__;!!Mih3wA!BFiQPdmgJ37k8GZOcBrJZAngI_pYXflQ7gJxBxmc2anavhccJsAj-yQ_CdrS_gEyA2BaaMyYNSGXEJSNS9VJhXyxXQ$. Also see https://keypoint-moseq.readthedocs.io/en/latest/troubleshooting.htmlhttps://urldefense.com/v3/__https://keypoint-moseq.readthedocs.io/en/latest/troubleshooting.html__;!!Mih3wA!BFiQPdmgJ37k8GZOcBrJZAngI_pYXflQ7gJxBxmc2anavhccJsAj-yQ_CdrS_gEyA2BaaMyYNSGXEJSNS9UKDE6W8w$

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/dattalab/keypoint-moseq/issues/19*issuecomment-1521773038__;Iw!!Mih3wA!BFiQPdmgJ37k8GZOcBrJZAngI_pYXflQ7gJxBxmc2anavhccJsAj-yQ_CdrS_gEyA2BaaMyYNSGXEJSNS9WOF47Ntw$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AHXPYCKSZ2DDL6POYH5C4ETXC7E6JANCNFSM6AAAAAAXAMB73Q__;!!Mih3wA!BFiQPdmgJ37k8GZOcBrJZAngI_pYXflQ7gJxBxmc2anavhccJsAj-yQ_CdrS_gEyA2BaaMyYNSGXEJSNS9XItrqEYg$. You are receiving this because you authored the thread.Message ID: @.***>

calebweinreb commented 1 year ago

You have to reinstall. Using pip this would be:

pip install -U keypoint_moseq

My guess is that originally there was a NaN during fitting, which caused all the frames to collapse to a single syllable. This appears to have happened in iteration 70 of the notebook you shared with me via google drive.

juliagorman commented 1 year ago

Why might there be so many NaNs during fitting? Is there potentially something wrong with my data? Also, in the guide for how to deal with NaNs during fitting, there isn't too much information. I ran this command and got False as the output so I don't know where to go next.

Thanks for all the help btw!

JC Gorman PhD student | Millerhttps://millerlab.ucsd.edu/ lab Neurosciences Graduate Program | UCSD


From: Caleb Weinreb @.> Sent: Tuesday, April 25, 2023 12:59 PM To: dattalab/keypoint-moseq @.> Cc: Julia C Gorman @.>; Author @.> Subject: Re: [dattalab/keypoint-moseq] Error when creating trajectory plots: ValueError: need at least one array to concatenate (Issue #19)

You have to reinstall. Using pip this would be:

pip install -U keypoint_moseq

My guess is that originally there was a NaN during fitting, which caused all the frames to collapse to a single syllable. This appears to have happened in iteration 70 of the notebook you shared with me via google drive.

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/dattalab/keypoint-moseq/issues/19*issuecomment-1522341380__;Iw!!Mih3wA!BKlxNM-mOYdclNNEnXncWJpIREnwUzVSxF35N23GRO3zvOp2kPkSxfb2UtHIUCk6KRRhwPHRusFev2xQ5OJ1jdKlnA$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AHXPYCPLVZ3UPLLXZJWXF6DXDAUI3ANCNFSM6AAAAAAXAMB73Q__;!!Mih3wA!BKlxNM-mOYdclNNEnXncWJpIREnwUzVSxF35N23GRO3zvOp2kPkSxfb2UtHIUCk6KRRhwPHRusFev2xQ5OItViGrjw$. You are receiving this because you authored the thread.Message ID: @.***>

calebweinreb commented 1 year ago

No problem! See https://github.com/dattalab/keypoint-moseq/issues/26#issuecomment-1522919062