-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrapperCB.m
132 lines (112 loc) · 4.71 KB
/
wrapperCB.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
%% Pipeline Wrapper %%
% The only changes necessary should be within root and selecting which
% files to run in second line of indexing after findFilePathAF
root ='Z:\AFdata\2p2019\Experiments\MR4'; %% as character
ext ='.sbx'; %% Can find any character (text) matching ext. Also faster than the File Explorer
% ext='dsNidaq.mat'
sbxdirs = findFILE(root,ext); %% Will return cell array of all files under root containing extList
sbxDirs = sbxdirs(:) %% change here
% sbxDirs=cellDirs2(14:end)
% for ii=1:length(sbxDirs)
% customLabels={['Training Day Baseline 1']} %%optional, will label graphs within readSbxEphysCheck
% end
% sbxDirs=cellDirs
% customLabels=['Appetetive day 1'] %%optional, will label graphs within readSbxEphysCheck
for ii=1:length(sbxDirs)
readSbxEphysCheck(sbxDirs{ii});
end
%% WRITE TIFFS
stimTimes=[];
n=500;
%n=trialLength-1
%customStart=[1:1000:25000];
customStart=[];
for ii=1:length(sbxDirs);
tiffLoop(sbxDirs{ii},n,0,customStart,'Z:\Fiji.app'); %% write TIFFs for all sbx files found above to run suite2p
end
% % %
%
javaaddpath 'C:\Program Files\MATLAB\R2022a\java\mij.jar'
javaaddpath 'C:\Program Files\MATLAB\R2022a\java\ij.jar'
%% Eye vids - find and write them to .avi
root ='Z:\AFdata\2p2019\Experiments\T07'; %% as character
ext = 'eye.mat';
eyedirs = findFILE(root,ext);
eyeDirs = eyedirs(:)
for ii=1:length(eyeDirs)
[temp]=writeVid(eyeDirs{ii}); % change this so that it will find the eye.mat files from the sbx directories
goodEyeFile(ii)=temp; %%%%%% put this into
end
%% Convert BHV files - from MonkeyLogic
root ='Z:\AFdata\2p2019\Experiments\T07'; %% as character
ext = '.bhv2';
bhvdirs = findFILE(root,ext);
bhvPath = bhvdirs(:)
%bhvPath = cellDirs(:);
for ii=1:length(bhvPath);
[~]= bhv2Convert(bhvPath{ii},'Z:\AFdata\2p2019\Experiments\AF_allBehavior_LTLearning Scripts'); %% MAKE SURE THERE IS A RUN # in THE .bhv2 FILE NAME (A 001 or 002 etc) IN THERE
end
% %
% % for ii=1:length(bhvPath);
% % [~]= bhv2Convert(bhvPath{ii},'Z:\AFdata\2p2019', 'Z:\AFdata\2p2019\Eight_orientations_AF.txt');
% % %% MAKE SURE THERE IS A RUN # in THE .bhv2 FILE NAME (A 001 or 002 etc) IN THERE
% % end
%for sut mice need to specify the ori
%% Run Facemap and conversion script before running:
ext = '_stim';
stimdirs = findFILE(root,ext);
stimDirs=stimdirs(9);
time_window=90;
%%%%%%%%%%%%%%% behaviorPlots
for ii=1:length(stimDirs) %should this go back to looking for dsnidaq? If there is no stim... skip behavior plots?
behaviorPlots(stimDirs{ii},time_window,'FC App Day 3') % last is custom label (useful for labeling behavioral day ex: FC)
end %still needs some cleaning/optimization (such as adding graphing fxn?)
%% RUN SUITE2P + CELL CLICKING!
%%%%%%%% once finished cell clicking write to Fall.mat within suite2p GUI
%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% %% get dFF calculations
root ='Z:\AFdata\2p2019\Experiments\T03'; %% as character
ext = 'Fall.mat';
% ext = 'Suite2p_dff.mat';
stimdir = findFILE(root,ext);
stimDirs=stimdir(11) %%210210 and 210209 are fucky. FUN! just make it so it skips the last trial, its too much of a fucking hassle.
% stimDirs=stimdir(:)
time_window=10;
percentile=20;
% runNums={['001'],['002']} %%manual for the flipped files, no good way around this bc the tiffs arent named
%%%%%%%%%%%%%%%%%%%%%%%
%%%% if file exists, won't overwrite
%%% still need to fix alignStim
tic
for ii=1:length(stimDirs)
close all
dffCalc(stimDirs{ii},percentile,time_window);
end
toc
root ='Z:\AFdata\2p2019\Experiments\W05'; %% as character
ext = 'dff.mat';
ext = 'Suite2p_dff.mat';
stimdir = findFILE(root,ext);
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
ii=1
for ii=1:length(stimDirs)
load(stimDirs{ii})
Sut1cells(ii)=length(find(iscell(:,1)))
[fullRoot,filename,~] = fileparts(stimDirs{ii});
idcs = strfind(fullRoot,filesep);
FILENAMESut1(ii) = fullRoot(idcs(end-4)+1:idcs(end-3)-1); % expects Fall.mat to be 3 folders up. This WILL break w diff file arrangement (ex: update of Suite2p that changes file locations)
end
=fileparts(stimDirs{ii})
fileName = regexprep(stimDirs,'.*\', ''); %%filename of cell list
clear all
root ='Z:\AFdata\2p2019\Experiments\Sut3'; %% as character
%%% Generate plots
ext = 'dff.mat';
stimdir = findFILE(root,ext);
stimDirs=stimdir(9:end);
for ii=1:length(stimDirs)
generateCellPlots(stimDirs{ii},5); %change to be just stim path
end