-
Notifications
You must be signed in to change notification settings - Fork 2
/
PopulationTuningAnalysis.m
47 lines (36 loc) · 1.46 KB
/
PopulationTuningAnalysis.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
% Population Tuning analysis
% Run BatchSaveSessions first
clearvars
subjectDir=cd;
% List session directories
expDirs= dir([subjectDir filesep '*' filesep 'Analysis']);
expDirs = expDirs([expDirs.isdir]);
expDirs = expDirs(~cellfun(@(folderName) any(strcmp(folderName,...
{'.','..'})),{expDirs.name}));
for sessionNum=1:numel(expDirs)
dataDir=fullfile(expDirs(sessionNum).folder,expDirs(sessionNum).name);
try
load(fullfile(dataDir,[expDirs(sessionNum).name '_ephys.mat']));
load(fullfile(dataDir,[expDirs(sessionNum).name '_pulses.mat']));
if isempty(pulses.TTLTimes)
load(fullfile(dataDir,[expDirs(sessionNum).name '_export_trial.mat']));
pulses.TTLTimes=times;
clearvars times
end
%load traces
traces = memmapfile(fullfile(dataDir,[expDirs(sessionNum).name '_traces.bin']),'Format','single');
traces = traces.Data;
ephys.traces=reshape(traces,[ephys.recInfo.numRecChan ephys.recInfo.dataPoints]);
clearvars traces
catch
disp(['error loading data from ' dataDir])
continue
end
handpick=[]; %46 %vIRt47_0803_5900 : 54
% ephys = SelectUnits(ephys,'quality',handpick); %quality frequency
% ephys = OrderByDepth(ephys);
if ~isfield(pulses,'duration'); pulses.duration=0.01; end
taggedCells = FindPhototagged(ephys,pulses);
ephys.selectedUnits = find(taggedCells);
PhotoTagPlots(ephys,pulses);
end