nirspipe.pipeline.hyper.pair_null_group#
The re-paired null read above the cell: one verdict per occasion, one per cohort.
pair-null ranks each channel of each dyad inside its own draws, and a cell drawn against
n stand-ins cannot reach a p below 1/(n+1). Averaging first cannot say which channel, but it
can say whether the pairing beats its null at all.
Two levels, because they need different data and only one of them fits inside the per-dyad stage:
occasionthe channels averaged, ranked in that occasion’s own draws, each draw put onthe real pairing’s channels (matched_pools). One dyad’s draws are enough; it is here so that both levels come off one table.
cohortthe channels averaged and then the occasions averaged, against a null thatdraws one stand-in per occasion. This needs every occasion’s draws at once, which is why it cannot live in a stage that runs one dyad at a time.
A group of more than two members is one value per occasion as well, the mean over its member
pairings, and where the pairs table named roles each unordered role pair is also read on its
own (granularity rolepair).
A homologous null tests the homologous pairings only, since a crossed real table’s other cells have no null behind it. A crossed null also tests every pairing and, given a region map, every ordered region pair.
Module Contents#
Functions#
|
|
Each occasion-condition’s real channel mean, and its draws moved onto the real pairing’s channels. |
|
Each occasion’s channel mean, ranked in that occasion’s own draws on the real pairing’s channels. |
|
The cohort mean against its null, by both reads, one row of each per condition. |
|
Correct the cohort p within one condition at one level, when a method is asked for. |
|
The per-cell percentiles a null already wrote, turned into p values. |
|
Each channel pairing, and each region, ranked in its own draws. |
|
The nulls whose draws, coherence or correlation, a dyad tree holds for |
|
The chromophores one null’s draws, coherence or correlation, hold for |
|
Every level the draws support, for each statistic whose draws are on disk. |
Data#
API#
- nirspipe.pipeline.hyper.pair_null_group.logger = 'get_logger(...)'#
- nirspipe.pipeline.hyper.pair_null_group.REAL_SUFFIX = '_tail(...)'#
- nirspipe.pipeline.hyper.pair_null_group.CELL_SUFFIX = None#
- nirspipe.pipeline.hyper.pair_null_group.DRAWS_SUFFIX = None#
- nirspipe.pipeline.hyper.pair_null_group.ISC_REAL_SUFFIX = '_tail(...)'#
- nirspipe.pipeline.hyper.pair_null_group.ISC_DRAWS_SUFFIX = None#
- nirspipe.pipeline.hyper.pair_null_group.ISC_TESTS = ('signed', 'magnitude')#
- nirspipe.pipeline.hyper.pair_null_group.magnitude_against_unwhitened_phase(isc_test, null_kind, isc_whiten_s) bool#
|r|ranked against the phase null on correlations that were not whitened, whose p runs small.
- nirspipe.pipeline.hyper.pair_null_group.matched_pools(draws: pandas.DataFrame, real: pandas.DataFrame) dict[tuple, tuple[float, np.ndarray]]#
Each occasion-condition’s real channel mean, and its draws moved onto the real pairing’s channels.
real kept a b c at .40 .30 .20 (mean .30), a draw kept a b at .35 .25 -> over a and b the draw is .05 under the real; the draw counts as .30 - .05 = .25
Each draw is compared on the pairings it shares with the real one and the difference is taken off the real mean, so the pool ranks, averages and spreads as the draws would on the real pairing’s channels. With nothing rejected it is the draws’ own means. A draw sharing no pairing is left out.
A group of more than two members takes the mean over its member pairings of each one’s channel mean, and so does each draw: matched pairing by pairing, then averaged under the draw id its pairings share. A draw missing one of the pairings is left out.
- nirspipe.pipeline.hyper.pair_null_group.by_occasion(draws: pandas.DataFrame, real: pandas.DataFrame, two_sided: bool = False) pandas.DataFrame#
Each occasion’s channel mean, ranked in that occasion’s own draws on the real pairing’s channels.
- nirspipe.pipeline.hyper.pair_null_group.by_cohort(draws: pandas.DataFrame, real: pandas.DataFrame, n_resample: int = 20000, seed: int | None = None, two_sided: bool = False) pandas.DataFrame#
The cohort mean against its null, by both reads, one row of each per condition.
resampleredraws one stand-in per occasion and ranks the real statistic inside that, so the null’s width is the spread between an occasion’s own draws. Resampling rather than pairing the pools by index, because a draw’s position in one occasion’s pool means nothing in another’s.pairedaverages each occasion’s draws into one baseline and tests real against it paired over occasions, so the width is the spread between occasions.liftis the same number in both rows; what differs is what it is divided by. Each occasion’s draws are on the real pairing’s channels, as in matched_pools.
- nirspipe.pipeline.hyper.pair_null_group.correct_cohort(frame: pandas.DataFrame, method: str = 'none') pandas.DataFrame#
Correct the cohort p within one condition at one level, when a method is asked for.
channel granularity, N channels in one condition -> family N
familyis the number of tests a correction runs over, written whether or not one ran. At whole-brain granularity the family is one cell, so a corrected p equals its p.Rows whose
pis absent, which is what a paired test over fewer than three occasions leaves, take no part in any family.
- nirspipe.pipeline.hyper.pair_null_group.by_cell(output_dir: pathlib.Path, task: str, chroma: str, null: str, method: str = 'none') pandas.DataFrame | None#
The per-cell percentiles a null already wrote, turned into p values.
percentile 94.74 off 19 draws -> p 0.1, because 18 of 19 beaten is rank 2 of 20
The stage that writes a cell’s percentile runs one dyad at a time and so cannot correct across cells. One family per condition and level, so the crossed ROI matrix is corrected apart from the homologous regions: its diagonal is a different quantity from theirs.
- nirspipe.pipeline.hyper.pair_null_group.by_cell_from_draws(draws: pandas.DataFrame, real: pandas.DataFrame, two_sided: bool = False, method: str = 'none', roi_map: dict | None = None, min_channels: int = ROI_MIN_CHANNELS) pandas.DataFrame | None#
Each channel pairing, and each region, ranked in its own draws.
one occasion's S1_D1 > S2_D2 in game, real 0.31 against 9 draws -> one row with its p
For tables that store no percentile: the correlation’s cells are ranked here rather than read back, so that one switch sets their tail and the cohort’s. The levels and families are the ones by_cell reads for the coherence: channel, homologous region, and the crossed region matrix, each corrected on its own.
- nirspipe.pipeline.hyper.pair_null_group.nulls_on_disk(output_dir: pathlib.Path, task: str) list[str]#
The nulls whose draws, coherence or correlation, a dyad tree holds for
task.
- nirspipe.pipeline.hyper.pair_null_group.chromas_on_disk(output_dir: pathlib.Path, task: str, null: str) list[str]#
The chromophores one null’s draws, coherence or correlation, hold for
task.
- nirspipe.pipeline.hyper.pair_null_group.write_group_null(output_dir: pathlib.Path, task: str, chroma: str = 'hbo', null: str = 'repaired', roi_map: dict | None = None, n_resample: int = 20000, seed: int | None = None, p_correction: str = 'none', isc_test: str = 'signed') list[pathlib.Path]#
Every level the draws support, for each statistic whose draws are on disk.
Two files per statistic, not one per level: the levels differ in two columns and are read against each other, so they belong in one table. level is
wholeor a region name, pairings is which channel pairings entered the mean.Coherence is tested one-tailed, being unsigned. The correlation follows
isc_test.