@@ -354,7 +354,8 @@ def get_params(self, name, col=None):
354354
355355 Notes
356356 -----
357- For further description of the data you can extract, check the FOOOFResults documentation.
357+ When extracting peak information ('peak_params' or 'gaussian_params'), an additional column
358+ is appended to the returned array, indicating the index of the model that the peak came from.
358359 """
359360
360361 if not self .has_model :
@@ -375,21 +376,18 @@ def get_params(self, name, col=None):
375376 # As a special case, peak_params are pulled out in a way that appends
376377 # an extra column, indicating which FOOOF run each peak comes from
377378 if name in ('peak_params' , 'gaussian_params' ):
378- out = np .array ([np .insert (getattr (data , name ), 3 , index , axis = 1 )
379- for index , data in enumerate (self .group_results )])
379+
380+ # Collect peak data, appending the index of the model it comes from
381+ out = np .vstack ([np .insert (getattr (data , name ), 3 , index , axis = 1 )
382+ for index , data in enumerate (self .group_results )])
383+
380384 # This updates index to grab selected column, and the last column
381385 # This last column is the 'index' column (FOOOF object source)
382386 if col is not None :
383387 col = [col , - 1 ]
384388 else :
385389 out = np .array ([getattr (data , name ) for data in self .group_results ])
386390
387- # Some data can end up as a list of separate arrays
388- # If so, concatenate it all into one 2d array
389- if isinstance (out [0 ], np .ndarray ):
390- out = np .concatenate ([arr .reshape (1 , len (arr )) \
391- if arr .ndim == 1 else arr for arr in out ], 0 )
392-
393391 # Select out a specific column, if requested
394392 if col is not None :
395393 out = out [:, col ]
0 commit comments