Skip to content

Commit

Permalink
Fix data hook bug
Browse files Browse the repository at this point in the history
ERROR: When apply the paradigm that inherit from BaseTimeEncodingParadigm, using the data hook may cause a error. In the last version, the data hook input X is a Dict type with a deep list as value. This X can not be filtered using Scipy filter.

SOLUTION: Considering the purpose of the  data hook is do some process on single epoch (minimal data unit), I changed its input as unit_x and unit_y, which is a 2_D array-like type that can be filtered.
  • Loading branch information
ch-MEIJIE committed Mar 21, 2024
1 parent 0a7d37f commit 3a7ad8d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions metabci/brainda/paradigms/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,13 @@ def _get_single_subject_data(self, dataset, subject_id, verbose=False):
}
)

if self._data_hook:
unit_X, unit_y, meta, caches = self._data_hook(
unit_X, unit_y, meta, caches)
elif hasattr(dataset, "data_hook"):
unit_X, unit_y, meta, caches = dataset.data_hook(
unit_X, unit_y, meta, caches)

# collecting data
pre_X = Xs.get(event_name)
if pre_X is not None:
Expand All @@ -724,13 +731,6 @@ def _get_single_subject_data(self, dataset, subject_id, verbose=False):
)
else:
metas[event_name] = meta

if self._data_hook:
Xs, ys, metas, caches = self._data_hook(
Xs, ys, metas, caches)
elif hasattr(dataset, "data_hook"):
Xs, ys, metas, caches = dataset.data_hook(
Xs, ys, metas, caches)
return Xs, ys, metas

@verbose
Expand Down

0 comments on commit 3a7ad8d

Please sign in to comment.