Skip to content

Commit

Permalink
Merge pull request #34 from ComputationalPhysiology/pre-commit-ci-upd…
Browse files Browse the repository at this point in the history
…ate-config

[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
finsberg authored Aug 21, 2024
2 parents 5538151 + 71262d6 commit 3991f86
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.5.7'
rev: 'v0.6.1'
hooks:
# Run the linter.
- id: ruff
Expand Down
31 changes: 17 additions & 14 deletions docs/features.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"outputs": [],
"source": [
"from pathlib import Path\n",
"import matplotlib.pyplot as plt # For plotting\n",
"import mps # Package to load data\n",
"import mps_motion # Package for motion analysis\n",
"import matplotlib.pyplot as plt # For plotting\n",
"import mps # Package to load data\n",
"import mps_motion # Package for motion analysis\n",
"import ap_features as apf # Package for analzying traces\n",
"import numpy as np\n",
"import logging\n",
Expand Down Expand Up @@ -124,11 +124,9 @@
"metadata": {},
"outputs": [],
"source": [
"reference_frame_index = (\n",
" mps_motion.motion_tracking.estimate_referece_image_from_velocity(\n",
" t=data.time_stamps[:-5],\n",
" v=v_mean_norm,\n",
" )\n",
"reference_frame_index = mps_motion.motion_tracking.estimate_referece_image_from_velocity(\n",
" t=data.time_stamps[:-5],\n",
" v=v_mean_norm,\n",
")\n",
"reference_frame = data.time_stamps[reference_frame_index]"
]
Expand Down Expand Up @@ -221,9 +219,11 @@
" t=data.time_stamps[start : end - spacing],\n",
")\n",
"\n",
"\n",
"def normalize(y):\n",
" return (y - np.min(y)) / (np.max(y) - np.min(y))\n",
"\n",
"\n",
"u_norm = normalize(u.y)\n",
"v_norm = normalize(v.y)\n",
"time = normalize(u.t)\n",
Expand All @@ -235,6 +235,7 @@
"indices_u = [7, 16, 31, 43, 56]\n",
"indices_v = [i - spacing // 2 for i in indices_u]\n",
"\n",
"\n",
"def arrow_annotate(axi, y, t1, t2, label):\n",
" mid_t = 0.5 * (t1 + t2)\n",
" axi.annotate(\n",
Expand All @@ -250,7 +251,8 @@
" size=\"large\",\n",
" bbox=dict(boxstyle=\"circle\", fc=\"w\", ec=\"k\"),\n",
" )\n",
" \n",
"\n",
"\n",
"def adjust_spines(ax, spines):\n",
" for loc, spine in ax.spines.items():\n",
" if loc in spines:\n",
Expand All @@ -271,6 +273,7 @@
" # no xaxis ticks\n",
" ax.xaxis.set_ticks([])\n",
"\n",
"\n",
"fig, ax = plt.subplots(2, 1, sharex=True, figsize=(8, 8))\n",
"\n",
"\n",
Expand All @@ -293,7 +296,7 @@
" size=\"large\",\n",
" bbox=dict(boxstyle=\"circle\", fc=\"w\", ec=\"k\"),\n",
" )\n",
" \n",
"\n",
"# Beat duratiom\n",
"arrow_annotate(\n",
" ax[0],\n",
Expand Down Expand Up @@ -372,12 +375,12 @@
"ax[1].set_xticks(points)\n",
"ax[1].set_xticklabels([f\"{vi:.0f}\" for vi in t_points])\n",
"ax[1].set_xlabel(\"Time [ms]\")\n",
" \n",
"\n",
"for axi in ax:\n",
" axi.grid()\n",
" \n",
"ax[0].set_ylabel(\"Displacement [\\u00B5m]\")\n",
"ax[1].set_ylabel(\"Velocity [\\u00B5m / s]\")\n",
"\n",
"ax[0].set_ylabel(\"Displacement [\\u00b5m]\")\n",
"ax[1].set_ylabel(\"Velocity [\\u00b5m / s]\")\n",
"\n",
"legend = \"\\n\".join(\n",
" [\n",
Expand Down
1 change: 1 addition & 0 deletions docs/gui.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"outputs": [],
"source": [
"from IPython.display import Video\n",
"\n",
"Video(\"mps-motion-gui.mp4\", width=700, height=400)"
]
}
Expand Down
19 changes: 9 additions & 10 deletions docs/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
"outputs": [],
"source": [
"from pathlib import Path\n",
"import matplotlib.pyplot as plt # For plotting\n",
"import mps # Package to load data\n",
"import mps_motion # Package for motion analysis\n",
"import matplotlib.pyplot as plt # For plotting\n",
"import mps # Package to load data\n",
"import mps_motion # Package for motion analysis\n",
"import logging\n",
"\n",
"# Set loglevel to WARNING to not spill the output\n",
Expand Down Expand Up @@ -167,11 +167,9 @@
"outputs": [],
"source": [
"v_norm = v.norm().mean().compute()\n",
"reference_frame_index = (\n",
" mps_motion.motion_tracking.estimate_referece_image_from_velocity(\n",
" t=data.time_stamps[:-5],\n",
" v=v_norm,\n",
" )\n",
"reference_frame_index = mps_motion.motion_tracking.estimate_referece_image_from_velocity(\n",
" t=data.time_stamps[:-5],\n",
" v=v_norm,\n",
")\n",
"reference_frame = data.time_stamps[reference_frame_index]\n",
"print(f\"Found reference frame at index {reference_frame_index} and time {reference_frame:.2f}\")"
Expand Down Expand Up @@ -233,7 +231,7 @@
"outputs": [],
"source": [
"u_norm = u.norm()\n",
"print(u_norm) # FrameSequence((817, 469, 267), dx=0.8125, scale=0.4)"
"print(u_norm) # FrameSequence((817, 469, 267), dx=0.8125, scale=0.4)"
]
},
{
Expand Down Expand Up @@ -313,6 +311,7 @@
"outputs": [],
"source": [
"from IPython.display import Video\n",
"\n",
"Video(movie_path)"
]
},
Expand Down Expand Up @@ -376,7 +375,7 @@
"outputs": [],
"source": [
"# Green-Lagrange strain\n",
"print(mech.E) # TensorFrameSequence((817, 469, 267, 2, 2), dx=0.8125, scale=0.4)\n",
"print(mech.E) # TensorFrameSequence((817, 469, 267, 2, 2), dx=0.8125, scale=0.4)\n",
"\n",
"# Plot the X-component of the Green-Lagrange strain\n",
"fig, ax = plt.subplots()\n",
Expand Down

0 comments on commit 3991f86

Please sign in to comment.