nirspipe.pipeline.hyper.pair_null#
The re-paired null: one member against people they never interacted with.
Split from nirspipe.pipeline.hyper.wtc_null rather than folded into it because the two
nulls sit at different levels. Phase randomisation needs one dyad and can run inside the
per-dyad pass; re-pairing needs the rest of the cohort, so it reads the pairs table and the
finished derivatives tree and runs after them.
Its parameters are read back off the real table’s sidecar instead of being taken from the command line, so the null and the table it is subtracted from cannot disagree. The few the command line still takes are checked against that sidecar.
Module Contents#
Functions#
The draws a group’s re-paired null is made of: in each, a stand-in per replaced member. |
|
A draw’s name, its stand-ins’ recording ids joined by |
|
Each pairing’s |
|
The real WTC table’s own record of how it was computed, off its sidecar. |
|
|
|
A stand-in’s name: a recording, not a person, so one person can stand in from several sessions. |
|
Draw, rank and write one group’s re-paired null. |
Data#
API#
- nirspipe.pipeline.hyper.pair_null.logger = 'getLogger(...)'#
- nirspipe.pipeline.hyper.pair_null.POOLS = ('position', 'any')#
- nirspipe.pipeline.hyper.pair_null.stand_in_draws(groups: dict, group_id: str, task: str, pool: str = 'position', session: str | None = None) list[dict]#
The draws a group’s re-paired null is made of: in each, a stand-in per replaced member.
groupsisparse_group_csv()’s mapping. Every member after the first is replaced, keyed by its index in the target group; the first is held in every pairing.G1 (t, s, s), G2 (t, s, s), G3 (t, s), by role stand_in_draws(groups, "G1", "main") -> [{1: G2 s#1, 2: G2 s#2}, {1: G2 s#2, 2: G2 s#1}, {1: G3 s}]
Each draw comes from one other occasion, never the target’s own. Within it a replaced member’s stand-in matches by key: its index under
position, its role there where the pairs table has a role column, nothing underany. The donor’s members of a key rotate over the target’s members of that key, the k-th draw giving the target’s q-th the donor’s (q + k)-th, so a stand-in fills a member at most once and no draw uses a donor member twice; a donor gives as many draws as its scarcest key has members, and a member it cannot fill goes without in that donor’s draws. For a dyad this is one draw per other group’s member of that key.positionkeeps a member’s role where the members of a group are not interchangeable. It is also the only safe pool where one person appears in several groups, sinceanywould there pair somebody with themselves.anydoubles a dyad’s pool and is refused unless the table shows nobody is repeated. Who may not stand in against whom is the caller’s rule, applied per pairing.A group recorded in several sessions is one occasion per session, and
sessionnames the target’s; the group’s other sessions are other occasions, as other groups are.
- nirspipe.pipeline.hyper.pair_null.draw_id(draw: dict) str#
A draw’s name, its stand-ins’ recording ids joined by
+.
- nirspipe.pipeline.hyper.pair_null.pairing_stand_ins(ids: list[str], draws: list[dict]) dict#
Each pairing’s
(draw id, stand-in)for its later member, in draw order.ids [a, b, c], draws [{1: d, 2: e}] -> {(0, 1): [("d+e", d)], (0, 2): [("d+e", e)], (1, 2): [("d+e", e)]}
A draw’s id joins its stand-ins’ recording ids, so the pairings it serves share it and a dyad’s is its stand-in’s. A stand-in who is the pairing’s held member, another session of that person, is left out of that pairing only.
- nirspipe.pipeline.hyper.pair_null.real_table_params(real_tsv: pathlib.Path) dict#
The real WTC table’s own record of how it was computed, off its sidecar.
Raises rather than falling back on defaults, since nothing downstream could tell a null built on a guessed band from one built on the recorded one.
- nirspipe.pipeline.hyper.pair_null.complete_draws(candidates: dict, order: list[str], n_max: int, accepts) dict#
candidatescut to the firstn_maxdraws, inorder, whose every stand-inaccepts((i, j), entry)takes.A group’s pairings then share one list of draws, where a cap counted per pairing would let a pairing whose stand-in was refused run on to a later draw than the others:
draws d1, d2, d3; d1's stand-in for member 2 refused; n_max 2 -> every pairing gets d2 and d3
- nirspipe.pipeline.hyper.pair_null.recording_id(entry) str#
A stand-in’s name: a recording, not a person, so one person can stand in from several sessions.
- nirspipe.pipeline.hyper.pair_null.run_pair_null(group_id: str, task: str, members: list, groups: dict, derivatives_dir: pathlib.Path, output_dir: pathlib.Path, *, pool: str = 'position', n_max: int | None = None, desc: str | None = None, bads_scope: str | None = None, chroma: tuple[str, ...] = ('hbo', 'hbr'), cross: bool | None = None, limit_scales: bool = True, roi_map: dict[str, list[str]] | None = None, roi_map_name: str = 'custom', roi_min_channels: int | None = None, isc_whiten_s: float = 0.0, isc_max_lag_s: float = 0.0, isc_band: tuple[float | None, float | None] | None = None, session: str | None = None, device=None) pathlib.Path#
Draw, rank and write one group’s re-paired null.
Writes
..._cond-all_null-pair_stat-wtc_relmat.tsvwith the columns the phase-scrambled table has, plus the per-condition and homologous-ROI tables where the real side has them, and the crossed ROI table when both sides are crossed. Returns the whole-run path.Each pairing holds its earlier member and replaces its later one, by the draws of
stand_in_draws(): one stand-in per replaced member in each draw, the same in every pairing it closes, and the draw’s id, its stand-ins’ ids joined by+, shared by those pairings. A group with a pairing no draw can fill is refused before anything is drawn.The re-paired ISC rides along on the same draws.
Unlike the phase-scrambled null this runs after the real table rather than around it, and takes its band, its mask, its frequency range and its window off that sidecar. Its stage, its rejection scope and its ROI minimum come off it too unless given, and a given one that differs is refused; its crossing follows the table unless given, since a homologous null over a crossed table is a legitimate cheaper one. Its separation bands, the tasks a subject scope pooled rejections over, and whether the group was aligned or trimmed are always the table’s, so the null is drawn on the channels and the clock of the table it is ranked against. Draw and write are one step for the same reason: there is nothing to write between them, the table being ranked against is already on disk.
deviceis the card the transforms run on, None for the CPU; with no run record here, its check against the CPU goes into the sidecars.