-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdata_info.m
79 lines (69 loc) · 2.72 KB
/
data_info.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
function [rexnumtrials, trialdirs] = data_info( rdd_filename, reload, skipunproc )
% [nt, curtasktype, trialdirs, saccadeInfo] = data_info( name )
%
% Returns the type of task, how many trials are in the Rex data, and loads a
% number of global variables
%
% If the data for 'name' are not in memory, num_rex_trials will attempt to
% load them with rex_load_processed.
%
% If for some reason loading fails, num_rex_trials returns 0;
% global rexloadedname rexnumtrials alloriginaltrialnums allnewtrialnums...
% allcodes alltimes allspkchan allspk allrates ...
% allh allv allstart allbad alldeleted allsacstart allsacend...
% allcodelen allspklen alleyelen allsaclen saccadeInfo;
global allcodes alltimes allspkchan allspk allspk_clus allrates ...
allh allv allstart allbad saccadeInfo;
global sessiondata rexloadedname rexnumtrials;
% using the matfile function to access file
sessiondata=matfile(rdd_filename);
if nargin<3
skipunproc=0;
end
if nargin<2
reload=0;
end
includeaborted = 1; %by default
rdd_includeaborted = includeaborted;
rexloadedname=get(findobj('Tag','filenamedisplay'),'String');
if ~strcmp(rdd_filename,rexloadedname) || reload; % rexloadedname is created in rex_process
rexnumtrials = 0;
%disp( 'File not loaded yet...');
% success = rex_load_processed( rdd_filename, skipunproc);
success = load_REXfile(rdd_filename);
if ~success
return;
end
set(findobj('Tag','filenamedisplay'),'String',rdd_filename);
set(findobj('Tag','nboftrialsdisplay'),'String',num2str(rexnumtrials));
else
rexnumtrials=str2num(get(findobj('Tag','nboftrialsdisplay'),'String'));
disp( 'File already loaded ...');
end;
% matfile access takes ~3.5s. for the commands below (if initial matfile
% called taken into account). Loading the whole file takes .5s.
% May be due to the file being saved in v7.3 rather than 7 (but we need
% 7.3) . In the future, could be done by saving data into database and
% using http://www.mathworks.com/products/database/
% allcodes = sessiondata.allcodes;
% alltimes = sessiondata.alltimes;
% allspkchan = sessiondata.allspkchan;
% allspk = sessiondata.allspk;
% allrates = sessiondata.allrates;
% allh = sessiondata.allh;
% allv = sessiondata.allv;
% allstart = sessiondata.allstart;
% allbad = sessiondata.allbad;
% saccadeinfo = sessiondata.saccadeinfo;
% detecting tasktype
curtasktype=taskdetect(allcodes);
% if strcmp(curtasktype,'reproc')
% curtasktype
% end
set(findobj('Tag','taskdisplay'),'String',curtasktype);
%findings all used directions from ecodes
trialtypes=allcodes(:,2);
if trialtypes(1) < 4000; % twoafc drops the basecode in allcodes(:, 4)
trialtypes = allcodes(:, 4);
end
trialdirs=unique(trialtypes-floor(trialtypes./10)*10);