-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.m
72 lines (59 loc) · 2.5 KB
/
main.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
%MAIN Script to run/time batch processes during development
%
% Objects are arranged according to the hierarchy (Highest to Lowest)
% * `solRat` -- All recordings for a given acute procedure (rat)
% * `solBlock` -- Data for an individual recording (experiment; block)
% * `solChannel` -- Data for individual channels within a recording
%
% To load files from local:
% rats = cfg.default('rats'); % Server tank or folder containing Animal folders
% r = solRat.loadAll(pwd,rats);
clear;
clc
%% SET FILES HERE
[p,rats] = cfg.default('path','rats'); % Server tank or folder containing Animal folders
%% CREATE RAT OBJECTS
maintic = tic;
if any(arrayfun(@(s)exist(fullfile(pwd,strcat(s,".mat")),'file')==0,rats))
r = solRat(fullfile(p,rats)); % approx. 3-minutes on Nudo lab desktop, if files already extracted
tocData = struct('construction',round(toc(maintic)));
savetic = tic;
save(r);
tocData.save = round(toc(savetic));
else
r = solRat.loadAll(pwd,rats);
tocData = struct('construction',round(toc(maintic)));
end
%% CREATE PETH GRAPHICS
graphicstic = tic;
% batchProbePETH(r,cfg.TrialType('Solenoid'));
% batchProbePETH(r,cfg.TrialType('ICMS'));
% batchProbePETH(r,cfg.TrialType('Solenoid_ICMS'));
tocData.graphics = round(toc(graphicstic));
%% LAUNCH FIGURE BROWSER
% h = figBrowser(r);
%% CREATE MASTER TABLE FOR FURTHER STATISTICS
T = makeTables(r);
T = tbl.parseBlockID(T); % Format block-related info
T = tbl.parseProbeData(T); % Format channel-related info
T = utils.roundEventTimesToNearestMillisecond(T);
T = tbl.addTrialLFPtMin(T,T.Solenoid_Onset*1e3); % adds `TrialType` and `ElectrodeID` and `Lamina` and `Solenoid_Dwell` variables also
% Remove "bad blocks":
T = tbl.excludeBlocks(T); % Remove listed "bad blocks" (may not all be "bad", but might have different experimental parameters etc.)
% save(cfg.default('exported_database_table__local'),'T','-v7.3'); % (Large-ish)
% save(cfg.default('exported_database_table__remote'),'T','-v7.3'); % (Large-ish)
tocData.total = round(toc(maintic));
%% EXAMPLES FOR CREATING GRAPHICS OF EVENT-RELATED DATA
surgID = 'R19-227';
blockIndex = 3;
trialType = 1;
channelName = 'B005';
% Make spike histogram (peri-event histogram; PETH)
fig_peth = analyze.rat.plotPETH(T,surgID,blockIndex,trialType,channelName);
% Make LFP event-related potential (peri-event potential; PEP)
for probe = ['A', 'B']
CH = randi(32,1,4);
for ch = CH
fig_pep = analyze.rat.plotPEP(T,surgID,blockIndex,trialType,sprintf('%s%03d',probe,ch));
end
end