Skip to content

DeprecationWarning in extract_spontaneous_parameters() due to improper array-to-scalar conversion (NumPy 1.25) #47

@qarden

Description

@qarden

When analyzing spontaneous gait using ALMA, I encountered a DeprecationWarning caused by the attempted conversion of a multidimensional NumPy array into a scalar. This occurs in KinematicsFunctions.py during the extract_spontaneous_parameters() call.

Traceback (most recent call last):
File "C:\Users\DSI\slip_detector\Panels\AnalyzeStride.py", line 702, in ExtractParameters
parameters, pd_dataframe_coords, is_stance, bodyparts = KinematicsFunctions.extract_spontaneous_parameters(
self.frame_rate, self.df, self.cutoff_f, self.pixels_per_cm, self.no_outlier_filter, self.dragging_filter)
File "C:\Users\DSI\slip_detector\Functions\KinematicsFunctions.py", line 1127, in extract_spontaneous_parameters
treadmill_y = float(stance_threshold + np.sqrt(gm.covariances_[np.where(gm.means_ == stance_threshold)]))
DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)

System Info:
OS: Windows 10
Python: 3.10.14 (via conda environment venv_python_3_10)
NumPy: 1.26.0
ALMA commit: latest from main branch of sollan/slip_detector
Analysis type: spontaneous gait
Input: DLC CSV

After this error I decreased the numpy version to 1.23.25 and got this error message:

[]
Traceback (most recent call last):
File "C:\Users\DSI\slip_detector\Panels\AnalyzeStride.py", line 702, in ExtractParameters
parameters, pd_dataframe_coords, is_stance, bodyparts = KinematicsFunctions.extract_spontaneous_parameters(self.frame_rate, self.df, self.cutoff_f, self.pixels_per_cm, self.no_outlier_filter, self.dragging_filter)
File "C:\Users\DSI\slip_detector\Functions\KinematicsFunctions.py", line 1367, in extract_spontaneous_parameters
return pd.DataFrame(data=np.array([
numpy.VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.

Request:
Would it be possible to update the main repo with this compatibility fix? I’m happy to test any proposed solution

sideview_1_3DLC_resnet50_Gait_Side_ViewApr28shuffle1_250000.csv

Config.yaml file:

GUI settings

window_height: 1100 # height of the GUI window - adjust to fit your screen resolution
window_width: 1400 # width of the GUI window

video specs

frame_rate: 119.88 # frame rate of your video data (n. frames per second)

ladder rung analysis

likelihood_threshold: 0.1 # threshold of bodypart coordinate estimation likelihood, highlight estimates above threshold for ladder rung user validation
depth_threshold: 0.8 # percentage of recovery relative to depth of previous footfall / slip
threshold: '' # for threshold method in ladder rung

kinematics analysis

lowpass_filter_cutoff: 6 # cutoff frequency for Butterworth filter applied to bodypart coordinate estimation in kinematics analysis
pixels_per_cm: '20' # provide px - cm ratio of the video, if known
cm_speed: '' # only for semi-automated kinematics analysis
px_to_cm_speed_ratio: 0.4806 # only for fully automated kinematics analysis
right_to_left: False # direction of walking (False if animal walks from left to right)
no_outlier_filter: False # only for spontaneous walking setup (requires more testing; True to get parameters for all step cycles)
dragging_filter: False # only for spontaneous walking setup (requires more testing; False to get parameters also for potentially 100% dragging mice)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions