Hi,
Appogies, it took me a bit to get back to this analysis properly.
First of all, thank you very much for the response!
Model-selection method
I had noticed this method, but I had not looked into it until now. I have now applied it to my data and found that it did improve the estimates. Nevertheless, negative values are still present at lower frequencies (which may be a result of the knee effect) and, depending on the cohort, they appear at higher frequencies as well (potentially due to flooring caused by EMG). Here are the new estimates from the two groups:
Peak estimation issue
When examining individual estimates, I have noticed that the method relatively often identifies a single large peak even when several are clearly present. As my setting is peak_width_limits = [1, 10], this is very likely caused by the higher upper limit (i.e., 10 Hz).
To mitigate this, I could consider lowering the limit to, for instance, 8 Hz… but, I believe that it is good to have the option to fit broader peaks as well. So, I thought to add the following logic to my code (after line 276):
% Unusual to have just one peak
% If only one peak is detected, it is typically not correct
if size(est_pars, 1) == 1
% disp(chan);
delta_lim = 0;
% fprintf('start: %d\n', size(est_pars, 1));
while true
delta_lim = delta_lim + 1;
% peak_threshold = 1.5;
peak_threshold = opt.peak_threshold;
% Calculate the effective upper limit for this iteration
current_upper_lim = opt.peak_width_limits(2) - delta_lim;
[est_pars, peak_function] = est_peaks(fs, flat_spec, opt.max_peaks, peak_threshold, opt.min_peak_height, ...
[opt.peak_width_limits(1) current_upper_lim]/2, opt.proximity_threshold, opt.border_threshold, opt.peak_type);
% Stop condition:
% 1. If we have found more than 1 peak OR
% 2. If the upper width limit has dropped too low
% fprintf('-> %d\n', size(est_pars, 1));
if size(est_pars, 1) > 1 || current_upper_lim == 4
break;
end
end
end
In essence, this snippet gives the method an opportunity to fit more peaks by iteratively lowering the upper limit. While I understand that there may genuinely be only one peak in data, I also wonder how often that is actually the case in practice. After all, the model-selection apporach can determine the best number of peaks in the subsequent steps of the original code.
Anyway… This idea helped, but it did not always resolve the issue completely:
Non-linearity in the log-log space
Finally, I have noticed another problem where certain electrodes are simply not linear in the specified frequency range. I am not entirely sure how to deal with these situations, especially as they occur occasionally and inconsistently across different participants and electrodes (BTW, this does not always happen in the peripheral electrodes where you would expect EMG/EOG activity to cause non-linearity).
While I could restrict the range to, for instance, 3-30 Hz, I am unsure if this is the best thing to do. First, this would sacrifice frequency ranges that carry important information. Second, because these frequencies are within the range where true oscillations can be present, the method would not fit the correct model if the limits happen to be where the peaks are in the data.
So, I wonder if there is a good solution to handle these occasional incorrect estimates, or if it is better to treat these data points simply as missing data?
Thank you very much!
Best,
Stefan