From 865630cf7e98cd88e5e81ebd4386360a8626e1df Mon Sep 17 00:00:00 2001 From: Christan Gerloff Date: Fri, 11 Feb 2022 02:53:39 +0800 Subject: [PATCH 1/2] Fix exception handling empty fooof --- fooof_mat/fooof.m | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/fooof_mat/fooof.m b/fooof_mat/fooof.m index 1d31221..5b94eb9 100644 --- a/fooof_mat/fooof.m +++ b/fooof_mat/fooof.m @@ -65,20 +65,22 @@ % back to the internal call to `np.cov`, and fails when this function % gets two arrays as input. % Therefore, we can simply recalculate r-squared - coefs = corrcoef(double(py.array.array('d', fm.power_spectrum)), ... - double(py.array.array('d', fm.fooofed_spectrum_))); - fooof_results.r_squared = coefs(2); + try + coefs = corrcoef(double(py.array.array('d', fm.power_spectrum)), ... + double(py.array.array('d', fm.fooofed_spectrum_))); + fooof_results.r_squared = coefs(2); - % Also return the actual model fit, if requested - % This will default to not return model, if variable not set - if exist('return_model', 'var') && return_model - - % Get the model, and add outputs to fooof_results - model_out = fooof_get_model(fm); - for field = fieldnames(model_out)' - fooof_results.(field{1}) = model_out.(field{1}); + % Also return the actual model fit, if requested + % This will default to not return model, if variable not set + if (exist('return_model', 'var') && return_model) + % Get the model, and add outputs to fooof_results + model_out = fooof_get_model(fm); + for field = fieldnames(model_out)' + fooof_results.(field{1}) = model_out.(field{1}); + end end - + catch + warning(strcat('Result object contains not all properties.',... + 'This may be caused by an failed modle fit.')); end - end From 07086b934a0b17f764f191bdd8d122d11fec926c Mon Sep 17 00:00:00 2001 From: Christan Gerloff Date: Fri, 11 Feb 2022 03:11:12 +0800 Subject: [PATCH 2/2] minor typo --- fooof_mat/fooof.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fooof_mat/fooof.m b/fooof_mat/fooof.m index 5b94eb9..4d0388b 100644 --- a/fooof_mat/fooof.m +++ b/fooof_mat/fooof.m @@ -81,6 +81,6 @@ end catch warning(strcat('Result object contains not all properties.',... - 'This may be caused by an failed modle fit.')); + 'This may be caused by an failed model fit.')); end end