Skip to content

Commit

Permalink
[FIX] Applying suggestions from the revision
Browse files Browse the repository at this point in the history
  • Loading branch information
bruAristimunha committed Oct 23, 2024
1 parent 1c927ea commit 586b0cd
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions moabb/datasets/physionet_mi.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,41 +176,3 @@ def _load_data(self, subject, runs, path=None, force_update=False, verbose=None)
p = data_dl(url, sign, path, force_update, verbose)
data_paths.append(p)
return data_paths

def _create_stim_channels(self, raw):
# Define a consistent mapping from event descriptions to integer IDs
desired_event_id = self.events

# Get events using the consistent event_id mapping
events, _ = mne.events_from_annotations(raw, event_id=desired_event_id)

# Filter the events array to include only desired events
desired_event_ids = list(desired_event_id.values())
filtered_events = events[np.isin(events[:, 2], desired_event_ids)]

# Create annotations from filtered events using the inverted mapping
event_desc = {v: k for k, v in desired_event_id.items()}
annot_from_events = mne.annotations_from_events(
events=filtered_events,
event_desc=event_desc,
sfreq=raw.info["sfreq"],
orig_time=raw.info["meas_date"],
)
raw.set_annotations(annot_from_events)

# Create the stim channel data array
stim_channs = np.zeros((1, raw.n_times))
for event in filtered_events:
sample_index = event[0]
event_code = event[2] # Consistent event IDs
stim_channs[0, sample_index] = event_code

# Create the stim channel and add it to raw
stim_channel_name = "STIM"
stim_info = mne.create_info(
[stim_channel_name], sfreq=raw.info["sfreq"], ch_types=["stim"]
)
stim_raw = mne.io.RawArray(stim_channs, stim_info, verbose=False)
raw_with_stim = raw.copy().add_channels([stim_raw], force_update_info=True)

return raw_with_stim

0 comments on commit 586b0cd

Please sign in to comment.