Package 'fmrireport'

Title: PDF Reporting for fMRI GLM Fits
Description: Generates publication-oriented PDF reports for fitted fMRI GLM models from 'fmrireg'. Reports include model/design summaries, HRF plots, coefficient summaries, contrast brain maps, and peak coordinate tables.
Authors: Bradley Buchsbaum [aut, cre]
Maintainer: Bradley Buchsbaum <[email protected]>
License: GPL (>= 2)
Version: 0.1.0
Built: 2026-06-02 22:54:31 UTC
Source: https://github.com/bbuchsbaum/fmrireport

Help Index


Coerce cluster_table to a Flat data.frame

Description

Produces a flat data.frame suitable for table rendering. Cluster rows have all columns populated; sub-peak rows have k and volume_mm3 set to NA.

Usage

## S3 method for class 'cluster_table'
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  max_clusters = 30L,
  max_sub_peaks = 3L,
  ...
)

Arguments

x

A cluster_table object.

row.names

Ignored.

optional

Ignored.

max_clusters

Maximum clusters to include.

max_sub_peaks

Maximum sub-peaks per cluster.

...

Ignored.

Value

A data.frame.


Build a Publication-Quality Activation Cluster Table

Description

Detects suprathreshold clusters in a statistical brain volume and returns a structured table of cluster-level and peak-level statistics suitable for publication (NeuroImage / HBM / COBIDAS compliant).

Usage

cluster_table(
  vol,
  threshold,
  atlas = NULL,
  stat_type = c("t", "z", "F", "other"),
  df = NULL,
  coord_space = NULL,
  min_cluster_size = 10L,
  local_maxima_dist = 15,
  max_peaks = 3L,
  connectivity = c("26-connect", "18-connect", "6-connect"),
  sort_by = c("size", "peak_stat")
)

Arguments

vol

A NeuroVol object containing the statistical map.

threshold

Numeric threshold for cluster detection (absolute value).

atlas

Optional atlas object (e.g., a volatlas from neuroatlas) for anatomical labeling.

stat_type

Type of statistic in the volume: "t", "z", "F", or "other".

df

Degrees of freedom for p-value computation. A single value for t/z statistics, or a length-2 vector c(df1, df2) for F statistics. NULL omits p-values.

coord_space

Character string naming the coordinate space (e.g., "MNI152", "MNI305"). If NULL, inferred from atlas or set to "Unknown".

min_cluster_size

Minimum number of voxels for a cluster to be retained.

local_maxima_dist

Minimum distance (mm) between local maxima within a cluster.

max_peaks

Maximum number of sub-peaks reported per cluster.

connectivity

Voxel connectivity for cluster detection.

sort_by

Sort clusters by "size" (descending) or "peak_stat" (descending absolute value).

Value

An S3 object of class "cluster_table" with elements:

clusters

A data.frame with one row per cluster.

peaks

A data.frame with sub-peaks (local maxima) per cluster.

threshold

The threshold used.

stat_type

The statistic type.

df

Degrees of freedom.

n_clusters

Number of clusters.

coord_space

Coordinate space label.

atlas_name

Name of atlas used, or NA.


Format a cluster_table as a tinytable

Description

Returns a tinytable::tt() object with appropriate caption and formatting for Quarto/Typst rendering.

Usage

format_cluster_tt(x, max_clusters = 30L, max_sub_peaks = 3L, digits = 3L, ...)

Arguments

x

A cluster_table object.

max_clusters

Maximum clusters to include.

max_sub_peaks

Maximum sub-peaks per cluster.

digits

Number of digits for rounding numeric columns.

...

Passed to tinytable::tt().

Value

A tinytable object.


Print a cluster_table Object

Description

CLI-formatted hierarchical output showing clusters with sub-peaks indented.

Usage

## S3 method for class 'cluster_table'
print(x, max_clusters = 20L, max_sub_peaks = 3L, ...)

Arguments

x

A cluster_table object.

max_clusters

Maximum number of clusters to display.

max_sub_peaks

Maximum sub-peaks per cluster to display.

...

Ignored.

Value

Invisibly returns x.


Render Analysis Reports

Description

Generic report interface and fmri_lm implementation that renders a publication-style PDF report through Quarto.

Usage

report(x, ...)

## Default S3 method:
report(x, ...)

## S3 method for class 'fmri_lm'
report(
  x,
  output_file = "fmri_lm_report.pdf",
  title = "fMRI GLM Analysis Report",
  author = NULL,
  sections = c("model", "design", "hrf", "estimates", "contrasts", "diagnostics"),
  brain_map_stat = c("tstat", "estimate", "prob"),
  slice_axis = 3L,
  n_slices = 9L,
  threshold = NULL,
  bg_vol = NULL,
  atlas = NULL,
  cluster_thresh = 3,
  min_cluster_size = 10L,
  max_peaks = 15L,
  local_maxima_dist = 15,
  max_sub_peaks = 3L,
  open = interactive(),
  quiet = TRUE,
  ...
)

Arguments

x

Object to report on.

...

Additional arguments passed to methods.

output_file

Output PDF path.

title

Report title.

author

Optional author string.

sections

Sections to include.

brain_map_stat

Statistic for contrast maps: "tstat", "estimate", or "prob".

slice_axis

Axis for montage slicing (1, 2, or 3).

n_slices

Number of slices to render in contrast maps.

threshold

Optional hard threshold for contrast map rendering.

bg_vol

Optional background NeuroVol for overlay plots.

atlas

Optional atlas object for peak labeling.

cluster_thresh

Absolute statistic threshold for peak clustering.

min_cluster_size

Minimum cluster size (voxels) in peak table.

max_peaks

Maximum peaks per contrast table.

local_maxima_dist

Minimum distance (mm) between local maxima within a cluster for sub-peak detection. Default 15.

max_sub_peaks

Maximum number of sub-peaks per cluster in the activation table. Default 3.

open

If TRUE, open the generated PDF after rendering.

quiet

If TRUE, suppress Quarto render logs.

Value

Method-specific report output. For fmri_lm fits, returns the output PDF path invisibly.