Skip to content

Commit 904f66d

Browse files
committed
number of channels and sampling frequency will be read from the channel map file if available and NOT already specified in ops
1 parent 662bdcd commit 904f66d

6 files changed

+31
-20
lines changed

configFiles/StandardConfig_MOVEME.m

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
ops.fproc = 'C:\DATA\Spikes\Piroska\temp_wh.dat'; % residual from RAM of preprocessed data
99
ops.root = 'C:\DATA\Spikes\Piroska'; % 'openEphys' only: where raw files are
1010

11-
ops.fs = 25000; % sampling rate
12-
ops.NchanTOT = 32; % total number of channels
13-
ops.Nchan = 32; % number of active channels
14-
ops.Nfilt = 32; % number of filters to use (2-4 times more than Nchan, should be a multiple of 32)
11+
ops.fs = 25000; % sampling rate (omit if already in chanMap file)
12+
ops.NchanTOT = 32; % total number of channels (omit if already in chanMap file)
13+
ops.Nchan = 32; % number of active channels (omit if already in chanMap file)
14+
ops.Nfilt = 64; % number of clusters to use (2-4 times more than Nchan, should be a multiple of 32)
1515
ops.nNeighPC = 12; % visualization only (Phy): number of channnels to mask the PCs, leave empty to skip (12)
1616
ops.nNeigh = 16; % visualization only (Phy): number of neighboring templates to retain projections of (16)
1717

configFiles/createChannelMapFile.m

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
ycoords = [1:Nchannels]';
99
kcoords = ones(Nchannels,1); % grouping of channels (i.e. tetrode groups)
1010

11+
fs = 25000; % sampling frequency
1112
save('C:\DATA\Spikes\20150601_chan32_4_900s\chanMap.mat', ...
12-
'chanMap','connected', 'xcoords', 'ycoords', 'kcoords', 'chanMap0ind')
13+
'chanMap','connected', 'xcoords', 'ycoords', 'kcoords', 'chanMap0ind', 'fs')
1314

1415
%%
1516

@@ -24,8 +25,10 @@
2425
ycoords = ycoords(:);
2526
kcoords = ones(Nchannels,1); % grouping of channels (i.e. tetrode groups)
2627

28+
fs = 25000; % sampling frequency
29+
2730
save('C:\DATA\Spikes\Piroska\chanMap.mat', ...
28-
'chanMap','connected', 'xcoords', 'ycoords', 'kcoords', 'chanMap0ind')
31+
'chanMap','connected', 'xcoords', 'ycoords', 'kcoords', 'chanMap0ind', 'fs')
2932
%%
3033

3134
% kcoords is used to forcefully restrict templates to channels in the same

eMouse/config_eMouse.m

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
ops.chanMap = fullfile(fpath, 'chanMap.mat'); % make this file using createChannelMapFile.m
1313
% ops.chanMap = 1:ops.Nchan; % treated as linear probe if unavailable chanMap file
1414

15-
ops.fs = 25000; % sampling rate
16-
ops.NchanTOT = 34; % total number of channels
17-
ops.Nchan = 32; % number of active channels
18-
ops.Nfilt = 64; % number of filters to use (2-4 times more than Nchan, should be a multiple of 32)
15+
ops.Nfilt = 64; % number of clusters to use (2-4 times more than Nchan, should be a multiple of 32)
1916
ops.nNeighPC = 12; % visualization only (Phy): number of channnels to mask the PCs, leave empty to skip (12)
2017
ops.nNeigh = 16; % visualization only (Phy): number of neighboring templates to retain projections of (16)
2118

eMouse/make_eMouseChannelMap.m

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,7 @@ function make_eMouseChannelMap(fpath)
4141
% no "adjacency graphs" like in KlustaKwik).
4242
% Now we can save our channel map for the eMouse.
4343

44-
save(fullfile(fpath, 'chanMap.mat'), 'chanMap', 'connected', 'xcoords', 'ycoords', 'kcoords')
44+
% would be good to also save the sampling frequency here
45+
fs = 25000;
46+
47+
save(fullfile(fpath, 'chanMap.mat'), 'chanMap', 'connected', 'xcoords', 'ycoords', 'kcoords', 'fs')

fitTemplates.m

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
function rez = fitTemplates(rez, DATA, uproj)
22

3-
rez.ops.nt0 = getOr(rez.ops, {'nt0'}, 61);
43
nt0 = rez.ops.nt0;
54
rez.ops.nt0min = ceil(20 * nt0/61);
65

preprocessData.m

+17-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
function [rez, DATA, uproj] = preprocessData(ops)
22
tic;
33
uproj = [];
4-
nt0 = getOr(ops, {'nt0'}, 61);
4+
ops.nt0 = getOr(ops, {'nt0'}, 61);
5+
56

67
if strcmp(ops.datatype , 'openEphys')
78
ops = convertOpenEphysToRawBInary(ops); % convert data, only for OpenEphys
@@ -19,12 +20,20 @@
1920
xc = zeros(numel(chanMapConn), 1);
2021
yc = [1:1:numel(chanMapConn)]';
2122
end
23+
ops.Nchan = sum(connected>1e-6);
24+
ops.NchanTOT = numel(connected);
25+
if exist('fs', 'var')
26+
ops.fs = fs;
27+
end
2228
else
2329
chanMap = ops.chanMap;
2430
chanMapConn = ops.chanMap;
2531
xc = zeros(numel(chanMapConn), 1);
2632
yc = [1:1:numel(chanMapConn)]';
27-
connected = true(numel(chanMap), 1);
33+
connected = true(numel(chanMap), 1);
34+
35+
ops.Nchan = numel(connected);
36+
ops.NchanTOT = numel(connected);
2837
end
2938
else
3039
chanMap = 1:ops.Nchan;
@@ -40,14 +49,14 @@
4049
kcoords = kcoords(connected);
4150
end
4251
NchanTOT = ops.NchanTOT;
43-
NT = ops.NT ;
52+
NT = ops.NT ;
4453

54+
rez.ops = ops;
4555
rez.xc = xc;
4656
rez.yc = yc;
4757
rez.xcoords = xcoords;
4858
rez.ycoords = ycoords;
4959
rez.connected = connected;
50-
rez.ops = ops;
5160
rez.ops.chanMap = chanMap;
5261
rez.ops.kcoords = kcoords;
5362

@@ -66,7 +75,7 @@
6675

6776
NTbuff = NT + 4*ops.ntbuff;
6877
Nbatch = ceil(d.bytes/2/NchanTOT /(NT-ops.ntbuff));
69-
Nbatch_buff = floor(4/5 * nint16s/ops.Nchan /(NT-ops.ntbuff)); % factor of 4/5 for storing PCs of spikes
78+
Nbatch_buff = floor(4/5 * nint16s/rez.ops.Nchan /(NT-ops.ntbuff)); % factor of 4/5 for storing PCs of spikes
7079
Nbatch_buff = min(Nbatch_buff, Nbatch);
7180

7281
%% load data into patches, filter, compute covariance
@@ -79,7 +88,7 @@
7988
fprintf('Time %3.0fs. Loading raw data... \n', toc);
8089
fid = fopen(ops.fbinary, 'r');
8190
ibatch = 0;
82-
Nchan = ops.Nchan;
91+
Nchan = rez.ops.Nchan;
8392
if ops.GPU
8493
CC = gpuArray.zeros( Nchan, Nchan, 'single');
8594
else
@@ -93,7 +102,7 @@
93102
end
94103
end
95104
if ~exist('DATA', 'var')
96-
DATA = zeros(NT, ops.Nchan, Nbatch_buff, 'int16');
105+
DATA = zeros(NT, rez.ops.Nchan, Nbatch_buff, 'int16');
97106
end
98107

99108
isproc = zeros(Nbatch, 1);
@@ -183,7 +192,7 @@
183192

184193
if strcmp(ops.initialize, 'fromData')
185194
i0 = 0;
186-
ixt = round(linspace(1, size(ops.wPCA,1), nt0));
195+
ixt = round(linspace(1, size(ops.wPCA,1), ops.nt0));
187196
wPCA = ops.wPCA(ixt, 1:3);
188197
uproj = zeros(1e6, size(wPCA,2) * Nchan, 'single');
189198
end

0 commit comments

Comments
 (0)