nirspipe.pipeline.hyper.wtc_store#
Save the WTC time-frequency maps to disk, and re-average a saved one over a new band.
The band mean written beside the archive is the cheap half of the calculation, so the maps saved here let a new band be averaged offline, without a new wavelet transform.
Module Contents#
Functions#
Write every pair’s coherence map, its cone of influence and the axes to one npz. |
|
Read back what |
|
Write the phase-scrambled null’s per-frequency levels, keyed the way the maps are. |
|
Read back what |
|
Write per-condition levels, |
|
Read back |
|
What a per-frequency level depends on, so a report can tell whether one still fits it. |
|
Why the level at |
|
Band means over a new band, from saved maps rather than a new wavelet transform. |
|
Re-average every saved map under output_dir, writing one TSV beside each npz. |
Data#
API#
- nirspipe.pipeline.hyper.wtc_store.logger = 'get_logger(...)'#
- nirspipe.pipeline.hyper.wtc_store.save_wtc(result: nirspipe.pipeline.hyper.wtc.WTCResult, path: pathlib.Path) pathlib.Path#
Write every pair’s coherence map, its cone of influence and the axes to one npz.
Stored as float32, which is what the maps already are.
The relative phase is stored beside each map when the pair carries one, so the arrows can be redrawn from a saved run. A pair stored without one gets a phase of None from
load_wtc(). A pairing’s excluded columns are stored when it has any, so a re-band leaves them out as the table beside it did.
- nirspipe.pipeline.hyper.wtc_store.load_wtc(path: pathlib.Path) nirspipe.pipeline.hyper.wtc.WTCResult#
Read back what
save_wtc()wrote, as the same WTCResult the pipeline builds.
- nirspipe.pipeline.hyper.wtc_store.save_null_levels(levels: dict, path: pathlib.Path) pathlib.Path#
Write the phase-scrambled null’s per-frequency levels, keyed the way the maps are.
{("sub-01", "sub-02", "S1_D1"): ndarray(51,)} -> one npz of 51-long float32 arrays
Tiny beside the maps: one row per pair, not one map per pair, so it is written whether or not
--wtc-save-mapswas asked for. The report needs it to draw arrows against the null.
- nirspipe.pipeline.hyper.wtc_store.load_null_levels(path: pathlib.Path) dict#
Read back what
save_null_levels()wrote, keyed asresult.pairsis.
- nirspipe.pipeline.hyper.wtc_store.save_cond_null_levels(levels: dict, path: pathlib.Path) pathlib.Path#
Write per-condition levels,
{condition: {(sub1, sub2, label): ndarray}}, to one npz.
- nirspipe.pipeline.hyper.wtc_store.load_cond_null_levels(path: pathlib.Path) dict#
Read back
save_cond_null_levels(), as{condition: {(sub1, sub2): {label: level}}}.
- nirspipe.pipeline.hyper.wtc_store.level_params(raws: dict, *, wtc_fmin: float, wtc_fmax: float, mask_coi: bool, whiten_s: float = 0.0) dict#
What a per-frequency level depends on, so a report can tell whether one still fits it.
The writer of a level and the report that thresholds against it both call this on their own recordings, and a level is used only when the two dicts agree. The band is not in it: a level is per frequency, and the band only chooses which frequencies are averaged. Nor is
--tstart/--tend: the phase-scrambled level is counted over the whole record, and a re-paired one is checked condition by condition against its spans. Each member’sBAD_spans are, since the level leaves their time out.
- nirspipe.pipeline.hyper.wtc_store.level_mismatch(path: pathlib.Path, expected: dict, raws: dict) str | None#
Why the level at
pathcannot be used for these recordings, or None if it can.a level written on desc-preproc, read by a run on desc-errts -> "its Sources differ"
- nirspipe.pipeline.hyper.wtc_store.reband(path: pathlib.Path, fmin: float, fmax: float, mask_coi: bool = True) pandas.DataFrame#
Band means over a new band, from saved maps rather than a new wavelet transform.
The band has to sit inside the range the maps were computed over: what was filtered out before saving cannot be recovered here, and
wtc_band_mean()says so if it is empty.
- nirspipe.pipeline.hyper.wtc_store.reband_tree(output_dir: pathlib.Path, fmin: float, fmax: float, suffix: str | None = None, mask_coi: bool = True) list[pathlib.Path]#
Re-average every saved map under output_dir, writing one TSV beside each npz.
The new tables are named after the band so they sit next to the original without overwriting it.
An archive carrying a
chromo-entity gets itschromophorecolumn back, so the re-banded table has the shapenirspipe-hyperwrites.