0:int(np.floor(sorted.size / 3))], axis=2) second_half = np.mean( dat['pxx'][:, :, int(np.floor(sorted.size / 3)) + 1:sorted.size - int(np.floor(sorted.size / 3))], axis=2) third_half = np.mean( dat['pxx'][:, :, sorted.size - int(np.floor(sorted.size / 3)) + 1:], axis=2) fm = FOOOFGroup(peak_width_limits=[1, 8], min_peak_height=0.05, max_n_peaks=6) fm._maxfev = 30000 freq_range = [3, 40] freqs = np.squeeze(dat['fxx']) aperiodic = np.zeros([2, np.shape(dat['pxx'])[1], 2]) fm.fit(freqs, np.transpose(first_half), freq_range) fm.save( '/home/tpfeffer/pp/proc/src/pp_hh_task_fooof_result_lo_s%d_b%d_v%d' % (isubj, iblock, v), save_results=True, save_settings=False, save_data=True) fm.fit(freqs, np.transpose(second_half), freq_range)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # So far, we have no model failures (as is typical). # # For this example, to induce some model fits, we will use a trick to change the number of # iterations the model uses to fit parameters (`_maxfev`), making it much more likely to fail. # # Note that in normal usage, you would likely never want to change the value of `_maxfev`, # and this here is a 'hack' of the code in order to induce reproducible failure modes # in simulated data. # ################################################################################################### # Hack the object to induce model failures fg._maxfev = 50 ################################################################################################### # Try fitting again fg.fit(freqs, powers) ################################################################################################### # # As we can see, there are now some model fit failures! Note that, as above, it will # be printed out if there is as model fit failure when in verbose mode. # ################################################################################################### # Check how many model fit failures we have failed model fits