Skip to content
Snippets Groups Projects
Commit 3c93ffed authored by Christophe Bradley Smith's avatar Christophe Bradley Smith
Browse files

Implemented check for incorrectly named ls files and added protection for...

Implemented check for incorrectly named ls files and added protection for exports that violate naming conventions
parent f99bcca2
No related branches found
No related tags found
No related merge requests found
clearvars -except ls lss remainingFiles %% Main code
% Prepare work space
clc
%% For testing % Check for miscelaneous transcriptions in the work space
% load('C:\Users\chris\Box\Nelson Lab Data\Other Data\NTAud Transcription\Transcript_OrigAudio_AudSentStim.mat', 'lss'); miscLS = who('-regexp', '^ls.*[0-9]');
% test = load('C:\Users\chris\Box\Nelson Lab Data\Other Data\NTAud Transcription\Transcript_Version2_AudSent.mat'); newLS = CheckmiscLS(miscLS);
% ls = test.lss; 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 % Search the workspace for ls and lss and check for the tracker
if ~ValidateWorkspace(ls, lss); return; end if ~ValidateWorkspace(ls, lss); return; end
...@@ -24,6 +21,36 @@ lss = TransferLabels(ls, lss); ...@@ -24,6 +21,36 @@ lss = TransferLabels(ls, lss);
uisave({'lss', 'remainingFiles'}, 'lss.mat') uisave({'lss', 'remainingFiles'}, 'lss.mat')
%% Functions %% 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) function extStatus = ValidateWorkspace(ls, lss)
if ~exist("ls", "var") if ~exist("ls", "var")
...@@ -63,7 +90,6 @@ memberNames = ls.getMemberNames; ...@@ -63,7 +90,6 @@ memberNames = ls.getMemberNames;
File_Name = memberNames(isUntouched); File_Name = memberNames(isUntouched);
remainingFiles = table(File_Pos, File_Name); remainingFiles = table(File_Pos, File_Name);
% could always print out a nice little status msg to encourage the user
end end
function lss = TransferLabels(ls, lss) function lss = TransferLabels(ls, lss)
...@@ -77,4 +103,13 @@ for iTrial = 1:nTrials ...@@ -77,4 +103,13 @@ for iTrial = 1:nTrials
setLabelValue(lss, iTrial, 'Words', ls.Labels.Words{iTrial}.ROILimits, ls.Labels.Words{iTrial}.Value) setLabelValue(lss, iTrial, 'Words', ls.Labels.Words{iTrial}.ROILimits, ls.Labels.Words{iTrial}.Value)
end end
end end
\ No newline at end of file
%% 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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment