diff --git a/configFiles/StandardConfig_MOVEME.m b/configFiles/StandardConfig_MOVEME.m index 40f7b75..23471e0 100644 --- a/configFiles/StandardConfig_MOVEME.m +++ b/configFiles/StandardConfig_MOVEME.m @@ -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) diff --git a/configFiles/createChannelMapFile.m b/configFiles/createChannelMapFile.m index 96b7872..d9a254c 100644 --- a/configFiles/createChannelMapFile.m +++ b/configFiles/createChannelMapFile.m @@ -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') %% @@ -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 diff --git a/eMouse/config_eMouse.m b/eMouse/config_eMouse.m index 723235b..d06a446 100644 --- a/eMouse/config_eMouse.m +++ b/eMouse/config_eMouse.m @@ -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) diff --git a/eMouse/make_eMouseChannelMap.m b/eMouse/make_eMouseChannelMap.m index 7962fd0..74b006e 100644 --- a/eMouse/make_eMouseChannelMap.m +++ b/eMouse/make_eMouseChannelMap.m @@ -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') \ No newline at end of file +% would be good to also save the sampling frequency here +fs = 25000; + +save(fullfile(fpath, 'chanMap.mat'), 'chanMap', 'connected', 'xcoords', 'ycoords', 'kcoords', 'fs') \ No newline at end of file diff --git a/fitTemplates.m b/fitTemplates.m index 80e0e4b..1bff348 100644 --- a/fitTemplates.m +++ b/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); diff --git a/preprocessData.m b/preprocessData.m index 5959f68..a78335b 100644 --- a/preprocessData.m +++ b/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 @@ -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; @@ -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; @@ -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 @@ -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 @@ -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); @@ -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