surface
tit.stats.surface ¶
fsaverage surface backend for cluster-based permutation stats.
The volumetric engine (:mod:tit.stats.engine) clusters voxels with
scipy.ndimage.label on a 3-D grid -- which has no meaning for surface
vertices. This module is the surface counterpart: it stacks the per-subject
fsaverage field projections (.msh) written by
:func:tit.source.project_fields_to_fsaverage
into a (n_vertices, n_subjects) matrix and runs the same statistics with
the same cluster conventions, swapping the grid clustering for graph
connected-components over the fsaverage triangle adjacency.
It deliberately reuses the engine's space-agnostic kernels
(:func:~tit.stats.engine.correlation, :func:~tit.stats.engine.ttest_ind,
:func:~tit.stats.engine.ttest_rel, :func:~tit.stats.engine.pval_from_histogram)
so the surface and volume paths give identical numbers on identical inputs; only
the spatial layer differs. The volumetric engine is left untouched --
:mod:tit.stats.permutation dispatches here when config.space == "fsaverage".
Cluster conventions mirror the engine exactly: a cluster is a connected set of
vertices with p < cluster_threshold (sign-restricted for one-sided tests);
singletons (size 1) are ignored; cluster mass is the signed sum of t over its
vertices; the null is the per-permutation max cluster stat; per-cluster p-values
come from :func:~tit.stats.engine.pval_from_histogram.
load_group_surface_data ¶
load_group_surface_data(subjects: list[tuple[str, str]], field: str, spacing: int) -> tuple[ndarray, list[str]]
Stack per-subject fsaverage projections into (n_vertices, n_subjects).
Each column is one node field of a *_space-fsaverage<N>_fields.msh
(:func:tit.source.fsaverage.write_fsaverage_msh).
Parameters¶
subjects : list of (str, str)
(subject_id, simulation_name) pairs (bare ids, no sub- prefix).
field : str
Which projected field to load -- one of :data:VALID_FSAVG_FIELDS.
spacing : int
fsaverage subdivision factor (5, 6, or 7).
Returns¶
(numpy.ndarray, list of str)
The (n_vertices, n_subjects) data matrix and the subject ids in
column order.
Source code in tit/stats/surface.py
build_fsaverage_adjacency ¶
build_fsaverage_adjacency(spacing: int)
Block-diagonal lh+rh fsaverage vertex adjacency (cached per spacing).
No edges cross the hemisphere boundary, so a slow-wave cluster can never
bridge the two hemispheres through a spurious midline edge -- matching the
[lh; rh] node ordering the field projections are written in.
Mesh source, tried in order (see resources/fsaverage/README.md for
why the bundled source is preferred on correctness grounds, not just to
avoid a download): the vendored resources/fsaverage/{spacing}/ GIFTI
surfaces (SimNIBS's own bundled fsaverage -- the same source
:func:tit.source.fsaverage._compute_fields projects each subject's
fields onto, via SimNIBS's cross_subject_map); then nilearn's
fetch_surf_fsaverage (a runtime download, the previous sole
behavior); a :class:RuntimeError naming both failed sources if
neither is available.
Source code in tit/stats/surface.py
run_surface_correlation ¶
run_surface_correlation(config, callback_handler=None, stop_callback=None) -> CorrelationResult
Vertexwise field-vs-response correlation on the fsaverage surface.
Source code in tit/stats/surface.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | |
run_surface_group_comparison ¶
run_surface_group_comparison(config, callback_handler=None, stop_callback=None) -> GroupComparisonResult
Responder-vs-non-responder t-test on the fsaverage surface.
Source code in tit/stats/surface.py
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | |