%% LongGluCESTJob.m
% Testing/Debugging Osprey with 7T longglucest spectroscopy data
%   - also testing .rda vs. .dcm svs files
%
% AUTHOR: Ally Atkins
% DATE CREATED: Jul 19th, 2023 (2023-07-19)


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% 1. Specify Sequence Information %%%%


% SeqType describes the type of sequence used and is a required input
% in the form of a string -- determines whether the supplied datasets have
% been acquired with spectral editing experiments
%
% OPTIONS: unedited (default), MEGA, HERMES, HERCULES

seqType = 'unedited';

% editTarget describes sequence type and is a required input in the form
% of a cell array -- determines the target spin system(s) of spectral
% editing experiments (if none has been performed, enter {'none'}

editTarget = {'none'};

% dataScenario specifies the conditions in which the data were acquired
% use invivo for in-vivo single-voxel MRS
% OPTIONS: invivo, phantom, PRIAM, MRSI

dataScenario = 'invivo';


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% 2. Specify Data Handling and Modeling Options %%%%


% opts.SpecReg allows specification of desired spectral registration method
% setting SpecReg to 'RobSpecReg' --> alignment is performed with lipid/water
% removal using similarity metric and weighted averaging
% SpecReg to 'ProbSpecReg' --> probabilistic spectral alignment is performed,
% registering to a median target with weighted averaging
% SpecReg to 'RestrSpecReg' --> frequency restricted (fit range) spectral
% alignment, using similarity metric and weighted averaging
% OPTIONS: RobSpecReg, ProbSpecReg, RestrSpecReg, none

opts.SpecReg = 'RobSpecReg';

% opts.SubSpecAlignment allows specification of the metric used to optimize
% sub-spectral alignment
% OPTIONS: L2Norm (default), L1Norm, none

opts.SubSpecAlignment.mets = 'L2Norm';

% opts.ECC specifies data to be eddy-current corrected using a
% corresponding water-unsuppressed ref scan
% opts.ECC.raw --> raw metabolite
% opts.ECC.mm --> macromolecule spectra 
% OPTIONS: 1 (apply to all data), 0 (don't apply at all), or vector ([]) to
% apply to a sub-set of data

opts.ECC.raw = 1; 
opts.ECC.mm = 1;
% save LCModel files for each spectrum?
opts.saveLCM = 1;

% save jMRUI files?
opts.savejMRUI = 1;

% save processed spectra in vendor-specific format?
opts.saveVendor = 1; 

% save processed spectra in NIFTI-MRS format?
opts.saveNII = 0;

% save PDF output for all Osprey modules and subjects?
opts.savePDF = 1;

% choose fitting algorithm
% OPTIONS: Osprey or LCModel
opts.fit.method = 'Osprey';
opts.fit.basisSetFile = '/Applications/osprey/fit/basissets/user/BASIS_MM.mat' ;

% opts.fit.includeMetabs can be used to specify a custom set of metabolites
% to be included in the fitting -- subsets can be specified as a cell array
% of strings ({Cr, CrCH2, GABA,...}
% OPTIONS: 'default', 'full', or custom
opts.fit.includeMetabs = {'default'};

% opts.fit.style determines how difference-edited data are modeled
% Concatenated --> difference and sum spectra in MEGA, HERMES, and HERCULES
% datasets will be modeled simultaneously (common metabolite amplitude
% parameters across spectra
% Separate --> difference and edit-OFF spectra will be modeled
% independently
opts.fit.style = 'Separate';

% opts.fit.range and opts.fit.rangeWater determine fitting range (in ppm)
% of metabolite and water spectra, respectively
opts.fit.range = [0.5 4];
opts.fit.rangeWater = [2.0 7.4];

% opts.fit.GAP specifies a range to be excluded from the fitting of
% specified sub-spectra -- input is a vector specifying upper and lower
% bounds
% opts.fit.GAP.A = [];
% opts.fit.GAP.diff1 = [];

% opts.fit.bLineKnotSpace determines spacing (in ppm) between two adjacent
% knots of the cubic B-spline baseline -- higher values: stiffer baseline
% choosing lower values will improve the fit quality at the expense of
% overparametrization of the model
opts.fit.bLineKnotSpace = 0.4; % Default

% opts.fit.fitMM determines whether simulated Gaussian signals representing
% broad macromolecular and lipid signals are included in the basis set
opts.fit.fitMM = 1;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% 3. Specify MRS Data and Structural Imaging Files %%%%
% when using single-average Siemens RDA or DICOM files, specify their
% folders instead of single files

% clear existing files
clear files files_ref files_w files_nii files_mm

% files variable refers to raw data containing metabolite
% (water-suppressed) data
files ={
    '/Users/alatkins/Desktop/osprey/osprey_7t_test/sub-19790/ses-12528/mrs/svsglu_SUPPRESSED',...
    '/Users/alatkins/Desktop/osprey/osprey_7t_test/sub-88608/ses-12108/mrs/svsglu_SUPPRESSED',...
    '/Users/alatkins/Desktop/osprey/osprey_7t_test/sub-88608/ses-12578/mrs/svsglu_SUPPRESSED',...
    '/Users/alatkins/Desktop/osprey/osprey_7t_test/sub-132224/ses-12372/mrs/svsglu_SUPPRESSED'};

% files_ref is array of paths to water-unsuppressed data
files_ref ={
    '/Users/alatkins/Desktop/osprey/osprey_7t_test/sub-19790/ses-12528/mrs/svsglu_UNSUPPRESSED',...
    '/Users/alatkins/Desktop/osprey/osprey_7t_test/sub-88608/ses-12108/mrs/svsglu_UNSUPPRESSED',...
    '/Users/alatkins/Desktop/osprey/osprey_7t_test/sub-88608/ses-12578/mrs/svsglu_UNSUPPRESSED',...
    '/Users/alatkins/Desktop/osprey/osprey_7t_test/sub-132224/ses-12372/mrs/svsglu_UNSUPPRESSED'};

% specify water data for quantification (short-TE water data)
files_w = {};

% specify metabolite-nulled data for quantification
files_mm = {};

% specify T1-weighted structural imaging folder

files_nii = {
    '/Users/alatkins/Desktop/osprey/osprey_7t_test/sub-19790/ses-12528/anat/sub-19790_ses-12528_INV1.nii',...
    '/Users/alatkins/Desktop/osprey/osprey_7t_test/sub-88608/ses-12108/anat/sub-88608_ses-12108_INV1.nii',...
    '/Users/alatkins/Desktop/osprey/osprey_7t_test/sub-88608/ses-12578/anat/sub-88608_ses-12578_INV1.nii',...
    '/Users/alatkins/Desktop/osprey/osprey_7t_test/sub-132224/ses-12372/anat/sub-132224_ses-12372_INV1.nii'};

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% 4. Specify Output Folder %%%%
outputFolder = '/Users/alatkins/Desktop/osprey/osprey_7t_test/firstrun_output';




















