Coding for **By trial group (folder average)**

Thanks for your input Francois I appreciate it!

  1. As per your suggestion I've included the block that loads all the input files into AllMat to the "SAVE THE RESULTS" section within the "for" loop for grouping. As I included the AllMat within the "for" loop for grouping I did NOT change AllMat(: , : , i) into AllMat(:, :, iGroups(i)).
    I hope what I'm showing here is correct.

  2. As per your suggestion I've used GetOutputStudy and changed line 132 from:
    OutputFiles{1} = bst_process('GetNewFilename', fileparts(sInputs(1).FileName), 'data_WAvg');
    to
    OutputFiles{1} = bst_process('GetOutputStudy', sProcess, sInputs(iGroups(i)), 'data_WAvg');

However, I then get an error message saying that "Index exceeds the number of array elements. Index must not exceed 4."


image

So I then went through "bst_process.m" and discovered that 'GetOutputStudy' only requires 3 inputs:
[sStudy, iStudy, Comment, uniqueDataFile] = GetOutputStudy(sProcess, [sInputA, sInputB], sOutput.Condition);

Is this why I am getting the error message? How do I solve this issue?