diff --git a/SaveTranscriptions.m b/SaveTranscriptions.m index 4a372ba70118702f8268b504cf4b18cd3339eb9d..d17c1267550c56d13c96029431e60cc6901a1d4a 100644 --- a/SaveTranscriptions.m +++ b/SaveTranscriptions.m @@ -1,15 +1,12 @@ -clearvars -except ls lss remainingFiles +%% Main code +% Prepare work space +clc -%% 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; +% Check for miscelaneous transcriptions in the work space +miscLS = who('-regexp', '^ls.*[0-9]'); +newLS = CheckmiscLS(miscLS); +if ~isempty(newLS); ls = eval(newLS); end -% testpos = 6; -% resetLabelValues(lss, testpos) -% setLabelValue(lss, testpos, 'Words', ls.Labels.Words{testpos}.ROILimits, ls.Labels.Words{testpos}.Value) - -%% Main code % Search the workspace for ls and lss and check for the tracker if ~ValidateWorkspace(ls, lss); return; end @@ -24,6 +21,36 @@ lss = TransferLabels(ls, lss); uisave({'lss', 'remainingFiles'}, 'lss.mat') %% Functions +function ls = CheckmiscLS(miscLS) +ls = []; +if isempty(miscLS); return; end + +fprintf(2, 'Warning: multiple potential ''ls'' files were found in the work space. \n\n') + +nLS = length(miscLS); +lsNames = string(['ls'; miscLS]); +formatPat = '\t%i. %s\n'; +formattedstring = compose(formatPat, (0:nLS)', lsNames); +listSet = join(formattedstring' , ''); + +validResp = 0:nLS; +while true + fprintf('Select the most up to date ls file by inputing a number from 0 to %i\n', nLS) + fprintf(listSet{1}); + userResp = input('Resp:'); + + if any(ismember(validResp, userResp)) + fprintf('%s has been selected.', lsNames(userResp + 1)) + break + else + fprintf('%i is an invalid response.', userResp) + end +end + +ls = lsNames(userResp + 1); + +end + function extStatus = ValidateWorkspace(ls, lss) if ~exist("ls", "var") @@ -63,7 +90,6 @@ memberNames = ls.getMemberNames; File_Name = memberNames(isUntouched); remainingFiles = table(File_Pos, File_Name); -% could always print out a nice little status msg to encourage the user end function lss = TransferLabels(ls, lss) @@ -77,4 +103,13 @@ for iTrial = 1:nTrials setLabelValue(lss, iTrial, 'Words', ls.Labels.Words{iTrial}.ROILimits, ls.Labels.Words{iTrial}.Value) end -end \ No newline at end of file +end + +%% 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; + +% testpos = 6; +% resetLabelValues(lss, testpos) +% setLabelValue(lss, testpos, 'Words', ls.Labels.Words{testpos}.ROILimits, ls.Labels.Words{testpos}.Value)