Skip to content

fix: correct min_radial_dist unit mismatch in calc_sfaps#10

Merged
RaulSimpetru merged 1 commit into
NsquaredLab:mainfrom
veylantis:fix/radial-distance-clamping
May 19, 2026
Merged

fix: correct min_radial_dist unit mismatch in calc_sfaps#10
RaulSimpetru merged 1 commit into
NsquaredLab:mainfrom
veylantis:fix/radial-distance-clamping

Conversation

@veylantis
Copy link
Copy Markdown
Contributor

Summary

The default min_radial_dist in MotorUnitSim.calc_sfaps() is computed as:

min_radial_dist = float(np.mean(self.muscle_fiber_diameters__mm) * 1000)

With typical fiber diameters of ~0.05 mm, this yields a clamping threshold of ~52.5 mm. Since radial_distance (fiber-to-electrode, line 349) is in mm and ranges from 0.03–8.5 mm, every fiber is clamped to the same value, making SFAPs spatially invariant to electrode XY displacement.

Changes

  • Remove * 1000 multiplier — the clamping threshold now equals the mean fiber diameter (~0.05 mm), keeping consistent mm units.
  • Update docstring — clarify that min_radial_dist is in mm and serves as a singularity guard.

Impact

After this fix, calc_sfaps() correctly produces distance-dependent SFAP amplitudes. All existing tests pass (39 passed, 2 skipped).

The default min_radial_dist was computed as mean(fiber_diameters) * 1000,
which converts ~0.05 mm diameters to ~52.5 mm.  Since radial_distance
(fiber-to-electrode) is in mm and typically 0.03-8.5 mm, every fiber was
clamped to the same 52.5 mm threshold, making SFAPs spatially invariant
to electrode XY displacement.

Remove the * 1000 multiplier so the clamping threshold equals the mean
fiber diameter (~0.05 mm), restoring correct XY sensitivity.
@RaulSimpetru RaulSimpetru merged commit ad39752 into NsquaredLab:main May 19, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants