Skip to content

Depend on micromotion instead of carrying our own quantity-of-motion code - #362

Open
alexarje wants to merge 1 commit into
masterfrom
depend-on-micromotion
Open

Depend on micromotion instead of carrying our own quantity-of-motion code#362
alexarje wants to merge 1 commit into
masterfrom
depend-on-micromotion

Conversation

@alexarje

Copy link
Copy Markdown
Contributor

_qom, _mocap, _posture and _physio move to micromotion and become re-export shims. Public API and behaviour are unchanged.

Why

These functions are credited in their own docstrings to the Still Standing study, which was independently extracting the same measure into micromotion. Left alone, the project's central measure would have existed in two disagreeing copies inside one lab — MGT's band_limited_qom reads 4.0% above micromotion.qom at its own default band and 2.6% above it on a matched band.

The dependency points this way because micromotion needs only numpy, scipy and pandas. Depending on it costs nothing; the reverse would make anyone analysing accelerometer data install a computer-vision stack. It matches the arrow MGT already has to ambiscape.

Behaviour is unchanged

All 53 tests in test_qom, test_mocap, test_posture and test_physio pass against micromotion unmodified — they are vendored there as tests/mgt/ so the guarantee keeps holding. band_limited_qom still returns 5.675 mm/s on the reference 200 Hz optical recording, still defaults to 0.3–15 Hz, still uses a two-point difference and still does not band-limit again afterwards.

Deduplicated

Two genuine duplicates collapsed onto one code path in micromotion:

  • dfa — MGT returned a float, micromotion.dynamics.dfa a dict. Now one implementation with a float-returning wrapper. They agreed to 1.2% on Brownian motion; the survivor sits closer to the analytic 1.5.
  • sample_entropy — agreed to 0.2%, now wraps dynamics.sampen.

Left alone on purpose

axial_rayleigh. Ours returns R = 0.9985 where micromotion.circular.rayleigh_axial returns 0.9222 for the same bimodal input, and only the latter matches the textbook resultant length of the doubled angles. Ours is kept as-is because it is the one under test; the discrepancy deserves its own fix rather than being buried in a move.

Before merging

micromotion is not yet on PyPI, so micromotion>=0.3 will not resolve for end users until it is published. Merge order matters.

…code

_qom, _mocap, _posture and _physio move to the micromotion package and become
re-export shims. Behaviour is unchanged: every one of the 53 tests in
test_qom/test_mocap/test_posture/test_physio passes against micromotion
unmodified, and band_limited_qom still returns 5.675 mm/s on the reference
200 Hz optical recording.

Why this direction. These functions are credited in their own docstrings to the
Still Standing study, which was independently extracting the same measure into
micromotion — so the project's central measure was about to exist in two
disagreeing copies inside one lab. micromotion needs only numpy, scipy and
pandas, so depending on it costs nothing, whereas the reverse would make anyone
analysing accelerometer data install a computer-vision stack. It matches the
arrow MGT already has to ambiscape.

Two duplicate implementations were collapsed onto one code path in micromotion:
dfa (float wrapper over the dict-returning version; they agreed to 1.2 per cent
on Brownian motion) and sample_entropy (agreed to 0.2 per cent).

One item is deliberately left alone: axial_rayleigh. Ours returns R = 0.9985
where micromotion's circular.rayleigh_axial returns 0.9222 for the same bimodal
input, and only the latter matches the textbook resultant length of the doubled
angles. Ours is kept as-is here because it is the one under test; the
discrepancy needs resolving on its own rather than inside this move.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant