Hi, Thanks you very much for your answer.
My PSD array have a dimension of (20,201). And for the frequencies iām using an array of float64 (201,).
There is the code :
#FOOOFGroup accross a group of Power Spectra (eg : PSD_DCZ)
#Initialize a FOOOFGroup object, specifying some parameters
fg = FOOOFGroup(peak_width_limits=[1.0, 12], max_n_peaks=8)
#Fit FOOOF model across the matrix of power spectra
fg.fit(freq, PSD_DCZ, freq_range)
fg.print_results() #probleme display here
#Create and save out a report summarizing the results across the group of power spectra
fg.save_report()
#Save out FOOOF results for further analysis later
fg.save(file_name=āfooof_group_resultsā, save_results=True)
fg.plot()
#Check why the FOOOFGroup Peak-centerfrequ doesnāt work :
print(fg.group_results)
test = fg.group_results #check what group_result contain
#Extract aperiodic parameters
aps = fg.get_params(āaperiodic_paramsā) #ok
exps = fg.get_params(āaperiodic_paramsā, āexponentā) #ok
#Extract peak parameters
peaks = ft.get_params(āpeak_paramsā)# out = np.array([np.insert(getattr(data, name), 3, index, axis=1) ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (20,) + inhomogeneous part.
cfs = fg.get_params(āpeak_paramsā, āCFā)# same error
#Extract goodness-of-fit metrics
errors = fg.get_params(āerrorā) #ok
r2s = fg.get_params(ār_squaredā) #ok
And there is the code of the function get_params() :
def get_params(self, name, col=None):
if not self.has_model:
raise NoModelError(āNo model fit results are available, can not proceed.ā)
# Allow for shortcut alias, without adding `_params`
if name in ['aperiodic', 'peak', 'gaussian']:
name = name + '_params'
# If col specified as string, get mapping back to integer
if isinstance(col, str):
col = get_indices(self.aperiodic_mode)[col]
elif isinstance(col, int):
if col not in [0, 1, 2]:
raise ValueError("Input value for `col` not valid.")
# Pull out the requested data field from the group data
# 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)])
# 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:
col = [col, -1]
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]
return out