Repository navigation
Ported fixes: iEMG SFAP units and execution route, fibre CV units, Gfluctdv noise - #43
Merged
Merged
Conversation
Gfluctdv.mod multiplies both fluctuating conductances by GLOBAL multex/multin, which default to 0, so AlphaMN.insert_Gfluctdv() added a silent mechanism. Set both to 1 on insert. Ported from the fresh-trunk line (bef5cbe79, 2026-04-17), which never reached main.
… fibre layouts Fibre CV used a slope of 5.5 (m/s)/mm with diameters in mm, giving ~1.1 m/s before the 2 m/s clip, so every fibre had exactly 2.0 m/s. Use CV = 0.95 m/s + 0.05 m/s per um (Nandedkar & Stalberg 1983), shared with SurfaceFiberDispersion through CV_INTERCEPT__M_S / CV_PER_DIAMETER__M_S_PER_MM. Affects intramuscular EMG; surface EMG uses the mean CV. voronoi_pi1e5.csv covers a square, so only ~313 k points form a full disc. Larger fibre counts got a corner-only outer ring and, above 399 499, a silent cap. Those counts now use a scrambled Halton sequence in the disc (seeded from MyoGen's RNG) with a warning; smaller counts are unchanged. Fresh-trunk fixed both differently (be9cdfe35, a82923b2b); see docs/pr/2026-11-01-upstream-changes.md for why its numbers were not used.
…ation Four errors in the intramuscular source and volume conductor nearly cancelled at the default 0.01 mm spatial step: - muscle conductivities defaulted to 63 / 330 "S/m" (1000x tissue values); now 0.063 / 0.33 S/m, converted to S/mm (bioelectric.py, fiber_simulation.py) - the Rosenfalck IAP was evaluated at 2x the distance with the chain rule applied twice (half-length IAP, 8x current); now lambda = 1 mm, as in sEMG - the wave towards the shorter fibre half was subtracted, inverting it; the two waves now add (a second derivative is unchanged by reflection) - calc_sfaps summed over z without the spatial step, so amplitude scaled with 1/dz; both CPU and GPU paths now multiply by dz A single-fibre SFAP through MotorUnitSim.calc_sfaps now matches an independent SI line source within 3 % at 0.1-1 mm, is mirror-symmetric about the end-plate, independent of dz, and identical on GPU and CPU (tests/test_iemg_sfap_units.py). Output documented in mV.
runtime/density.py is a numba port of bioelectric.get_current_density and still had the pre-fix kernel: IAP at twice the distance with the chain rule applied twice, the shorter-half wave subtracted, and runtime/iemg.py summed the line source without dz. MUAPs from execution=ExecutionPolicy() disagreed with the default route (peak ratio ~1/8, correlation ~0.09 on a single fibre). Pin the kernel to the reference with an equivalence test, add a default-route vs execution-route MUAP test, and bump IEMG_CACHE_NAMESPACE to v3 so stale cached templates are recomputed. CHANGELOG entries for the ported fixes and the SFAP units.
This was referenced Nov 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second of four stacked PRs that replace #41: #40 → this → #44 (tooling) → #45 (fibre model). Base is
fix/semg-farina2004; retarget tomainonce #40 merges, since GitHub only closes issues on merges into the default branch.Closes #31, closes #33, closes #34.
Fixes
execution=route (runtime/density.py,runtime/iemg.py) still had the old kernel. Its numba kernel now mirrorsbioelectric.get_current_density: an equivalence test to rtol 1e-10, a MUAP test of the default against theexecution=route, and the iEMG cache namespace moves to v3.Musclefibre conduction velocities and large fibre layouts #34Musclefibre CVs were all clipped to 2.0 m/s (diameter in µm on a line in mm); large circular fibre layouts were capped and filled only at the diagonals.Tests. Full suite: 412 passed, 2 skipped; later commits on #40 change docs only.
Upgrade notes. iEMG amplitudes and fibre CVs change and Gfluctdv pools become noisy; see
CHANGELOG.md(Unreleased).