You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling moseq2_viz.model.dist.get_behavioral_distance() is crashing on syllables that have no emissions in the dataset when computing the distance metric pca[dtw]. Given the call
File "c:\users\josh\git\moseq2\moseq2-viz\moseq2_viz\model\dist.py", line 165, in get_behavioral_distance
**use_options)
File "c:\users\josh\git\moseq2\moseq2-viz\moseq2_viz\model\util.py", line 1092, in retrieve_pcs_from_slices
inds = np.random.randint(0, len(filtered_slices), size=max_samples)
File "mtrand.pyx", line 741, in numpy.random.mtrand.RandomState.randint
File "_bounded_integers.pyx", line 1353, in numpy.random._bounded_integers._rand_int32
ValueError: low >= high
Stepping through with a debugger, it looks like moseq2_viz.model.util.retrieve_pcs_from_slices() is failing if slices is an empty list, specifically when trying to sample random slices (because there are none!). This was not the behavior in earlier versions of moseq2-viz. I suspect the same errors would occur when computing the distance metric combined.
I'm not really sure the best course of action to resolve this bug. While investigating, I found a few other related issues:
The kwargs provided by get_behavioral_distance() for retrieve_pcs_from_slices() includes 'max_samples': None,, but then retrieve_pcs_from_slices() will fail when trying to enumerate(use_slices). This is due to np.random.randint() only returning a single value when size is None, so use_slices ends up with a value of a single slice and not a list of slices. Not sure if the use of None for max_samples is intentional or not.
The unit tests do not cover some of the possible execution paths for get_behavioral_distance(). Namely, they omit the distance metrics of pca[dtw] and combined. Probably this contributes to these problems not being discovered sooner.
My suggested patch would be something along the lines of below, which seems to work on my machine.
Calling
moseq2_viz.model.dist.get_behavioral_distance()
is crashing on syllables that have no emissions in the dataset when computing the distance metricpca[dtw]
. Given the callI see the (partial) stack trace:
Stepping through with a debugger, it looks like
moseq2_viz.model.util.retrieve_pcs_from_slices()
is failing ifslices
is an empty list, specifically when trying to sample random slices (because there are none!). This was not the behavior in earlier versions ofmoseq2-viz
. I suspect the same errors would occur when computing the distance metriccombined
.I'm not really sure the best course of action to resolve this bug. While investigating, I found a few other related issues:
kwargs
provided byget_behavioral_distance()
forretrieve_pcs_from_slices()
includes'max_samples': None,
, but thenretrieve_pcs_from_slices()
will fail when trying toenumerate(use_slices)
. This is due tonp.random.randint()
only returning a single value whensize
isNone
, souse_slices
ends up with a value of a single slice and not a list of slices. Not sure if the use ofNone
formax_samples
is intentional or not.get_behavioral_distance()
. Namely, they omit the distance metrics ofpca[dtw]
andcombined
. Probably this contributes to these problems not being discovered sooner.My suggested patch would be something along the lines of below, which seems to work on my machine.
The text was updated successfully, but these errors were encountered: