From 608fe71d71429f46572d670f51d70f2dec1153f4 Mon Sep 17 00:00:00 2001 From: Tom Donoghue Date: Wed, 24 Feb 2021 21:30:28 -0500 Subject: [PATCH 1/3] update array mechanics --- fooof/objs/group.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/fooof/objs/group.py b/fooof/objs/group.py index 91abcee9e..91d7b9e73 100644 --- a/fooof/objs/group.py +++ b/fooof/objs/group.py @@ -375,8 +375,11 @@ def get_params(self, name, col=None): # As a special case, peak_params are pulled out in a way that appends # an extra column, indicating which FOOOF run each peak comes from if name in ('peak_params', 'gaussian_params'): - out = np.array([np.insert(getattr(data, name), 3, index, axis=1) - for index, data in enumerate(self.group_results)]) + + # Collect peak data, appending the index of the model it comes from + out = np.vstack([np.insert(getattr(data, name), 3, index, axis=1) + for index, data in enumerate(self.group_results)]) + # This updates index to grab selected column, and the last column # This last column is the 'index' column (FOOOF object source) if col is not None: @@ -384,12 +387,6 @@ def get_params(self, name, col=None): else: out = np.array([getattr(data, name) for data in self.group_results]) - # Some data can end up as a list of separate arrays - # If so, concatenate it all into one 2d array - if isinstance(out[0], np.ndarray): - out = np.concatenate([arr.reshape(1, len(arr)) \ - if arr.ndim == 1 else arr for arr in out], 0) - # Select out a specific column, if requested if col is not None: out = out[:, col] From e1c815e2d79aa09d6e04677162ae1ff7ce8159e8 Mon Sep 17 00:00:00 2001 From: Tom Donoghue Date: Wed, 24 Feb 2021 21:38:58 -0500 Subject: [PATCH 2/3] update docstrings for get_params --- fooof/objs/fit.py | 4 +--- fooof/objs/group.py | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fooof/objs/fit.py b/fooof/objs/fit.py index fba745d27..911ec4219 100644 --- a/fooof/objs/fit.py +++ b/fooof/objs/fit.py @@ -586,9 +586,7 @@ def get_params(self, name, col=None): Notes ----- - For further description of the data you can extract, check the FOOOFResults documentation. - - If there is no data on periodic features, this method will return NaN. + If there are no fit peak (no peak parameters), this method will return NaN. """ if not self.has_model: diff --git a/fooof/objs/group.py b/fooof/objs/group.py index 91d7b9e73..2fb4da2bf 100644 --- a/fooof/objs/group.py +++ b/fooof/objs/group.py @@ -354,7 +354,8 @@ def get_params(self, name, col=None): Notes ----- - For further description of the data you can extract, check the FOOOFResults documentation. + When extracting peak informartion ('peak_params' or 'gaussian_params'), an additional column + is appended to the returned array, indicating the index of the model that the peak came from. """ if not self.has_model: From 47188e90c9a74fa6d7f7d023276bd217cda49960 Mon Sep 17 00:00:00 2001 From: Tom Donoghue Date: Wed, 24 Feb 2021 21:39:23 -0500 Subject: [PATCH 3/3] update docstrings for get_params --- fooof/objs/group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fooof/objs/group.py b/fooof/objs/group.py index 2fb4da2bf..44cdfdb4b 100644 --- a/fooof/objs/group.py +++ b/fooof/objs/group.py @@ -354,7 +354,7 @@ def get_params(self, name, col=None): Notes ----- - When extracting peak informartion ('peak_params' or 'gaussian_params'), an additional column + When extracting peak information ('peak_params' or 'gaussian_params'), an additional column is appended to the returned array, indicating the index of the model that the peak came from. """