-
Notifications
You must be signed in to change notification settings - Fork 19
/
sc_load_mua_dialog.m
101 lines (67 loc) · 3.17 KB
/
sc_load_mua_dialog.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
[features,mua]=sc_loadmuadata(features.muafile,1,s_opt);
features.muafilepath =[PathName];
if s_opt.batch
features.muafile =[PathName,multifiles{multi_N}];
features.muafile_justfile =multifiles{multi_N};
else
features.muafile =[PathName,FileName];
features.muafile_justfile =FileName;
end;
% cd(PathName); % for faster selection of later input files
% ask to load other files
% this can be used to make a feature that counts how many
% channels a spike occurs in simultaneously
if ~isfield(features,'skipsetup') % backwards comp. - if no field, assume its not a prev. simpleclust file
features.skipsetup=0;
end;
if s_opt.auto_overlap && (features.skipsetup==0) % automatically load all others
features.loadmultiple=1;
otherfiles=[ dir([PathName,'*.ntt']) ;dir([PathName,'*.nst']) ;dir([PathName,'*.nse']) ;dir([PathName,'*_extracted.mat']) ;dir([PathName,'*.spikes']) ];
cc=1;j=1;
while cc && (j<=numel(otherfiles)) % throw put current channel
if strcmp(otherfiles(j).name,mua.fname)
otherfiles(j)=[]; cc=0;
end;
j=j+1;
end;
if s_opt.auto_overlap_max > 0 % cut down to limits
otherfiles=otherfiles(1:min(numel(otherfiles),s_opt.auto_overlap_max));
end;
features.otherchannelfiles={otherfiles.name};
if numel(otherfiles) >1
[features,mua]=sc_addotherchannelstomua(features,mua);
else
disp('no other files to process for overlap feature');
end;
if s_opt.auto_noise
features.clusterlabels(2)=2; % make 2nd cluster 'noise'
features.clustervisible(2)=0; % make invisible
fn=find(strcmp(features.name,'Ch.overlap')); % find feature
if numel(fn)==0
warning('selected automatic noise rejection but not Ch.overlap feature found!');
else
ii= features.data(fn(1),:)>s_opt.auto_noise_trs;
features.clusters(ii)=2; % assign
features=sc_updateclusterimages(features,mua,s_opt);
end;
end;
else % select manually
if s_opt.auto_overlap_dontask
features.loadmultiple=0;
else
if (debugstate >0) || (s_opt.batch)
button='no';
else
button = questdlg('Open other channnels from same recording?','open?','Yes','No','Yes');
end;
if strcmp(button,'Yes')
features.loadmultiple=1;
[FileName,PathName,FilterIndex] = uigetfile({'*.wf;*.nse;*.nst;*.ntt;','all base electrode file types';'*_simpleclust.mat', 'simpleclust file';'*.mat', 'matlab file';'*_extracted.mat', 'extracted matlab file';'*.wf','Waveform file';'*.nse' ,'neuralynx single electrode file'; '*.nst', 'neuralynx stereotrode file'; '*.ntt', 'neuralynx tetrode file'},['choose files for other channels (vs ch ',num2str(spikes.sourcechannel),')'],'MultiSelect','on');
features.otherchannelfiles=FileName;
[features,mua]=sc_addotherchannelstomua(features,mua);
else
features.loadmultiple=0;
end;
end
end;
dataloaded=1;