-
Notifications
You must be signed in to change notification settings - Fork 1
/
bairWhichExperimentList.m
49 lines (40 loc) · 1.6 KB
/
bairWhichExperimentList.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function [numberOfExperiments, experimentTypes, runIDs, selectionMade] = bairWhichExperimentList(site)
% Which experiment list file?
filespec = fullfile(vistadispRootPath, 'RunMe', '*.txt');
[fname, pathname, fileselected] = uigetfile(filespec, 'Select a text file with the experiment list');
if fileselected
% Read the content of the selected text file
fileID = fopen(fullfile(pathname,fname));
TXT = textscan(fileID, '%s');
fclose(fileID);
% Parse the filename string
TXT = TXT{:};
numberOfExperiments = size(TXT,1);
for ii = 1:numberOfExperiments
thisExperimentName = TXT{ii,:};
dashPos = strfind(thisExperimentName,'_');
experimentTypes{ii} = thisExperimentName(1:dashPos-1);
runIDs(ii) = str2num(thisExperimentName(dashPos+1:end));
end
% DEBUG: code below doesn't work when file has just a single experiment
% T = readtable(fullfile(pathname, fname));
% experimentType = T.Var1;
% runID = T.Var2;
% numberOfExperiments = height(T);
% Check that the experiment files exist
stimPath = fullfile(vistadispRootPath, 'StimFiles');
for ii = 1:numberOfExperiments
fname = sprintf('%s_%s_%d.mat', site, experimentTypes{ii}, runIDs(ii));
if ~exist(fullfile(stimPath, fname), 'file')
error('Requested experiment file %s not found in expected location:\n%s', fname, stimPath);
end
end
fprintf('All experiment files ready to go!\n');
selectionMade = 1;
else
numberOfExperiments = [];
experimentTypes = [];
runIDs = [];
selectionMade = 0;
end
end