andersonwinkler / PALM

PALM: Permutation Analysis of Linear Models
70 stars 28 forks source link

palm_gcdf.m: betainc require 0-1 input #15

Closed dawnsong closed 4 years ago

dawnsong commented 5 years ago

Dear Anderson,

Thanks for your permutation test tool PALM. When I am testing my model, occasionally, I encountered an error due to unbounded values input to betainc (the 63th line of palm_gcdf.m). 62 if any(ig(:)), 63 gcdf(ig) = betainc(1./(1+G(ig).^2./df2(ig)),df2(ig)/2,.5)/2; 64 end

Can I just simply enforce this "legal input" as the following modification? I checked for one case of mine, the array can be as large as 220K (some number related to voxel count), even only one value out of range [0,1] will make PALM stop. What I was encountering is 5, still a very tiny number, not able to check which voxel is wrong. I am aware that this error was reported before (https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=ind1704&L=fsl&D=0&P=131143).

To sum up, can I change 63th line to 3 lines to enforce legal input to betainc? rng01=1./(1+G(ig).^2./df2(ig)); rng01(rng01<0)=0; rng01(rng01>1)=1; gcdf(ig) = betainc(rng01, df2(ig)/2,.5)/2;

Thanks,

Best, Xiaowei

andersonwinkler commented 4 years ago

I would first investigate the data... the function should be robust... generally....

dawnsong commented 4 years ago

Thanks for your reply. Yes, I agree with you that we should always check the data first before enforcing the code :) However, it is kind of 5 needles (5 voxels) in the haystack (220K voxels in the brain mask). The 5 voxels are scattered and not possible to be seen by eye. Anyway, this was just a possible small error (either data or code, or even both). I guess I may not be the only one encountering such error, especially when dealing with anatomical datasets which have huge amount of voxels within brain gray matter mask.

It might be helpful for other people to have such a record if they encounter too and there might be better solutions compared to mine :)