MATLAB Source Code and Executable Examples
Abstract
# BCMC-Net: MATLAB code and executable examples This package provides MATLAB source code and two example workflows forexploring the BCMC-Net computational pipeline. It is intended for methodologicalinspection, practical implementation, and education. These examples are notindependently verified reproductions of the manuscript's numerical tables. ## Requirements - MATLAB R2025b or newer (target environment)- Deep Learning Toolbox- Statistics and Machine Learning Toolbox The examples have not been run in the release-preparation environment becauseMATLAB is not installed there. Test them in MATLAB before relying on the output. ## Example 1: synthetic demonstration Open MATLAB in this directory and run: ```matlabrun_bcmc_demo``` `run_bcmc_demo.m` creates a small **synthetic** cohort, partitions athletes,trains a reduced-size model for three epochs, and illustrates the predictionand audit interfaces. All labels and results are simulated; they are **notexperimental findings** and cannot reproduce reported study performance.Scientific biomechanical constraints are inactive in this particular example. ## Example 2: SoccerMon-based workflow `run_bcmc_soccermon.m` illustrates loading longitudinal SoccerMon data,building windows, calibrating workload constraints from the training partition,training the model, and evaluating held-out athletes. The dataset is **notincluded** in this archive. Expected dataset directory structure: ```textdataset/ subjective/ training-load/ # wide Excel exports including daily_load wellness/ # wide Excel exports injury/ # event tables illness/ # optional event tables game-performance/ # optional event tables``` Set `BCMC_DATA_ROOT` to the directory that contains `subjective/`: ```matlabsetenv('BCMC_DATA_ROOT', 'C:\path\to\dataset');run_bcmc_soccermon``` Alternatively, the script searches for `dataset`, `data`, or the legacy`194_dataset` folder near the code directory. This educational script uses **80 epochs, patience 15, and batch size 32**.The general defaults in `bcmc_config.m` are 200, 20, and 16, respectively.Do not compare outputs directly with published results without verifying allstudy-specific settings, datasets, and athlete partitions. The example writes output files to `bcmc_output/`. These may contain athleteidentifiers and sensitive derived information. Review and anonymize thembefore distribution. ## Interpretation of biomechanical constraints The provided SoccerMon loader constructs four **workload proxies**: ACWR,monotony, strain, and load change. `bcmc_workload_bio_spec.m` defines boundedinequalities on these variables; `bcmc_fit_constraint_bounds.m` estimates theirlimits using training athletes only. This path is **not** a reconstructionof AddBiomechanics joint angles, force trajectories, or inverse dynamics. `bcmc_biomech_spec.m` also describes an interface for joint/force constraints.Its presence does not mean that synchronized motion and SoccerMon observationsare paired in this example. Joint-level implementation would require measuredand aligned targets, validated physical bounds, and independent testing. ## Outcome and implementation scope - The SoccerMon loader identifies a **new reported musculoskeletal complaint onset** when an active injury report follows seven consecutive days without an active injury report. It does not independently establish a clinically confirmed time-loss injury or a full day of unavailability.- The fast and slow feature windows cover 7 and 28 days. Temporal branches in this source implementation use configurable multilayer perceptrons (MLPs), not an independently implemented temporal convolution/attention model.- The loss function contains optional counterfactual and stability terms, but they contribute only if the corresponding batch targets are supplied. The provided training batch constructor does not supply those targets. `bcmc_counterfactual.m` offers a separate action-generation utility. ## Basic data interface For a custom dataset, prepare a MATLAB `raw` struct with: | Field | Shape or meaning || --- | --- || `Xfast` | `N x 7 x Dfast` historical features || `Xslow` | `N x 28 x Dslow` historical features || `context` | `N x Dc` contextual data || `profile` | `N x Dp` athlete descriptors || `quality` | `N x M` modality quality scores, 0 to 1 || `availability` | `N x M` modality indicators || `y` | `N x 1` outcome labels || `athleteId` | `N x 1` grouping identifiers || Optional | `eventInterval`, `censored`, `supportDistance`, `historyDays`, `bioTarget` | Configure feature slices in `cfg.modalitySlicesFast` and`cfg.modalitySlicesSlow`. Biomechanical decoder targets must have consistentdimensions and units. Do not treat workload proxy constraints as validatedjoint-level physical constraints. ## Main modules - `bcmc_config.m`: settings and random seeds- `bcmc_load_soccermon.m`: SoccerMon-style data and onset labels- `bcmc_prepare_data.m`: athlete-level splitting and train-only preprocessing- `bcmc_quality_fusion.m`: modality quality/availability fusion- `bcmc_forward.m`: predictive forward pass and latent refinement- `bcmc_train.m`, `bcmc_train_model.m`: custom Adam model training- `bcmc_train_biomechanics.m`: optional decoder pretraining- `bcmc_constraint_report.m`: constraint feasibility summaries- `bcmc_counterfactual.m`: separate action-generation utility- `bcmc_evaluate.m`: validation-selected test metrics and abstention ## Requirements for full numerical reproduction This source archive does not include the original data, fixed athlete splitmanifests, experiment checkpoints, or all external benchmark settings.Reproducing published numerical results requires those resources plus theidentical preprocessing, model architecture, hyperparameters, random seeds,software versions, and independently validated execution. Neither examplealone establishes numerical equivalence with the manuscript. ## Background references - Jiang and Liu, *Data-Driven Approach to Simulating Realistic Human Joint Constraints*, ICRA 2018.- Werling et al., *AddBiomechanics Dataset: Capturing the Physics of Human Motion at Scale*, ECCV 2024.- Halilaj et al., *Machine learning in human movement biomechanics: Best practices, common pitfalls, and new opportunities*, Journal of Biomechanics 81 (2018).