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

Method __init__

mne/io/base.py:188–307  ·  view source on GitHub ↗
(
        self,
        info,
        preload=False,
        first_samps=(0,),
        last_samps=None,
        filenames=None,
        raw_extras=(None,),
        orig_format="double",
        dtype=np.float64,
        buffer_size_sec=1.0,
        orig_units=None,
        *,
        verbose=None,
    )

Source from the content-addressed store, hash-verified

186
187 @verbose
188 def __init__(
189 self,
190 info,
191 preload=False,
192 first_samps=(0,),
193 last_samps=None,
194 filenames=None,
195 raw_extras=(None,),
196 orig_format="double",
197 dtype=np.float64,
198 buffer_size_sec=1.0,
199 orig_units=None,
200 *,
201 verbose=None,
202 ):
203 # wait until the end to preload data, but triage here
204 if isinstance(preload, np.ndarray):
205 # some functions (e.g., filtering) only work w/64-bit data
206 if preload.dtype not in (np.float64, np.complex128):
207 raise RuntimeError(
208 f"datatype must be float64 or complex128, not {preload.dtype}"
209 )
210 if preload.dtype != dtype:
211 raise ValueError("preload and dtype must match")
212 self._data = preload
213 self.preload = True
214 assert len(first_samps) == 1
215 last_samps = [first_samps[0] + self._data.shape[1] - 1]
216 load_from_disk = False
217 else:
218 if last_samps is None:
219 raise ValueError(
220 "last_samps must be given unless preload is an ndarray"
221 )
222 if not preload:
223 self.preload = False
224 load_from_disk = False
225 else:
226 load_from_disk = True
227 self._last_samps = np.array(last_samps)
228 self._first_samps = np.array(first_samps)
229 orig_ch_names = info["ch_names"]
230 with info._unlock(check_after=True):
231 # be permissive of old code
232 if isinstance(info["meas_date"], tuple):
233 info["meas_date"] = _stamp_to_dt(info["meas_date"])
234 self.info = info
235 self.buffer_size_sec = float(buffer_size_sec)
236 cals = np.empty(info["nchan"])
237 for k in range(info["nchan"]):
238 cals[k] = info["chs"][k]["range"] * info["chs"][k]["cal"]
239 bad = np.where(cals == 0)[0]
240 if len(bad) > 0:
241 raise ValueError(
242 f"Bad cals for channels {dict((ii, self.ch_names[ii]) for ii in bad)}"
243 )
244 self._cals = cals
245 if raw_extras is None:

Callers

nothing calls this directly

Calls 10

set_annotationsMethod · 0.95
_preload_dataMethod · 0.95
_stamp_to_dtFunction · 0.85
_validate_typeFunction · 0.85
_check_optionFunction · 0.85
_check_orig_unitsFunction · 0.85
_get_argvaluesFunction · 0.85
_unlockMethod · 0.80
infoMethod · 0.80
removeMethod · 0.45

Tested by

no test coverage detected