nirspipe.pipeline.hyper.wtc_null#
The phase-scrambled null, computed and written on its own.
Called from nirspipe-hyper when --wtc-phase-null is given, so it inherits that run’s
stage, band, window and ROI minimum by construction. Crossing follows the real table unless
--wtc-phase-null-cross says otherwise, and n channels crossed give n^2 pairings and so n
times the surrogate cost of the n homologous ones.
The chromophores are inherited, unlike crossing, so no half of the real table is left with nothing to be tested against.
Two halves, and the report sits between them. run_wtc_null() draws the surrogates and
writes the per-frequency level the phase arrows are drawn against, which has to exist before
the figures are built. write_wtc_null() ranks those draws against the real band means,
which the same report writes.
Module Contents#
Functions#
Draw the null for one group and write the level its phase arrows are read against. |
|
Where the ROI maps’ phase-scrambled level goes, beside the channels’ own. |
|
What an ROI level depends on beyond a channel level: the map, its minimum, the crossing. |
|
Rank what |
Data#
API#
- nirspipe.pipeline.hyper.wtc_null.logger = 'getLogger(...)'#
- nirspipe.pipeline.hyper.wtc_null.run_wtc_null(group_id: str, task: str, aligned_raws: dict, output_dir: pathlib.Path, n_iter: int = 100, wtc_fmin: float = 0.004, wtc_fmax: float = 0.2, band_fmin: float | None = None, band_fmax: float | None = None, seed: int | None = None, cross: bool = False, limit_scales: bool = True, mask_coi: bool = True, chroma: tuple[str, ...] | list[str] = ('hbo', 'hbr'), sep_bands=None, windows: list[tuple[str, float, float]] | None = None, analysis_window: tuple[float, float] | None = None, whiten_s: float = 0.0, session: str | None = None, roi_map: dict[str, list[str]] | None = None, roi_map_name: str = 'custom', roi_min_channels: int = ROI_MIN_CHANNELS, device=None, reuse: bool = False, shared: bool = False, cond_cone: bool = False, margins: dict[str, tuple[float, float]] | None = None) dict#
Draw the null for one group and write the level its phase arrows are read against.
The expensive half:
n_iterfull WTC runs per chromophore. Writes..._chromo-<chroma>_null-phase_stat-wtc_desc-level_relmat.npz, the coherence a cell has to clear at each frequency to beat the null, and returns{chromophore: NullDraws}forwrite_wtc_null()to rank once the real tables exist.chromahas to cover the real run’s chromophores: a null computed on HbO says nothing about an HbR coupling, so a table missing one chromophore leaves that half of the real table with nothing to be tested against.analysis_windowis--tstart/--tend. The whole-run table has to be windowed the same way the real whole-run table was, or the two describe different spans of the recording and the comparison between them is not one.windowsis what--by-conditionread its conditions out of, and carries through to the second table. Both tables come out of this one pass ofn_itertransforms.cond_coneandmarginsmark each window’s condition cone as the real run did.roi_mapadds the ROI maps’ own level,roi_level_path(), from the same pass.deviceis the card the transforms run on, None for the CPU.reusekeeps a null already on disk when every level it wrote was drawn on these recordings with these settings, iterations and seed, and returns{}so nothing is written again; otherwise the null is drawn as usual.sharedrotates the scrambled member’s channels together in each draw; seecompute_wtc_phase_null().
- nirspipe.pipeline.hyper.wtc_null.roi_level_path(output_dir: pathlib.Path, group_id: str, task: str, ch_type: str, roi_map_name: str, session: str | None = None) pathlib.Path#
Where the ROI maps’ phase-scrambled level goes, beside the channels’ own.
- nirspipe.pipeline.hyper.wtc_null.roi_level_params(roi_map: dict, roi_min_channels: int, cross: bool) dict#
What an ROI level depends on beyond a channel level: the map, its minimum, the crossing.
A crossed (R, R) map averages every pairing inside R and an uncrossed R only the same-channel ones, so a level of one is not a level of the other.
- nirspipe.pipeline.hyper.wtc_null.write_wtc_null(nulls: dict, group_id: str, task: str, aligned_raws: dict, output_dir: pathlib.Path, n_iter: int = 100, wtc_fmin: float = 0.004, wtc_fmax: float = 0.2, band_fmin: float | None = None, band_fmax: float | None = None, seed: int | None = None, cross: bool = False, mask_coi: bool = True, windows: list[tuple[str, float, float]] | None = None, analysis_window: tuple[float, float] | None = None, roi_map: dict[str, list[str]] | None = None, roi_map_name: str = 'custom', roi_min_channels: int = ROI_MIN_CHANNELS, whiten_s: float = 0.0, session: str | None = None, shared: bool = False, cond_cone: bool = False) pathlib.Path#
Rank what
run_wtc_null()drew against the real band means, and write it.Writes
..._null-phase_stat-wtc_relmat.tsv, one table with achromophorecolumn, matching the real band-mean tables. The sidecar additionally recordsn_iter,cross,chromaandphase_null_shared, without which a 5-iteration probe and a 100-iteration null are indistinguishable on disk.roi_mapadds theagg-homologoustwin, the null for the homologous ROI means beside it. It is free: the iterations are grouped into regions before they are summarised, so no surrogate is transformed a second time, and grouping inside the iteration is what makes it the null of the ROI mean rather than a bracket around it. A null drawn crossed also writes theagg-roitwin, the null for the crossed ROI x ROI matrix, when the real ROI table is crossed too; a homologous null never drew the off-diagonal pairings that matrix averages. Both group their cells underroi_min_channels, the rule the real ROI tables were blanked by.windowsadds the null for what--by-conditionwrote, as rows of the same tables with aconditioncolumn, the whole run’s rows carryingn/a: the shape of the real tables. Only the draws, which exist per condition only, keep acond-allfile of their own.The real tables are read back off disk rather than passed in, the report step having just written them, and are what gives the rows their
percentilecolumn. A tree without them still gets a null, just one nothing has been ranked against yet.