guide_build
tit.scene.guide_build ¶
Generate a packaged guide scene (tit/scene/guide*/) from one head model.
This is a developer tool, not part of the running app: it needs SimNIBS,
nibabel and scipy, it reads a 184 MB mesh, and it takes minutes. The server
only ever reads what it wrote (:mod:tit.scene.guide).
Run it inside the toolbox container, where SimNIBS lives::
docker exec ti-toolbox-fad740e5-tit-1 \
/root/SimNIBS-4.6/bin/simnibs_python -m tit.scene.guide_build \
--project <bids> --subject ernie --out /ti-toolbox/tit/scene/guide
The head needs surfaces/{lh,rh}.central.gii, its cortical .annot files for a subject
guide, and segmentation/labeling.nii.gz; each guide's PROVENANCE.md says where they came from.
What it does, and why in this order:
- Builds the two surfaces and every cortical atlas' labels through the
ordinary :mod:
tit.scene.buildpipeline, into the project's own scene cache. The guide is therefore built by the same code that builds a subject's pane, so a budget or winding fix cannot apply to one and not the other. - Copies those exact cached bytes into the package, renamed to fingerprint-free, stable file names — the packaged guide is immutable, so the fingerprint that keys a cache has no job here.
- Reads every EEG net as JSON (a few hundred rows each; cheap and exact).
- Writes
manifest.jsonenumerating all of it with asha256and a byte count per file, so the gate test can prove that what the manifest advertises is what the package contains.
Never copied: the m2m_ directory, the head mesh, the label volume.
Nothing here publishes anything: the guides are tracked files in this repository.
build_label_volume ¶
build_label_volume(source: Path, lut: Path, out: Path, *, part_id: str, atlas_id: str, select_all: bool = False) -> tuple[dict, dict]
Freeze one label volume as a pickable surface plus its legend.
Only the developer build reads a label volume. Runtime requests reuse the same compact binary surface and legend API as cortical atlas requests.
select_all keeps every label the volume contains rather than the
subcortical subset :func:tit.scene.volume_surfaces.default_visible would
show. It is what a packaged MNI atlas wants: its whole point is that the
user picks any of its regions, and the "is this name a deep structure"
heuristic exists for a per-subject labeling.nii.gz, not for CIT168.
Source code in tit/scene/guide_build.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
paint_on_cortex ¶
One cortical label volume as per-vertex labels on the whole central surfaces.
The subject path's transfer (:func:tit.scene.build.labels_from_nearest, then the mode
filter) with labelled voxels in place of annotated vertices. A vertex looks only on its own
side of the midline: the medial wall lies within the radius of the other hemisphere.
Source code in tit/scene/guide_build.py
build_subcortical ¶
The subject's own labeling.nii.gz as the guide's subcortical layer.
Source code in tit/scene/guide_build.py
build_mni_atlases ¶
Every packaged MNI atlas: cortical ones on cortex, the rest as label surfaces.
Skipped with a printed reason rather than a failure: a volume with no colour table, or too large for its own surface, is not a reason to have no MNI guide at all. What it costs is that that atlas cannot be picked in the pane; it is still selectable in the ROI picker's list, which reads the catalog, not the guide.
Source code in tit/scene/guide_build.py
generate ¶
generate(project: str, subject: str, out: Path, label: str, *, atlas_source: str = 'subject', guide_id: str = 'default') -> dict[str, Any]
Build every guide asset and write out/manifest.json. Returns it.
atlas_source is "subject" for the anatomy guide (the subject's own
cortical parcellations and labeling.nii.gz) or "mni" for the MNI152
guide, whose atlases are the packaged MNI volumes in resources/atlas/.
Source code in tit/scene/guide_build.py
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 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 | |