Commit 34c8415
Integrate two old_to_integrate tests; harden test discovery (#80)
* Integrate two old_to_integrate tests; harden test discovery
Convert two quarantined standalone scripts into real matlab.unittest tests
and move them into the discovered suite, and make the runner robust against
non-test files that match the canlab_test_*.m glob.
- image_vector/canlab_test_check_roi_extraction.m: converts
old_to_integrate/check_roi_extraction.m. The original printed PASS/FAIL but
never asserted. Now asserts multi-region 'unique_mask_values' extraction and
invariance of the region averages across a write->reload round-trip
(RelTol 1e-3 / AbsTol 1e-2 absorbs single-precision NIfTI rounding).
Complements canlab_test_extract_roi (single-mask only).
- image_vector/canlab_test_resampling_pattern_expression.m: converts
old_to_integrate/resampling_pattern_expression_unit_test1.m, which only
plotted. Now asserts SIIPS pattern expression is stable (corr > 0.99) across
default/nearest/spline resampling; skips if SIIPS is unavailable.
- helpers/canlab_safe_suite_from_file.m + canlab_run_all_tests.m: wrap
TestSuite.fromFile so a stray non-test canlab_test_*.m is warn-skipped
instead of throwing NonTestFile and aborting discovery of the whole suite.
- canlab_test_runner_robustness.m: pins that behavior (non-test file ->
warn + empty + ok=false; valid file -> loads).
Old originals removed from old_to_integrate (jackknife_similarity_unit_test.m
stays - it is a characterization/figure script, not a unit test).
Full default suite after: 147 passed, 0 failed, 2 incomplete (pre-existing
environment skips).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Convert 5 xval_* tests to matlab.unittest; move to predictive_model/
The five xval_*_unit_test.m files at the Unit_tests root were genuine tests
(real assertions, no graphics, deterministic, bundled DPSP / synthetic data)
but were plain-assert functions named outside the canlab_test_* convention,
so the runner never discovered them.
Convert each into a functiontests file under a new predictive_model/ subdir:
the model is fit once in setupOnce (skipped via assumeTrue if the DPSP sample
data is absent) and cached, and the assertions are split into focused test
functions using tc.verify* for granular reporting. Behavior preserved.
- predictive_model/canlab_test_xval_SVM.m
- predictive_model/canlab_test_xval_SVR.m
- predictive_model/canlab_test_xval_regression_multisubject.m
- predictive_model/canlab_test_xval_regression_multisubject_featureselect.m
- predictive_model/canlab_test_xval_discriminant_classifier.m
- helpers/canlab_get_dpsp_hot_warm.m: shared DPSP Hot/Warm loader.
Old xval_*_unit_test.m removed. New suite: 25 test points, all pass, ~7.5s.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Convert predictive_model_unit_test to matlab.unittest (minimal nboot/nperm)
predictive_model_unit_test.m exercised the @predictive_model object's own
public API (fit/predict/score/crossval/bootstrap/weight_map_object/
permutation_test/calibrate/select_features/grid_search/stability_selection/
pipeline/newapi routing/regression+report/summary). This is non-redundant
with the xval_* tests, which cover the legacy wrapper functions rather than
the object methods - so it is worth keeping.
Convert to predictive_model/canlab_test_predictive_model_api.m: the shared
fit -> crossval -> bootstrap chain is computed once in setupOnce and cached;
the rest are focused test functions using tc.verify*; visualisation methods
(plot/confusionchart/montage) are smoke-tested and skipped on a headless
runner via canlab_classify_environment_error.
Drop the bootstrap/permutation/stability counts to minimum-viable values
(nboot 25->5, nperm 10->3, stability nboot 20->5) since this is a smoke test,
not real inference; assertions are structural (shapes/ranges/p-floor), so the
counts only need to exercise the code paths. Runtime 131s -> 73s locally; the
residual cost is the high-dimensional (194,676-feature) cross-validation, not
the resampling counts. Skipped if DPSP_hotwarm is not on the path.
Old predictive_model_unit_test.m removed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* predictive_model API test: mask to sparse gray-matter ROI for speed
The dominant cost was cross-validating on the full ~195k-voxel volume. In
setupOnce, restrict hw_obj to gray matter (gray_matter_mask.img) and then
deterministically thin to every 8th voxel (~20k features). hw_obj and X stay
in lockstep, so weight_map_object / montage back-project consistently, and
all assertions are structural so masking does not change them. Falls back to
the full volume if the mask is not on the path.
Runtime: 131s (original) -> 73s (minimal nboot/nperm) -> ~20s now. All 17
test points still pass; model behaviour unchanged (AUC ~0.83).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 1f6ec61 commit 34c8415
20 files changed
Lines changed: 957 additions & 662 deletions
File tree
- CanlabCore/Unit_tests
- helpers
- image_vector
- old_to_integrate
- predictive_model
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
Lines changed: 42 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
Lines changed: 58 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
Lines changed: 48 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 0 additions & 40 deletions
This file was deleted.
0 commit comments