MCPcopy
hub / github.com/mne-tools/mne-python / __init__

Method __init__

mne/io/fiff/raw.py:92–176  ·  view source on GitHub ↗
(
        self,
        fname,
        allow_maxshield=False,
        preload=False,
        on_split_missing="raise",
        verbose=None,
    )

Source from the content-addressed store, hash-verified

90
91 @verbose
92 def __init__(
93 self,
94 fname,
95 allow_maxshield=False,
96 preload=False,
97 on_split_missing="raise",
98 verbose=None,
99 ):
100 raws = []
101 do_check_ext = not _file_like(fname)
102 next_fname = fname
103 while next_fname is not None:
104 raw, next_fname, buffer_size_sec = self._read_raw_file(
105 next_fname, allow_maxshield, preload, do_check_ext
106 )
107 do_check_ext = False
108 raws.append(raw)
109 if next_fname is not None:
110 if not op.exists(next_fname):
111 msg = (
112 f"Split raw file detected but next file {next_fname} "
113 "does not exist. Ensure all files were transferred "
114 "properly and that split and original files were not "
115 "manually renamed on disk (split files should be "
116 "renamed by loading and re-saving with MNE-Python to "
117 "preserve proper filename linkage)."
118 )
119 _on_missing(on_split_missing, msg, name="on_split_missing")
120 break
121 # If using a file-like object, we need to be careful about serialization and
122 # types.
123 #
124 # 1. We must change both the variable named "fname" here so that _get_argvalues
125 # (magic) does not store the file-like object.
126 # 2. We need to ensure "filenames" passed to the constructor below gets a list
127 # of Path or None.
128 # 3. We need to remove the file-like objects from _raw_extras. This must
129 # be done *after* the super().__init__ call, because the constructor
130 # needs the file-like objects to read the data (which it will do because we
131 # force preloading for file-like objects).
132
133 # Avoid file-like in _get_argvalues (1)
134 fname = _path_from_fname(fname)
135
136 _check_raw_compatibility(raws)
137 super().__init__(
138 copy.deepcopy(raws[0].info),
139 preload=False,
140 first_samps=[r.first_samp for r in raws],
141 last_samps=[r.last_samp for r in raws],
142 # Avoid file-like objects in raw.filenames (2)
143 filenames=[_path_from_fname(r._raw_extras["filename"]) for r in raws],
144 raw_extras=[r._raw_extras for r in raws],
145 orig_format=raws[0].orig_format,
146 dtype=None,
147 buffer_size_sec=buffer_size_sec,
148 verbose=verbose,
149 )

Callers

nothing calls this directly

Calls 9

_read_raw_fileMethod · 0.95
_file_likeFunction · 0.85
_on_missingFunction · 0.85
_check_raw_compatibilityFunction · 0.85
AnnotationsClass · 0.85
_preload_dataMethod · 0.80
_path_from_fnameFunction · 0.70
appendMethod · 0.45
set_annotationsMethod · 0.45

Tested by

no test coverage detected