ActiveInferenceInstitute

geo-infer-spm

Statistical Parametric Mapping for geospatial data. Use when performing GLM-based spatial analysis, random field theory corrections, cluster-level inference, or neuroimaging-style statistical mapping on geographic datasets.

ActiveInferenceInstitute 15 2 Updated 2w ago

Resources

9
GitHub

Install

npx skillscat add activeinferenceinstitute/geo-infer/geo-infer-spm

Install via the SkillsCat registry.

About this skill

This skill performs statistical parametric mapping on geospatial datasets using General Linear Models and random field theory. It enables cluster-level inference and multiple comparison corrections for geographic data. Developers should use it when performing neuroimaging-style statistical mapping or spatial contrast testing on coordinate-based datasets.

SKILL.md

GEO-INFER-SPM

Instructions

Core Capabilities

  • GLM fitting: General linear models with spatial design matrices
  • Random field theory: Multiple comparison correction for spatial data
  • Cluster inference: Cluster-level and peak-level statistics
  • Contrast testing: T-contrasts and F-contrasts on spatial maps
  • Visualization: Interactive time series explorer (mean±SD + residuals)

Key Imports

from geo_infer_spm.core.glm import GeneralLinearModel
from geo_infer_spm.core.rft import RandomFieldTheory
from geo_infer_spm.models.data_models import SPMData, SPMResult
from geo_infer_spm.visualization.interactive import create_time_series_explorer

Random Field Theory Inference

import numpy as np
from geo_infer_spm.core.rft import RandomFieldTheory

rft = RandomFieldTheory(
    field_shape=(64, 64),
    smoothness=np.array([4.5, 4.5]),
)
rft.compute_resel_counts()

peak_height = rft.peak_threshold(0.05, stat_type="Z", two_sided=True)
cluster_p = rft.cluster_extent_p_value(
    extent=1.25,
    cluster_forming_threshold=3.09,
    stat_type="Z",
    two_sided=True,
)

Examples

from geo_infer_spm.models.data_models import SPMData
import numpy as np

data = SPMData(
    data=np.random.randn(100, 50),
    coordinates=np.column_stack([
        np.random.uniform(-90, 90, 100),   # latitudes
        np.random.uniform(-180, 180, 100)   # longitudes
    ])
)

Guidelines

  • Coordinates must be valid: latitude ∈ [-90, 90], longitude ∈ [-180, 180]
  • GLM implementation is Alpha status — spatial design matrices in progress
  • Time series explorer uses Plotly for interactive mean±SD visualization
  • Test: uv run python -m pytest GEO-INFER-SPM/tests/ -v

Integrations

  • MATH → Spatial statistics and topology input
  • BAYES → Bayesian GLM parameter estimation
  • SPACE → Spatial residual fields from H3 grids
  • AI → Feature engineering for statistical maps