Source MixStyle
neureptrace.decoding.source_mixstyle implements a source-only feature-space MixStyle augmentation for cross-subject domain generalization.
The method estimates per-source-domain feature means and scales, then creates synthetic source rows by mixing each row's domain statistics with another source domain's statistics. Labels are copied from the source rows. Held-out target features and target labels are not part of the API.
This is a Protocol 1 / strict source-only augmentation:
- uses
X_s,y_s, and source-domain ids, - does not use
X_t, - does not use
y_t.
neureptrace.decoding.source_mixstyle
Source-only MixStyle augmentation for cross-subject domain generalization.
The helpers in this module implement a feature-space variant of MixStyle for M/EEG transfer experiments. Synthetic source rows are generated by replacing a trial's source-domain style statistics with a convex mixture of its own domain statistics and another source domain's statistics. Labels are copied from the source row; held-out target features and target labels are intentionally absent from the public API.
SourceMixStyleConfig
dataclass
Configuration for source-only feature-space MixStyle augmentation.
Source code in src/neureptrace/decoding/source_mixstyle.py
28 29 30 31 32 33 34 35 36 37 | |
SourceMixStyleResult
dataclass
Augmented source features, labels, weights, and provenance.
Source code in src/neureptrace/decoding/source_mixstyle.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
n_original
property
Number of original rows retained in the output.
n_synthetic
property
Number of synthetic rows appended to the output.
source_mixstyle_config(*, mixes_per_row=DEFAULT_MIXSTYLE_MIXES_PER_ROW, alpha=DEFAULT_MIXSTYLE_ALPHA, style_strength=DEFAULT_MIXSTYLE_STYLE_STRENGTH, synthetic_weight=DEFAULT_MIXSTYLE_SYNTHETIC_WEIGHT, include_original=True, random_state=13)
Normalize user-facing MixStyle augmentation options.
Source code in src/neureptrace/decoding/source_mixstyle.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
augment_source_domains_mixstyle(source_features, source_labels, source_domains, *, config=None)
Return source-only MixStyle-augmented feature rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_features
|
Sequence[Sequence[float]] | ndarray
|
Source feature rows pooled across source subjects or source domains. |
required |
source_labels
|
Sequence[Any] | ndarray
|
One source label per feature row. Labels are copied to synthetic rows. |
required |
source_domains
|
Sequence[Hashable] | ndarray
|
One source-domain identifier per feature row, typically the source subject. |
required |
config
|
SourceMixStyleConfig | Mapping[str, Any] | None
|
MixStyle configuration. A mapping is normalized through
:func: |
None
|
Returns:
| Type | Description |
|---|---|
SourceMixStyleResult
|
Augmented source rows, copied labels, sample weights, source-domain ids, a synthetic-row mask, and protocol metadata. |
Notes
This is a strict source-only Protocol-1 augmentation. It uses X_s,
y_s, and source-domain ids only. No held-out target features or target
labels are accepted by this API.
Source code in src/neureptrace/decoding/source_mixstyle.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
mixstyle_row(row, *, source_stats, partner_stats, lam, style_strength=DEFAULT_MIXSTYLE_STYLE_STRENGTH)
Transform one feature row with mixed source-domain style statistics.
Source code in src/neureptrace/decoding/source_mixstyle.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |