sollan / alma

Fully automated (rodent) limb motion analysis toolbox for behavioral analysis with bodypart coordinate data, building upon markerless pose estimation.
GNU General Public License v3.0
13 stars 5 forks source link

Regarding issue with GAIT analysis #30

Closed mano2991 closed 1 year ago

mano2991 commented 1 year ago

I have trained my mouse using DLC and extracted the data point for GAIT analysis.

while choosing the semi-automated methos im getting an error as shown below. I have also enclosed my video and the csv file provided by the DLC.

Traceback (most recent call last):
  File "/home/ivlab/miniconda3/envs/alma_new/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 2646, in get_loc
    return self._engine.get_loc(key)
  File "pandas/_libs/index.pyx", line 111, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 1619, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 1627, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'toe x'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ivlab/Downloads/alma-1.1.0/Panels/AnalyzeStride.py", line 441, in OnMethod
    self.EstimateParams(self)
  File "/home/ivlab/Downloads/alma-1.1.0/Panels/AnalyzeStride.py", line 481, in EstimateParams
    self.est_cm_speed, self.est_px_speed, self.est_pixels_per_cm, self.est_px_to_cm_speed_ratio = KinematicsFunctions.estimate_speed(self.df, 'toe', self.cm_speed, None, self.frame_rate, self.right_to_left)
  File "/home/ivlab/Downloads/alma-1.1.0/Functions/KinematicsFunctions.py", line 59, in estimate_speed
    x_change = np.diff(pd_dataframe[f'{bodypart} x'][pd_dataframe[f'{bodypart} likelihood']>0.5])
  File "/home/ivlab/miniconda3/envs/alma_new/lib/python3.8/site-packages/pandas/core/frame.py", line 2800, in __getitem__
    indexer = self.columns.get_loc(key)
  File "/home/ivlab/miniconda3/envs/alma_new/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 2648, in get_loc
    return self._engine.get_loc(self._maybe_cast_indexer(key))
  File "pandas/_libs/index.pyx", line 111, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 1619, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 1627, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'toe x'

TestDLC_resnet50_GAITMar23shuffle1_100000.csv

https://user-images.githubusercontent.com/13638496/228850848-f8a28108-fe8d-4845-9872-ff7d6b516bc6.mp4

sollan commented 1 year ago

Hi! It’s because in your DLC model there is no bodypart named “toe”, so in the resulting csv file there is no “toe x” column that our app relies on. You could rename the corresponding columns in your csv result files, or update the bodypart definition in DLC (see Wiki for details of how the program works: https://github.com/sollan/alma/wiki/Gait-kinematics)

Note that for for gait analysis there are 6 required bodyparts:

In a treadmill set-up, the program assumes (at least) labels of one hind limb: iliac crest, hip, knee, ankle, MTP joint (mtp), and toe.

In a spontaneous walking set-up, the program assumes (at least) labels of left and right hind limbs: crestL / crestR, hipL / hipR, kneeL / kneeR, ankleL/ankleR, mtpL / mtpR, and toeL / toeR.

mano2991 commented 1 year ago

@sollan Thanks i will train my DLC data using 6 data points as you have mentioned in the example.

mano2991 commented 1 year ago

@sollan I have done my analysis as you have mentioned now an new error pops up image

My input data from DLC

https://user-images.githubusercontent.com/13638496/229461783-a190503f-813c-4efa-9507-d7b70031e18e.mp4

Noraml_update_testDLC_resnet50_GaitMar31shuffle1_100000.csv

sollan commented 1 year ago

Hi! The error means no step cycles were detected. However, your videos weren't visible until now, and now I can see that you have a "ladder rung" experiment set-up instead of a treadmill / free walking set-up for gait analysis.

If you are trying to detect the foot falls, there's a different section in the app for that: https://github.com/sollan/alma/wiki/Ladder-rung-footfall-analysis. You can select "toe" as the bodypart to use.

Also, make sure you've edited all relevant parameters in your config.yaml file (https://github.com/sollan/alma/blob/master/config.yaml). Wrong configurations can also cause the analysis to malfunction / give false results.

mano2991 commented 1 year ago

I have enclosed my video. Yes, @sollan i have used lader rug. i though we can use lader for the GAIT analysis.

https://drive.google.com/file/d/1gOuv4hB0QUoobU8MoebJ_v1M6wp68eBl/view?usp=sharing

sollan commented 1 year ago

Well, if you want, you can try the "spontaneous walking" option under kinematics analysis (and check the config.yaml to make sure the configurations are correct), since the mouse is not walking on a treadmill but on a ladder. We didn't test if it works for a "ladder gait" set up, though. Just keep in mind that the results might not be meaningful, since the kinematics analysis was intended for when the animal is walking on even ground.

mano2991 commented 1 year ago

@sollan thanks for your sugesstion. i will use an threadmill for doing the analysis.