% Example script for batch-processing multiple subjects' Siemens IMA data
% with accompanying water references. Each subject has four scans each to
% be joined together and treated as single datasets during data processing.
% 
% Remember to check GannetPreInitialise.m has the appropriate settings for
% your data: 'join' must be set to '1'.

data_dir = '/Users/username/Documents/my_project/data'; % Root data directory

% For joining the four files per subject and batching over multiple
% subjects, the data must be entered an an M x N cell array, where M is the
% number of files per subject and N is the number of subjects. In this
% example, we have only two subjects, each with four files that are to be
% joined.
sub01 = {'sub-01-1/MPRESS1_1.IMA', ...
         'sub-01-2/MPRESS2_1.IMA', ...
         'sub-01-3/MPRESS3_1.IMA', ...
         'sub-01-4/MPRESS4_1.IMA'};

sub02 = {'sub-02-1/MPRESS1_1.IMA', ...
         'sub-02-2/MPRESS2_1.IMA', ...
         'sub-02-3/MPRESS3_1.IMA', ...
         'sub-02-4/MPRESS4_1.IMA'};

metab_data = [sub01(:), sub02(:)]; % Make an M x N cell array
metab_data = fullfile(data_dir, metab_data); % It is good practice to include the full pathname
         
% Now we do the same for the water reference data. Because of how file
% joining is currently coded in Gannet, there needs to be the same number
% of water reference files per subject as the metabolite data.
sub01_w = {'sub-01-1_w/WATREF1_1.IMA', ...
           'sub-01-2_w/WATREF2_1.IMA', ...
           'sub-01-3_w/WATREF3_1.IMA', ...
           'sub-01-4_w/WATREF4_1.IMA'};

sub02_w = {'sub-02-1_w/WATREF1_1.IMA', ...
           'sub-02-2_w/WATREF2_1.IMA', ...
           'sub-02-3_w/WATREF3_1.IMA', ...
           'sub-02-4_w/WATREF4_1.IMA'};

water_data = [sub01_w(:), sub02_w(:)];
water_data = fullfile(data_dir, water_data);

anat = {'sub-01_T1w.nii', 'sub-02_T1w.nii'};

MRS = GannetLoad(metab_data, water_data);
MRS = GannetFit(MRS);
MRS = GannetCoRegister(MRS, anat);
MRS = GannetSegment(MRS);
MRS = GannetQuantify(MRS);
LS0tCnRpdGxlOiAiSm9pbmluZyBkYXRhIGZpbGVzIgpkYXRlOiAiTGFzdCB1cGRhdGVkOiBgciBmb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