-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaAnalyze_mainscript.m
More file actions
91 lines (77 loc) · 2.82 KB
/
caAnalyze_mainscript.m
File metadata and controls
91 lines (77 loc) · 2.82 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
%% caAnalyze_mainscript
% INPUTS: (to be placed in a directory for each session to analyze)
% Directory Containing:
% 1) 'data_processed' output file from MIN1PIPE
% (contining sigfn, dff, and spkfn)
% 2) Cue information CSVs (csp = tones, us = shocks)
% 3) Behavior annotations (BehaviorDEPOT 'analyzed' folder)
% 4a) Timestamp files for miniscope and behCAM
% OR
% 4b) frlu.mat file (containing frame lookup table)
% OR
% Directory of directories with files as described above
% OUTPUTS:
% 1) ROC Analysis Report for cue/behavior cell responses
% 2) Folders with ROC plot .fig files for each responsive cell analyzed
% FUTURE: 3) PCA Analysis Report for various trial-averaged / concatenated
% cue/behavior assessments of population activity
% FUTURE: 4) TCA Analysis Report for PCA assessments with trial factors
% FUTURE: 5) Population Analysis
% FUTURE: 6) GLM Variance Analysis
function caAnalyze_mainscript(prep_data, run_roc)
%% ADJUSTABLE PARAMETERS
prep_data = false;
ca_downsample = 2; %Factor by which calcium data was temporally downsampled by
ca_fileID = '*minian_processed*';
csp_ID = 'tones';
us_ID = 'shocks';
run_roc = true;
sig_label = 'rdff';
%% Ask for Input Directory and Decide if Single or Batch
% Record base directory
base_dir = pwd;
% Collect data directory
input_dir = uigetdir('Select Directories for Analysis');
cd(input_dir)
% Check for presence of miniscope output file in given data_dir
batch_check = dir(ca_fileID);
analysis_dirs = {};
% If miniscope output detected, turn off batch
if size(batch_check, 1) == 1
batch = 0;
analysis_dirs = {input_dir};
% If no miniscope output files detected, turn on batch
elseif size(batch_check, 1) == 0
batch = 1;
data_check = dir; data_check(1:2) = [];
for i = 1 : size(data_check, 1)
if data_check(i).isdir
analysis_dirs = [analysis_dirs; data_check(i).folder, addSlash(), data_check(i).name];
end
end
end
clearvars batch_check data_check
%% Prep Single/Batch Session
if prep_data
caAnalyze_prepData(analysis_dirs, ca_downsample, csp_ID, us_ID, ca_fileID);
end
%% Run ROC Analysis
if run_roc
for i = 1:length(analysis_dirs)
cd(analysis_dirs{i})
if exist('rFeatures.mat') > 1
load('rFeatures.mat')
else
load('Features.mat')
end
sig_search = dir(ca_fileID);
S = load(sig_search.name, sig_label);
signal = S.(sig_label);
clearvars S sig_search
caAnalyze_runROC(Features, signal, sig_label)
[~,this_ID] = fileparts(analysis_dirs{i});
disp(['Finished analyzing: ' this_ID])
disp(['@ ' datestr(now, 'HH:MM:SS')])
disp([int2str(length(analysis_dirs)-i) ' more sessions in this batch'])
end
end