Skip to content

Commit

Permalink
number of channels and sampling frequency will be read from the chann…
Browse files Browse the repository at this point in the history
…el map file if available and NOT already specified in ops
  • Loading branch information
marius10p committed Sep 17, 2016
1 parent 662bdcd commit 904f66d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 20 deletions.
8 changes: 4 additions & 4 deletions configFiles/StandardConfig_MOVEME.m
Expand Up @@ -8,10 +8,10 @@
ops.fproc = 'C:\DATA\Spikes\Piroska\temp_wh.dat'; % residual from RAM of preprocessed data
ops.root = 'C:\DATA\Spikes\Piroska'; % 'openEphys' only: where raw files are

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

Expand Down
7 changes: 5 additions & 2 deletions configFiles/createChannelMapFile.m
Expand Up @@ -8,8 +8,9 @@
ycoords = [1:Nchannels]';
kcoords = ones(Nchannels,1); % grouping of channels (i.e. tetrode groups)

fs = 25000; % sampling frequency
save('C:\DATA\Spikes\20150601_chan32_4_900s\chanMap.mat', ...
'chanMap','connected', 'xcoords', 'ycoords', 'kcoords', 'chanMap0ind')
'chanMap','connected', 'xcoords', 'ycoords', 'kcoords', 'chanMap0ind', 'fs')

%%

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

fs = 25000; % sampling frequency

save('C:\DATA\Spikes\Piroska\chanMap.mat', ...
'chanMap','connected', 'xcoords', 'ycoords', 'kcoords', 'chanMap0ind')
'chanMap','connected', 'xcoords', 'ycoords', 'kcoords', 'chanMap0ind', 'fs')
%%

% kcoords is used to forcefully restrict templates to channels in the same
Expand Down
5 changes: 1 addition & 4 deletions eMouse/config_eMouse.m
Expand Up @@ -12,10 +12,7 @@
ops.chanMap = fullfile(fpath, 'chanMap.mat'); % make this file using createChannelMapFile.m
% ops.chanMap = 1:ops.Nchan; % treated as linear probe if unavailable chanMap file

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

Expand Down
5 changes: 4 additions & 1 deletion eMouse/make_eMouseChannelMap.m
Expand Up @@ -41,4 +41,7 @@ function make_eMouseChannelMap(fpath)
% no "adjacency graphs" like in KlustaKwik).
% Now we can save our channel map for the eMouse.

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

save(fullfile(fpath, 'chanMap.mat'), 'chanMap', 'connected', 'xcoords', 'ycoords', 'kcoords', 'fs')
1 change: 0 additions & 1 deletion fitTemplates.m
@@ -1,6 +1,5 @@
function rez = fitTemplates(rez, DATA, uproj)

rez.ops.nt0 = getOr(rez.ops, {'nt0'}, 61);
nt0 = rez.ops.nt0;
rez.ops.nt0min = ceil(20 * nt0/61);

Expand Down
25 changes: 17 additions & 8 deletions preprocessData.m
@@ -1,7 +1,8 @@
function [rez, DATA, uproj] = preprocessData(ops)
tic;
uproj = [];
nt0 = getOr(ops, {'nt0'}, 61);
ops.nt0 = getOr(ops, {'nt0'}, 61);


if strcmp(ops.datatype , 'openEphys')
ops = convertOpenEphysToRawBInary(ops); % convert data, only for OpenEphys
Expand All @@ -19,12 +20,20 @@
xc = zeros(numel(chanMapConn), 1);
yc = [1:1:numel(chanMapConn)]';
end
ops.Nchan = sum(connected>1e-6);
ops.NchanTOT = numel(connected);
if exist('fs', 'var')
ops.fs = fs;
end
else
chanMap = ops.chanMap;
chanMapConn = ops.chanMap;
xc = zeros(numel(chanMapConn), 1);
yc = [1:1:numel(chanMapConn)]';
connected = true(numel(chanMap), 1);
connected = true(numel(chanMap), 1);

ops.Nchan = numel(connected);
ops.NchanTOT = numel(connected);
end
else
chanMap = 1:ops.Nchan;
Expand All @@ -40,14 +49,14 @@
kcoords = kcoords(connected);
end
NchanTOT = ops.NchanTOT;
NT = ops.NT ;
NT = ops.NT ;

rez.ops = ops;
rez.xc = xc;
rez.yc = yc;
rez.xcoords = xcoords;
rez.ycoords = ycoords;
rez.connected = connected;
rez.ops = ops;
rez.ops.chanMap = chanMap;
rez.ops.kcoords = kcoords;

Expand All @@ -66,7 +75,7 @@

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

%% load data into patches, filter, compute covariance
Expand All @@ -79,7 +88,7 @@
fprintf('Time %3.0fs. Loading raw data... \n', toc);
fid = fopen(ops.fbinary, 'r');
ibatch = 0;
Nchan = ops.Nchan;
Nchan = rez.ops.Nchan;
if ops.GPU
CC = gpuArray.zeros( Nchan, Nchan, 'single');
else
Expand All @@ -93,7 +102,7 @@
end
end
if ~exist('DATA', 'var')
DATA = zeros(NT, ops.Nchan, Nbatch_buff, 'int16');
DATA = zeros(NT, rez.ops.Nchan, Nbatch_buff, 'int16');
end

isproc = zeros(Nbatch, 1);
Expand Down Expand Up @@ -183,7 +192,7 @@

if strcmp(ops.initialize, 'fromData')
i0 = 0;
ixt = round(linspace(1, size(ops.wPCA,1), nt0));
ixt = round(linspace(1, size(ops.wPCA,1), ops.nt0));
wPCA = ops.wPCA(ixt, 1:3);
uproj = zeros(1e6, size(wPCA,2) * Nchan, 'single');
end
Expand Down

0 comments on commit 904f66d

Please sign in to comment.