Repository navigation
Conversation
compute_all_measures stored the length-weighted variance of the per-tract scalar means under "per tract distance weighted std <scalar>": take its square root. The tract length standard deviation was already a standard deviation in mm but was labelled "length std (mm^2)"; label it "length std (mm)". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 4, 2026
This branch has not been deployed
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.
What was wrong
tensor_operations.compute_all_measuresstored the length-weighted variance of the per-tract scalar means underper tract distance weighted std <scalar>(the square root was missing). This is whatscalar_per_tract_mean_stdandscalar_compute_mostreport.For the tract length, the value was already a standard deviation (
lengths.std(), in mm), but the column was labelledlength std (mm^2). I kept the value and fixed the label, so value and unit agree.The change
per tract distance weighted std <scalar>=sqrt(average((m_i - mean)**2, weights=L_i)), wherem_iis the length-weighted mean of the scalar along tractiandL_iits length.length std (mm^2)→length std (mm)(incompute_all_measures,length_mean_stdandscalar_compute_most).This changes numeric output and a column name:
per tract distance weighted std <scalar>values change (now the square root of the old value). Example on 100 tracts of the test.trkfile with a synthetic per-point scalarfa = |sin(x)|,tract_math a.trk scalar_per_tract_mean_std fa:per tract distance weighted std fa=0.0028079537354601916per tract distance weighted std fa=0.05299012866053631length_mean_stdandscalar_compute_most: the columnlength std (mm^2)is now calledlength std (mm); its value does not change. On the full test file,tract_math IIT3mean_left_hemisphere_small.trk length_mean_stdgives44.18812674562544before and after. Scripts that read this column by name need updating.Testing
test_compute_all_measures_std: synthetic tracts of different lengths with a constant scalar per tract; checks the length std againstnumpy.std, and the weighted mean/std againstnumpy.average-based formulas; with equal tract lengths the weighted std equalsnumpy.stdof the per-tract values. Fails on master, passes here.python -m pytest -q -p no:cacheprovider tract_querier: 43 passed, 1 skipped (pre-existing unconditional skip).tract_mathcommands above on master and on this branch.Merge order
Touches
operations.pylines 43 and 96 and appends totests/test_tract_math.py, like #143 and #144 (textual conflicts only). Independent otherwise.Closes #102
🤖 Generated with Claude Code