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

Function _read_brainstorm_annotations

mne/annotations.py:1968–2006  ·  view source on GitHub ↗

Read annotations from a Brainstorm events_ file. Parameters ---------- fname : path-like The filename orig_time : float | int | instance of datetime | array of int | None A POSIX Timestamp, datetime or an array containing the timestamp as the first element an

(fname, orig_time=None)

Source from the content-addressed store, hash-verified

1966
1967
1968def _read_brainstorm_annotations(fname, orig_time=None):
1969 """Read annotations from a Brainstorm events_ file.
1970
1971 Parameters
1972 ----------
1973 fname : path-like
1974 The filename
1975 orig_time : float | int | instance of datetime | array of int | None
1976 A POSIX Timestamp, datetime or an array containing the timestamp as the
1977 first element and microseconds as the second element. Determines the
1978 starting time of annotation acquisition. If None (default),
1979 starting time is determined from beginning of raw data acquisition.
1980 In general, ``raw.info['meas_date']`` (or None) can be used for syncing
1981 the annotations with raw data if their acquisition is started at the
1982 same time.
1983
1984 Returns
1985 -------
1986 annot : instance of Annotations | None
1987 The annotations.
1988 """
1989
1990 def get_duration_from_times(t):
1991 return t[1] - t[0] if t.shape[0] == 2 else np.zeros(len(t[0]))
1992
1993 annot_data = loadmat(fname)
1994 onsets, durations, descriptions = (list(), list(), list())
1995 for label, _, _, _, times, _, _ in annot_data["events"][0]:
1996 onsets.append(times[0])
1997 durations.append(get_duration_from_times(times))
1998 n_annot = len(times[0])
1999 descriptions += [str(label[0])] * n_annot
2000
2001 return Annotations(
2002 onset=np.concatenate(onsets),
2003 duration=np.concatenate(durations),
2004 description=descriptions,
2005 orig_time=orig_time,
2006 )
2007
2008
2009def _is_iso8601(candidate_str):

Callers 1

read_annotationsFunction · 0.85

Calls 3

get_duration_from_timesFunction · 0.85
AnnotationsClass · 0.85
appendMethod · 0.45

Tested by

no test coverage detected