Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arm swing quantification #94

Merged
merged 63 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
3c43c8f
Set lower bound MFCCs to filter cutoff
Erikpostt Dec 18, 2024
7b1409d
Add flexibility to arm swing feature extraction methods
Erikpostt Dec 19, 2024
13a5289
Add flexibility to tabulating windows methods
Erikpostt Dec 19, 2024
400678e
Merge branch 'create-prepared-data' of github.com:biomarkersParkinson…
Erikpostt Dec 19, 2024
0ca87de
Add flexibility to tabulating windows methods and update angle features
Erikpostt Dec 19, 2024
8ded47c
Remove redundant features
Erikpostt Dec 19, 2024
52c7f88
Merge branch 'main' of github.com:biomarkersParkinson/paradigma into …
Erikpostt Dec 30, 2024
6d86658
Simplify
Erikpostt Dec 30, 2024
ae8fc41
Updating Poetry
Erikpostt Dec 30, 2024
7ccd195
Remove angle and velocity from preprocessing
Erikpostt Dec 30, 2024
bd473da
Change rotation axes
Erikpostt Dec 31, 2024
ec094e7
Adjust parameters segmentation
Erikpostt Dec 31, 2024
dcb58df
Add flexibility for pathing
Erikpostt Dec 31, 2024
28b41d2
Return a Series instead of df
Erikpostt Dec 31, 2024
5d4a715
ensure features dont scale when storing
Erikpostt Dec 31, 2024
602f392
Update tabulate windows
Erikpostt Dec 31, 2024
aa9c5bc
Vectorize merging of predictions with timestamps
Erikpostt Jan 2, 2025
7f81265
Add flexibility to filtering gait parameters
Erikpostt Jan 2, 2025
45ce907
Merge branch 'main' of github.com:biomarkersParkinson/paradigma into …
Erikpostt Jan 2, 2025
2a5f21a
Solve conflict
Erikpostt Jan 2, 2025
3e81fc2
Continue process when dataframe is empty
Erikpostt Jan 2, 2025
e362cc0
Modify quantification
Erikpostt Jan 3, 2025
1cc1290
Modify quantification
Erikpostt Jan 3, 2025
0cd72d0
Typo
Erikpostt Jan 3, 2025
27239d9
Add flexibility for pred proba to merging
Erikpostt Jan 3, 2025
5b17c96
Add flexibility for pred proba to merging
Erikpostt Jan 3, 2025
cfe5faf
Add flexibility for pred proba to merging
Erikpostt Jan 3, 2025
90085ce
Solve numpy/list bug
Erikpostt Jan 3, 2025
845165f
Solve numpy/list bug
Erikpostt Jan 3, 2025
28f8231
Solve numpy/list bug
Erikpostt Jan 3, 2025
a6cf1ac
Solve numpy/list bug
Erikpostt Jan 3, 2025
c2de121
Start catching errors
Erikpostt Jan 3, 2025
e540af8
Start catching errors
Erikpostt Jan 3, 2025
a332126
Fix np.nan issue
Erikpostt Jan 3, 2025
0a33e5d
Fix np.nan issue
Erikpostt Jan 3, 2025
15e2139
Reduce memory reqs
Erikpostt Jan 3, 2025
a28b0a4
Temp for debugging
Erikpostt Jan 3, 2025
7c375b2
Temp for debugging
Erikpostt Jan 3, 2025
519f914
Typo
Erikpostt Jan 3, 2025
ca15a8d
Expand feature extraction docs
Erikpostt Jan 6, 2025
4e03eb4
Update notebooks
Erikpostt Jan 6, 2025
c1ed1b0
Add '1' to MFCC filter points
Erikpostt Jan 6, 2025
7ae822d
Modify test data
Erikpostt Jan 7, 2025
1b6865f
Change mfcc param
Erikpostt Jan 7, 2025
5b82d52
Change mfcc param
Erikpostt Jan 7, 2025
3d3c9c2
Structure
Erikpostt Jan 7, 2025
a888022
Reset legacy for the time being
Erikpostt Jan 7, 2025
6bd4f4e
Adjust test scripts to changes
Erikpostt Jan 7, 2025
e32fd5e
Adjust tremor to changes
Erikpostt Jan 7, 2025
8beef37
structure docstrings
Erikpostt Jan 7, 2025
b0366f8
Improve consistency of docstrings
Erikpostt Jan 7, 2025
617437d
Structure testing
Erikpostt Jan 7, 2025
a76e6a4
Update test data
Erikpostt Jan 7, 2025
f874984
Resolve pytype error
Erikpostt Jan 7, 2025
27de00a
Merge branch 'main' of github.com:biomarkersParkinson/paradigma into …
Erikpostt Jan 7, 2025
fa16a8d
Adjust tabulate_windows to new version
Erikpostt Jan 7, 2025
48b9f02
Ensure first column is returned for PPG
Erikpostt Jan 7, 2025
e3a996e
Solve issues raised by reviewer
Erikpostt Jan 8, 2025
7023f6a
Resolve conflict
Erikpostt Jan 8, 2025
076dcd2
Rerun notebooks ppg
Erikpostt Jan 8, 2025
ff4ccf5
Change scalers, classifiers and thresholds
Erikpostt Jan 8, 2025
a4ca13f
Update test files
Erikpostt Jan 8, 2025
2e34ec7
Add aggregation of quantification
Erikpostt Jan 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 75 additions & 10 deletions docs/notebooks/gait/gait_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
"outputs": [],
"source": [
"import os\n",
"from paradigma.gait.gait_analysis import extract_gait_features_io, detect_gait_io, extract_arm_activity_features_io, filter_gait_io\n",
"from paradigma.config import IMUConfig, GaitFeatureExtractionConfig, GaitDetectionConfig, ArmActivityFeatureExtractionConfig, FilteringGaitConfig\n",
"\n",
"from paradigma.config import IMUConfig, GaitFeatureExtractionConfig, GaitDetectionConfig, \\\n",
" ArmActivityFeatureExtractionConfig, FilteringGaitConfig, ArmSwingQuantificationConfig\n",
"from paradigma.gait.gait_analysis import extract_gait_features_io, detect_gait_io, \\\n",
" extract_arm_activity_features_io, filter_gait_io, quantify_arm_swing_io\n",
"from paradigma.preprocessing import preprocess_imu_data_io"
]
},
Expand All @@ -32,8 +35,21 @@
"branch = 'gait'\n",
"sensor = 'imu'\n",
"\n",
"gait_detection_classifier_filename = 'gait_detection_classifier.pkl'\n",
"gait_detection_scaler_filename = 'gait_detection_scaler_params.json'\n",
"gait_detection_threshold_filename = 'gait_detection_threshold.txt'\n",
"\n",
"gait_filtering_classifier_filename = 'gait_filtering_classifier.pkl'\n",
"gait_filtering_scaler_filename = 'gait_filtering_scaler_params.json'\n",
"gait_filtering_threshold_filename = 'gait_filtering_threshold.txt'\n",
"\n",
"path_to_data = '../../../tests/data'\n",
"path_to_classifiers = os.path.join(path_to_data, '0.classification', branch)\n",
"\n",
"path_to_classifier_input = os.path.join(path_to_data, '0.classification', branch)\n",
"path_to_classifiers = os.path.join(path_to_classifier_input, 'classifiers')\n",
"path_to_scalers = os.path.join(path_to_classifier_input, 'scalers')\n",
"path_to_thresholds = os.path.join(path_to_classifier_input, 'thresholds')\n",
"\n",
"path_to_sensor_data = os.path.join(path_to_data, '1.prepared_data', sensor)\n",
"path_to_preprocessed_data = os.path.join(path_to_data, '2.preprocessed_data', sensor)\n",
"path_to_extracted_features = os.path.join(path_to_data, '3.extracted_features', branch)\n",
Expand All @@ -57,7 +73,13 @@
"outputs": [],
"source": [
"config = IMUConfig()\n",
"preprocess_imu_data_io(path_to_sensor_data, path_to_preprocessed_data, config, sensor='both')"
"\n",
"preprocess_imu_data_io(\n",
" input_path=path_to_sensor_data, \n",
" output_path=path_to_preprocessed_data, \n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency you can change this to path_to_input and path_to_output

" config=config, \n",
" sensor='both'\n",
")"
]
},
{
Expand All @@ -74,7 +96,12 @@
"outputs": [],
"source": [
"config = GaitFeatureExtractionConfig()\n",
"extract_gait_features_io(path_to_preprocessed_data, path_to_extracted_features, config)"
"\n",
"extract_gait_features_io(\n",
" config=config,\n",
" path_to_preprocessed_input=path_to_preprocessed_data, \n",
" path_to_output=path_to_extracted_features, \n",
" )"
]
},
{
Expand All @@ -91,7 +118,17 @@
"outputs": [],
"source": [
"config = GaitDetectionConfig()\n",
"detect_gait_io(path_to_extracted_features, path_to_predictions, path_to_classifiers, config)"
"\n",
"full_path_to_classifier = os.path.join(path_to_classifiers, gait_detection_classifier_filename)\n",
"full_path_to_scaler = os.path.join(path_to_scalers, gait_detection_scaler_filename)\n",
"\n",
"detect_gait_io(\n",
" config=config, \n",
" path_to_input_features=path_to_extracted_features, \n",
" path_to_output=path_to_predictions, \n",
" full_path_to_classifier=full_path_to_classifier, \n",
" full_path_to_scaler=full_path_to_scaler\n",
")"
]
},
{
Expand All @@ -108,7 +145,15 @@
"outputs": [],
"source": [
"config = ArmActivityFeatureExtractionConfig()\n",
"extract_arm_activity_features_io(path_to_preprocessed_data, path_to_predictions, path_to_classifiers, path_to_extracted_features, config)"
"full_path_to_threshold = os.path.join(path_to_thresholds, gait_detection_threshold_filename)\n",
"\n",
"extract_arm_activity_features_io(\n",
" config=config,\n",
" path_to_timestamp_input=path_to_preprocessed_data, \n",
" path_to_prediction_input=path_to_predictions, \n",
" full_path_to_threshold=full_path_to_threshold, \n",
" path_to_output=path_to_extracted_features\n",
" )"
]
},
{
Expand All @@ -125,7 +170,16 @@
"outputs": [],
"source": [
"config = FilteringGaitConfig()\n",
"filter_gait_io(path_to_extracted_features, path_to_classifiers, path_to_predictions, config)"
"full_path_to_classifier = os.path.join(path_to_classifiers, gait_filtering_classifier_filename)\n",
"full_path_to_scaler = os.path.join(path_to_scalers, gait_filtering_scaler_filename)\n",
"\n",
"filter_gait_io(\n",
" config=config,\n",
" path_to_feature_input=path_to_extracted_features, \n",
" path_to_output=path_to_predictions,\n",
" full_path_to_classifier=full_path_to_classifier, \n",
" full_path_to_scaler=full_path_to_scaler\n",
")"
]
},
{
Expand All @@ -141,8 +195,19 @@
"metadata": {},
"outputs": [],
"source": [
"# config = ArmSwingQuantificationConfig()\n",
"# quantify_arm_swing_io(path_to_extracted_features, path_to_predictions, path_to_classifiers, path_to_quantification, config)"
"asq_config = ArmSwingQuantificationConfig()\n",
"imu_config = IMUConfig()\n",
"\n",
"imu_config.set_sensor('gyroscope')\n",
"\n",
"quantify_arm_swing_io(\n",
" imu_config=imu_config,\n",
" asq_config=asq_config,\n",
" path_to_timestamp_input=path_to_preprocessed_data, \n",
" path_to_prediction_input=path_to_predictions, \n",
" full_path_to_threshold=full_path_to_threshold, \n",
" path_to_output=path_to_quantification, \n",
")"
]
}
],
Expand Down
5 changes: 5 additions & 0 deletions docs/tutorials/data_preparation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@
"\n",
"watch_side = 'right'\n",
"\n",
"df_imu[DataColumns.ACCELEROMETER_Y] *= -1\n",
"df_imu[DataColumns.ACCELEROMETER_Z] *= -1\n",
"df_imu[DataColumns.GYROSCOPE_Y] *= -1\n",
"df_imu[DataColumns.GYROSCOPE_Z] *= -1\n",
"\n",
"df_imu = invert_watch_side(df_imu, watch_side)\n",
"df_imu.head(5)"
]
Expand Down
Loading
Loading