I ran into the following error when trying to use a script to make Marsbar extract betas
Error in pr_stat_compute at 34
Indices too large for contrast structure
This problem occurred when I was trying to extract the betas for an unusual participant who had an empty bin for one condition, and for whom I had therefore had to manually alter the set of contrasts. In doing this, it turns out that I had inadvertently duplicated one contrast vector. Although the names were different, the number of contrasts had been amended to reflect the number of unique contrast vectors in SPM.xCon but not in Marsbar’s D, meaning that pr_stat_compute’s ‘xCon = SPM.xCon’ (line 23), did not return the same value as my own script’s ‘xCon = get_contrasts(D)’. This was causing the two xCons to differ in their length and the resultant error in pr_stat_compute.
The solution lay in removing the duplicate contrasts from the contrast specification for that participant.