Precomputed foundation features
neureptrace.decoding.precomputed_foundation supports a dependency-light frozen-feature workflow for external EEG/MEG foundation encoders.
Use this when BENDR, LaBraM, EEGPT, CBraMod, or a project-local encoder has already exported a row-aligned feature table. NeuRepTrace then aligns rows by id and trains a source-label probe without importing the upstream model package.
Supported table formats:
.npzwith a feature matrix and optional row ids,.npyfeature matrix with sequential row ids,.csv/.tsvwith a row-id column and numeric feature columns.
The module does not accept held-out target labels in the probe API. The feature_fit_scope metadata records whether the external feature extractor was declared as strict source-only, unlabeled target-adaptive, target-calibrated, or oracle/target-included.
neureptrace.decoding.precomputed_foundation
Precomputed foundation-feature tables for frozen M/EEG probes.
This module covers the dependency-light foundation-model path: external encoders such as BENDR, LaBraM, EEGPT, CBraMod, or project-local models can export a table of trial features, and NeuRepTrace can align those rows to fold-local metadata and train ordinary source-label probes without importing the upstream model package.
The loader/probe API intentionally does not accept held-out target labels. The
feature_fit_scope metadata records how the external features were produced so
strict source-only, unlabeled target-adaptive, and calibrated feature extractors
remain distinguishable in reports.
PrecomputedFoundationFeatureTable
dataclass
Immutable feature table keyed by row id.
Source code in src/neureptrace/decoding/precomputed_foundation.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
n_features
property
Number of feature columns in the table.
n_rows
property
Number of rows in the feature table.
row_index()
Return a row-id to row-index mapping.
Source code in src/neureptrace/decoding/precomputed_foundation.py
101 102 103 104 | |
PrecomputedFoundationProbeResult
dataclass
Source-label probe fitted on precomputed foundation features.
Source code in src/neureptrace/decoding/precomputed_foundation.py
107 108 109 110 111 112 113 114 115 116 117 | |
load_precomputed_foundation_features(path, *, features_key=DEFAULT_FEATURES_KEY, row_id_key=DEFAULT_ROW_ID_KEY, row_id_column=DEFAULT_ROW_ID_COLUMN, feature_columns=None, feature_prefix=None, allow_pickle=False, delimiter=None, feature_fit_scope='external_frozen', source_model='external')
Load precomputed foundation features from .npy, .npz, or CSV/TSV.
Source code in src/neureptrace/decoding/precomputed_foundation.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
make_precomputed_foundation_feature_table(features, row_ids=None, *, feature_names=None, feature_fit_scope='external_frozen', source_model='external')
Create a feature table directly from in-memory arrays.
Source code in src/neureptrace/decoding/precomputed_foundation.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
align_precomputed_foundation_features(table, row_ids)
Return table rows in the requested row-id order.
Source code in src/neureptrace/decoding/precomputed_foundation.py
190 191 192 193 194 195 196 197 198 199 200 201 202 | |
fit_precomputed_foundation_probe(*, feature_table, train_row_ids, train_labels, test_row_ids, classifier=None, classifier_C=1.0, classifier_max_iter=1000, classifier_class_weight='balanced', sample_weight=None)
Train a source-label probe on precomputed foundation features.
Source code in src/neureptrace/decoding/precomputed_foundation.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
normalize_feature_fit_scope(value)
Normalize feature-extractor fit-scope aliases to protocol categories.
Source code in src/neureptrace/decoding/precomputed_foundation.py
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |