moonbit_forceplate

    MoonBit sports science and biomechanics force plate signal analysis library

    force-plate
    biomechanics
    jump-analysis
    dsp
    cop-sway
    Download zip
    Author
    Version
    0.1.1
    License
    Apache-2.0
    Last updated
    2 months ago
    Downloads
    36

    No dependencies

    #MoonBit Force Plate

    CI License

    MoonBit libraries and command-line tools for force-plate biomechanics. The project turns synchronized force, moment, timestamp, and center-of-pressure (COP) samples into reproducible jump, kinetics, posturography, bilateral-loading, quality, and export reports.

    The implementation is designed for real acquisition data: malformed timestamps, non-finite channels, short recordings, duplicate samples, invalid filter parameters, zero denominators, and incomplete COP trajectories are handled explicitly instead of being silently converted into plausible-looking metrics.

    #Capabilities

    • Force and COP primitives, calibration, robust baseline estimation, metadata validation, feature vectors, windowed statistics, and signal agreement metrics.
    • Butterworth low/high/band-pass, notch, moving-average, Savitzky–Golay, zero-phase, and validated filter chains.
    • Linear, cubic-spline, Akima/PCHIP resampling, time normalization, and complete multichannel trial resampling.
    • Net force, impulse, RFD, velocity, displacement, work, mechanical envelopes, and force-window statistics.
    • Movement onset, take-off/landing, persistent thresholds, hysteresis segments, contact intervals, and phase metrics.
    • CMJ, squat jump, drop jump, pogo, IMTP, landing impact, readiness, and repeated-jump summaries.
    • COP path, velocity, covariance, confidence ellipse, convex hull, spectral, entropy, crossing, and windowed stability metrics.
    • Bilateral load shares, symmetry/asymmetry indices, pointwise profiles, binned profiles, and integrated load balance.
    • Quality gates, robust MAD outlier detection, interpolation repair, physical-range clamping, and auditable repair reports.
    • Repeated-session assessment with robust trial statistics, baseline comparison, direction-aware change interpretation, readiness scoring, and repeatability/outlier reports.
    • CSV, JSON, Markdown, ASCII, batch, stage-trace, feature, and quality-report exports.
    • A composable pipeline package with quality gates, optional tare/filter stages, CMJ/sway/bilateral workflows, batch execution, and stage diagnostics.

    #Package layout

    PackageResponsibility
    coreTypes, calibration, metadata, timebase, robust statistics, signal comparison, trial/window features
    filterValidated DSP filters and auditable filter chains
    resampleInterpolation, splines, time normalization, and multichannel trial resampling
    kineticForce-derived quantities, integration, impulse, RFD, work, and kinematic envelopes
    eventOnset, contact, hysteresis, jump-event, phase, TKEO, and CUSUM detection
    jumpCMJ, SJ, DJ, IMTP, pogo, landing, stiffness, readiness, and repeated-trial metrics
    swayCOP metrics, ellipse/hull/spectral analysis, stability, entropy, and sliding windows
    asymmetryBilateral metrics, trajectories, profiles, bins, and load integration
    qualityTrial validation, quality scoring, quality gates, outliers, repair, and report export
    assessmentRepeated-trial statistics, session summaries, baseline comparison, readiness, and report export
    pipelineAuditable single-trial and batch workflows plus CSV diagnostics
    exportMachine-readable and human-readable report generation
    cmd / cmd/mainDeterministic synthetic fixtures, benchmark API, and runnable CLI demonstration

    #Quick start

    Install the current stable MoonBit toolchain, then run the demo:

    moon update moon check --deny-warn moon test --deny-warn moon run cmd/main

    The CLI generates deterministic synthetic CMJ, IMTP, and sway trials, applies a zero-phase filter, prints biomechanical reports, and runs the same CMJ pipeline used by the benchmark API.

    Library consumers can compose the pipeline from a ForceTrial:

    let quality = @quality.assess_trial(
    trial,
    @quality.QualityPolicy::default(),
    )
    let result = @pipeline.run_cmj(
    trial,
    body_mass_kg,
    @pipeline.PipelineOptions::default(),
    )
    match result.status {
    @pipeline.PipelineStatus::Completed => println("analysis complete")
    @pipeline.PipelineStatus::Rejected => println("quality gate rejected trial")
    }

    For a batch, use @pipeline.run_cmj_batch; for pre-analysis ingestion use @pipeline.run_quality_batch. The quality and pipeline reports retain issue categories, scores, stage status, changed-sample counts, and exportable traces.

    For repeated testing, convert scalar results into an assessment session. The assessment layer ignores non-finite values, applies the configured quality floor, and keeps baseline changes direction-aware:

    let trial = @assessment.AssessmentTrial::from_cmj(
    "cmj-01",
    1,
    98.0,
    true,
    jump_height_m=0.42,
    peak_force_n=2350.0,
    rsi_modified=0.44,
    peak_power_w=2176.0,
    takeoff_velocity_m_s=1.75,
    )
    let session = @assessment.AssessmentSession::new(
    "session-2026-08-20",
    "morning CMJ",
    [trial],
    )
    let summary = @assessment.summarize_session(
    session,
    @assessment.AssessmentPolicy::default(),
    )
    let csv = @assessment.session_summary_to_csv(summary)

    #Benchmark

    The benchmark performs real work: synthetic trial generation, quality assessment, the configured pipeline, event detection, kinematics, and CMJ metrics. Its checksum accumulates peak force so a benchmark cannot accidentally measure an unused result.

    moon run cmd/main

    The CLI benchmark configuration is 3 iterations, 1,000 Hz, 75 kg, and a requested maximum of 2,000 samples. Two consecutive local Windows runs on 2026-08-19 produced:

    iterations=3 samples=1700 elapsed_ms=8 trials_per_second=375 mean_jump_height_m=0.1961330000000001 checksum_peak_force_n=7060.7880000000005 iterations=3 samples=1700 elapsed_ms=12 trials_per_second=250 mean_jump_height_m=0.1961330000000001 checksum_peak_force_n=7060.7880000000005

    Elapsed time is machine- and toolchain-dependent; the sample count, configuration, and checksum are the reproducibility anchors. Use @cmd.run_cmj_benchmark when a program needs structured results rather than console text.

    #Verification

    The repository keeps tests next to their package and emphasizes boundary behavior as well as nominal biomechanical fixtures:

    moon fmt --check moon check --deny-warn moon test --deny-warn moon check --target all --deny-warn moon build cmd/main --target wasm-gc --release

    The GitHub Actions workflow also checks formatting and package interfaces, tests the supported target matrix, and records the toolchain version used by each job. Local native backends may require the platform C toolchain supplied by the runner.

    The current source inventory contains 160 handwritten .mbt files: 94 production files and 66 test files. Excluding generated build output, these contain 9,916 production lines and 2,890 test lines. The figures are generated from the working tree and reported by category so implementation and tests remain visible separately.

    #License

    Licensed under the Apache License 2.0.