Skip to content

Commit c5705eb

Browse files
committed
Resolving Epoch Handling Issues
1 parent b6cd5f4 commit c5705eb

File tree

3 files changed

+1389
-1387
lines changed

3 files changed

+1389
-1387
lines changed

mne/report/report.py

Lines changed: 25 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Generate self-contained HTML reports from MNE objects."""
1+
"Generate self-contained HTML reports from MNE objects."""
22

33
# Authors: The MNE-Python contributors.
44
# License: BSD-3-Clause
@@ -830,7 +830,9 @@ def __init__(
830830
img_max_res=MAX_IMG_RES,
831831
collapse=(),
832832
verbose=None,
833+
833834
):
835+
self.projs = projs # Initialize self.projs
834836
self.info_fname = str(info_fname) if info_fname is not None else None
835837
self.cov_fname = str(cov_fname) if cov_fname is not None else None
836838
self.baseline = baseline
@@ -842,7 +844,7 @@ def __init__(
842844
self.subject = subject
843845
self.title = title
844846
self.image_format = _check_image_format(None, image_format)
845-
self.projs = projs
847+
846848
# dom_id is mostly for backward compat and testing nowadays
847849
self._dom_id = 0
848850
self._dup_limit = 10000 # should be enough duplicates
@@ -1249,19 +1251,26 @@ def add_epochs(
12491251
.. versionadded:: 0.24
12501252
"""
12511253
tags = _check_tags(tags)
1252-
add_projs = self.projs if projs is None else projs
1253-
self._add_epochs(
1254-
epochs=epochs,
1255-
psd=psd,
1256-
add_projs=add_projs,
1257-
image_kwargs=image_kwargs,
1258-
topomap_kwargs=topomap_kwargs,
1259-
drop_log_ignore=drop_log_ignore,
1260-
section=title,
1261-
tags=tags,
1262-
image_format=self.image_format,
1263-
replace=replace,
1264-
)
1254+
add_projs = self.projs if projs is None else projs
1255+
1256+
if epochs._bad_dropped:
1257+
reject_info = f"<p><strong>Rejection Thresholds:</strong> {epochs.reject}</p>"
1258+
flat_info = f"<p><strong>Flat Thresholds:</strong> {epochs.flat}</p>"
1259+
self.add_html(reject_info + flat_info)
1260+
1261+
self._add_epochs(
1262+
epochs=epochs,
1263+
psd=psd,
1264+
add_projs=add_projs,
1265+
image_kwargs=image_kwargs,
1266+
topomap_kwargs=topomap_kwargs,
1267+
drop_log_ignore=drop_log_ignore,
1268+
section=title,
1269+
tags=tags,
1270+
image_format=self.image_format,
1271+
replace=replace,
1272+
)
1273+
12651274

12661275
@fill_doc
12671276
def add_evokeds(
@@ -1304,6 +1313,7 @@ def add_evokeds(
13041313
%(n_jobs)s
13051314
13061315
Notes
1316+
13071317
-----
13081318
.. versionadded:: 0.24.0
13091319
"""
@@ -2212,68 +2222,6 @@ def remove(self, *, title=None, tags=None, remove_all=False):
22122222

22132223
return remove_idx
22142224

2215-
@fill_doc
2216-
def _add_or_replace(self, *, title, section, tags, html_partial, replace=False):
2217-
"""Append HTML content report, or replace it if it already exists.
2218-
2219-
Parameters
2220-
----------
2221-
title : str
2222-
The title entry.
2223-
%(section_report)s
2224-
tags : tuple of str
2225-
The tags associated with the added element.
2226-
html_partial : callable
2227-
Callable that renders a HTML string, called as::
2228-
2229-
html_partial(id_=...)
2230-
replace : bool
2231-
Whether to replace existing content if the title and section match.
2232-
If an object is replaced, its dom_id is preserved.
2233-
"""
2234-
assert callable(html_partial), type(html_partial)
2235-
2236-
# Temporarily set HTML and dom_id to dummy values
2237-
new_content = _ContentElement(
2238-
name=title, section=section, dom_id="", tags=tags, html=""
2239-
)
2240-
2241-
append = True
2242-
if replace:
2243-
matches = [
2244-
ii
2245-
for ii, element in enumerate(self._content)
2246-
if (element.name, element.section) == (title, section)
2247-
]
2248-
if matches:
2249-
dom_id = self._content[matches[-1]].dom_id
2250-
self._content[matches[-1]] = new_content
2251-
append = False
2252-
if append:
2253-
dom_id = self._get_dom_id(section=section, title=title)
2254-
self._content.append(new_content)
2255-
new_content.dom_id = dom_id
2256-
new_content.html = html_partial(id_=dom_id)
2257-
assert isinstance(new_content.html, str), type(new_content.html)
2258-
2259-
def _add_code(self, *, code, title, language, section, tags, replace):
2260-
if isinstance(code, Path):
2261-
code = Path(code).read_text()
2262-
html_partial = partial(
2263-
_html_code_element,
2264-
tags=tags,
2265-
title=title,
2266-
code=code,
2267-
language=language,
2268-
)
2269-
self._add_or_replace(
2270-
title=title,
2271-
section=section,
2272-
tags=tags,
2273-
html_partial=html_partial,
2274-
replace=replace,
2275-
)
2276-
22772225
@fill_doc
22782226
def add_code(
22792227
self,

0 commit comments

Comments
 (0)