From a487b9606d9422509262e4cfca97386e33911d0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20K=C3=BCderle?= Date: Thu, 23 Jun 2022 11:47:48 +0200 Subject: [PATCH] Updated examples to use new group attribute --- examples/datasets/_01_datasets_basics.py | 6 +++--- examples/datasets/_02_datasets_real_world_example.py | 4 ++-- examples/datasets/datasets_final_ecg.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/datasets/_01_datasets_basics.py b/examples/datasets/_01_datasets_basics.py index e1fd8593..8e094456 100644 --- a/examples/datasets/_01_datasets_basics.py +++ b/examples/datasets/_01_datasets_basics.py @@ -266,10 +266,10 @@ def data(self) -> str: # Note that we need to make our checks from the least restrictive to the most restrictive (if there is only a # single trail, there is only just a single recording). if self.is_single(["participant", "recording"]): - return "This is the data for participant {} and rec {}".format(*self.groups[0]) + return "This is the data for participant {} and rec {}".format(*self.group) # None -> single row if self.is_single(None): - return "This is the data for participant {}, rec {} and trial {}".format(*self.groups[0]) + return "This is the data for participant {}, rec {} and trial {}".format(*self.group) raise ValueError( "Data can only be accessed when their is only a single recording of a single participant in the subset" ) @@ -283,7 +283,7 @@ def segmented_stride_list_(self) -> str: # We use assert here, as we don't have multiple options. # (We could also used `None` for the `groupby_cols` here) self.assert_is_single(["participant", "recording", "trial"], "segmented_stride_list_") - return "This is the segmented stride list for participant {}, rec {} and trial {}".format(*self.groups[0]) + return "This is the segmented stride list for participant {}, rec {} and trial {}".format(*self.group) def create_index(self): return index diff --git a/examples/datasets/_02_datasets_real_world_example.py b/examples/datasets/_02_datasets_real_world_example.py index 58244c01..50048551 100644 --- a/examples/datasets/_02_datasets_real_world_example.py +++ b/examples/datasets/_02_datasets_real_world_example.py @@ -355,7 +355,7 @@ def data(self) -> pd.DataFrame: # Check that there is only a single participant in the dataset self.assert_is_single(None, "data") # Reconstruct the ecg file path based on the data index - p_id = self.index["participant"][0] + p_id = self.group.participant file_path = self.data_path / f"{p_id}.pk.gz" # We try to use the cache if enabled. if self.use_lru_cache: @@ -369,7 +369,7 @@ def r_peak_positions_(self) -> pd.DataFrame: This includes all R-Peaks (PVC or normal) """ self.assert_is_single(None, "r_peaks_") - p_id = self.index["participant"][0] + p_id = self.group.participant r_peaks = pd.read_csv(self.data_path / f"{p_id}_all.csv", index_col=0) r_peaks = r_peaks.rename(columns={"R": "r_peak_position"}) return r_peaks diff --git a/examples/datasets/datasets_final_ecg.py b/examples/datasets/datasets_final_ecg.py index 9e201320..ba48b330 100644 --- a/examples/datasets/datasets_final_ecg.py +++ b/examples/datasets/datasets_final_ecg.py @@ -70,7 +70,7 @@ def r_peak_positions_(self) -> pd.DataFrame: This includes all R-Peaks (PVC or normal) """ self.assert_is_single(None, "r_peaks_") - p_id = self.index["participant"][0] + p_id = self.group.participant r_peaks = pd.read_csv(self.data_path / f"{p_id}_all.csv", index_col=0) r_peaks = r_peaks.rename(columns={"R": "r_peak_position"}) return r_peaks @@ -82,7 +82,7 @@ def pvc_positions_(self) -> pd.DataFrame: The position is equivalent to a position entry in `self.r_peak_positions_`. """ self.assert_is_single(None, "pvc_positions_") - p_id = self.index["participant"][0] + p_id = self.group.participant pvc_peaks = pd.read_csv(self.data_path / f"{p_id}_pvc.csv", index_col=0) pvc_peaks = pvc_peaks.rename(columns={"PVC": "pvc_position"}) return pvc_peaks