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

Hello Francois,

So I've modified the code that you've provided to keep all the possible options available for avgtype. [iGroups, GroupComments] = process_average('SortFiles', sInputs, sProcess.options.avgtype.Value);
I've added the "avgtype" description under "%% Get Description" so it should provide a value to specify the "avgtype".

I understand that (please correct me if I'm wrong):

  1. "process_average('SortFiles'" calls for the "SortFiles" function. I know that this means I don't have to copy and paste the entire "SortFiles" function from process_average.
  2. "sInputs" is the input structure.
  3. "sProcess.options.avgtype.Value" specifies the avgtype (i.e. everthing, by subject, by condition etc) based on the selection made.

Based on the above information I need to implement the following code somewhere within my code:
[iGroups, GroupComments] = process_average('SortFiles', sInputs, sProcess.options.avgtype.Value);
for i = 1:length(iGroups)
end

What I'm having trouble implementing is the [iGroups, GroupComments] part and the "for" loop with "i = 1:length(iGroups)" where and how do I implement this?
Looking at "process_average" the "%Group files" is under "%%Run" but I'm not sure where under the "%%Run" I should insert this code.

At the moment, I've included the code just before where the actual data manipulation and calculation starts. But I feel like this code needs to be somewhere higher up within "% Load the Data"
Any suggestions? Bear in mind I wrote the following code from "[process_example_customavg.m]".