%% For testing
load('C:\Users\chris\Box\Nelson Lab Data\Other Data\NTAud Transcription\Transcript_OrigAudio_AudSentStim.mat', 'lss');
test = load('C:\Users\chris\Box\Nelson Lab Data\Other Data\NTAud Transcription\Transcript_Version2_AudSent.mat');
ls = test.lss;

%% Main code
% Search the workspace for ls and lss and check for the tracker
if ~ValidWorkspace(ls, lss); return; end

% Update progress
    % Compare ls and lss roi and values

% Transfer labels
lss = TransferLabels(ls, lss);

% Save lss and progress
    % use uiget element to select save location

%% Functions
function extStatus = ValidWorkspace(ls, lss)

if ~exist("ls", "var")
    fprintf(2, 'No exported transcript found. Please export your transciription to the work space as ''ls''\n')
    extStatus = false;
    return
end

if ~exist("lss", 'var')
    fprintf(2, 'The original transcription file is missing, please ensure the work you have done is saved to ''ls'' and load in the original transcription\n');
    extStatus = false;
    return
end

extStatus = true;

end

function lss = TransferLabels(ls, lss)

% Clear lss labels
resetLabelValues(lss)

% Move ls labels to lss
nTrials = height(ls.Labels);
for iTrial = 1:nTrials
    setLabelValue(lss, iTrial, 'Words', ls.Labels.Words{iTrial}.ROILimits, ls.Labels.Words{iTrial}.Value)
end

end