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 caches 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 field caches into (n_vertices, n_subjects).
Parameters¶
subjects : list of (str, str)
(subject_id, simulation_name) pairs (bare ids, no sub- prefix).
field : str
Which cached 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 caches 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
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 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 | |
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
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 591 592 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 | |