Skip to content

Commit

Permalink
Merge branches 'neuroread' and 'neuroread' of https://github.com/with…
Browse files Browse the repository at this point in the history
  • Loading branch information
withmywoessner committed Jan 28, 2024
2 parents de18c6b + 6c261f8 commit f605dc1
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions mne/io/cnt/cnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def _get_cnt_info(
sfreq = np.fromfile(fid, dtype="<u2", count=1).item()
if mode == "epoch":
fid.seek(505)
cnt_info['tmin'] = np.fromfile(fid, dtype="<f4", count=1).item()
cnt_info["tmin"] = np.fromfile(fid, dtype="<f4", count=1).item()
if eog == "header":
fid.seek(402)
eog = [idx for idx in np.fromfile(fid, dtype="i2", count=2) if idx >= 0]
Expand Down Expand Up @@ -559,7 +559,7 @@ def _get_cnt_info(
baselines.append(np.fromfile(fid, dtype="i2", count=1).item())
fid.seek(data_offset + 75 * ch_idx + 59)
sensitivity = np.fromfile(fid, dtype="f4", count=1).item()
print(f'sensitivity: {sensitivity}')
print(f"sensitivity: {sensitivity}")
fid.seek(data_offset + 75 * ch_idx + 71)
cal = np.fromfile(fid, dtype="f4", count=1).item()
if mode == "evoked":
Expand Down Expand Up @@ -882,7 +882,6 @@ def __init__(
header="auto",
verbose=None,
):

_check_option("date_format", date_format, ["mm/dd/yy", "dd/mm/yy"])
if date_format == "dd/mm/yy":
_date_format = "%d/%m/%y %H:%M:%S"
Expand Down Expand Up @@ -919,9 +918,7 @@ def __init__(
(events is None and event_id is None)
or (events is not None and event_id is not None)
):
raise ValueError(
"Both `events` and `event_id` must be "
"None or not None")
raise ValueError("Both `events` and `event_id` must be " "None or not None")

assert data.shape == (
self._raw_extras[0]["n_epochs"],
Expand Down Expand Up @@ -988,7 +985,8 @@ def _read_cnt_epochs_data(self):
# short Reserved; /* not used */
f.seek(i)
epoch_header = np.fromfile(
f, dtype=np.dtype('<c,h,h,f,h,h'),
f,
dtype=np.dtype("<c,h,h,f,h,h"),
count=1,
)
print(epoch_header)
Expand All @@ -997,7 +995,8 @@ def _read_cnt_epochs_data(self):
f.seek(i + SWEEP_HEAD_SIZE)
# Read the data points as a 4-byte integer array
data_points = np.fromfile(
f, dtype=np.dtype('<i4,'), # little-endian 4-byte integer
f,
dtype=np.dtype("<i4,"), # little-endian 4-byte integer
count=n_pnts * n_channels,
)
print(data_points)
Expand All @@ -1008,17 +1007,18 @@ def _read_cnt_epochs_data(self):
print(epoch_headers)
print(data)
return epoch_headers, data

def _epoch_event_parser(self, epoch_headers, data):
"""Format neuroscan events into mne format."""
events = []
cnt_info = self._raw_extras[0]
sfreq = self.info["sfreq"]
tmin = cnt_info['tmin']
tmin = cnt_info["tmin"]
tmax = ((data.shape[2] - 1) / self.info["sfreq"]) + tmin
event_time = np.arange(0, len(epoch_headers)
) * np.ceil((tmax - tmin) * sfreq).astype(int)
event_time = np.arange(0, len(epoch_headers)) * np.ceil(
(tmax - tmin) * sfreq
).astype(int)
place_holder = np.array([0] * len(epoch_headers))
event_codes = [event[1] for event in epoch_headers]
events = np.vstack((event_time, place_holder, event_codes)).astype(int).T
return events
return events

0 comments on commit f605dc1

Please sign in to comment.