Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MRG: Add fnirs and snirf support to report #9443

Merged
merged 6 commits into from
Jun 6, 2021
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 doc/changes/latest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Enhancements
- Add projections when printing a :class:`mne.Info` in the notebook (:gh:`9403` by `Alex Gramfort`_)

- Add support for interpolating oxy and deoxyhaemoglobin data types (:gh:`9431` by `Robert Luke`_)

- Add support for SNIRF files in :class:`mne.Report` (:gh:`9443` by `Robert Luke`_)

Bugs
~~~~
Expand Down
3 changes: 2 additions & 1 deletion mne/io/_read_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
read_raw_fif, read_raw_eeglab, read_raw_cnt, read_raw_egi,
read_raw_eximia, read_raw_nirx, read_raw_fieldtrip,
read_raw_artemis123, read_raw_nicolet, read_raw_kit,
read_raw_ctf, read_raw_boxy)
read_raw_ctf, read_raw_boxy, read_raw_snirf)
from ..utils import fill_doc


Expand All @@ -39,6 +39,7 @@ def _read_unsupported(fname, **kwargs):
".mff": read_raw_egi,
".nxe": read_raw_eximia,
".hdr": read_raw_nirx,
".snirf": read_raw_snirf,
".mat": read_raw_fieldtrip,
".bin": read_raw_artemis123,
".data": read_raw_nicolet,
Expand Down
5 changes: 3 additions & 2 deletions mne/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
RAW_EXTENSIONS.append(f'meg{ext}')
RAW_EXTENSIONS.append(f'eeg{ext}')
RAW_EXTENSIONS.append(f'ieeg{ext}')
RAW_EXTENSIONS.append(f'nirs{ext}')

# Processed data will always be in (gzipped) FIFF format
VALID_EXTENSIONS = ('sss.fif', 'sss.fif.gz',
Expand Down Expand Up @@ -258,7 +259,7 @@ def _get_toc_property(fname):
div_klass = 'ssp'
tooltip = fname
text = op.basename(fname)
elif _endswith(fname, ['raw', 'sss', 'meg']):
elif _endswith(fname, ['raw', 'sss', 'meg', 'nirs']):
div_klass = 'raw'
tooltip = fname
text = op.basename(fname)
Expand Down Expand Up @@ -314,7 +315,7 @@ def _update_html(html, report_fname, report_sectionlabel):
% op.join('...' + report.data_path[-20:],
fname))
try:
if _endswith(fname, ['raw', 'sss', 'meg']):
if _endswith(fname, ['raw', 'sss', 'meg', 'nirs']):
html = report._render_raw(fname, data_path)
report_fname = fname
report_sectionlabel = 'raw'
Expand Down
8 changes: 7 additions & 1 deletion mne/tests/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
'data'))
evoked_fname = op.join(base_dir, 'test-ave.fif')

nirs_fname = op.join(data_dir, 'SNIRF', 'NIRx', 'NIRSport2', '1.0.3',
'2021-05-05_001.snirf')


def _get_example_figures():
"""Create two example figures."""
Expand All @@ -70,14 +73,16 @@ def test_render_report(renderer, tmpdir):
proj_fname_new = op.join(tempdir, 'temp_ecg-proj.fif')
fwd_fname_new = op.join(tempdir, 'temp_raw-fwd.fif')
inv_fname_new = op.join(tempdir, 'temp_raw-inv.fif')
nirs_fname_new = op.join(tempdir, 'temp_raw-nirs.snirf')
for a, b in [[raw_fname, raw_fname_new],
[raw_fname, raw_fname_new_bids],
[ms_fname, ms_fname_new],
[event_fname, event_fname_new],
[cov_fname, cov_fname_new],
[proj_fname, proj_fname_new],
[fwd_fname, fwd_fname_new],
[inv_fname, inv_fname_new]]:
[inv_fname, inv_fname_new],
[nirs_fname, nirs_fname_new]]:
shutil.copyfile(a, b)

# create and add -epo.fif and -ave.fif files
Expand Down Expand Up @@ -105,6 +110,7 @@ def test_render_report(renderer, tmpdir):

# Check correct paths and filenames
fnames = glob.glob(op.join(tempdir, '*.fif'))
fnames.extend(glob.glob(op.join(tempdir, '*.snirf')))
for fname in fnames:
assert (op.basename(fname) in
[op.basename(x) for x in report.fnames])
Expand Down