Skip to content

Commit 4ae85b5

Browse files
committed
Merge pull request #1881 from teonlamont/read_raw_fif
Add reader function for Raw FIF files
2 parents d794fd9 + be1c6fd commit 4ae85b5

11 files changed

Lines changed: 95 additions & 6 deletions

File tree

doc/source/python_reference.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Functions:
110110
read_raw_kit
111111
read_raw_brainvision
112112
read_raw_egi
113+
read_raw_fif
113114

114115
.. currentmodule:: mne.io.kit
115116

doc/source/whats_new.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ Changelog
8181

8282
- Add support for adding an empty reference channel to data by `Teon Brooks`_
8383

84+
- Add reader function for Raw FIF files by `Teon Brooks`_
85+
8486
BUG
8587
~~~
8688

mne/io/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from .edf import read_raw_edf
2727
from .egi import read_raw_egi
2828
from .kit import read_raw_kit
29+
from .fiff import read_raw_fif
2930

3031
# for backward compatibility
3132
from .fiff import RawFIFF

mne/io/brainvision/brainvision.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,11 @@ def read_raw_brainvision(vhdr_fname, montage=None,
620620
verbose : bool, str, int, or None
621621
If not None, override default verbose level (see mne.verbose).
622622
623+
Returns
624+
-------
625+
raw : Instance of RawBrainVision
626+
A Raw object containing BrainVision data.
627+
623628
See Also
624629
--------
625630
mne.io.Raw : Documentation of attribute and methods.

mne/io/bti/bti.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,14 +1208,23 @@ def read_raw_bti(pdf_fname, config_fname='config',
12081208
translation : array-like
12091209
The translation to place the origin of coordinate system
12101210
to the center of the head.
1211-
ecg_ch: str | None
1211+
ecg_ch : str | None
12121212
The 4D name of the ECG channel. If None, the channel will be treated
12131213
as regular EEG channel.
1214-
eog_ch: tuple of str | None
1214+
eog_ch : tuple of str | None
12151215
The 4D names of the EOG channels. If None, the channels will be treated
12161216
as regular EEG channels.
12171217
verbose : bool, str, int, or None
12181218
If not None, override default verbose level (see mne.verbose).
1219+
1220+
Returns
1221+
-------
1222+
raw : Instance of RawBTi
1223+
A Raw object containing BTI data.
1224+
1225+
See Also
1226+
--------
1227+
mne.io.Raw : Documentation of attribute and methods.
12191228
"""
12201229
return RawBTi(pdf_fname, config_fname=config_fname,
12211230
head_shape_fname=head_shape_fname,

mne/io/edf/edf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,11 @@ def read_raw_edf(input_fname, montage=None, eog=None, misc=None,
657657
verbose : bool, str, int, or None
658658
If not None, override default verbose level (see mne.verbose).
659659
660+
Returns
661+
-------
662+
raw : Instance of RawEDF
663+
A Raw object containing EDF data.
664+
660665
See Also
661666
--------
662667
mne.io.Raw : Documentation of attribute and methods.

mne/io/egi/egi.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,12 @@ def read_raw_egi(input_fname, montage=None, eog=None, misc=None,
167167
168168
Returns
169169
-------
170-
raw : instance of mne.io.Raw
171-
A raw object containing EGI data.
170+
raw : Instance of RawEGI
171+
A Raw object containing EGI data.
172+
173+
See Also
174+
--------
175+
mne.io.Raw : Documentation of attribute and methods.
172176
"""
173177
return _RawEGI(input_fname, montage, eog, misc, include, exclude, verbose)
174178

mne/io/fiff/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
from .raw import RawFIFF
2+
from .raw import read_raw_fif

mne/io/fiff/raw.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Matti Hamalainen <msh@nmr.mgh.harvard.edu>
33
# Martin Luessi <mluessi@nmr.mgh.harvard.edu>
44
# Denis Engemann <denis.engemann@gmail.com>
5+
# Teon Brooks <teon.brooks@gmail.com>
56
#
67
# License: BSD (3-clause)
78

@@ -621,3 +622,53 @@ def _check_raw_compatibility(raw):
621622
'could result in precision mismatch. Setting '
622623
'raw.orig_format="unknown"')
623624
raw[0].orig_format = 'unknown'
625+
626+
627+
def read_raw_fif(fnames, allow_maxshield=False, preload=False,
628+
proj=False, compensation=None, add_eeg_ref=True,
629+
verbose=None):
630+
"""Reader function for Raw FIF data
631+
632+
Parameters
633+
----------
634+
fnames : list, or string
635+
A list of the raw files to treat as a Raw instance, or a single
636+
raw file. For files that have automatically been split, only the
637+
name of the first file has to be specified. Filenames should end
638+
with raw.fif, raw.fif.gz, raw_sss.fif, raw_sss.fif.gz,
639+
raw_tsss.fif or raw_tsss.fif.gz.
640+
allow_maxshield : bool, (default False)
641+
allow_maxshield if True, allow loading of data that has been
642+
processed with Maxshield. Maxshield-processed data should generally
643+
not be loaded directly, but should be processed using SSS first.
644+
preload : bool or str (default False)
645+
Preload data into memory for data manipulation and faster indexing.
646+
If True, the data will be preloaded into memory (fast, requires
647+
large amount of memory). If preload is a string, preload is the
648+
file name of a memory-mapped file which is used to store the data
649+
on the hard drive (slower, requires less memory).
650+
proj : bool
651+
Apply the signal space projection (SSP) operators present in
652+
the file to the data. Note: Once the projectors have been
653+
applied, they can no longer be removed. It is usually not
654+
recommended to apply the projectors at this point as they are
655+
applied automatically later on (e.g. when computing inverse
656+
solutions).
657+
compensation : None | int
658+
If None the compensation in the data is not modified.
659+
If set to n, e.g. 3, apply gradient compensation of grade n as
660+
for CTF systems.
661+
add_eeg_ref : bool
662+
If True, add average EEG reference projector (if it's not already
663+
present).
664+
verbose : bool, str, int, or None
665+
If not None, override default verbose level (see mne.verbose).
666+
667+
Returns
668+
-------
669+
raw : Instance of RawFIFF
670+
A Raw object containing FIF data.
671+
"""
672+
return RawFIFF(fnames=fnames, allow_maxshield=allow_maxshield,
673+
preload=preload, proj=proj, compensation=compensation,
674+
add_eeg_ref=add_eeg_ref, verbose=verbose)

mne/io/fiff/tests/test_raw.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
from mne.datasets import testing
2222
from mne.io.constants import FIFF
23-
from mne.io import Raw, concatenate_raws, get_chpi_positions
23+
from mne.io import (Raw, concatenate_raws, get_chpi_positions,
24+
read_raw_fif)
2425
from mne import (concatenate_events, find_events, equalize_channels,
2526
compute_proj_raw, pick_types, pick_channels)
2627
from mne.utils import (_TempDir, requires_nitime, requires_pandas,
@@ -51,7 +52,7 @@
5152
def test_hash_raw():
5253
"""Test hashing raw objects
5354
"""
54-
raw = Raw(fif_fname)
55+
raw = read_raw_fif(fif_fname)
5556
assert_raises(RuntimeError, raw.__hash__)
5657
raw = Raw(fif_fname, preload=True).crop(0, 0.5)
5758
raw_2 = Raw(fif_fname, preload=True).crop(0, 0.5)

0 commit comments

Comments
 (0)