tag:blogger.com,1999:blog-5737874959005852552.post5252675652028695649..comments2023-10-18T16:31:41.080-05:00Comments on MVPA Meanderings: demo: R code to perform a voxelwise t-testJo Etzelhttp://www.blogger.com/profile/04277620767760987432noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-5737874959005852552.post-70313953517147500672017-05-19T12:46:45.881-05:002017-05-19T12:46:45.881-05:00Thank you. I checked and the values are correct.On...Thank you. I checked and the values are correct.One problem I think is that I have only two images (same subject before and after a condition): I guess t.test() does not have enough values.What is your opinion? thanksAnonymoushttps://www.blogger.com/profile/08039637746641804723noreply@blogger.comtag:blogger.com,1999:blog-5737874959005852552.post-50733674741840783622017-05-19T11:30:13.813-05:002017-05-19T11:30:13.813-05:00I don't know the seq_len function, but probabl...I don't know the seq_len function, but probably your i, j, k aren't being set to in-brain integers. Regardless, it's always easier to debug out of a loop ... I'd check the values that are going into x and y for a single voxel, that the t-test is reasonable, etc., before scaling up to whole-brain.Jo Etzelhttps://www.blogger.com/profile/04277620767760987432noreply@blogger.comtag:blogger.com,1999:blog-5737874959005852552.post-49736938737643524112017-05-19T09:07:44.864-05:002017-05-19T09:07:44.864-05:00Hi Jo thanks for replying. I did this:
for (i in s...Hi Jo thanks for replying. I did this:<br />for (i in seq_len(dim(big)[1])) {<br /> for (j in seq_len(dim(big)[2])) {<br /> for (k in seq_len(dim(big)[3])) {<br /> x <- big[i, j, k,]; <br /> y <- big[i, j, k,];<br /> stat[i,j,k] <- t.test(x, y, paired=TRUE,var.equal=T)$statistic;<br /> }<br /> }<br />} <br /><br />but it is giving me all NaNs in the output for some reason...Anonymoushttps://www.blogger.com/profile/08039637746641804723noreply@blogger.comtag:blogger.com,1999:blog-5737874959005852552.post-40225962472820201242017-05-18T17:36:55.057-05:002017-05-18T17:36:55.057-05:00Not sure of a one-line solution with aaply, but it...Not sure of a one-line solution with aaply, but it should work with massive loops. For example, if you have paired people in two 4D images (so the 4th dimension is the same size in each image), you could run the test on each voxel sequentially, like this, for the voxel at i,j,k: <br />x <- img1[vox.i, vox.j, vox.k,]; <br />y <- img2[vox.i, vox.j, vox.k,];<br />t.test(x, y, alternative="greater", mu=0.5, paired=TRUE);Jo Etzelhttps://www.blogger.com/profile/04277620767760987432noreply@blogger.comtag:blogger.com,1999:blog-5737874959005852552.post-68712828859301182332017-05-18T17:29:57.152-05:002017-05-18T17:29:57.152-05:00the dropbox sharing settings changed, which broke ...the dropbox sharing settings changed, which broke the links ... I just updated it, so give it a try again.Jo Etzelhttps://www.blogger.com/profile/04277620767760987432noreply@blogger.comtag:blogger.com,1999:blog-5737874959005852552.post-31304888310299513202017-05-18T16:59:59.765-05:002017-05-18T16:59:59.765-05:00Hi! Thanks a lot for this post. I wanted to use it...Hi! Thanks a lot for this post. I wanted to use it to run a t-test on accuracy maps from a searchlight analysis. Unfortunately the files have been moved. Is the code still accessible somewhere? Or do you have other suggestions how run the group level t-test on accuracy maps?Anonymoushttps://www.blogger.com/profile/11147784349376642373noreply@blogger.comtag:blogger.com,1999:blog-5737874959005852552.post-63741015317917166872017-05-12T10:43:53.983-05:002017-05-12T10:43:53.983-05:00I'm sorry but how can I extract recursively th...I'm sorry but how can I extract recursively the corresponding paired value of x from the other dataset (let's say we have only two datasets stacked together)? I feel my question is really trivial but I'm stuck for days finding a solution..Anonymoushttps://www.blogger.com/profile/08039637746641804723noreply@blogger.comtag:blogger.com,1999:blog-5737874959005852552.post-86085274563839137842017-05-12T09:53:01.908-05:002017-05-12T09:53:01.908-05:00If you put the pairs of x into the vector y, then ...If you put the pairs of x into the vector y, then it's t.test(x, y, alternative="greater", mu=0.5, paired=TRUE);Jo Etzelhttps://www.blogger.com/profile/04277620767760987432noreply@blogger.comtag:blogger.com,1999:blog-5737874959005852552.post-49888239400431428922017-05-12T08:43:18.823-05:002017-05-12T08:43:18.823-05:00hi thank you a lot for this post!I need to do a pa...hi thank you a lot for this post!I need to do a paired t test though and I find really hard implementing the function: any suggestion? thanks a lot againAnonymoushttps://www.blogger.com/profile/08039637746641804723noreply@blogger.com