From 3a7ad8d9b1616dda6b14809c0fce77033f39f7fc Mon Sep 17 00:00:00 2001 From: BettyJiang22 <45817951+ch-MEIJIE@users.noreply.github.com> Date: Thu, 21 Mar 2024 17:58:42 +0800 Subject: [PATCH] Fix data hook bug 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. --- metabci/brainda/paradigms/base.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/metabci/brainda/paradigms/base.py b/metabci/brainda/paradigms/base.py index dda66cd6..ffe81e26 100644 --- a/metabci/brainda/paradigms/base.py +++ b/metabci/brainda/paradigms/base.py @@ -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: @@ -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