| Title: | Musculoskeletal Network Analysis for Physiological Data |
|---|---|
| Description: | Network science analysis of the human musculoskeletal system. Implements hypergraph representations of muscle-bone connections, physical simulation via damped harmonic oscillators, perturbation-based impact scoring, community detection, and clinical outcome prediction. Based on Murphy et al. (2018) <doi:10.1371/journal.pbio.2002811>. |
| Authors: | Yusuke Matsui |
| Maintainer: | Yusuke Matsui <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-05-16 05:17:59 UTC |
| Source: | https://github.com/x-biosignal/PhysioMSKNet |
Computes the degree distribution for bones or muscles.
degreeDistribution(hg, type = c("muscle", "bone"))degreeDistribution(hg, type = c("muscle", "bone"))
hg |
An MSKHypergraph object. |
type |
Character, either "muscle" (hyperedge degree) or "bone" (vertex degree). |
A data.frame with columns: degree, count, probability
Detects functional communities from EMG coherence and compares them with structural communities from the MSK network.
emgCommunityCompare(pe, hg = NULL, gamma = 4.3, mapping = NULL)emgCommunityCompare(pe, hg = NULL, gamma = 4.3, mapping = NULL)
pe |
A SummarizedExperiment-like object or numeric signal matrix. |
hg |
An MSKHypergraph object (NULL loads default). |
gamma |
Resolution parameter for MSK community detection (default: 4.3). |
mapping |
Optional data.frame from |
A list with:
Named integer vector of EMG community assignments
Named integer vector of MSK community assignments
z-Rand score comparing the two partitions
The channel-to-muscle mapping used
Tests whether EMG activation levels differ across MSK community assignments using a Kruskal-Wallis test.
emgMSKEnrichment(pe, hg = NULL, gamma = 4.3, mapping = NULL)emgMSKEnrichment(pe, hg = NULL, gamma = 4.3, mapping = NULL)
pe |
A SummarizedExperiment-like object or numeric signal matrix. |
hg |
An MSKHypergraph object (NULL loads default). |
gamma |
Resolution parameter for MSK community detection (default: 4.3). |
mapping |
Optional data.frame from |
A list with:
Data frame with community, mean/median activation
Kruskal-Wallis test result
Named numeric vector of RMS activation
Computes EMG functional coherence and compares it with structural adjacency from the MSK muscle graph using a Mantel test.
emgStructuralCoherence(pe, hg = NULL, freq_band = c(20, 50), mapping = NULL)emgStructuralCoherence(pe, hg = NULL, freq_band = c(20, 50), mapping = NULL)
pe |
A SummarizedExperiment-like object or a numeric signal matrix (time x channels). |
hg |
An MSKHypergraph object (NULL loads default). |
freq_band |
Numeric vector of length 2, frequency band in Hz for coherence (default: c(20, 50) for EMG beta/gamma). |
mapping |
Optional data.frame from |
A list with:
EMG functional coherence matrix
MSK structural adjacency (matched subset)
Mantel correlation coefficient
Permutation-based p-value
Names of matched muscles
## Not run: result <- emgStructuralCoherence(pe_emg, freq_band = c(20, 50)) ## End(Not run)## Not run: result <- emgStructuralCoherence(pe_emg, freq_band = c(20, 50)) ## End(Not run)
Matches EMG channel names from a PhysioExperiment/SummarizedExperiment object to muscles in an MSK hypergraph.
emgToMSKMapping(pe, hg = NULL, method = c("exact", "fuzzy"), threshold = 0.8)emgToMSKMapping(pe, hg = NULL, method = c("exact", "fuzzy"), threshold = 0.8)
pe |
A SummarizedExperiment-like object with channel names in
|
hg |
An MSKHypergraph object (NULL loads default). |
method |
Character, matching method: "exact" or "fuzzy". |
threshold |
Numeric, fuzzy matching threshold (default: 0.8). |
A data.frame with columns: channel_idx, channel_name, muscle_idx, muscle_name, match_quality.
## Not run: mapping <- emgToMSKMapping(pe_emg, method = "fuzzy") ## End(Not run)## Not run: mapping <- emgToMSKMapping(pe_emg, method = "fuzzy") ## End(Not run)
Returns the degree of each hyperedge (muscle), i.e., the number of bones each muscle attaches to.
hyperedgeDegree(hg)hyperedgeDegree(hg)
hg |
An MSKHypergraph object or incidence matrix. |
Named numeric vector of muscle degrees.
Analyzes movement synchrony from IMU sensors in the context of MSK network communities. Computes within-community vs between-community sensor synchrony and tests for significance.
imuCommunityDynamics( imu_data, hg = NULL, gamma = 4.3, mapping = NULL, window_sec = NULL )imuCommunityDynamics( imu_data, hg = NULL, gamma = 4.3, mapping = NULL, window_sec = NULL )
imu_data |
Named list of per-sensor data (see |
hg |
An MSKHypergraph object (NULL loads default). |
gamma |
Numeric, resolution parameter for community detection (default 4.3). |
mapping |
Pre-computed mapping (optional). |
window_sec |
Numeric or NULL. If provided, computes time-resolved
synchrony in sliding windows of this duration (seconds). Requires
|
A list with:
Mean synchrony within communities
Mean synchrony between communities
Within/between ratio
Wilcoxon test p-value
Data frame if window_sec provided, NULL otherwise
Computes bone stress from IMU acceleration/angular velocity data and propagates it through the MSK incidence matrix to predict muscle vulnerability.
imuImpactPrediction( imu_data, hg = NULL, mapping = NULL, stress_metric = c("acceleration", "angular_velocity", "jerk", "composite"), use_proxy = TRUE )imuImpactPrediction( imu_data, hg = NULL, mapping = NULL, stress_metric = c("acceleration", "angular_velocity", "jerk", "composite"), use_proxy = TRUE )
imu_data |
A named list of per-sensor data, or a matrix (see
|
hg |
An MSKHypergraph object (NULL loads default). |
mapping |
Pre-computed mapping (optional). |
stress_metric |
Character: |
use_proxy |
Logical, use degree-based proxy for impact deviation (faster) or run full simulation. |
A list with:
Named numeric vector of muscle vulnerability scores
Named numeric vector of bone stress
Named numeric of stress propagated to muscles
Data frame ranked by vulnerability (descending)
Computes pairwise kinematic coupling from IMU orientation or acceleration data and compares it to the structural adjacency of the MSK bone graph using a Mantel test.
imuNetworkKinematics( imu_data, hg = NULL, mapping = NULL, signal = c("orientation", "acceleration"), method = c("correlation", "mutual_info") )imuNetworkKinematics( imu_data, hg = NULL, mapping = NULL, signal = c("orientation", "acceleration"), method = c("correlation", "mutual_info") )
imu_data |
A named list of per-sensor data. Each element should be a
matrix or data.frame with orientation/acceleration columns. The list names
are sensor placement names (e.g., |
hg |
An MSKHypergraph object (NULL loads default). |
mapping |
A pre-computed mapping from |
signal |
Character, which signal to use for coupling:
|
method |
Character, coupling method: |
A list with:
Pairwise coupling matrix between mapped bones
Corresponding MSK bone graph adjacency
Mantel test correlation coefficient
Permutation p-value
Data frame of sensor-to-bone mapping used
Matches IMU sensor placement names to bones in the MSK hypergraph using a curated lookup table with fuzzy matching fallback. Supports naming conventions from Xsens, APDM, Shimmer, and generic body-segment labels.
imuToMSKMapping( sensors, hg = NULL, method = c("exact", "fuzzy"), threshold = 0.7 )imuToMSKMapping( sensors, hg = NULL, method = c("exact", "fuzzy"), threshold = 0.7 )
sensors |
Character vector of IMU sensor placement names
(e.g., |
hg |
An MSKHypergraph object (NULL loads default). |
method |
Character, matching method: "exact" or "fuzzy". |
threshold |
Numeric, fuzzy matching threshold (default: 0.7). |
A data.frame with columns: sensor_name, bone_idx, bone_name, match_quality, match_method.
## Not run: mapping <- imuToMSKMapping(c("upper_arm", "thigh", "lumbar")) ## End(Not run)## Not run: mapping <- imuToMSKMapping(c("upper_arm", "thigh", "lumbar")) ## End(Not run)
Loads the bipartite incidence matrix C where rows are bones (vertices) and columns are muscles (hyperedges). Entry C[i,j] = 1 indicates that muscle j attaches to bone i.
loadIncidenceMatrix()loadIncidenceMatrix()
A sparse Matrix (dgCMatrix) of dimensions 173 x 270
Murphy AC et al. (2018) PLOS Biology.
Loads the complete musculoskeletal network dataset from Murphy et al. (2018). Returns a list containing the incidence matrix, muscle metadata, and validation data for reproducing the paper's results.
loadMSKData()loadMSKData()
A list with components:
Sparse incidence matrix C (bones x muscles)
Data frame with muscle names, community assignments, homunculus categories
Character vector of bone/vertex names
Character vector of muscle/hyperedge names
Murphy AC et al. (2018) "Structure, function, and control of the human musculoskeletal network." PLOS Biology 16(1): e2002811.
Loads metadata for all 270 muscles including community assignments and homunculus category labels from the paper.
loadMuscleMetadata()loadMuscleMetadata()
A data.frame with columns: index, muscle, community, homunculus_category
Murphy AC et al. (2018) PLOS Biology.
Loads validation datasets used to reproduce key figures from the paper.
loadValidationData( dataset = c("degree_distribution", "impact_vs_recovery", "homunculus_deviation", "fmri_activation", "homunculus_coordinates", "impact_vs_path", "impact_scores") )loadValidationData( dataset = c("degree_distribution", "impact_vs_recovery", "homunculus_deviation", "fmri_activation", "homunculus_coordinates", "impact_vs_path", "impact_scores") )
dataset |
Character string specifying which dataset to load:
|
A data.frame with the requested validation data
Murphy AC et al. (2018) PLOS Biology.
Computes displacement synchrony (correlation) between matched bones and tests whether within-community pairs are more synchronized than between-community pairs using a Wilcoxon test.
mocapCommunityDynamics( pe_mocap, hg = NULL, gamma = 4.3, mapping = NULL, window_sec = NULL )mocapCommunityDynamics( pe_mocap, hg = NULL, gamma = 4.3, mapping = NULL, window_sec = NULL )
pe_mocap |
A numeric matrix (frames x segments) with MoCap data. |
hg |
An MSKHypergraph object (NULL loads default). |
gamma |
Resolution parameter for community detection (default: 4.3). |
mapping |
Optional data.frame from |
window_sec |
Optional numeric, window size in seconds for time-resolved analysis (NULL for global analysis only). |
A list with:
Mean within-community synchrony
Mean between-community synchrony
Within/between ratio
Wilcoxon test p-value
Data frame with per-window results (if window_sec set)
Computes kinematic stress per bone from MoCap data and propagates it through the MSK incidence matrix to estimate muscle vulnerability.
mocapImpactPrediction( pe_mocap, hg = NULL, mapping = NULL, stress_metric = c("acceleration", "jerk", "range"), use_proxy = TRUE )mocapImpactPrediction( pe_mocap, hg = NULL, mapping = NULL, stress_metric = c("acceleration", "jerk", "range"), use_proxy = TRUE )
pe_mocap |
A numeric matrix (frames x segments) with MoCap data. |
hg |
An MSKHypergraph object (NULL loads default). |
mapping |
Optional data.frame from |
stress_metric |
Character, kinematic stress metric: "acceleration", "jerk", or "range". |
use_proxy |
Logical, if TRUE uses degree-based proxy instead of full simulation for impact deviation (default: TRUE). |
A list with:
Named numeric vector of muscle vulnerability scores
Named numeric vector of bone stress values
Named numeric vector of muscle stress exposure
Data frame ranking muscles by vulnerability
Computes pairwise movement coupling between MoCap segments and compares the kinematic coupling matrix with MSK structural adjacency.
mocapNetworkKinematics( pe_mocap, hg = NULL, mapping = NULL, method = c("correlation", "mutual_info") )mocapNetworkKinematics( pe_mocap, hg = NULL, mapping = NULL, method = c("correlation", "mutual_info") )
pe_mocap |
A numeric matrix (frames x segments) or SummarizedExperiment with MoCap position data. |
hg |
An MSKHypergraph object (NULL loads default). |
mapping |
Optional data.frame from |
method |
Character, coupling method: "correlation" or "mutual_info". |
A list with:
Pairwise coupling matrix
MSK bone adjacency (matched subset)
Mantel correlation coefficient
Permutation-based p-value
Matches MoCap segment names from a SkeletonModel or character vector to bones in an MSK hypergraph using a curated lookup table with fuzzy matching fallback.
mocapToMSKMapping( skeleton, hg = NULL, method = c("exact", "fuzzy"), threshold = 0.7 )mocapToMSKMapping( skeleton, hg = NULL, method = c("exact", "fuzzy"), threshold = 0.7 )
skeleton |
A PhysioMoCap SkeletonModel object or character vector of segment names. |
hg |
An MSKHypergraph object (NULL loads default). |
method |
Character, matching method: "exact" or "fuzzy". |
threshold |
Numeric, fuzzy matching threshold (default: 0.7). |
A data.frame with columns: segment_name, bone_idx, bone_name, match_quality, match_method.
## Not run: mapping <- mocapToMSKMapping(c("upper_arm", "forearm", "thigh")) ## End(Not run)## Not run: mapping <- mocapToMSKMapping(c("upper_arm", "forearm", "thigh")) ## End(Not run)
Modifies a rehabilitation protocol based on patient reassessment results. Uses decision rules to determine whether to advance, continue, reduce, or modify the current protocol.
mskAdaptProtocol(reassessment, current_protocol, hg = NULL)mskAdaptProtocol(reassessment, current_protocol, hg = NULL)
reassessment |
An |
current_protocol |
An |
hg |
An MSKHypergraph object (NULL loads default). |
An S3 object of class "MSKAdaptedProtocol" with:
character: "advance", "continue", "reduce", "modify"
data.frame with modified exercise prescription
character explanation
character vector of muscles needing attention
exercises to drop
new exercises to add
## Not run: protocol <- mskRehabProtocol("Biceps Brachii") adapted <- mskAdaptProtocol(reassessment, protocol) print(adapted) ## End(Not run)## Not run: protocol <- mskRehabProtocol("Biceps Brachii") adapted <- mskAdaptProtocol(reassessment, protocol) print(adapted) ## End(Not run)
Attaches anatomical annotations from PhysioAnnotationHub to an MSK hypergraph, matching muscle and bone names between the two data sources. Annotations include body region, innervation, actions, and spinal levels.
mskAnnotate(hg = NULL, hub = NULL)mskAnnotate(hg = NULL, hub = NULL)
hg |
An MSKHypergraph object. If NULL, loads default 173-bone/270-muscle network. |
hub |
A PhysioAnnotationHub object. If NULL, loads via
|
An annotated MSKHypergraph with additional fields:
Data frame of muscle annotations merged from hub
Data frame of bone annotations merged from hub
Logical flag indicating annotations are attached
List with muscle and bone match rates
Annotations are derived from PhysioAnnotationHub's curated knowledge graph. Name matching uses fuzzy matching with a 0.2 edit distance threshold, which may produce incorrect matches for similarly named structures. Always verify critical annotations against primary anatomical references.
Murphy AC et al. (2018) PLOS Biology 16(1): e2002811.
## Not run: hg <- mskAnnotate() head(hg$muscle_annotations) ## End(Not run)## Not run: hg <- mskAnnotate() head(hg$muscle_annotations) ## End(Not run)
Computes betweenness centrality for the projected graph. Uses igraph if available, otherwise a pure-R BFS implementation.
mskBetweenness(hg, type = c("bone", "muscle"))mskBetweenness(hg, type = c("bone", "muscle"))
hg |
An MSKHypergraph object. |
type |
Character, "bone" or "muscle" projection. |
Named numeric vector of betweenness centrality values.
Generates a clinical evidence report for a set of injured muscles by querying the knowledge graph for ICD-10 codes, ICF codes, innervation, functional impact, and related muscles (synergists and antagonists).
mskClinicalEvidence(injury_muscles, hub = NULL, hg = NULL)mskClinicalEvidence(injury_muscles, hub = NULL, hg = NULL)
injury_muscles |
Character or integer vector identifying injured muscles. |
hub |
A PhysioAnnotationHub object (NULL loads default). |
hg |
An MSKHypergraph object (NULL loads default). |
An S3 object of class "MSKClinicalEvidence" with:
Data frame of injury muscle annotations
Matching ICD-10 entries
Matching ICF entries
Nerves innervating injured muscles
Spinal segments involved
Affected actions/movements
Synergistic muscles from KG
Antagonistic muscles from KG
ICD-10 and ICF code mappings are based on knowledge graph associations and may not capture all valid codes for a clinical scenario. This tool provides evidence aggregation for research; clinical coding should follow local guidelines and be reviewed by qualified professionals.
## Not run: evidence <- mskClinicalEvidence(c("Biceps Brachii", "Deltoid")) print(evidence) ## End(Not run)## Not run: evidence <- mskClinicalEvidence(c("Biceps Brachii", "Deltoid")) print(evidence) ## End(Not run)
Predicts recovery time, identifies compensatory muscles, and estimates secondary injury risk based on MSK network impact analysis.
mskClinicalPredictor(injury_muscles, hg = NULL, sim = NULL, verbose = TRUE)mskClinicalPredictor(injury_muscles, hg = NULL, sim = NULL, verbose = TRUE)
injury_muscles |
Character or integer vector identifying injured muscles. |
hg |
An MSKHypergraph object (NULL loads default 173-bone/270-muscle network). |
sim |
An MSKSimulation object (NULL creates one with default parameters). |
verbose |
Logical, print progress messages (default: TRUE). |
An S3 object of class "MSKClinicalPrediction" with:
Data frame with predicted recovery weeks and CI per muscle
List of compensatory muscles per injured muscle
Data frame of secondary injury risk scores
Resolved muscle names
Resolved integer indices
The recovery model was validated on 14 aggregate muscle groups, not individual muscles. Patient factor adjustments are heuristic, not independently validated. This is a research exploration tool, not a clinical diagnostic.
Murphy AC et al. (2018) PLOS Biology 16(1): e2002811.
## Not run: pred <- mskClinicalPredictor(c("Biceps Brachii", "Deltoid")) print(pred) ## End(Not run)## Not run: pred <- mskClinicalPredictor(c("Biceps Brachii", "Deltoid")) print(pred) ## End(Not run)
Closeness Centrality
mskCloseness(hg, type = c("bone", "muscle"))mskCloseness(hg, type = c("bone", "muscle"))
hg |
An MSKHypergraph object. |
type |
Character, "bone" or "muscle" projection. |
Named numeric vector of closeness centrality values.
Detects communities in the projected muscle-muscle graph using the Louvain algorithm with a resolution parameter gamma.
mskCommunityDetect(hg = NULL, gamma = 4.3, type = c("muscle", "bone"))mskCommunityDetect(hg = NULL, gamma = 4.3, type = c("muscle", "bone"))
hg |
An MSKHypergraph object. If NULL, loads built-in data. |
gamma |
Resolution parameter for modularity (default: 4.3, as in paper). Higher values produce more, smaller communities. |
type |
Projection type: "muscle" (default, as in paper) or "bone". |
A list with:
Named integer vector of community assignments
Number of communities detected
Modularity value Q
Resolution parameter used
Table of community sizes
Murphy AC et al. (2018) PLOS Biology 16(1): e2002811.
Generates a detailed functional profile of a musculoskeletal community by combining network topology metrics with knowledge graph annotations. This enables characterization of communities by their anatomical region, innervation patterns, primary actions, and spinal segment involvement.
mskCommunityProfile(hg = NULL, community_id, hub = NULL, gamma = 4.3)mskCommunityProfile(hg = NULL, community_id, hub = NULL, gamma = 4.3)
hg |
An MSKHypergraph object. If NULL, loads default network. |
community_id |
Integer, the community to profile (1-based). |
hub |
A PhysioAnnotationHub object (NULL loads default). |
gamma |
Numeric, resolution parameter for community detection (default: 4.3, as in Murphy et al. 2018). |
An S3 object of class "MSKCommunityProfile" with:
Integer, the profiled community
Character vector of muscle names in the community
Integer, number of muscles
Table of primary action distribution
Table of innervating nerves distribution
Table of body region distribution
Table of spinal level distribution
Most frequent primary action
Most frequent innervating nerve
Most frequent body region
Mean hyperedge degree of community muscles
Mean impact deviation score
Community membership depends on the resolution parameter gamma and the stochastic Louvain algorithm. Profile annotations depend on KG completeness. Community boundaries are network-derived, not anatomical boundaries.
Murphy AC et al. (2018) PLOS Biology 16(1): e2002811.
## Not run: profile <- mskCommunityProfile(community_id = 1) print(profile) ## End(Not run)## Not run: profile <- mskCommunityProfile(community_id = 1) print(profile) ## End(Not run)
Tracks changes in compensation patterns across multiple timepoints, identifying onset, resolution, and trends.
mskCompensationEvolution( timepoints_emg, injured_muscles, hg = NULL, emg_mapping = NULL, sr = NULL, z_threshold = 1.96 )mskCompensationEvolution( timepoints_emg, injured_muscles, hg = NULL, emg_mapping = NULL, sr = NULL, z_threshold = 1.96 )
timepoints_emg |
Named list of EMG matrices. The first element is treated as baseline. |
injured_muscles |
Character vector of injured muscle names or integer indices. |
hg |
An MSKHypergraph object (NULL loads default). |
emg_mapping |
Optional pre-computed data.frame from |
sr |
Optional sampling rate override. |
z_threshold |
Numeric, z-score threshold (default: 1.96). |
An S3 object of class "MSKCompensationEvolution" with:
Data.frame of per-timepoint per-muscle z-scores
Per-muscle first timepoint of compensation
Per-muscle first timepoint of resolution
Per-muscle trend classification
Data.frame of per-timepoint summary statistics
## Not run: evolution <- mskCompensationEvolution( timepoints_emg = list(week0 = emg0, week2 = emg2, week4 = emg4), injured_muscles = c("Biceps Brachii") ) ## End(Not run)## Not run: evolution <- mskCompensationEvolution( timepoints_emg = list(week0 = emg0, week2 = emg2, week4 = emg4), injured_muscles = c("Biceps Brachii") ) ## End(Not run)
Constructs a compensation-weighted subgraph from compensation detection results, identifying compensation chains and hub muscles.
mskCompensationNetwork(compensation_result, hg = NULL, emg_mapping = NULL)mskCompensationNetwork(compensation_result, hg = NULL, emg_mapping = NULL)
compensation_result |
An |
hg |
An MSKHypergraph object (NULL loads default). |
emg_mapping |
Optional pre-computed data.frame from |
A list with:
Weighted compensation adjacency matrix
List of compensation chains
Muscles in multiple compensation chains
MSK communities affected by compensation
## Not run: net <- mskCompensationNetwork(compensation_result, hg) ## End(Not run)## Not run: net <- mskCompensationNetwork(compensation_result, hg) ## End(Not run)
Computes risk scores for compensating muscles based on biomechanical overuse principles, integrating network topology, duration of compensation, and loading intensity.
mskCompensationRiskScore( compensation_result, hg = NULL, duration_weeks = 0, load_intensity = c("low", "moderate", "high") )mskCompensationRiskScore( compensation_result, hg = NULL, duration_weeks = 0, load_intensity = c("low", "moderate", "high") )
compensation_result |
An |
hg |
An MSKHypergraph object (NULL loads default). |
duration_weeks |
Numeric, how long compensation has been occurring. |
load_intensity |
Character, one of "low", "moderate", "high". |
An S3 object of class "MSKCompensationRisk" with:
Data.frame of per-muscle risk scores
Numeric overall risk score
Character risk category
Name of highest-risk muscle
Clinical action recommendation
Per compensating muscle: risk = z_excess * degree_normalized * duration_factor * load_factor where z_excess = max(0, z_score - z_threshold), degree_normalized = hyperedgeDegree / mean_degree, duration_factor = 1 + log(1 + duration_weeks), load_factor = intensity multiplier (0.5, 1.0, 1.5).
## Not run: risk <- mskCompensationRiskScore(compensation_result, duration_weeks = 4, load_intensity = "moderate") ## End(Not run)## Not run: risk <- mskCompensationRiskScore(compensation_result, duration_weeks = 4, load_intensity = "moderate") ## End(Not run)
Orchestrator that runs all compensation analyses and returns a unified summary. Uses tryCatch for each sub-analysis so partial results are available even if some analyses fail.
mskCompensationSummary( emg, emg_baseline, injured_muscles, timepoints_emg = NULL, hg = NULL, sr = NULL, z_threshold = 1.96, duration_weeks = 0, load_intensity = c("low", "moderate", "high") )mskCompensationSummary( emg, emg_baseline, injured_muscles, timepoints_emg = NULL, hg = NULL, sr = NULL, z_threshold = 1.96, duration_weeks = 0, load_intensity = c("low", "moderate", "high") )
emg |
Current EMG data (matrix or SummarizedExperiment). |
emg_baseline |
Baseline/pre-injury EMG data. |
injured_muscles |
Character vector of injured muscle names or integer indices. |
timepoints_emg |
Optional named list of EMG matrices for evolution analysis. |
hg |
An MSKHypergraph object (NULL loads default). |
sr |
Optional sampling rate override. |
z_threshold |
Numeric, z-score threshold (default: 1.96). |
duration_weeks |
Numeric, compensation duration for risk scoring. |
load_intensity |
Character, load intensity for risk scoring. |
An S3 object of class "MSKCompensationSummary" with
sub-results and available_analyses vector.
## Not run: summary <- mskCompensationSummary( emg = emg_current, emg_baseline = emg_pre, injured_muscles = c("Biceps Brachii"), duration_weeks = 4, load_intensity = "moderate" ) ## End(Not run)## Not run: summary <- mskCompensationSummary( emg = emg_current, emg_baseline = emg_pre, injured_muscles = c("Biceps Brachii"), duration_weeks = 4, load_intensity = "moderate" ) ## End(Not run)
Runs Louvain community detection multiple times and extracts a consensus partition. The paper uses 100 runs and takes the most frequent partition for each node pair.
mskConsensusPartition( hg = NULL, gamma = 4.3, n_runs = 100L, type = c("muscle", "bone") )mskConsensusPartition( hg = NULL, gamma = 4.3, n_runs = 100L, type = c("muscle", "bone") )
hg |
An MSKHypergraph object. |
gamma |
Resolution parameter (default: 4.3). |
n_runs |
Number of runs for consensus (default: 100). |
type |
Projection type: "muscle" or "bone". |
Same structure as mskCommunityDetect, but with consensus partition.
Murphy AC et al. (2018) PLOS Biology.
Compares a subject's EMG coordination pattern against a reference (healthy baseline or normative data) to produce a 0-1 quality score.
mskCoordinationQualityScore( emg, reference_emg = NULL, hg = NULL, method = c("synergy_distance", "correlation_profile", "network_similarity") )mskCoordinationQualityScore( emg, reference_emg = NULL, hg = NULL, method = c("synergy_distance", "correlation_profile", "network_similarity") )
emg |
EMG data: matrix (time x channels), SummarizedExperiment, or vector. |
reference_emg |
Reference EMG matrix (or NULL for within-subject reference). |
hg |
An MSKHypergraph object (NULL loads default). |
method |
Character, comparison method: "synergy_distance" (default), "correlation_profile", or "network_similarity". |
A list with: quality_score (0-1, 1=perfect match to reference), component_scores, muscle_contributions.
## Not run: cqs <- mskCoordinationQualityScore(emg, reference_emg, method = "synergy_distance") ## End(Not run)## Not run: cqs <- mskCoordinationQualityScore(emg, reference_emg, method = "synergy_distance") ## End(Not run)
Detects compensatory movement patterns by comparing current EMG activation against a baseline, using MSK network topology to identify muscles that are structurally positioned to compensate for injured muscles.
mskDetectCompensation( emg, emg_baseline, injured_muscles, hg = NULL, emg_mapping = NULL, sr = NULL, z_threshold = 1.96, neighborhood_order = 2L )mskDetectCompensation( emg, emg_baseline, injured_muscles, hg = NULL, emg_mapping = NULL, sr = NULL, z_threshold = 1.96, neighborhood_order = 2L )
emg |
Current EMG data (matrix, SummarizedExperiment, or numeric vector). |
emg_baseline |
Baseline/pre-injury EMG data (same format as |
injured_muscles |
Character vector of injured muscle names or integer indices. |
hg |
An MSKHypergraph object (NULL loads default). |
emg_mapping |
Optional pre-computed data.frame from |
sr |
Optional sampling rate override. |
z_threshold |
Numeric, z-score threshold for flagging compensation (default: 1.96). |
neighborhood_order |
Integer, MSK graph distance to search for compensators (default: 2). |
An S3 object of class "MSKCompensation" with:
Data.frame of muscles showing compensatory activation
Data.frame of injured muscle activation status
Data.frame of neighbors that did NOT compensate
Proportion of neighbors showing compensation
List with neighborhood info
Map EMG channels to MSK muscles via emgToMSKMapping
Compute RMS activation for both current and baseline
Compute z-score of change: z = (current_rms - baseline_rms) / baseline_sd
Identify MSK neighbors of injured muscles within neighborhood_order hops
Flag muscles where they are neighbors AND z-score > z_threshold
Also detect decreased activation in injured muscles (z < -z_threshold)
## Not run: result <- mskDetectCompensation( emg = emg_current, emg_baseline = emg_pre, injured_muscles = c("Biceps Brachii"), z_threshold = 1.96 ) print(result) ## End(Not run)## Not run: result <- mskDetectCompensation( emg = emg_current, emg_baseline = emg_pre, injured_muscles = c("Biceps Brachii"), z_threshold = 1.96 ) print(result) ## End(Not run)
Identifies when recovery has plateaued using rolling window slope analysis or change rate assessment.
mskDetectRecoveryPlateau( tracker, window = 3L, min_slope = NULL, method = c("slope", "change_rate") )mskDetectRecoveryPlateau( tracker, window = 3L, min_slope = NULL, method = c("slope", "change_rate") )
tracker |
An |
window |
Integer, number of consecutive timepoints to assess (default: 3). |
min_slope |
Numeric, minimum slope to be considered "improving" (default: NULL, auto-computed from data variability). |
method |
Character, "slope" (default) or "change_rate". |
An S3 object of class "MSKRecoveryPlateau" with:
logical per muscle
timepoint index where plateau begins (NA if none)
data.frame with per-window slopes
character ("continue", "modify_protocol", "reassess")
## Not run: plateau <- mskDetectRecoveryPlateau(tracker, window = 3) ## End(Not run)## Not run: plateau <- mskDetectRecoveryPlateau(tracker, window = 3) ## End(Not run)
Compares first and last timepoint to determine if each muscle shows clinically meaningful change beyond the MDC threshold.
mskDetectResponderStatus( tracker, mdc_result = NULL, threshold_type = c("mdc", "effect_size") )mskDetectResponderStatus( tracker, mdc_result = NULL, threshold_type = c("mdc", "effect_size") )
tracker |
An |
mdc_result |
An |
threshold_type |
Character, "mdc" (default) or "effect_size" (Cohen's d > 0.8). |
An S3 object of class "MSKResponderStatus" with:
data.frame (muscle, status, change, threshold, effect_size_d)
counts of responders/non-responders/deteriorated
"responder" if majority of muscles improve
## Not run: status <- mskDetectResponderStatus(tracker, mdc_result) ## End(Not run)## Not run: status <- mskDetectResponderStatus(tracker, mdc_result) ## End(Not run)
Tests whether a set of muscles is enriched for specific anatomical or functional annotations (actions, nerves, body regions, spinal levels) compared to the full background set of muscles in the hypergraph.
mskEnrichKG( muscles, annotation_type = c("action", "nerve", "body_region", "spinal_level"), hub = NULL, hg = NULL )mskEnrichKG( muscles, annotation_type = c("action", "nerve", "body_region", "spinal_level"), hub = NULL, hg = NULL )
muscles |
Character or integer vector identifying muscles to test. |
annotation_type |
Character, one of |
hub |
A PhysioAnnotationHub object (NULL loads default). |
hg |
An MSKHypergraph object (NULL loads default). |
A data.frame with columns:
Annotation term
Number of query muscles with this term
Number of background muscles with this term
Expected count under null
Ratio of observed to expected
P-value from hypergeometric test
Logical, TRUE if p < 0.05
Enrichment analysis depends on the completeness and accuracy of the underlying knowledge graph annotations. P-values are not adjusted for multiple testing; consider applying Bonferroni or FDR correction when testing multiple annotation types simultaneously.
## Not run: # Test enrichment of upper limb muscles for nerve innervation enrichment <- mskEnrichKG( c("Biceps Brachii", "Deltoid", "Trapezius"), annotation_type = "nerve" ) enrichment[enrichment$significant, ] ## End(Not run)## Not run: # Test enrichment of upper limb muscles for nerve innervation enrichment <- mskEnrichKG( c("Biceps Brachii", "Deltoid", "Trapezius"), annotation_type = "nerve" ) enrichment[enrichment$significant, ] ## End(Not run)
Takes the output of mskPredictFunctionalOutcome and generates
time-based milestones for tracking rehabilitation progress.
mskFunctionalMilestones( outcome_prediction, n_milestones = 4L, milestone_type = c("clinical", "linear", "accelerating") )mskFunctionalMilestones( outcome_prediction, n_milestones = 4L, milestone_type = c("clinical", "linear", "accelerating") )
outcome_prediction |
An |
n_milestones |
Integer, number of milestones to generate (default: 4). |
milestone_type |
Character: "linear" (evenly spaced), "accelerating" (front-loaded), or "clinical" (based on standard rehab phases). |
An S3 object of class "MSKFunctionalMilestones" with:
data.frame with milestone_id, week, target_rom, target_strength, target_function, phase_name, description
total timeline in weeks
character
## Not run: outcome <- mskPredictFunctionalOutcome("Biceps Brachii") milestones <- mskFunctionalMilestones(outcome, milestone_type = "clinical") print(milestones) ## End(Not run)## Not run: outcome <- mskPredictFunctionalOutcome("Biceps Brachii") milestones <- mskFunctionalMilestones(outcome, milestone_type = "clinical") print(milestones) ## End(Not run)
Tests the correspondence between MSK network community structure and the motor cortex homunculus. Reproduces Fig 4b results. Target: F(1,19) = 21.3, R² = 0.52, p < 0.001
mskHomuncCorrelation(membership = NULL, homunculus_data = NULL)mskHomuncCorrelation(membership = NULL, homunculus_data = NULL)
membership |
Named integer vector of community assignments. |
homunculus_data |
Optional data.frame with columns: homunc_area, dev_ratio. If NULL, loads the built-in validation data. |
A list with regression result and deviation ratio by category.
Murphy AC et al. (2018) PLOS Biology.
Constructs a musculoskeletal hypergraph from an incidence matrix. In this hypergraph, bones are vertices and muscles are hyperedges. A muscle (hyperedge) connects all bones it attaches to.
MSKHypergraph(C = NULL, muscle_meta = NULL)MSKHypergraph(C = NULL, muscle_meta = NULL)
C |
A matrix or sparse Matrix (bones x muscles) where C[i,j]=1 means muscle j attaches to bone i. If NULL, loads the built-in data. |
muscle_meta |
Optional data.frame with muscle metadata. |
An S3 object of class "MSKHypergraph" containing:
Sparse incidence matrix (bones x muscles)
Number of bones (vertices)
Number of muscles (hyperedges)
Character vector of bone names
Character vector of muscle names
Muscle metadata if provided
Murphy AC et al. (2018) PLOS Biology 16(1): e2002811.
Computes the impact deviation for each muscle, which is the difference between the observed impact score and the expected impact score for a muscle of that degree, expressed in standard deviations.
mskImpactDeviation(impact_scores, hg, null_scores = NULL)mskImpactDeviation(impact_scores, hg, null_scores = NULL)
impact_scores |
Named numeric vector of impact scores (from mskImpactScoreAll). |
hg |
An MSKHypergraph object. |
null_scores |
Optional matrix of null model impact scores (muscles x null_runs). If NULL, deviation is computed relative to a degree-based regression. |
The expected impact score is estimated from null model simulations or from a regression of impact score vs. degree.
A named numeric vector of impact deviations.
Murphy AC et al. (2018) PLOS Biology.
Reproduces the key result from Fig 3b: correlation between impact deviation and clinical muscle injury recovery time. Target: F(1,12) = 37.3, R² = 0.757, p < 0.0001
mskImpactRecoveryModel(impact_deviation = NULL, recovery_data = NULL)mskImpactRecoveryModel(impact_deviation = NULL, recovery_data = NULL)
impact_deviation |
Named numeric vector of impact deviations. |
recovery_data |
Optional data.frame with columns: recovery_time, impact_deviation, weight. If NULL, loads the built-in validation data. |
Result from mskRobustRegression with additional paper comparison.
Murphy AC et al. (2018) PLOS Biology Table 4.
Perturbs a single muscle and simulates the network dynamics to compute the total displacement of all bones (impact score). The perturbation is applied in the 4th spatial dimension to avoid directional artifacts.
mskImpactScore(sim, muscle_index)mskImpactScore(sim, muscle_index)
sim |
An MSKSimulation object. |
muscle_index |
Integer index of the muscle to perturb. |
Numeric impact score (total displacement summed over all bones).
Murphy AC et al. (2018) PLOS Biology.
Runs perturbation analysis for all 270 muscles and returns impact scores. This is the main computational function for reproducing Fig. 3a of the paper.
mskImpactScoreAll(sim = NULL, verbose = TRUE)mskImpactScoreAll(sim = NULL, verbose = TRUE)
sim |
An MSKSimulation object. If NULL, creates one with default parameters. |
verbose |
Logical, print progress (default: TRUE). |
A named numeric vector of impact scores for each muscle.
Murphy AC et al. (2018) PLOS Biology.
Computes a personalized injury risk profile for all muscles based on MSK network topology and patient characteristics.
mskInjuryRiskProfile(patient_data, hg = NULL, sim = NULL)mskInjuryRiskProfile(patient_data, hg = NULL, sim = NULL)
patient_data |
A list with patient characteristics:
|
hg |
An MSKHypergraph object (NULL loads default). |
sim |
An MSKSimulation object (NULL creates default). |
An S3 object of class "MSKInjuryRiskProfile" with:
Data frame with muscle name, base risk, adjusted risk
Input patient data
Applied adjustment factors
Patient factor adjustments (age, BMI, activity level) are heuristic multipliers, not derived from validated epidemiological models. This is a research exploration tool, not a clinical diagnostic.
## Not run: profile <- mskInjuryRiskProfile(list(age = 45, activity_level = "active")) ## End(Not run)## Not run: profile <- mskInjuryRiskProfile(list(age = 45, activity_level = "active")) ## End(Not run)
Produces a comprehensive summary of the MSK network annotated with knowledge graph data. Profiles all communities, identifies cross-community nerve pathways, and summarizes annotation coverage.
mskKGSummary(hg = NULL, hub = NULL, gamma = 4.3)mskKGSummary(hg = NULL, hub = NULL, gamma = 4.3)
hg |
An MSKHypergraph object (NULL loads default). |
hub |
A PhysioAnnotationHub object (NULL loads default). |
gamma |
Numeric, resolution parameter for community detection (default: 4.3). |
An S3 object of class "MSKKGSummary" with:
Annotated MSKHypergraph
List of MSKCommunityProfile objects
Number of detected communities
Data frame of nerves spanning communities
Annotation match statistics
This is a summary tool combining network topology with knowledge graph annotations. Community boundaries and annotation mappings are model-derived. Use as a research exploration tool, not for clinical decision-making.
## Not run: summary <- mskKGSummary() print(summary) ## End(Not run)## Not run: summary <- mskKGSummary() print(summary) ## End(Not run)
Computes per-timepoint RMS activation, synergy decomposition (W/H/VAF), and optionally CMC for a series of EMG measurements taken at different timepoints during rehabilitation.
mskLongitudinalTracker( timepoints, hg = NULL, emg_mapping = NULL, metrics = c("rms", "synergy"), sr = NULL )mskLongitudinalTracker( timepoints, hg = NULL, emg_mapping = NULL, metrics = c("rms", "synergy"), sr = NULL )
timepoints |
Named list of EMG matrices (time x channels). Names should be timepoint labels (e.g., "T0", "T1", "T2"). |
hg |
An MSKHypergraph object (NULL loads default). |
emg_mapping |
Optional pre-computed data.frame from |
metrics |
Character vector of metrics to compute (default: c("rms", "synergy")). Options: "rms", "synergy", "mean_activation", "peak_activation". |
sr |
Optional sampling rate in Hz (overrides detected values). |
An S3 object of class "MSKLongitudinalTracker" with:
data.frame (timepoint, muscle, metric_name, value)
character vector
integer
list of synergy results per timepoint
matrix (n_muscles x n_timepoints)
## Not run: emg_t0 <- matrix(abs(rnorm(400)), 100, 4) emg_t1 <- matrix(abs(rnorm(400)), 100, 4) colnames(emg_t0) <- colnames(emg_t1) <- paste0("muscle_", 1:4) tracker <- mskLongitudinalTracker(list(T0 = emg_t0, T1 = emg_t1)) ## End(Not run)## Not run: emg_t0 <- matrix(abs(rnorm(400)), 100, 4) emg_t1 <- matrix(abs(rnorm(400)), 100, 4) colnames(emg_t0) <- colnames(emg_t1) <- paste0("muscle_", 1:4) tracker <- mskLongitudinalTracker(list(T0 = emg_t0, T1 = emg_t1)) ## End(Not run)
Computes ICC (intraclass correlation coefficient) across timepoints for each metric, then derives SEM and MDC values for clinimetric assessment.
mskMinimalDetectableChange( tracker, method = "standard", confidence = 0.95, icc_method = "ICC(2,1)" )mskMinimalDetectableChange( tracker, method = "standard", confidence = 0.95, icc_method = "ICC(2,1)" )
tracker |
An |
method |
Character, method for MDC computation (default: "standard"). |
confidence |
Numeric, confidence level for MDC (default: 0.95). |
icc_method |
Character, ICC formula variant (default: "ICC(2,1)"). |
An S3 object of class "MSKMinimalDetectableChange" with:
data.frame (muscle, metric, ICC, SEM, MDC, pooled_SD)
numeric
character
## Not run: mdc <- mskMinimalDetectableChange(tracker, confidence = 0.95) ## End(Not run)## Not run: mdc <- mskMinimalDetectableChange(tracker, confidence = 0.95) ## End(Not run)
Computes the modularity Q of a partition with resolution parameter. Q = (1/2m) * sum_ij (A_ij - gamma * k_i * k_j / (2m)) * delta(c_i, c_j)
mskModularity(A, membership, gamma = 1)mskModularity(A, membership, gamma = 1)
A |
Adjacency matrix. |
membership |
Integer vector of community assignments. |
gamma |
Resolution parameter (default: 1.0). |
Numeric modularity value.
Computes standard graph metrics for the projected bone or muscle graph.
mskNetworkMetrics(hg, type = c("bone", "muscle"))mskNetworkMetrics(hg, type = c("bone", "muscle"))
hg |
An MSKHypergraph object. |
type |
Character, "bone" or "muscle" projection. |
A list with: degree, strength, clustering_coef, density
Compares corticomuscular coherence (CMC) and directional coupling between two timepoints to quantify neural adaptation during rehabilitation.
mskNeuralAdaptationIndex( cmc_t0, cmc_t1, directional_t0 = NULL, directional_t1 = NULL )mskNeuralAdaptationIndex( cmc_t0, cmc_t1, directional_t0 = NULL, directional_t1 = NULL )
cmc_t0 |
CMC result at baseline (MSKNeuromechCMC object or coherence matrix). |
cmc_t1 |
CMC result at follow-up. |
directional_t0 |
Directional coupling at baseline (MSKNeuromechDirectional object or NULL). |
directional_t1 |
Directional coupling at follow-up (or NULL). |
A list with: cmc_change, directional_change, adaptation_index, interpretation ("improving"/"stable"/"declining").
## Not run: nai <- mskNeuralAdaptationIndex(cmc_t0, cmc_t1, dir_t0, dir_t1) ## End(Not run)## Not run: nai <- mskNeuralAdaptationIndex(cmc_t0, cmc_t1, dir_t0, dir_t1) ## End(Not run)
Creates multiple null hypergraphs and computes impact scores for each. This is used to compute impact deviations relative to the null distribution.
mskNullEnsemble(hg = NULL, n_null = 100L, sim_params = list(), verbose = TRUE)mskNullEnsemble(hg = NULL, n_null = 100L, sim_params = list(), verbose = TRUE)
hg |
An MSKHypergraph object. |
n_null |
Number of null models to generate (default: 100). |
sim_params |
List of simulation parameters (dt, n_steps, beta). |
verbose |
Logical, print progress. |
A list with:
Matrix of impact scores (n_muscles x n_null)
List, impact scores grouped by degree for each null
Number of null models
Murphy AC et al. (2018) PLOS Biology.
Creates a randomized version of the musculoskeletal hypergraph by rewiring muscle-bone connections while preserving each muscle's degree (number of bones it connects to). This is done by randomly reassigning which bones each muscle attaches to, within anatomical categories if specified.
mskNullHypergraph(hg = NULL, preserve_category = FALSE)mskNullHypergraph(hg = NULL, preserve_category = FALSE)
hg |
An MSKHypergraph object. If NULL, loads built-in data. |
preserve_category |
Logical, whether to preserve anatomical category during rewiring (default: FALSE for the basic model). |
An MSKHypergraph object with rewired connections.
Murphy AC et al. (2018) PLOS Biology.
Computes confidence intervals for functional outcome predictions using bootstrap resampling or analytical delta method.
mskOutcomeConfidenceInterval( predictions, method = c("bootstrap", "analytical"), n_boot = 100L, confidence_level = 0.95 )mskOutcomeConfidenceInterval( predictions, method = c("bootstrap", "analytical"), n_boot = 100L, confidence_level = 0.95 )
predictions |
An |
method |
Character: "bootstrap" (default) or "analytical". |
n_boot |
Integer, number of bootstrap resamples (default: 100). |
confidence_level |
Numeric, confidence level (default: 0.95). |
A list with:
data.frame with outcome, point_estimate, lower, upper, width
character
integer (for bootstrap)
numeric, mean CI width
## Not run: outcome <- mskPredictFunctionalOutcome("Biceps Brachii") ci <- mskOutcomeConfidenceInterval(outcome) ## End(Not run)## Not run: outcome <- mskPredictFunctionalOutcome("Biceps Brachii") ci <- mskOutcomeConfidenceInterval(outcome) ## End(Not run)
Orchestrator function that combines functional outcome prediction, milestones, and optional reassessment into a comprehensive report.
mskOutcomeReport(outcome, milestones = NULL, reassessment = NULL, hg = NULL)mskOutcomeReport(outcome, milestones = NULL, reassessment = NULL, hg = NULL)
outcome |
An |
milestones |
Optional |
reassessment |
Optional |
hg |
An MSKHypergraph object (NULL loads default). |
An S3 object of class "MSKOutcomeReport" with all sub-results.
## Not run: outcome <- mskPredictFunctionalOutcome("Biceps Brachii") milestones <- mskFunctionalMilestones(outcome) report <- mskOutcomeReport(outcome, milestones) print(report) ## End(Not run)## Not run: outcome <- mskPredictFunctionalOutcome("Biceps Brachii") milestones <- mskFunctionalMilestones(outcome) report <- mskOutcomeReport(outcome, milestones) print(report) ## End(Not run)
Orchestrator function that calls all clinical bridge functions with shared hypergraph and simulation objects, producing a comprehensive report.
mskOutcomeSummary(injury_muscles, patient_data = NULL, hg = NULL, sim = NULL)mskOutcomeSummary(injury_muscles, patient_data = NULL, hg = NULL, sim = NULL)
injury_muscles |
Character or integer vector identifying injured muscles. |
patient_data |
Optional list with patient characteristics (see
|
hg |
An MSKHypergraph object (NULL loads default). |
sim |
An MSKSimulation object (NULL creates default). |
An S3 object of class "MSKOutcomeSummary" containing:
MSKClinicalPrediction object
Recovery timeline data.frame
MSKInjuryRiskProfile object (if patient_data provided)
MSKRehabProtocol object
All predictions are model-based estimates using MSK network topology. Recovery model was validated on 14 aggregate muscle groups. Patient factors are heuristic. This is a research exploration tool, not a clinical diagnostic.
## Not run: summary <- mskOutcomeSummary("Trapezius") print(summary) ## End(Not run)## Not run: summary <- mskOutcomeSummary("Trapezius") print(summary) ## End(Not run)
Finds the shortest anatomical pathway between two entities (muscles, bones, nerves, etc.) in the knowledge graph. Useful for tracing innervation chains, biomechanical linkages, and anatomical relationships.
mskPathwayQuery(from, to, hub = NULL, max_depth = 5L)mskPathwayQuery(from, to, hub = NULL, max_depth = 5L)
from |
Character, the source entity name (e.g., "Biceps Brachii"). |
to |
Character, the target entity name (e.g., "C5"). |
hub |
A PhysioAnnotationHub object (NULL loads default). |
max_depth |
Integer, maximum BFS depth (default: 5). |
A list with:
Character vector of entities along the path
Character vector of relationship types between entities
Integer, path length
Human-readable path description
Logical, whether a path was found
Pathways reflect relationships encoded in the knowledge graph. The shortest path in the KG may not correspond to the most clinically relevant connection. Always verify pathway interpretations against anatomical references.
## Not run: path <- mskPathwayQuery("Biceps Brachii", "C5") cat(path$description, "\n") ## End(Not run)## Not run: path <- mskPathwayQuery("Biceps Brachii", "C5") cat(path$description, "\n") ## End(Not run)
Predicts clinical functional outcomes (ROM, strength, composite function score) for injured muscles based on MSK network topology, impact analysis, and optional EMG activation data. Provides evidence-based regression models with confidence intervals.
mskPredictFunctionalOutcome( injured_muscles, hg = NULL, outcome_type = c("all", "rom", "strength", "function"), patient_factors = NULL, emg = NULL, emg_mapping = NULL, confidence_level = 0.95 )mskPredictFunctionalOutcome( injured_muscles, hg = NULL, outcome_type = c("all", "rom", "strength", "function"), patient_factors = NULL, emg = NULL, emg_mapping = NULL, confidence_level = 0.95 )
injured_muscles |
Character or integer vector identifying injured muscles. |
hg |
An MSKHypergraph object (NULL loads default 173-bone/270-muscle network). |
outcome_type |
Character: "rom" (range of motion), "strength", "function" (composite functional score), or "all" (default). |
patient_factors |
Optional list with: age (numeric), sex (character), bmi (numeric), activity_level (character), injury_severity ("mild"/"moderate"/"severe"). |
emg |
Optional EMG data (SummarizedExperiment, matrix, or numeric vector) for activation-based prediction refinement. |
emg_mapping |
Optional pre-computed data.frame from |
confidence_level |
Numeric, confidence level for CIs (default: 0.95). |
An S3 object of class "MSKFunctionalOutcome" with:
data.frame with muscle, outcome_type, predicted_value, lower_ci, upper_ci, unit
list with overall_rom, overall_strength, overall_function
estimated weeks to reach 90 percent of predicted outcome
numeric
character
list
The prediction models are based on MSK network topology and heuristic adjustments. They are not independently validated clinical tools. Use as a research exploration tool, not a clinical diagnostic.
## Not run: outcome <- mskPredictFunctionalOutcome( c("Biceps Brachii", "Deltoid"), patient_factors = list(age = 55, injury_severity = "moderate") ) print(outcome) ## End(Not run)## Not run: outcome <- mskPredictFunctionalOutcome( c("Biceps Brachii", "Deltoid"), patient_factors = list(age = 55, injury_severity = "moderate") ) print(outcome) ## End(Not run)
Compares current physiological measurements to a previous assessment, computing progress metrics and generating recommendations.
mskReassess( current_data, previous_assessment, hg = NULL, emg_mapping = NULL, sr = NULL )mskReassess( current_data, previous_assessment, hg = NULL, emg_mapping = NULL, sr = NULL )
current_data |
A list with: emg (required, matrix or SummarizedExperiment), and optional eeg, kinematics, force. |
previous_assessment |
A previous |
hg |
An MSKHypergraph object (NULL loads default). |
emg_mapping |
Optional pre-computed EMG-to-MSK mapping. |
sr |
Optional numeric sampling rate. |
An S3 object of class "MSKReassessment" with:
data.frame of current activation/synergy metrics
data.frame from previous assessment
data.frame with metric, previous, current, change, pct_change, significant
character vector per metric
weighted average progress score (0-100)
character
## Not run: reassessment <- mskReassess( current_data = list(emg = emg_matrix), previous_assessment = outcome ) print(reassessment) ## End(Not run)## Not run: reassessment <- mskReassess( current_data = list(emg = emg_matrix), previous_assessment = outcome ) print(reassessment) ## End(Not run)
Generates a week-by-week recovery timeline based on exponential decay of network impact, with clinical phase assignments.
mskRecoveryTimeline(injury_muscles, hg = NULL, sim = NULL, n_weeks = 12L)mskRecoveryTimeline(injury_muscles, hg = NULL, sim = NULL, n_weeks = 12L)
injury_muscles |
Character or integer vector identifying injured muscles. |
hg |
An MSKHypergraph object (NULL loads default). |
sim |
An MSKSimulation object (NULL creates default). |
n_weeks |
Integer, number of weeks to project (default: 12). |
A data.frame with columns: week, muscle, remaining_impact_pct, phase, milestone.
Phase assignments are based on exponential decay of network impact scores, not empirical clinical data. They should be interpreted as model-based estimates for research purposes only.
## Not run: timeline <- mskRecoveryTimeline("Biceps Brachii") ## End(Not run)## Not run: timeline <- mskRecoveryTimeline("Biceps Brachii") ## End(Not run)
Fits parametric recovery curves (exponential, sigmoid, or linear) to longitudinal muscle activation data from an MSKLongitudinalTracker.
mskRecoveryTrajectoryFit( tracker, model = c("exponential", "sigmoid", "linear"), muscle_subset = NULL )mskRecoveryTrajectoryFit( tracker, model = c("exponential", "sigmoid", "linear"), muscle_subset = NULL )
tracker |
An |
model |
Character, recovery curve model: "exponential" (default), "sigmoid", or "linear". |
muscle_subset |
Optional character vector of muscle names to fit (NULL = all muscles). |
An S3 object of class "MSKRecoveryTrajectory" with:
list per muscle with coefficients, residuals, R-squared, AIC
matrix of predicted values (muscles x timepoints)
character
numeric vector (slope at midpoint for each muscle)
estimated time to 90 percent of asymptotic recovery
## Not run: traj <- mskRecoveryTrajectoryFit(tracker, model = "exponential") ## End(Not run)## Not run: traj <- mskRecoveryTrajectoryFit(tracker, model = "exponential") ## End(Not run)
Generates a phased rehabilitation protocol using MSK network community structure and shortest path distances to determine exercise progression.
mskRehabProtocol(injury_muscles, hg = NULL, n_phases = 3L)mskRehabProtocol(injury_muscles, hg = NULL, n_phases = 3L)
injury_muscles |
Character or integer vector identifying injured muscles. |
hg |
An MSKHypergraph object (NULL loads default). |
n_phases |
Integer, number of rehabilitation phases (default: 3). |
An S3 object of class "MSKRehabProtocol" with per-phase muscle lists.
Phase ordering is based on network topology (community membership and shortest path distance), not validated rehabilitation protocols. Use as a research exploration tool, not clinical guidance.
## Not run: protocol <- mskRehabProtocol("Biceps Brachii") print(protocol) ## End(Not run)## Not run: protocol <- mskRehabProtocol("Biceps Brachii") print(protocol) ## End(Not run)
Master function that runs the complete analysis pipeline and compares results to the paper's reported values. This is the main validation function.
mskReproducePaper(run_simulation = FALSE, verbose = TRUE)mskReproducePaper(run_simulation = FALSE, verbose = TRUE)
run_simulation |
Logical, run the full simulation (slow, default: FALSE). If FALSE, uses validation data to reproduce statistical analyses. |
verbose |
Logical, print progress and comparison. |
A list with all results and paper comparisons.
Fits a robust linear model (using MASS::rlm if available, otherwise lm). Supports weighted regression as used in the paper.
mskRobustRegression(x, y, weights = NULL)mskRobustRegression(x, y, weights = NULL)
x |
Numeric vector of predictor values. |
y |
Numeric vector of response values. |
weights |
Optional numeric vector of weights. |
A list with:
Named vector (intercept, slope)
R-squared value
F-statistic
p-value for the regression
Residual values
Fitted values
The fitted model object
Computes shortest path distance matrix for the projected graph.
mskShortestPaths(hg, type = c("bone", "muscle"))mskShortestPaths(hg, type = c("bone", "muscle"))
hg |
An MSKHypergraph object. |
type |
Character, "bone" or "muscle" projection. |
A numeric matrix of shortest path distances.
Runs a damped harmonic oscillator simulation on the musculoskeletal network. Each muscle is modeled as a spring connecting its attached bones, and each bone is a unit-mass point particle. The system is evolved under perturbation and the total displacement is computed as the impact score.
mskSimulate( hg = NULL, dt = 0.01, n_steps = 500L, beta = 1, perturbation_magnitude = 1 )mskSimulate( hg = NULL, dt = 0.01, n_steps = 500L, beta = 1, perturbation_magnitude = 1 )
hg |
An MSKHypergraph object. If NULL, loads the built-in data. |
dt |
Time step for integration (default: 0.01). |
n_steps |
Number of time steps to integrate (default: 500). |
beta |
Damping coefficient (default: 1.0). |
perturbation_magnitude |
Magnitude of the 4th-dimension perturbation (default: 1.0). |
An S3 object of class "MSKSimulation" with:
The MSKHypergraph used
Named vector of spring constants per muscle
List of simulation parameters
Murphy AC et al. (2018) PLOS Biology 16(1): e2002811.
Compares two synergy decompositions by aligning synergy weight vectors and computing a change index reflecting structural reorganization.
mskSynergyChangeIndex( synergy_t0, synergy_t1, method = c("cosine", "correlation", "procrustes") )mskSynergyChangeIndex( synergy_t0, synergy_t1, method = c("cosine", "correlation", "procrustes") )
synergy_t0 |
An |
synergy_t1 |
An |
method |
Character, comparison method: "cosine" (default), "correlation", or "procrustes". |
A list with: global_change_index (0=identical, 1=maximally different), per_synergy_change, alignment (permutation used).
## Not run: sci <- mskSynergyChangeIndex(synergy_t0, synergy_t1, method = "cosine") ## End(Not run)## Not run: sci <- mskSynergyChangeIndex(synergy_t0, synergy_t1, method = "cosine") ## End(Not run)
Computes the z-scored Rand index between two partitions. Used to compare community structure with homunculus categories.
mskZRand(partition1, partition2)mskZRand(partition1, partition2)
partition1 |
Integer vector of community assignments. |
partition2 |
Integer vector of category assignments. |
Numeric z-Rand score. Values > 1.96 indicate significant similarity.
Traud et al. (2011) Physical Review E.
Computes pairwise corticomuscular coherence (CMC) between EEG and EMG channels, maps EMG channels to MSK muscles, builds a CMC-based functional distance matrix, and compares it with the structural muscle adjacency via Mantel test.
neuromechCorticomuscularCoupling( eeg, emg, hg = NULL, freq_band = c(15, 35), eeg_channels = NULL, emg_mapping = NULL, sr_eeg = NULL, sr_emg = NULL, nperseg = 256L, n_perm = 999L )neuromechCorticomuscularCoupling( eeg, emg, hg = NULL, freq_band = c(15, 35), eeg_channels = NULL, emg_mapping = NULL, sr_eeg = NULL, sr_emg = NULL, nperseg = 256L, n_perm = 999L )
eeg |
EEG data: a SummarizedExperiment, numeric matrix (time x channels), or numeric vector. |
emg |
EMG data: a SummarizedExperiment, numeric matrix (time x channels), or numeric vector. |
hg |
An MSKHypergraph object (NULL loads default). |
freq_band |
Numeric vector of length 2, frequency band in Hz for CMC (default: c(15, 35) for beta range). |
eeg_channels |
Optional character vector of EEG channel names to use.
If NULL, motor cortex channels are auto-selected via |
emg_mapping |
Optional pre-computed data.frame from |
sr_eeg |
Optional sampling rate for EEG (overrides detected value). |
sr_emg |
Optional sampling rate for EMG (overrides detected value). |
nperseg |
Integer, segment length for Welch's method (default: 256). |
n_perm |
Integer, number of permutations for Mantel test (default: 999). |
An S3 object of class "MSKNeuromechCMC" with:
Coherence matrix (n_eeg x n_emg)
MSK muscle adjacency (matched subset)
Per-muscle mean CMC across EEG channels
Data.frame of significant EEG-EMG pairs
Mantel test result (correlation, p_value)
EMG-to-muscle mapping used
## Not run: result <- neuromechCorticomuscularCoupling(eeg_data, emg_data) ## End(Not run)## Not run: result <- neuromechCorticomuscularCoupling(eeg_data, emg_data) ## End(Not run)
Computes directional (causal) connectivity between EEG and EMG channels using Granger causality or transfer entropy, distinguishing descending (cortical->muscle) from ascending (proprioceptive) pathways.
neuromechDirectionalCoupling( eeg, emg, hg = NULL, method = c("granger", "transfer_entropy", "both"), max_order_ms = 50, lag_ms = 20, n_bins = NULL, eeg_channels = NULL, emg_mapping = NULL, sr_eeg = NULL, sr_emg = NULL, n_perm = 999L, alpha = 0.05 )neuromechDirectionalCoupling( eeg, emg, hg = NULL, method = c("granger", "transfer_entropy", "both"), max_order_ms = 50, lag_ms = 20, n_bins = NULL, eeg_channels = NULL, emg_mapping = NULL, sr_eeg = NULL, sr_emg = NULL, n_perm = 999L, alpha = 0.05 )
eeg |
EEG data: SummarizedExperiment, matrix (time x channels), or vector. |
emg |
EMG data: SummarizedExperiment, matrix (time x channels), or vector. |
hg |
An MSKHypergraph object (NULL loads default). |
method |
Character: "granger" (default), "transfer_entropy", or "both". |
max_order_ms |
Numeric, maximum lag in ms for Granger (default: 50). |
lag_ms |
Numeric, TE lag in ms (default: 20). |
n_bins |
Integer, bins for TE discretization (NULL for auto). |
eeg_channels |
Optional character vector of EEG channels to use. |
emg_mapping |
Optional pre-computed data.frame from |
sr_eeg |
Optional sampling rate for EEG. |
sr_emg |
Optional sampling rate for EMG. |
n_perm |
Integer, permutations for Mantel test (default: 999). |
alpha |
Numeric, significance threshold (default: 0.05). |
An S3 object of class "MSKNeuromechDirectional" with:
Matrix (n_eeg x n_emg): EEG->EMG values
Matrix (n_emg x n_eeg): EMG->EEG values
descending - t(ascending)
Data.frame of significant descending pairs
Data.frame of significant ascending pairs
Per-muscle mean(descending)/mean(ascending)
Data.frame classifying each pair
Mantel test result
Method used
List of parameters used
## Not run: result <- neuromechDirectionalCoupling(eeg_data, emg_data, method = "granger") ## End(Not run)## Not run: result <- neuromechDirectionalCoupling(eeg_data, emg_data, method = "granger") ## End(Not run)
Computes the electromechanical delay (EMD) between EMG and kinematic signals for muscle-bone pairs connected in the MSK hypergraph. Optionally correlates EMD with MSK network distance.
neuromechElectromechanicalDelay( emg, kinematics, hg = NULL, emg_mapping = NULL, kin_mapping = NULL, sr = NULL, max_lag_ms = 200, window_sec = NULL, n_perm = 999L )neuromechElectromechanicalDelay( emg, kinematics, hg = NULL, emg_mapping = NULL, kin_mapping = NULL, sr = NULL, max_lag_ms = 200, window_sec = NULL, n_perm = 999L )
emg |
EMG data: SummarizedExperiment, matrix (time x channels), or vector. |
kinematics |
Kinematic data: matrix (time x segments) or SummarizedExperiment. |
hg |
An MSKHypergraph object (NULL loads default). |
emg_mapping |
Optional pre-computed data.frame from |
kin_mapping |
Optional pre-computed data.frame from
|
sr |
Optional sampling rate (overrides detected value). |
max_lag_ms |
Numeric, maximum lag in milliseconds (default: 200). |
window_sec |
Optional numeric, window size in seconds for sliding window EMD analysis (NULL for global only). |
n_perm |
Integer, number of permutations for correlation test (default: 999). |
A list with:
Data.frame with muscle, bone, emd_ms, peak_correlation per pair
Corresponding MSK shortest path distance
Pearson correlation between EMD and network distance
Permutation p-value for the correlation
Data.frame with per-window EMD (if window_sec set)
## Not run: result <- neuromechElectromechanicalDelay(emg_data, kin_data) ## End(Not run)## Not run: result <- neuromechElectromechanicalDelay(emg_data, kin_data) ## End(Not run)
Combines EMG activation, kinematic stress, and force data to compute a multi-source vulnerability score for each muscle. Propagates kinematic stress through the MSK incidence matrix and weights by impact deviation.
neuromechIntegratedVulnerability( emg, kinematics, force_data, hg = NULL, emg_mapping = NULL, kin_mapping = NULL, weights = c(1, 1, 1), use_proxy = TRUE )neuromechIntegratedVulnerability( emg, kinematics, force_data, hg = NULL, emg_mapping = NULL, kin_mapping = NULL, weights = c(1, 1, 1), use_proxy = TRUE )
emg |
EMG data: SummarizedExperiment, matrix, or vector. |
kinematics |
Kinematic data: matrix (time x segments) or SummarizedExperiment. |
force_data |
Force data: named numeric vector, data.frame, or matrix. |
hg |
An MSKHypergraph object (NULL loads default). |
emg_mapping |
Optional pre-computed data.frame from |
kin_mapping |
Optional pre-computed data.frame from |
weights |
Numeric vector of length 3, weights for EMG, kinematics, force components (default: c(1, 1, 1)). |
use_proxy |
Logical, use degree-based proxy for impact deviation (default: TRUE). |
A list with:
Named numeric vector of muscle vulnerability scores
Data.frame sorted by vulnerability (descending)
Pairwise correlations between EMG, kin, force sources
## Not run: result <- neuromechIntegratedVulnerability(emg, kinematics, force) ## End(Not run)## Not run: result <- neuromechIntegratedVulnerability(emg, kinematics, force) ## End(Not run)
Estimates joint torques from EMG activation and anatomical moment arms, computing per-muscle contributions, coactivation indices, and torque balance ratios across joints.
neuromechJointTorque( emg, hg = NULL, emg_mapping = NULL, moment_arm_table = NULL, activation_method = c("rms", "mean_rectified", "peak"), sr = NULL, joints = NULL, n_perm = 999L )neuromechJointTorque( emg, hg = NULL, emg_mapping = NULL, moment_arm_table = NULL, activation_method = c("rms", "mean_rectified", "peak"), sr = NULL, joints = NULL, n_perm = 999L )
emg |
EMG data: SummarizedExperiment, matrix (time x channels), or vector. |
hg |
An MSKHypergraph object (NULL loads default). |
emg_mapping |
Optional pre-computed data.frame from |
moment_arm_table |
Optional custom data.frame with columns: muscle_name, joint_name, moment_arm_m, direction. Overrides the built-in lookup. |
activation_method |
Character, method for computing activation: "rms" (default), "mean_rectified", "peak". |
sr |
Optional sampling rate. |
joints |
Optional character vector of joint names to restrict analysis. |
n_perm |
Integer, number of permutations for Mantel test (default: 999). |
An S3 object of class "MSKNeuromechTorque" with:
Data.frame: muscle, joint, activation, moment_arm, direction, torque_contribution
Data.frame: joint, net_torque, agonist_sum, antagonist_sum, coactivation_index, n_muscles
Data.frame: joint, balance_ratio
Mantel test result
Character: "lookup" or "custom"
## Not run: result <- neuromechJointTorque(emg_data, hg = hg) ## End(Not run)## Not run: result <- neuromechJointTorque(emg_data, hg = hg) ## End(Not run)
Maps cortical drive (CMC), muscle activation (EMG RMS), and force output to the MSK hypergraph to compute per-muscle drive efficiency and aggregate per community.
neuromechMotorDriveTopography( eeg, emg, force_data, hg = NULL, freq_band = c(15, 35), gamma = 4.3, emg_mapping = NULL, sr = NULL )neuromechMotorDriveTopography( eeg, emg, force_data, hg = NULL, freq_band = c(15, 35), gamma = 4.3, emg_mapping = NULL, sr = NULL )
eeg |
EEG data: SummarizedExperiment, matrix, or vector. |
emg |
EMG data: SummarizedExperiment, matrix, or vector. |
force_data |
Force data: named numeric vector (per muscle), data.frame with columns (muscle, force), or matrix (time x channels for RMS). |
hg |
An MSKHypergraph object (NULL loads default). |
freq_band |
Numeric vector of length 2, CMC frequency band (default: c(15, 35)). |
gamma |
Numeric, resolution parameter for community detection (default: 4.3). |
emg_mapping |
Optional pre-computed data.frame from |
sr |
Optional sampling rate. |
A list with:
Data.frame with muscle, cortical_drive, emg_activation, force, drive_efficiency
Data.frame with community, mean drive/activation/force
Pearson r between cortical drive and force
p-value for the correlation
## Not run: result <- neuromechMotorDriveTopography(eeg, emg, force) ## End(Not run)## Not run: result <- neuromechMotorDriveTopography(eeg, emg, force) ## End(Not run)
Extracts muscle synergies from EMG data via NMF or PCA, maps them to MSK structural communities, and compares synergy-based partitioning with structural communities via z-Rand.
neuromechMuscleSynergy( emg, hg = NULL, emg_mapping = NULL, method = c("nmf", "pca"), n_synergies = 4L, auto_select = FALSE, vaf_threshold = 0.9, max_k = 10L, gamma = 4.3, n_perm = 999L, seed = NULL, sr = NULL )neuromechMuscleSynergy( emg, hg = NULL, emg_mapping = NULL, method = c("nmf", "pca"), n_synergies = 4L, auto_select = FALSE, vaf_threshold = 0.9, max_k = 10L, gamma = 4.3, n_perm = 999L, seed = NULL, sr = NULL )
emg |
EMG data: SummarizedExperiment, matrix (time x channels), or vector. |
hg |
An MSKHypergraph object (NULL loads default). |
emg_mapping |
Optional pre-computed data.frame from |
method |
Character, decomposition method: "nmf" (default) or "pca". |
n_synergies |
Integer, number of synergies to extract (default: 4). |
auto_select |
Logical, automatically select n_synergies via VAF criterion (default: FALSE). |
vaf_threshold |
Numeric, VAF threshold for auto selection (default: 0.90). |
max_k |
Integer, maximum k to try during auto selection (default: 10). |
gamma |
Numeric, resolution parameter for MSK community detection (default: 4.3). |
n_perm |
Integer, permutations for z-Rand (unused, reserved). |
seed |
Optional integer seed for NMF reproducibility. |
sr |
Optional sampling rate. |
An S3 object of class "MSKNeuromechSynergy" with:
Synergy weight matrix (n_muscles x n_synergies)
Activation coefficients (n_synergies x n_timepoints)
Number of synergies extracted
Variance accounted for
VAF curve if auto_select (else NULL)
Decomposition method used
Synergy-to-community enrichment data.frame
Cosine similarity matrix (k x k)
z-Rand comparing synergy vs structural
Reconstruction error
## Not run: result <- neuromechMuscleSynergy(emg_data, method = "nmf", n_synergies = 4) ## End(Not run)## Not run: result <- neuromechMuscleSynergy(emg_data, method = "nmf", n_synergies = 4) ## End(Not run)
Orchestrator function that runs all available neuromechanics analyses with shared mapping, skipping analyses when inputs are NULL.
neuromechSummary( eeg = NULL, emg, kinematics = NULL, force_data = NULL, hg = NULL, freq_band = c(15, 35), gamma = 4.3, sr = NULL, n_synergies = 4L, synergy_method = "nmf" )neuromechSummary( eeg = NULL, emg, kinematics = NULL, force_data = NULL, hg = NULL, freq_band = c(15, 35), gamma = 4.3, sr = NULL, n_synergies = 4L, synergy_method = "nmf" )
eeg |
Optional EEG data (NULL to skip CMC and motor drive analyses). |
emg |
EMG data (required). |
kinematics |
Optional kinematic data (NULL to skip EMD and vulnerability). |
force_data |
Optional force data (NULL to skip motor drive and vulnerability). |
hg |
An MSKHypergraph object (NULL loads default). |
freq_band |
Numeric vector of length 2, CMC frequency band (default: c(15, 35)). |
gamma |
Numeric, resolution parameter (default: 4.3). |
sr |
Optional sampling rate. |
n_synergies |
Integer, number of synergies for muscle synergy analysis (default: 4). |
synergy_method |
Character, synergy decomposition method: "nmf" (default) or "pca". |
An S3 object of class "MSKNeuromechSummary" with:
CMC result or NULL
EMD result or NULL
Motor drive result or NULL
Vulnerability result or NULL
Joint torque result or NULL
Muscle synergy result or NULL
Directional coupling result or NULL
Character vector of successfully computed analyses
## Not run: summary <- neuromechSummary(eeg = eeg_data, emg = emg_data, kinematics = kin_data, force_data = force) ## End(Not run)## Not run: summary <- neuromechSummary(eeg = eeg_data, emg = emg_data, kinematics = kin_data, force_data = force) ## End(Not run)
Runs network analysis on multiple OpenSim models and performs statistical comparisons of their network properties.
opensimCompareModels(model_paths, names = NULL, gamma = 4.3)opensimCompareModels(model_paths, names = NULL, gamma = 4.3)
model_paths |
Character vector of paths to .osim files. |
names |
Optional character vector of model names. |
gamma |
Resolution parameter for community detection (default: 4.3). |
An S3 object of class "MSKModelComparison" with:
List of MSKOpenSimAnalysis objects
Data frame of pairwise comparison statistics
Combines muscle force data from OpenSim simulations with MSK network impact scores to compute force-weighted vulnerability.
opensimForceToImpact( model_path, force_data, hg = NULL, method = c("weighted_simulation", "weighted_scores") )opensimForceToImpact( model_path, force_data, hg = NULL, method = c("weighted_simulation", "weighted_scores") )
model_path |
Character, path to .osim file. |
force_data |
Force data as a data.frame (with muscle name column), named numeric vector, or path to an OpenSim .sto file. |
hg |
An optional pre-built MSKHypergraph (if NULL, built from model). |
method |
Character, weighting method:
|
A list with:
Force-weighted impact scores
Force values used for weighting
Original (unweighted) impact scores
Builds a hypergraph from an OpenSim model and runs complete network analysis including metrics, community detection, and optionally impact scoring.
opensimNetworkAnalysis( model = NULL, model_path = NULL, gamma = 4.3, run_simulation = TRUE )opensimNetworkAnalysis( model = NULL, model_path = NULL, gamma = 4.3, run_simulation = TRUE )
model |
An optional PhysioOpenSimModel object. |
model_path |
Character, path to .osim file. |
gamma |
Resolution parameter for community detection (default: 4.3). |
run_simulation |
Logical, whether to run full impact simulation (default: TRUE; set to FALSE for faster analysis). |
An S3 object of class "MSKOpenSimAnalysis" with:
The MSKHypergraph object
Network metrics from mskNetworkMetrics
Community detection results
Impact scores (if run_simulation = TRUE)
Parses an OpenSim .osim file to extract muscle-bone attachment points and constructs a subject-specific MSKHypergraph.
opensimToMSKHypergraph(model = NULL, model_path = NULL)opensimToMSKHypergraph(model = NULL, model_path = NULL)
model |
An optional PhysioOpenSimModel object. If provided, the model's path is used and results are cross-validated. |
model_path |
Character, path to a .osim file. Required if |
An MSKHypergraph object with subject-specific anatomy.
Requires the xml2 package.
## Not run: hg <- opensimToMSKHypergraph(model_path = "gait2392.osim") print(hg) ## End(Not run)## Not run: hg <- opensimToMSKHypergraph(model_path = "gait2392.osim") print(hg) ## End(Not run)
Visualizes detected communities with size information.
plotCommunityStructure(community, ...)plotCommunityStructure(community, ...)
community |
Result from mskCommunityDetect or mskConsensusPartition. |
... |
Additional arguments. |
Invisible NULL.
Plots the degree distribution of the hypergraph, comparing real and null model distributions. Reproduces Fig 2e.
plotDegreeDistribution( hg = NULL, type = c("muscle", "bone"), null_dist = NULL, log_scale = TRUE, ... )plotDegreeDistribution( hg = NULL, type = c("muscle", "bone"), null_dist = NULL, log_scale = TRUE, ... )
hg |
An MSKHypergraph object. |
type |
"muscle" or "bone" distribution. |
null_dist |
Optional numeric vector of null model degree counts. |
log_scale |
Logical, use log scale (default: TRUE for heavy-tail). |
... |
Additional arguments passed to barplot. |
Invisible NULL.
Recreates Fig 4b: deviation ratio vs homunculus area. Target: F(1,19) = 21.3, R^2 = 0.52
plotHomunculus(homunculus_data = NULL, ...)plotHomunculus(homunculus_data = NULL, ...)
homunculus_data |
Optional data.frame. If NULL, uses built-in data. |
... |
Additional arguments. |
Invisible the regression result.
Recreates Fig 3a: scatter plot of impact scores by hyperedge degree. Target: R^2 = 0.45 for the relationship.
plotImpactVsDegree(impact_scores, hg = NULL, show_regression = TRUE, ...)plotImpactVsDegree(impact_scores, hg = NULL, show_regression = TRUE, ...)
impact_scores |
Named numeric vector of impact scores. |
hg |
An MSKHypergraph object. |
show_regression |
Logical, overlay regression line. |
... |
Additional arguments. |
Invisible the regression result.
Recreates Fig 3b: weighted regression of impact deviation vs clinical recovery time. Target: R^2 = 0.757.
plotImpactVsRecovery(recovery_data = NULL, ...)plotImpactVsRecovery(recovery_data = NULL, ...)
recovery_data |
Optional data.frame. If NULL, uses built-in data. |
... |
Additional arguments. |
Invisible the regression result.
Visualizes the musculoskeletal network with optional community coloring.
plotMSKNetwork( hg = NULL, type = c("muscle", "bone"), membership = NULL, layout = "fr", vertex_size = 3, ... )plotMSKNetwork( hg = NULL, type = c("muscle", "bone"), membership = NULL, layout = "fr", vertex_size = 3, ... )
hg |
An MSKHypergraph object. |
type |
"bone" or "muscle" projection to plot. |
membership |
Optional community membership vector for coloring. |
layout |
Character, layout algorithm: "fr" (Fruchterman-Reingold), "circle", or "auto". |
vertex_size |
Numeric, base vertex size. |
... |
Additional arguments passed to plot. |
Invisible NULL. Produces a plot.
Creates the bone-bone weighted adjacency matrix A = t(C) %*% C where A[i,j] counts the number of muscles shared between bones i and j. This is the one-mode projection onto the bone (vertex) space.
projectBoneGraph(hg)projectBoneGraph(hg)
hg |
An MSKHypergraph object, or a sparse incidence matrix. |
A symmetric sparse Matrix (n_bones x n_bones)
Murphy AC et al. (2018) PLOS Biology.
Creates the muscle-muscle weighted adjacency matrix B = C %*% t(C) where B[i,j] counts the number of bones shared between muscles i and j. This is the one-mode projection onto the muscle (hyperedge) space.
projectMuscleGraph(hg)projectMuscleGraph(hg)
hg |
An MSKHypergraph object, or a sparse incidence matrix. |
A symmetric sparse Matrix (n_muscles x n_muscles)
Murphy AC et al. (2018) PLOS Biology.
Returns the degree of each vertex (bone), i.e., the number of muscles attached to each bone.
vertexDegree(hg)vertexDegree(hg)
hg |
An MSKHypergraph object or incidence matrix. |
Named numeric vector of bone degrees.