Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mne/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ def pytest_configure(config: pytest.Config):
# sklearn
ignore:Python binding for RankQuantileOptions.*:RuntimeWarning
ignore:.*The `disp` and `iprint` options of the L-BFGS-B solver.*:DeprecationWarning
# matplotlib<->nilearn
ignore:[\S\s]*You are using the 'agg' matplotlib backend[\S\s]*:UserWarning
""" # noqa: E501
for warning_line in warning_lines.split("\n"):
warning_line = warning_line.strip()
Expand Down
22 changes: 19 additions & 3 deletions mne/forward/_make_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ def __init__(
self.mindist = mindist
self.n_jobs = n_jobs
src = SourceSpaces([])
self.sensors, _, _, _, self.bem = _prepare_for_forward(
self.sensors, _, _, self.update_kwargs, self.bem = _prepare_for_forward(
src,
self.mri_head_t,
info,
Expand All @@ -988,8 +988,13 @@ def __init__(
def compute(self, src):
src = _ensure_src(src).copy()
src._transform_to("head", self.mri_head_t)
kwargs = dict(limit=self.mindist, mri_head_t=self.mri_head_t, src=src)
_filter_source_spaces(self.check_inside, n_jobs=self.n_jobs, **kwargs)
_filter_source_spaces(
self.check_inside,
n_jobs=self.n_jobs,
limit=self.mindist,
mri_head_t=self.mri_head_t,
src=src,
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a refactor that makes sense to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think that was just cruft from when I was working on it and there were two code paths 🤦

rr = np.concatenate([s["rr"][s["vertno"]] for s in src])
if len(rr) < 1:
raise RuntimeError(
Expand All @@ -1012,4 +1017,15 @@ def compute(self, src):
}
fwd = _merge_fwds(fwds, verbose=False)
del fwds

fwd.update(**self.update_kwargs)
# Delete some keys to clean up the source space:
for key in ["working_dir", "command_line"]:
if key in src.info:
del src.info[key]
# our `update_kwargs` set these, but they need to be updated for this src
fwd["src"] = src
fwd["nsource"] = sum(s["nuse"] for s in src)
fwd["source_rr"] = np.vstack([s["rr"][s["inuse"] == 1] for s in src])
fwd["source_nn"] = np.tile(np.eye(3), (fwd["nsource"], 1))
return fwd
2 changes: 2 additions & 0 deletions mne/forward/tests/test_make_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,8 @@ def test_make_forward_iterative():
fwd = make_forward_solution(raw.info, trans, src, bem, mindist=0, verbose=True)
# check against iterative version
fm = _ForwardModeler(raw.info, trans, bem)
fwd_iterative = fm.compute(src)
_compare_forwards(fwd, fwd_iterative, fwd["nchan"], 3 * fwd["nsource"])
midpt = fwd["nsource"] // 2
assert fwd["coord_frame"] == FIFF.FIFFV_COORD_HEAD
fwd_data = list()
Expand Down
Loading