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

"Input vector should be 1-D" #35

Closed Projector3567 closed 9 months ago

Projector3567 commented 11 months ago

While attempting to extract kinematic parameters using the extract_parameters function from KinematicsFunctions, I encountered a ValueError that says "Input vector should be 1-D". I'm using Python 3.11.

  1. I loaded .csv file from DLC output for treadmill.
  2. I defined speed.
  3. When I click extract parameters I get a window pop up with the following error:

Traceback (most recent call last): File "...AnalyzeStride.py", line 697, in ExtractParameters parameters, pd_dataframe_coords, is_stance, bodyparts = KinematicsFunctions.extract_parameters(...) File "...KinematicsFunctions.py", line 733, in extract_parameters pairwise_dtw_res_x_5 = pairwise_dtw(toe_xs) File "...KinematicsFunctions.py", line 194, in pairwisedtw distance, = fastdtw.fastdtw(iterable[i], iterable[j], dist=euclidean) File "...site-packages\fastdtw\fastdtw.py", line 53, in fastdtw return fastdtw(x, y, radius, dist) [Several recursive calls in fastdtw.py] File "...site-packages\fastdtw\fastdtw.py", line 130, in dtw return dtw(x, y, None, dist) File "...site-packages\fastdtw\fastdtw.py", line 141, in __dtw dt = dist(x[i-1], y[j-1]) File "...site-packages\scipy\spatial\distance.py", line 536, in euclidean return minkowski(u, v, p=2, w=w) File "...site-packages\scipy\spatial\distance.py", line 479, in minkowski u = _validate_vector(u) File "...site-packages\scipy\spatial\distance.py", line 318, in _validate_vector raise ValueError("Input vector should be 1-D.") ValueError: Input vector should be 1-D.

The error originates from the euclidean distance function in scipy.spatial.distance. The euclidean function expects 1-D vectors as input. However, it seems that one or both of the vectors being passed to it are not 1-D. This might be due to the data being processed or perhaps the way the fastdtw function is handling the data.

Any guidance on how to resolve this issue would be greatly appreciated.

sollan commented 11 months ago

Please share the following for us to identify the root cause:

  1. Header (column names) and a few rows of your raw data (DLC output)
  2. A screenshot of the ALMA UI which led up to the error, including all the options you selected before clicking the extract parameters button
  3. Your config.yaml
Projector3567 commented 11 months ago

This is our dataset: image

ALMA screenshot: image

Config.yaml: image

sollan commented 11 months ago

Hi! The set-up above looks alright. I wasn't able to replicate the error with the same data format and configurations on an existing installation.

I would recommend switching to Python 3.8 and see if the error disappears, as that's the version proven to work. If the error persists, it could be due to dependencies (and not necessarily fastdtw or scipy). Please share a copy of your dependency versions in that case for replication.

Projector3567 commented 9 months ago

N272_treadmill_30_baselineDLC_resnet50_2023 RtSt KinematicsAug29shuffle1_650000.csv I switched to Python 3.8 and managed to get it running. However, I don't receive any output. I am attaching the file I used to try to extract the parameters from. Thanks a lot.

sollan commented 9 months ago

Hi, to debug issues regarding data analysis, we need more information (configurations and recording parameters). Please get in touch directly :)

I'll close this thread, as the initial problem was solved by using a compatible Python version.