DOI: 10.5281/zenodo.16961465
title: Beyond propulsion: muscle proprioception enables hydrodynamic sensing in fish body

description: Project: Beyond propulsion: muscle proprioception enables hydrodynamic sensing in fish body

Journal: Proceedings of the Royal Society BAuthors: Afridi et al.DOI: doi.org/10.1098/rspb.2025.0474.

Repository Contents

1. Code File/

Contains all analysis scripts and raw data needed to reproduce the results.

a) Matlab code/





Dataset_actual_joint_angles.(csv|mat) – Ground-truth joint angle data extracted from video-based kinematics.




Dataset_BPNN_pred_joint_angles.(csv|mat) – Predicted joint angles from the BPNN model.




Dataset_CNN_pred_joint_angles.(csv|mat) – Predicted joint angles from the CNN model.




Dataset_LSTM_pred_joint_angles.(csv|mat) – Predicted joint angles from the LSTM model.




FishPoseDLCtoJointSpace.m – Script to convert DeepLabCut (DLC) outputs into joint space angles.




FishPosefromMLModelsPrediction.m – Script to reconstruct full-body pose from ML-predicted joint angles.




detect_EMGmaxima_dynamic_window.m – Detect EMG onset peaks using adaptive windowing.




instantaneous_phase_shift.m – Compute phase alignment between predicted and measured joint angles.




rmse.m – Utility to calculate Root Mean Square Error (RMSE).




TimeOrderAnalysisOfEMGandKinematicsSFcndtnWholeBodyNewDevice.m – Main script for computing Δt (delay) between EMG onset and body displacement (used in proprioceptive sensing analysis).




RMSE_0.274.csv – Example RMSE results at 0.274 m/s swimming speed.




Test DLC filtered data.csv, Test EMG raw data.csv – Example datasets used for validation.



b) Python code/





1 BPNN code.py – Neural network model (Backpropagation NN).




2 LSTM code.py – Neural network model (Long Short-Term Memory).




3 CNN code.py – Neural network model (Convolutional NN).




CustomFunctions.py – Helper functions for preprocessing and model training.




FilterAndFeatureExtraction.py – Preprocessing script for EMG signals: filtering and feature extraction.



c) EMG and Kinematic Data/

Contains synchronized raw EMG and kinematic recordings for all flow conditions.





LaminarFlowDATA/ – EMG and kinematics for control (steady laminar flow).




5cmD/ – EMG and kinematics for fish swimming behind 5 cm D-section cylinder (Kármán vortices).




7cmD/ – EMG and kinematics for fish swimming behind 7 cm D-section cylinder.



File naming convention:





EMG SBJ#_Condition.csv – EMG data.




Kin SBJ#_Condition.csv – Corresponding kinematic data.




EMG Stream_YYYY_MM_DD_HHMMSS.csv / Kin Stream_YYYY_MM_DD_HHMMSS.csv – Continuous stream data recordings.



How Files Relate to Manuscript Results





Figure 2 (ML validation):





Generated using 1 BPNN code.py, 2 LSTM code.py, 3 CNN code.py on data from LaminarFlowDATA/.




Output datasets: Dataset_BPNN_pred_joint_angles, Dataset_CNN_pred_joint_angles, Dataset_LSTM_pred_joint_angles.




Validation metrics (RMSE, phase alignment) computed with rmse.m and instantaneous_phase_shift.m.






Figure 3 (Temporal Δt analysis):





Uses TimeOrderAnalysisOfEMGandKinematicsSFcndtnWholeBodyNewDevice.m on data from LaminarFlowDATA/, 5cmD/, and 7cmD/.




Input: EMG and kinematic .csv files.




Output: Distributions of Δt delays used in Figure 3c, f, i.






Supplementary Figures S18–S19 (CFD comparison):





Not reproduced here (done via IBAMR simulations by collaborators), but synchronized EMG and kinematic datasets are provided for linking experimental recordings to CFD conditions.





Software Requirements





MATLAB (R2020a or later) – for temporal analysis, RMSE, Δt calculation, pose reconstruction.




Python (3.8 or later) – for neural network training and validation.




Dependencies: TensorFlow/Keras, NumPy, pandas, matplotlib (versions compatible with Python 3.8).



Instructions for Reproducing Key Results





ML-based validation (Figure 2):





Run FilterAndFeatureExtraction.py to preprocess EMG signals.




Train models using 1 BPNN code.py, 2 LSTM code.py, and 3 CNN code.py.




Evaluate predictions with rmse.m and instantaneous_phase_shift.m.






Body pose reconstruction:





Run FishPoseDLCtoJointSpace.m to generate joint angles from kinematic data.




Apply FishPosefromMLModelsPrediction.m to reconstruct body pose from ML-predicted angles.






Temporal analysis of proprioception (Figure 3):





Use detect_EMGmaxima_dynamic_window.m to identify EMG onset peaks.




Run TimeOrderAnalysisOfEMGandKinematicsSFcndtnWholeBodyNewDevice.m with EMG and kinematic data to compute Δt distributions.





Citation

If you use these data or scripts, please cite:Rahdar Hussain Afridi et al., “Beyond propulsion: muscle proprioception enables hydrodynamic sensing in fish body,” Proceedings of the Royal Society B, 2025, doi: https://doi.org/10.1098/rspb.2025.0474.