nirspipe.pipeline.hyper.hyper_post

Contents

nirspipe.pipeline.hyper.hyper_post#

The analysis behind nirspipe-hyper: the WTC and ISC runs, and the tables they write.

Nothing here draws. The transform covers every pairing at once and a figure is of one pairing, so the two are separated; nirspipe.qc.hyper.hyper_report draws the HyperPostResult this returns, and skips the transform when handed one.

Module Contents#

Classes#

HyperPostConfig

Every --wtc-* option of nirspipe-hyper, with the derived values resolved once.

HyperPostResult

What one dyad’s post run produced: the transforms, the numbers, and where they went.

Functions#

write_isc_matrix

Write the matrix the ISC panel is drawn from, so the numbers can leave the report.

run_hyper_post

Run the coherence and the correlation for one dyad, and write every table they make.

Data#

API#

nirspipe.pipeline.hyper.hyper_post.logger = 'get_logger(...)'#
class nirspipe.pipeline.hyper.hyper_post.HyperPostConfig#

Every --wtc-* option of nirspipe-hyper, with the derived values resolved once.

Field names are the CLI’s. band_fmin, band_fmax, chroma and cond_pad_s are the resolved forms, in one place so the tables and the figures cannot fall back differently.

wtc_fmin: float = 0.004#
wtc_fmax: float = 0.2#
wtc_band_fmin: float | None = None#
wtc_band_fmax: float | None = None#
wtc_significance: bool = False#
wtc_seed: int | None = None#
wtc_mc_count: int = 300#
wtc_channel_cross: bool = False#
wtc_by_condition: bool = False#
wtc_window_s: float | None = None#
wtc_cond_pad_s: float | None = None#
wtc_cond_cone: bool = True#
wtc_limit_scales: bool = True#
wtc_save_maps: bool = False#
wtc_mask_coi: bool = True#
wtc_roi_min_channels: int = None#
wtc_chroma: Any = ('hbo', 'hbr')#
wtc_whiten_s: float = 0.0#
isc_whiten_s: float = 0.0#
isc_max_lag_s: float = 0.0#
isc_phase_null: int = 0#
phase_null_shared: bool = False#
isc_band: tuple[float | None, float | None] | None = None#
roi_map: dict | None = None#
roi_map_name: str = 'custom'#
sep_bands: Any = None#
analysis_window: tuple[float, float] | None = None#
desc: str | None = None#
bads_scope: str | None = None#
bads_scope_tasks: list[str] | None = None#
device: Any = None#
member_roles: dict | None = None#
chroma: tuple = 'field(...)'#
band_fmin: float = 'field(...)'#
band_fmax: float = 'field(...)'#
cond_pad_s: float | None = 'field(...)'#
class nirspipe.pipeline.hyper.hyper_post.HyperPostResult#

What one dyad’s post run produced: the transforms, the numbers, and where they went.

passes is keyed by chromophore, each holding the whole-run WTCResult under result, its band means under chan and roichan, and the windows under cond_wtc / cond_bands positionally over cond_windows -- positional so the chromophores line up even where a guard failed on one.

isc is {pairing: {label or None: {chromophore: (matrix, channel names)}}}, and isc_roi the same shape over the ROI means of those matrices. chan_axis and roi_labels are the axes every panel and matrix is indexed by; they ride here so a panel cannot be drawn on a different axis than the table beside it.

subject_ids: list[str] = None#
chroma: tuple = None#
band_fmin: float = None#
band_fmax: float = None#
cond_windows: list = None#
cond_pad_s: float | None = None#
chan_axis: list[str] = None#
roi_labels: list[str] = None#
roi_rows: list[dict] = None#
passes: dict = None#
chan_band_df: Any = None#
roi_band_df: Any = None#
isc: dict = 'field(...)'#
isc_roi: dict = 'field(...)'#
isc_levels: dict = 'field(...)'#
isc_level_sources: dict = 'field(...)'#
align_info: dict = 'field(...)'#
tables: dict = 'field(...)'#
roi_levels: dict = 'field(...)'#
nirspipe.pipeline.hyper.hyper_post.write_isc_matrix(tsv_path: pathlib.Path, isc_mat, ch_names: list[str], ch_type: str, sources: list[str], subject_ids: list[str], align: dict | None = None, step: str = 'hyper_isc', index_label: str = 'channel', **params) → None#

Write the matrix the ISC panel is drawn from, so the numbers can leave the report.

Both axes carry the montage’s channel labels, which is how compute_isc_pairs() pairs the two brains: cell (i, j) is the first subject’s channel i against the other’s channel j. Rejected channels are blank rather than absent, so the file’s shape is the montage’s however many channels a given dyad lost.

step and index_label are what let this serve the ROI means of those matrices too, which are the same square shape over regions instead of channels.

align is what alignment_params() returned, so the file says which alignment it got.

A failure here costs the file and not the panel: the report is still readable without it.

nirspipe.pipeline.hyper.hyper_post.run_hyper_post(group_id: str, task: str, aligned_raws: dict, output_dir: pathlib.Path, config: nirspipe.pipeline.hyper.hyper_post.HyperPostConfig, *, subject_ids: list[str], pairings: list, align_info: dict, cond_windows: list[tuple[str, float, float]] | None = None, cond_margins: dict[str, tuple[float, float]] | None = None, errors: list | None = None, notes: list | None = None, scope: str = '', session: str | None = None) → nirspipe.pipeline.hyper.hyper_post.HyperPostResult#

Run the coherence and the correlation for one dyad, and write every table they make.

cond_windows supplies the per-condition windows instead of resolving them here: the caller passes the same list to the phase-scrambled null, and the two tables are only subtractable row by row if they describe the same windows.

cond_margins is, per window cut out of a condition, the seconds from it back to its condition’s start and on to its end, so wtc_cond_cone lays the cone at the condition’s edges and not the window’s. A window absent from it is a condition itself.

errors and notes are the report’s own lists, so a guard that fails here reaches the footer of the page this result is drawn on and not only the run log.