Clear Filters
Clear Filters

Stranger behavior with pmtm.m function, with one more data point the result could not show up.

2 views (last 30 days)
I have used pmtm.m function to do the multitaper decomposion of my EEG data. In one channel and only this one, I found as long I include the last data point (# 2050000), the calculation will never finish, while the duration for other channel are super fast. If I just decompose the signal from point 1 to 2049999, everything was fine. I plot the signal in the end. there is no big outlier at the last, at point 2050000. Does anyone could give me a hit about what happen? I could try to copy this one vector of EEG signal to let you try and see this super strange error.
[p_mt(chl, :) f_mt] = pmtm(,:),[],winput,5000); % have to end by myself
[p_mt(chl, :) f_mt] = pmtm(,1:100000),[],winput,5000);
[p_mt(chl, :) f_mt] = pmtm(,1:2045000),[],winput,5000);
[p_mt(chl, :) f_mt] = pmtm(,1:2049000),[],winput,5000);
[p_mt(chl, :) f_mt] = pmtm(,1:2049999),[],winput,5000);
[p_mt(chl, :) f_mt] = pmtm(,1:2050000),[],winput,5000); % have to end by myself

Answers (1)

arushi on 24 Jan 2024
Hi Shuo,
The behavior you're describing with the pmtm function in MATLAB, where the computation does not finish when including the last data point, is unusual. The pmtm function implements the multitaper method (MTM) for spectral analysis and should be able to handle data sequences of various lengths, including your full dataset.
Here are a few potential reasons and troubleshooting steps for the issue you're encountering:
  1. Resource Limitations: If the computation runs indefinitely, it might be a resource limitation issue. The multitaper method can be computationally intensive, and including the last data point might be pushing your system to its limits. Check your system's CPU and memory usage during the computation to see if resources are being maxed out.
  2. Data Type or Corruption: There might be something peculiar about the data type or the integrity of the last data point or surrounding points that is causing the function to hang. Although you mentioned there's no outlier, it's worth checking the data type and ensuring there's no NaN, Inf, or other unexpected values that might cause the function to behave incorrectly.
  3. Algorithmic Quirk: The MTM algorithm may have an edge case or a quirk that is only triggered by the specific length of your data sequence. This could be a bug or an undocumented behavior of the pmtm function.
  4. Windowing or Padding Issue: The MTM uses windowing and possibly padding. If the length of the data sequence interacts with the window or pad size in an unexpected way, it could potentially cause an issue.
  5. Frequency Resolution: When you specify the frequency resolution (NW parameter, referred to as winput in your code), the function calculates the required FFT length and the number of tapers. An edge case might occur with a specific combination of data length, NW, and sampling frequency.




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!