From 90950e7758c6b22474018087f148859ee1913519 Mon Sep 17 00:00:00 2001
From: Helge <47348963+HJZollner@users.noreply.github.com>
Date: Mon, 11 Mar 2024 10:37:33 -0400
Subject: [PATCH] Multiple external .BASIS files

- Added a feature to allow for two separate .BASIS files to be defined for MEGA-PRESS
---
 exampledata/sdat/MEGA/jobSDAT_MEGA_LCModel.m | 15 ++++++++++++---
 exampledata/sdat/UnEdited/jobSDAT_LCModel.m  |  2 +-
 fit/code/osp_fitInitialise.m                 |  4 ++--
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/exampledata/sdat/MEGA/jobSDAT_MEGA_LCModel.m b/exampledata/sdat/MEGA/jobSDAT_MEGA_LCModel.m
index ed1b6dd9..2a78866f 100644
--- a/exampledata/sdat/MEGA/jobSDAT_MEGA_LCModel.m
+++ b/exampledata/sdat/MEGA/jobSDAT_MEGA_LCModel.m
@@ -194,9 +194,18 @@
 
 opts.fit.FWHMcoMM3          = 14;
 
-% Optional: In case the automatic basisset picker is not working you can manually
-% select the path to the basis set in the osprey/fit/basis, i.e.:
-% opts.fit.basisSetFile = 'osprey/fit/basis/3T/philips/mega/press/gaba68/basis_philips_megapress_gaba68.mat';
+%%% ----- LCMODEL FITTING OPTIONS -----
+% Specify LCModel-format basis set (.BASIS)
+% If no basis set file is provided Osprey will generate the .BASIS file
+% from Osprey's database
+% opts.fit.basisSetFile       = {which('3T_megapress_Philips_68ms_noMM_A.BASIS'),
+%                                which('3T_megapress_Philips_68ms_noMM_diff1.BASIS')};
+
+
+% Specify LCModel-type control file (.CONTROL)
+% This is optional: If you leave this field blank, Osprey will create a
+% minimum control file for you.
+% opts.fit.controlFile        = '';
 
 % Optional: Deface the strucutral images in the Coreg/Seg figures for HIPAA
 % compliance 
diff --git a/exampledata/sdat/UnEdited/jobSDAT_LCModel.m b/exampledata/sdat/UnEdited/jobSDAT_LCModel.m
index 98c78366..79923462 100644
--- a/exampledata/sdat/UnEdited/jobSDAT_LCModel.m
+++ b/exampledata/sdat/UnEdited/jobSDAT_LCModel.m
@@ -191,7 +191,7 @@
 % Specify LCModel-format basis set (.BASIS)
 % If no basis set file is provided Osprey will generate the .BASIS file
 % from Osprey's database
-opts.fit.basisSetFile       = which('3T_PRESS_Philips_35ms_noMM.BASIS');
+% opts.fit.basisSetFile       = {which('3T_press_Philips_35ms_noMM.BASIS')};
 
 
 % Specify LCModel-type control file (.CONTROL)
diff --git a/fit/code/osp_fitInitialise.m b/fit/code/osp_fitInitialise.m
index 0c93f12b..356a41cc 100644
--- a/fit/code/osp_fitInitialise.m
+++ b/fit/code/osp_fitInitialise.m
@@ -53,7 +53,7 @@
     
 % Find the right basis set (provided as *.mat file in Osprey basis set
 % format)
-if ~(isfield(MRSCont.opts.fit,'basisSetFile') && ~isempty(MRSCont.opts.fit.basisSetFile) && ~isfolder(MRSCont.opts.fit.basisSetFile))
+if ~(isfield(MRSCont.opts.fit,'basisSetFile') && ~isempty(MRSCont.opts.fit.basisSetFile) && ~isfolder(MRSCont.opts.fit.basisSetFile{1}))
 
     % Intercept non-integer echo times and replace the decimal point with
     % an underscore to avoid file extension problems
@@ -164,7 +164,7 @@
 % Clear existing basis set
 MRSCont.fit.basisSet = [];
 
-if ~isfile(MRSCont.opts.fit.basisSetFile) && (ismcc || isdeployed)
+if ~isfile(MRSCont.opts.fit.basisSetFile(1)) && (ismcc || isdeployed)
     if ~strcmp(MRSCont.opts.fit.basisSetFile(1),filesep)
         MRSCont.opts.fit.basisSetFile = [filesep MRSCont.opts.fit.basisSetFile];
     end