The questions of the surrogate data about about tpac

The generation of surrogate data in this paper(“cross-frequency brain network dynamics support pitch change detection”) will lead to some trail when calculating PAC, the all 500 surrogate data at some time points will be 0, which will lead to the calculation value of formula (1) in this paper as NAN, because the variance and standard deviation are 0. How to solve this problem?

for example, a trail has no Fp peak at 1.05s, which will cause all the substitute data at 500 at this time to be 0, and the denominator of this formula 1 is problematic.
In fact, it is impossible for every trail to have an Fp peak at a time point.
image (1)

@Francois @Samiee @Sylvain

Thanks for your post. Please provide the data that led to this issue.

As I mentioned by email, if you encountered an issue in your own using of the code below, and in the spirit of open-source sharing and contributing, I encourage you to suggest a fix to improve the robustness of the tPAC code ; that would be truly appreciated. You can proceed via a pull request on Brainstorm’s GitHub's repository.

Thank you for your reply.

First of all, you have published some papers about tpac statistics. For example, "coupled oscillations enable rapid temporary retrieval to audio visual asynchrony", "Cross-frequency brain network dynamics support pitch change detection", and the number of trials is more than 500. Theoretically, not all trials can find the peak at the time of interest, so I think your research group should have encountered this problem, so I ask questions.

Second, according to your open source code design, the scripts process_pac_dynamic_sur2.m and process_pac_dynamic.m both report that it is possible to find no peak. For example, this line of code" if missedPcount>0 disp(['Missed Peaks:',num2str(missedPcount),'/',num2str(nFanTimenSources)])
end"。 So I think you have encountered this problem in the statistical link, so I hope you can provide the solution.

That is to say, I don't think this is a problem I have encountered alone, but it is a common problem. Since you have done relevant statistics and published papers, you should have encountered this problem, so seek your solution.

Thank you for your kind reply.

I don’t believe we have encountered the issues you are raising, from what I can understand. As I mentioned before and in our email exchanges, please post a time series that you have found to be problematic with tPAC, and we'll look into this whenever possible.