adaptivemotorcontrollab / dlc2kinematics Goto Github PK
View Code? Open in Web Editor NEWa module for kinematic analysis of deeplabcut outputs
Home Page: http://mackenziemathislab.org
License: Apache License 2.0
a module for kinematic analysis of deeplabcut outputs
Home Page: http://mackenziemathislab.org
License: Apache License 2.0
For a quaternion-vector, the scalar part for a unit quaternion is calculated incorrect.
The existing code square roots (1 - the already square rooted np.linalg.norm(inQuat, axis=1) which is incorrect.
Hello,
I am trying to compute the joint coordinates for the joint angles of the hindlimb.
I have inputted the following:
In [49]: joints_dict= {}
joints_dict['Ankle'] = ['Knee', 'Ankle', 'MTP']
In [50]: joint_angles = dlc2kinematics.compute_joint_angles(df,joints_dict)
The output I receive is: 'TypeError: Slicing a positional slice with .loc is not allowed, Use .loc with labels or .iloc with positions instead.'
I have tried to change from .loc to .iloc but have had no luck with getting it to work.
Please could you suggest a way to overcome this. Please forgive me if this is straight forward, but I am new to this.
Thank you in advance.
when trying to run dlc2kinematics.compute_umap(...
i got an error on the usage of umap.UMAP
In [23]: data = dlc2kinematics.compute_umap(
...: df,
...: key=bodyparts,
...: chunk_length=30,
...: fit_transform=True,
...: n_neighbors=30,
...: n_components=3,
...: metric="euclidean",
...: )
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [23], in <module>
----> 1 data = dlc2kinematics.compute_umap(
2 df,
3 key=bodyparts,
4 chunk_length=30,
5 fit_transform=True,
6 n_neighbors=30,
7 n_components=3,
8 metric="euclidean",
9 )
File C:\ProgramData\Anaconda3\envs\DLC2022\lib\site-packages\dlc2kinematics\mainfxns.py:317, in compute_umap(df, key, chunk_length, fit_transform, n_neighbors, n_components, metric, min_dist, metric_kwds, output_metric, output_metric_kwds, n_epochs, learning_rate, init, spread, low_memory, set_op_mix_ratio, local_connectivity, repulsion_strength, negative_sample_rate, transform_queue_size, a, b, random_state, angular_rp_forest, target_n_neighbors, target_metric, target_metric_kwds, target_weight, transform_seed, force_approximation_algorithm, verbose, unique)
314 X = poses.reshape((n_chunks, -1))
316 # Create embedding
--> 317 embedding = umap.UMAP(
318 n_components=n_components,
319 n_neighbors=n_neighbors,
320 min_dist=min_dist,
321 metric="euclidean",
322 metric_kwds=None,
323 output_metric="euclidean",
324 output_metric_kwds=output_metric_kwds,
325 n_epochs=n_epochs,
326 learning_rate=learning_rate,
327 init=init,
328 spread=spread,
329 low_memory=low_memory,
330 set_op_mix_ratio=set_op_mix_ratio,
331 local_connectivity=local_connectivity,
332 repulsion_strength=repulsion_strength,
333 negative_sample_rate=negative_sample_rate,
334 transform_queue_size=transform_queue_size,
335 a=a,
336 b=b,
337 random_state=random_state,
338 angular_rp_forest=angular_rp_forest,
339 target_n_neighbors=target_n_neighbors,
340 target_metric=target_metric,
341 target_metric_kwds=target_metric_kwds,
342 target_weight=target_weight,
343 transform_seed=transform_seed,
344 force_approximation_algorithm=force_approximation_algorithm,
345 verbose=verbose,
346 unique=unique,
347 )
348 embedding.fit(X)
349 transformed_data = embedding.transform(X) if fit_transform else None
AttributeError: module 'umap' has no attribute 'UMAP'
failing as in the tox.ini -cov=dlc2kinematics
is not recognized; maybe @jeylau you can take a look at what I'm missing here :)
Hi,
In the midst of calculating joint angles, I have encountered a predicament. Here is the code snippet along with the error message received:
wuye@WudeMacBook-Pro ~ % conda activate DEEPLABCUT_M1
(DEEPLABCUT_M1) wuye@WudeMacBook-Pro ~ % ipython
Python 3.9.16 | packaged by conda-forge | (main, Feb 1 2023, 21:38:11)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.14.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import dlc2kinematics
/Users/wuye/miniconda/envs/DEEPLABCUT_M1/lib/python3.9/site-packages/umap/distances.py:1063: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
@numba.jit()
/Users/wuye/miniconda/envs/DEEPLABCUT_M1/lib/python3.9/site-packages/umap/distances.py:1071: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
@numba.jit()
/Users/wuye/miniconda/envs/DEEPLABCUT_M1/lib/python3.9/site-packages/umap/distances.py:1086: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
@numba.jit()
/Users/wuye/miniconda/envs/DEEPLABCUT_M1/lib/python3.9/site-packages/umap/umap_.py:660: NumbaDeprecationWarning: The 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.
@numba.jit()
In [2]: print(dlc2kinematics.version)
0.0.7
In [3]: df, bodyparts, scorer = dlc2kinematics.load_data("/Users/wuye/Desktop/DL
...: C/newDLC_resnet50_DLC_trainJul4shuffle1_60000.h5")
In [4]: joints_dict= {}
In [5]: joints_dict['ankle joint'] = ['metatarsophalangeal joint', 'ankle joint'
...: , 'knee joint']
In [6]: joint_angles = dlc2kinematics.compute_joint_angles(df,joints_dict)
TypeError: Slicing a positional slice with .loc is not allowed, Use .loc with labels or .iloc with positions instead.
I saw someone asked this question
TypeError Traceback (most recent call last)
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\groupby\groupby.py:1824, in GroupBy.apply(self, func, include_groups, *args, **kwargs)
1823 try:
-> 1824 result = self._python_apply_general(f, self._selected_obj)
1825 if (
1826 not isinstance(self.obj, Series)
1827 and self._selection is None
1828 and self._selected_obj.shape != self._obj_with_exclusions.shape
1829 ):
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\groupby\groupby.py:1885, in GroupBy._python_apply_general(self, f, data, not_indexed_same, is_transform, is_agg)
1859 """
1860 Apply function f in python space
1861
(...)
1883 data after applying f
1884 """
-> 1885 values, mutated = self._grouper.apply_groupwise(f, data, self.axis)
1886 if not_indexed_same is None:
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\groupby\ops.py:919, in BaseGrouper.apply_groupwise(self, f, data, axis)
918 group_axes = group.axes
--> 919 res = f(group)
920 if not mutated and not _is_indexed_like(res, group_axes, axis):
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\groupby\groupby.py:1809, in GroupBy.apply..f(g)
1807 @wraps(func)
1808 def f(g):
-> 1809 return func(g, *args, **kwargs)
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\dlc2kinematics\joint_analysis.py:104, in compute_joint_angles..filter_low_prob(cols, prob)
103 mask = cols.iloc[:, 2] < prob
--> 104 cols.loc[mask, :2] = np.nan
105 return cols
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:907, in _LocationIndexer.setitem(self, key, value)
906 key = self._check_deprecated_callable_usage(key, maybe_callable)
--> 907 indexer = self._get_setitem_indexer(key)
908 self._has_valid_setitem_indexer(key)
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:774, in _LocationIndexer._get_setitem_indexer(self, key)
772 with suppress(IndexingError):
773 # suppress "Too many indexers"
--> 774 return self._convert_tuple(key)
776 if isinstance(key, range):
777 # GH#45479 test_loc_setitem_range_key
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:989, in _LocationIndexer._convert_tuple(self, key)
988 self._validate_key_length(key)
--> 989 keyidx = [self._convert_to_indexer(k, axis=i) for i, k in enumerate(key)]
990 return tuple(keyidx)
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:989, in (.0)
988 self._validate_key_length(key)
--> 989 keyidx = [self._convert_to_indexer(k, axis=i) for i, k in enumerate(key)]
990 return tuple(keyidx)
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:1470, in _LocIndexer._convert_to_indexer(self, key, axis)
1469 if isinstance(key, slice):
-> 1470 return labels._convert_slice_indexer(key, kind="loc")
1472 if (
1473 isinstance(key, tuple)
1474 and not isinstance(labels, MultiIndex)
1475 and self.ndim < 2
1476 and len(key) > 1
1477 ):
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexes\base.py:4275, in Index._convert_slice_indexer(self, key, kind)
4273 if kind == "loc":
4274 # GH#16121, GH#24612, GH#31810
-> 4275 raise TypeError(
4276 "Slicing a positional slice with .loc is not allowed, "
4277 "Use .loc with labels or .iloc with positions instead.",
4278 )
4279 indexer = key
TypeError: Slicing a positional slice with .loc is not allowed, Use .loc with labels or .iloc with positions instead.
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
Cell In[5], line 1
----> 1 joint_angles = dlc2kinematics.compute_joint_angles(df,joints_dict,
2 dropnan=True, smooth=True, save=False)
3 #you may want to set save=True once you settle on this; so you don't have to recompute.
4
5 #plot:
6 dlc2kinematics.plot_joint_angles(joint_angles)
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\dlc2kinematics\joint_analysis.py:107, in compute_joint_angles(df, joints_dict, save, destfolder, output_filename, dropnan, smooth, filter_window, order, pcutoff)
104 cols.loc[mask, :2] = np.nan
105 return cols
--> 107 df = df.groupby("bodyparts", axis=1).apply(filter_low_prob, prob=pcutoff)
109 angle_names = list(joints_dict)
110 if not destfolder:
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\groupby\groupby.py:1846, in GroupBy.apply(self, func, include_groups, *args, **kwargs)
1830 warnings.warn(
1831 message=_apply_groupings_depr.format(
1832 type(self).name, "apply"
(...)
1835 stacklevel=find_stack_level(),
1836 )
1837 except TypeError:
1838 # gh-20949
1839 # try again, with .apply acting as a filtering
(...)
1843 # fails on some columns, e.g. a numeric operation
1844 # on a string grouper column
-> 1846 return self._python_apply_general(f, self._obj_with_exclusions)
1848 return result
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\groupby\groupby.py:1885, in GroupBy._python_apply_general(self, f, data, not_indexed_same, is_transform, is_agg)
1850 @Final
1851 def _python_apply_general(
1852 self,
(...)
1857 is_agg: bool = False,
1858 ) -> NDFrameT:
1859 """
1860 Apply function f in python space
1861
(...)
1883 data after applying f
1884 """
-> 1885 values, mutated = self._grouper.apply_groupwise(f, data, self.axis)
1886 if not_indexed_same is None:
1887 not_indexed_same = mutated
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\groupby\ops.py:919, in BaseGrouper.apply_groupwise(self, f, data, axis)
917 # group might be modified
918 group_axes = group.axes
--> 919 res = f(group)
920 if not mutated and not _is_indexed_like(res, group_axes, axis):
921 mutated = True
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\groupby\groupby.py:1809, in GroupBy.apply..f(g)
1807 @wraps(func)
1808 def f(g):
-> 1809 return func(g, *args, **kwargs)
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\dlc2kinematics\joint_analysis.py:104, in compute_joint_angles..filter_low_prob(cols, prob)
102 def filter_low_prob(cols, prob):
103 mask = cols.iloc[:, 2] < prob
--> 104 cols.loc[mask, :2] = np.nan
105 return cols
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:907, in _LocationIndexer.setitem(self, key, value)
905 maybe_callable = com.apply_if_callable(key, self.obj)
906 key = self._check_deprecated_callable_usage(key, maybe_callable)
--> 907 indexer = self._get_setitem_indexer(key)
908 self._has_valid_setitem_indexer(key)
910 iloc = self if self.name == "iloc" else self.obj.iloc
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:774, in _LocationIndexer._get_setitem_indexer(self, key)
771 if isinstance(key, tuple):
772 with suppress(IndexingError):
773 # suppress "Too many indexers"
--> 774 return self._convert_tuple(key)
776 if isinstance(key, range):
777 # GH#45479 test_loc_setitem_range_key
778 key = list(key)
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:989, in _LocationIndexer._convert_tuple(self, key)
985 @Final
986 def _convert_tuple(self, key: tuple) -> tuple:
987 # Note: we assume _tupleize_axis_indexer has been called, if necessary.
988 self._validate_key_length(key)
--> 989 keyidx = [self._convert_to_indexer(k, axis=i) for i, k in enumerate(key)]
990 return tuple(keyidx)
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:989, in (.0)
985 @Final
986 def _convert_tuple(self, key: tuple) -> tuple:
987 # Note: we assume _tupleize_axis_indexer has been called, if necessary.
988 self._validate_key_length(key)
--> 989 keyidx = [self._convert_to_indexer(k, axis=i) for i, k in enumerate(key)]
990 return tuple(keyidx)
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexing.py:1470, in _LocIndexer._convert_to_indexer(self, key, axis)
1467 labels = self.obj._get_axis(axis)
1469 if isinstance(key, slice):
-> 1470 return labels._convert_slice_indexer(key, kind="loc")
1472 if (
1473 isinstance(key, tuple)
1474 and not isinstance(labels, MultiIndex)
1475 and self.ndim < 2
1476 and len(key) > 1
1477 ):
1478 raise IndexingError("Too many indexers")
File D:\anaconda\envs\DEEPLABCUT\lib\site-packages\pandas\core\indexes\base.py:4275, in Index._convert_slice_indexer(self, key, kind)
4272 elif is_positional:
4273 if kind == "loc":
4274 # GH#16121, GH#24612, GH#31810
-> 4275 raise TypeError(
4276 "Slicing a positional slice with .loc is not allowed, "
4277 "Use .loc with labels or .iloc with positions instead.",
4278 )
4279 indexer = key
4280 else:
TypeError: Slicing a positional slice with .loc is not allowed, Use .loc with labels or .iloc with positions instead.
Hi,
i'm trying to use DLC2Kinematics following the instructions. but getting errors about joints_dict not being defined.
it took me 2 hours, but i figured out that in this section:
"
Computations in joint coordinates
To compute joint angles, we first create a dictionary where keys are the joint angles and the corresponding values are the set of bodyparts:
joint_dict= {}
joints_dict['R-Elbow'] = ['R_shoulder', 'Right_elbow', 'Right_wrist']
and compute the joint angles with
joint_angles = dlc2kinematics.compute_joint_angles(df,joints_dict)
"
you define:
joint_dict= {} so "joint_dict"
but then try to asign into "joints_dict":
joints_dict['R-Elbow'] = ['R_shoulder', 'Right_elbow', 'Right_wrist']
best,
Shahaf
Using the DeepLabCut Google Colab:
!pip install dlc2kinematics
import dlc2kinematics
path_h5 = "/content/drive/MyDrive/DeepLabCut/sample-intern-2022-04-11-Cropped/videos/sample_TrimDLC_resnet50_sampleApr11shuffle1_20000_el.h5"
df, bodyparts, scorer = dlc2kinematics.load_data(path_h5)
After which I get the following:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
[<ipython-input-52-c8eee90f89d0>](https://localhost:8080/#) in <module>()
----> 1 df, bodyparts, scorer = dlc2kinematics.load_data(path_h5)
2 frames
[/usr/local/lib/python3.7/dist-packages/dlc2kinematics/preprocess.py](https://localhost:8080/#) in load_data(filename, smooth, filter_window, order)
41
42 """
---> 43
44 df = pd.read_hdf(filename, "df_with_missing")
45 bodyparts = df.columns.get_level_values("bodyparts").unique().to_list()
[/usr/local/lib/python3.7/dist-packages/pandas/io/pytables.py](https://localhost:8080/#) in read_hdf(path_or_buf, key, mode, errors, where, start, stop, columns, iterator, chunksize, **kwargs)
461 iterator=iterator,
462 chunksize=chunksize,
--> 463 auto_close=auto_close,
464 )
465 except (ValueError, TypeError, KeyError):
[/usr/local/lib/python3.7/dist-packages/pandas/io/pytables.py](https://localhost:8080/#) in select(self, key, where, start, stop, columns, iterator, chunksize, auto_close)
848 group = self.get_node(key)
849 if group is None:
--> 850 raise KeyError(f"No object named {key} in the file")
851
852 # create the storer and axes
KeyError: 'No object named df_with_missing in the file'
Hi @MMathisLab and team!
There is a strong chance I'm missing a step somewhere, but I can't figure out what I'm doing wrong. I'm trying to do the basic compute velocity etc, using the demo jupyter notebook as a guide. However, even though I don't get any error messages or similar, nothing seems to happen when I try to compute velocity - it just gives me an output of the body part x and y, and the likliehood. I've tried both with my own data and with the example demo data and run into the same issues.
Example code using the 2D demo data (since the data I'm trying to analyze is also 2D data)
DLC_2D_file1 = 'C:/Users/alb722/Desktop/DEMO/reachingDEMO_2D.h5'
config = 'C:/Users/alb722/Desktop/DEMO/config.yaml'
df, bodyparts, scorer = dlc2kinematics.load_data(DLC_2D_file1)
def_vel = dlc2kinematics.compute_velocity(df, bodyparts = ['Right_backofhand'], filter_window=3, order=1)
def_vel.head(3)
scorer DeepCut_resnet50_MackenzieJan21shuffle1_1030000
bodyparts Right_backofhand
coords x y likelihood
42150 -0.036558 -0.071750 1.0
42151 -0.036558 -0.071750 1.0
42152 0.090482 -0.069784 1.0
NameError Traceback (most recent call last)
Input In [10], in <cell line: 1>()
----> 1 dlc2kinematics.plot_velocity(df[scorer]['Right_backofhand'], df_vel)
NameError: name 'df_vel' is not defined
I'm assuming that the plotting doesn't work, because for some reason velocity didn't actually get calculated. Any suggestions? Did I miss a step somewhere?
Thanks in advance!
I'm having trouble using the joint coordinate computation and pca reconstruction functions of DLC2Kinematics.
Joint angle issues:
joints_dict= {}
joints_dict['whole-body'] = ['snout', 'MLA', 'MLB', 'MLC', 'MLD', 'MLE', 'MLF', 'MLG', 'MLH', 'tail']
joint_angles = dlc2kinematics.compute_joint_angles(df,joints_dict)
I then get the error message: `ValueError: cannot reshape array of size 30 into shape (3,3)'
Is there anyway that I can compute the angular velocity over a long video or do I need to specify a smaller subset of frames?
PCA reconstruction issue:
dlc2kinematics.plot_3d_pca_reconstruction(df_vel, n_components=10, framenumber=500, bodyparts2plot=['snout', 'MLA', 'MLB', 'MLC', 'MLD', 'MLE', 'MLF', 'MLG', 'MLH', 'tail'], bp_to_connect=['snout', 'MLA', 'MLB', 'MLC', 'MLD', 'MLE', 'MLF', 'MLG', 'MLH', 'tail'])
I then get the output:
`KeyError Traceback (most recent call last)
~\Anaconda3\envs\DEEPLABCUT3\lib\site-packages\pandas\core\indexes\base.py in get_loc(self, key, method, tolerance)
3360 try:
-> 3361 return self._engine.get_loc(casted_key)
3362 except KeyError as err:
~\Anaconda3\envs\DEEPLABCUT3\lib\site-packages\pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
~\Anaconda3\envs\DEEPLABCUT3\lib\site-packages\pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()
pandas_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
pandas_libs\hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'z'
The above exception was the direct cause of the following exception:`
Within half the filtering window of a nan-value, the speed is set to 0. Since immobility is often used as a parameter in behavioral analysis, I think it would be better to have the speed set to np.nan instead.
Additionally, I found that if a dataset has multiple scorers that have the same bodypart, it also produces interesting intermediate result and throws an error. I know this rarely happens, but it should be easy to fix.
I visualized both issues in a jupyter notebook that I used for testing
I think I have a solution for both (see jupyter notebook) and would be happy to contribute!
for some reason
pca = dlc2kinematics.compute_pca(joint_vel, plot=True)
only plot the dimensionality reduction figure. the rest of the plots are empty and the program is stuck / waiting.
pca = dlc2kinematics.compute_pca(joint_vel, plot=False) works however on the next stage:
(i wasn't sure on the formatting of "bp_to_connect" as there is no documentation on what this is so i tried putting "bodyparts" or one of the joints, or all joints there, with same issue as below)
In [27]: dlc2kinematics.plot_3d_pca_reconstruction(
...: df_vel,
...: n_components=10,
...: framenumber=500,
...: bodyparts2plot=bodyparts2plot,
...: bp_to_connect=bp_to_connect,
...: )
C:\ProgramData\Anaconda3\envs\DLC2022\lib\site-packages\sklearn\utils\validation.py:1688: FutureWarning: Feature names only support names that are all strings. Got feature names with dtypes: ['tuple']. An error will be raised in 1.2.
warnings.warn(
C:\ProgramData\Anaconda3\envs\DLC2022\lib\site-packages\sklearn\utils\validation.py:1688: FutureWarning: Feature names only support names that are all strings. Got feature names with dtypes: ['tuple']. An error will be raised in 1.2.
warnings.warn(
C:\ProgramData\Anaconda3\envs\DLC2022\lib\site-packages\dlc2kinematics\plotting.py:239: PerformanceWarning: indexing past lexsort depth may impact performance.
df_projected.loc(axis=1)[scorer, bp] = projected_reshape[:, idx]
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File C:\ProgramData\Anaconda3\envs\DLC2022\lib\site-packages\pandas\core\indexes\base.py:3621, in Index.get_loc(self, key, method, tolerance)
3620 try:
-> 3621 return self._engine.get_loc(casted_key)
3622 except KeyError as err:
File C:\ProgramData\Anaconda3\envs\DLC2022\lib\site-packages\pandas\_libs\index.pyx:136, in pandas._libs.index.IndexEngine.get_loc()
File C:\ProgramData\Anaconda3\envs\DLC2022\lib\site-packages\pandas\_libs\index.pyx:163, in pandas._libs.index.IndexEngine.get_loc()
File pandas\_libs\hashtable_class_helper.pxi:5198, in pandas._libs.hashtable.PyObjectHashTable.get_item()
File pandas\_libs\hashtable_class_helper.pxi:5206, in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: 'z'
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
Input In [27], in <module>
----> 1 dlc2kinematics.plot_3d_pca_reconstruction(
2 df_vel,
3 n_components=10,
4 framenumber=500,
5 bodyparts2plot=bodyparts2plot,
6 bp_to_connect=bp_to_connect,
7 )
File C:\ProgramData\Anaconda3\envs\DLC2022\lib\site-packages\dlc2kinematics\plotting.py:240, in plot_3d_pca_reconstruction(df, n_components, framenumber, bodyparts2plot, bp_to_connect)
238 for idx, bp in enumerate(bodyparts):
239 df_projected.loc(axis=1)[scorer, bp] = projected_reshape[:, idx]
--> 240 pca_plot(
241 num,
242 v,
243 fig,
244 k,
245 df_projected,
246 variance_explained,
247 n_comps,
248 bodyparts2plot,
249 bp_to_connect,
250 )
251 plt.show()
File C:\ProgramData\Anaconda3\envs\DLC2022\lib\site-packages\dlc2kinematics\plotting.py:177, in pca_plot(num, v, fig, k, df_projected, variance_explained, n_comps, bodyparts2plot, bp_to_connect)
175 xRight_3d_pca.append(df_projected.iloc[k][scorer][right_bp]["x"])
176 yRight_3d_pca.append(df_projected.iloc[k][scorer][right_bp]["y"])
--> 177 zRight_3d_pca.append(df_projected.iloc[k][scorer][right_bp]["z"])
179 for bpindex, bp in enumerate(bodyparts2plot):
180 xdata_3d_pca.append(df_projected.iloc[k][scorer][bp]["x"])
File C:\ProgramData\Anaconda3\envs\DLC2022\lib\site-packages\pandas\core\series.py:958, in Series.__getitem__(self, key)
955 return self._values[key]
957 elif key_is_scalar:
--> 958 return self._get_value(key)
960 if is_hashable(key):
961 # Otherwise index.get_value will raise InvalidIndexError
962 try:
963 # For labels that don't resolve as scalars like tuples and frozensets
File C:\ProgramData\Anaconda3\envs\DLC2022\lib\site-packages\pandas\core\series.py:1069, in Series._get_value(self, label, takeable)
1066 return self._values[label]
1068 # Similar to Index.get_value, but we do not fall back to positional
-> 1069 loc = self.index.get_loc(label)
1070 return self.index._get_values_for_loc(self, loc, label)
File C:\ProgramData\Anaconda3\envs\DLC2022\lib\site-packages\pandas\core\indexes\base.py:3623, in Index.get_loc(self, key, method, tolerance)
3621 return self._engine.get_loc(casted_key)
3622 except KeyError as err:
-> 3623 raise KeyError(key) from err
3624 except TypeError:
3625 # If we have a listlike key, _check_indexing_error will raise
3626 # InvalidIndexError. Otherwise we fall through and re-raise
3627 # the TypeError.
3628 self._check_indexing_error(key)
KeyError: 'z'
Hi, first of all, DLC2Kinematics its and amazing complement to DLC.
The probleme that I have is in the part of generate the PCA and Umap graphics.
In the part of the PCA i dont know what i need to put in the bp_to_connect' and how to do this.
The second problem
that i have is the next one
thanks for your help =)
Hello,
We have been trying to use the Visualizer3D function in order to view our 2 camera, 1 participant data. However our 3D matrix looks a bit off and we're unsure of how to adjust it properly. We were wondering if there is anyway we can adjust the z-axis to a smaller scale or if there are any tips for visualizing in a 3D graph representation. We have also tried to triangulate the videos following the 3Deeplabcut guide, however the skeleton is not represented accurately.
Thank you in advance!
Hello,
We were trying to use dlc2kinematics toolbox to compute joint angles with the computing joint angles command: dlc2kinematics.compute_joint_angles(df,joints_dict) however, we keep running into this error: single positional indexer is out-of-bounds
Our df has defined values and we have defined the joints_dict as well.
Does anyone have any suggestions regarding this issue?
Thanks in advance!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.