Add standalone DIPFIT source-localization parity - #169
Conversation
|
Claude finished @suraj-ranganath's task in 4m 30s —— View job Code review
BlockingNone. Important1. map_rows = _map_rows_for_channels(EEG, maps, chansel, len(chanlocs))
positions = _channel_positions([chanlocs[index - 1] for index in chansel])
...
selected_maps = maps[map_rows, :][:, [component - 1 for component in selected_components]]
labels = [str(chanlocs[index - 1].get("labels") or index) for index in chansel]When Why it matters: this breaks gridsearch/nonlinear/multifit for any dataset where Suggested fix: derive the matching channel subset together with Nits2. Redundant double threshold conversion in
Test gaps3. No coverage for EEGLAB parity notes4. Possible one-voxel offset in voxel_centers = indices * int(downsample) + (int(downsample) - 1) / 2.0
homogeneous = np.column_stack([voxel_centers + 1.0, np.ones(indices.shape[0])])
xyz = homogeneous @ np.asarray(image.affine, dtype=float).T
Checked: spherical leadfield/fit math, coordinate transforms ( |
|
🤖 Specification for the Phase 3 DIPFIT/source-localization implementation. Problem Approach Key code def leadfield_matrix(electrodes: np.ndarray, sources: np.ndarray) -> list[np.ndarray]:
"""Return one average-referenced 3-column leadfield per source point."""
source_points, _ = _as_positions(sources)
return [_average_reference(_unit_moment_leadfield(electrodes, point)) for point in source_points]
def dipfit_gridsearch(
EEG: dict[str, Any],
component: Any = None,
xgrid: Any = None,
ygrid: Any = None,
zgrid: Any = None,
*,
reject: float | None = None,
) -> dict[str, Any]:Tests |
|
🤖 Validation correction: initialized the EEGLAB submodule in the phase worktree plus the matrix-covered nested references ( |
|
🤖 Addressed the Claude review findings in
Validation after the fix:
|
…ompletion' into phase/160-dipfit-source-parity # Conflicts: # .notes/implementation-notes.html








Add native spherical DIPFIT fitting, coordinate transforms, electrode realignment, atlas loading boundary, leadfield generation, plotting, and batch/manual wrapper behavior for standalone workflows. Update help, docs, the parity matrix, visual evidence, and tests while keeping MRI/BEM/LORETA external-backend limitations explicit.
Closes #160