Skip to content

Commit

Permalink
Pre-release test version v2 (#127)
Browse files Browse the repository at this point in the history
* Bump for pypi versioning (#124)

* Bump for pypi versioning

* Change authors

* Update abstract readme and authorship

* Update badge to general DOI

* Change pathing to absolute

* Bump versioning
  • Loading branch information
Erikpostt authored Jan 21, 2025
1 parent 2887d24 commit 09db1f7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
27 changes: 13 additions & 14 deletions docs/tutorials/gait_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@
"df_preprocessed = preprocess_imu_data(\n",
" df=df_imu, \n",
" config=config,\n",
" sensor='both'\n",
" sensor='both',\n",
" watch_side='left',\n",
")\n",
"\n",
"print(f\"The dataset of {df_preprocessed.shape[0] / config.sampling_frequency} seconds is automatically resampled to {config.sampling_frequency} Hz.\")\n",
Expand Down Expand Up @@ -728,7 +729,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Out of 725 predictions, 53 (7.3%) were predicted as gait, and 672 (92.7%) as non-gait.\n"
"Out of 725 windows, 53 (7.3%) were predicted as gait, and 672 (92.7%) as non-gait.\n"
]
},
{
Expand Down Expand Up @@ -801,13 +802,13 @@
}
],
"source": [
"from importlib.resources import files\n",
"from paradigma.classification import ClassifierPackage\n",
"from paradigma.pipelines.gait_pipeline import detect_gait\n",
"\n",
"# Set the path to the classifier package\n",
"path_to_assets = Path('../../src/paradigma/assets')\n",
"classifier_package_filename = 'gait_detection_clf_package.pkl'\n",
"full_path_to_classifier_package = path_to_assets / classifier_package_filename\n",
"full_path_to_classifier_package = files('paradigma') / 'assets' / classifier_package_filename\n",
"\n",
"# Load the classifier package\n",
"clf_package = ClassifierPackage.load(full_path_to_classifier_package)\n",
Expand Down Expand Up @@ -1131,7 +1132,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Out of 50 predictions, 0 (0.0%) were predicted as no_other_arm_activity, and 50 (100.0%) as other_arm_activity.\n"
"Out of 50 windows, 0 (0.0%) were predicted as no_other_arm_activity, and 50 (100.0%) as other_arm_activity.\n"
]
},
{
Expand Down Expand Up @@ -1209,7 +1210,7 @@
"\n",
"# Set the path to the classifier package\n",
"classifier_package_filename = 'gait_filtering_clf_package.pkl'\n",
"full_path_to_classifier_package = path_to_assets / classifier_package_filename\n",
"full_path_to_classifier_package = files('paradigma') / 'assets' / classifier_package_filename\n",
"\n",
"# Load the classifier package\n",
"clf_package = ClassifierPackage.load(full_path_to_classifier_package)\n",
Expand All @@ -1221,8 +1222,6 @@
" clf_package=clf_package\n",
")\n",
"\n",
"\n",
"\n",
"n_windows = df_arm_activity.shape[0]\n",
"n_predictions_no_other_arm_activity = df_arm_activity.loc[df_arm_activity['pred_no_other_arm_activity_proba']>=clf_package.threshold].shape[0]\n",
"perc_predictions_no_other_arm_activity = round(100 * n_predictions_no_other_arm_activity / n_windows, 1)\n",
Expand Down Expand Up @@ -1435,16 +1434,16 @@
"name": "stdout",
"output_type": "stream",
"text": [
"{'long': {'time_s': 3.0,\n",
" 'median_range_of_motion': 14.612862824791089,\n",
" '95p_range_of_motion': 19.29924826375146,\n",
" 'median_peak_velocity': 78.64563778043262,\n",
" '95p_peak_velocity': 98.26817330011067},\n",
" 'moderately_long': {'time_s': 13.5,\n",
"{'moderately_long': {'time_s': 13.5,\n",
" 'median_range_of_motion': 14.394662839301768,\n",
" '95p_range_of_motion': 22.658748546739268,\n",
" 'median_peak_velocity': 59.475147961606005,\n",
" '95p_peak_velocity': 105.31356363194875},\n",
" 'long': {'time_s': 3.0,\n",
" 'median_range_of_motion': 14.612862824791089,\n",
" '95p_range_of_motion': 19.29924826375146,\n",
" 'median_peak_velocity': 78.64563778043262,\n",
" '95p_peak_velocity': 98.26817330011067},\n",
" 'all_segment_categories': {'time_s': 16.5,\n",
" 'median_range_of_motion': 14.57460571480515,\n",
" '95p_range_of_motion': 22.180208543070503,\n",
Expand Down
14 changes: 7 additions & 7 deletions docs/tutorials/heart_rate_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 1,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -582,7 +582,7 @@
"print(f\"Original data shapes:\\n- PPG data: {df_ppg.shape}\\n- Accelerometer data: {df_imu.shape}\")\n",
"df_ppg_proc, df_acc_proc = preprocess_ppg_data(\n",
" df_ppg=df_ppg, \n",
" df_imu=df_imu, \n",
" df_acc=df_acc, \n",
" ppg_config=ppg_config, \n",
" imu_config=imu_config, \n",
" start_time_ppg=metadata_time_ppg.start_iso8601,\n",
Expand Down Expand Up @@ -1038,18 +1038,18 @@
}
],
"source": [
"from importlib.resources import files\n",
"from paradigma.pipelines.heart_rate_pipeline import signal_quality_classification\n",
"\n",
"path_to_assets = Path('../../src/paradigma/assets') \n",
"ppg_quality_classifier_package_filename = 'ppg_quality_clf_package.pkl'\n",
"path_to_classifier_package = path_to_assets / ppg_quality_classifier_package_filename\n",
"full_path_to_classifier_package = files('paradigma') / 'assets' / ppg_quality_classifier_package_filename\n",
"\n",
"config = HeartRateConfig()\n",
"\n",
"df_sqa = signal_quality_classification(\n",
" df=df_features, \n",
" config=config, \n",
" full_path_to_classifier_package=path_to_classifier_package\n",
" full_path_to_classifier_package=full_path_to_classifier_package\n",
")\n",
"\n",
"df_sqa"
Expand Down Expand Up @@ -1219,7 +1219,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "paradigma-8ps1bg0Z-py3.12",
"display_name": "paradigma-Fn6RLG4_-py3.11",
"language": "python",
"name": "python3"
},
Expand All @@ -1233,7 +1233,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.6"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down
15 changes: 7 additions & 8 deletions docs/tutorials/tremor_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -221,7 +221,6 @@
"# Set the path to where the prepared data is saved and load the data.\n",
"# Note: the test data is stored in TSDF, but you can load your data in your own way\n",
"path_to_data = Path('../../tests/data')\n",
"path_to_assets = Path('../../src/paradigma/assets')\n",
"path_to_prepared_data = path_to_data / '1.prepared_data' / 'imu'\n",
"\n",
"df_data, metadata_time, metadata_values = load_tsdf_dataframe(path_to_prepared_data, prefix='IMU')\n",
Expand Down Expand Up @@ -394,7 +393,7 @@
"config = IMUConfig()\n",
"print(f'The data is resampled to {config.sampling_frequency} Hz.')\n",
"\n",
"df_preprocessed_data = preprocess_imu_data(df_data, config, sensor='gyroscope')\n",
"df_preprocessed_data = preprocess_imu_data(df_data, config, sensor='gyroscope', watch_side='left')\n",
"\n",
"df_preprocessed_data"
]
Expand Down Expand Up @@ -755,7 +754,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -917,20 +916,20 @@
"[182 rows x 5 columns]"
]
},
"execution_count": 6,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from importlib.resources import files\n",
"from paradigma.pipelines.tremor_pipeline import detect_tremor\n",
"\n",
"print(f'A threshold of {config.movement_threshold} deg\\u00b2/s\\u00b2 is used to determine whether the arm is at rest or in stable posture.')\n",
"\n",
"# Load the pre-trained logistic regression classifier\n",
"path_to_assets = Path('../../src/paradigma/assets') \n",
"tremor_detection_classifier_package_filename = 'tremor_detection_clf_package.pkl'\n",
"full_path_to_classifier_package = path_to_assets / tremor_detection_classifier_package_filename\n",
"full_path_to_classifier_package = files('paradigma') / 'assets' / tremor_detection_classifier_package_filename\n",
"\n",
"# Use the logistic regression classifier to detect tremor and check for rest tremor\n",
"df_predictions = detect_tremor(df_features, config, full_path_to_classifier_package)\n",
Expand All @@ -954,7 +953,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/paradigma/pipelines/gait_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def quantify_arm_swing(
# Group consecutive timestamps into segments, with new segments starting after a pre-specified gap
# Now segments are based on predicted gait without other arm activity for subsequent processes
df_focus[DataColumns.SEGMENT_NR] = create_segments(
time_array=df[DataColumns.TIME],
time_array=df_focus[DataColumns.TIME],
max_segment_gap_s=max_segment_gap_s
)
else:
Expand Down

0 comments on commit 09db1f7

Please sign in to comment.