-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compute spikeFeatures after detect in one recording or all recordings
- Loading branch information
Alan Liddell
committed
Feb 21, 2019
1 parent
52fa1fa
commit 033c331
Showing
48 changed files
with
1,024 additions
and
901 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
function [spikeWindows, spikeTimes] = CARRealign(obj, spikeWindows, samplesIn, spikeTimes, neighbors) | ||
%CARREALIGN Realign spike peaks after applying local CAR | ||
if ~strcmpi(obj.hCfg.getOr('vcSpkRef', 'nmean'), 'nmean') | ||
return; | ||
end | ||
|
||
% find where true peaks are not in the correct place after applying local CAR | ||
spikeWindowsCAR = jrclust.utils.localCAR(single(spikeWindows), obj.hCfg); | ||
[shiftMe, shiftBy] = findShifted(spikeWindowsCAR, obj.hCfg); | ||
|
||
if isempty(shiftMe) | ||
return; | ||
end | ||
|
||
% adjust spike times | ||
shiftedTimes = spikeTimes(shiftMe) - int32(shiftBy(:)); | ||
spikeTimes(shiftMe) = shiftedTimes; | ||
|
||
% extract windows at new shifted times | ||
spikeWindows(:, shiftMe, :) = obj.extractWindows(samplesIn, shiftedTimes, neighbors, 0); | ||
end | ||
|
||
%% LOCAL FUNCTIONS | ||
function [shiftMe, shiftBy] = findShifted(spikeWindows, hCfg) | ||
%FINDSHIFTED | ||
% spikeWindows: nSamples x nSpikes x nSites | ||
peakLoc = 1 - hCfg.evtWindowSamp(1); | ||
|
||
if hCfg.detectBipolar | ||
[~, truePeakLoc] = max(abs(spikeWindows(:, :, 1))); | ||
else | ||
[~, truePeakLoc] = min(spikeWindows(:, :, 1)); | ||
end | ||
|
||
shiftMe = find(truePeakLoc ~= peakLoc); | ||
shiftBy = peakLoc - truePeakLoc(shiftMe); | ||
|
||
shiftOkay = (abs(shiftBy) <= 2); % throw out drastic shifts | ||
shiftMe = shiftMe(shiftOkay); | ||
shiftBy = shiftBy(shiftOkay); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 10 additions & 12 deletions
22
...tController/private/cancel_overlap_spk_.m → ...+detect/@DetectController/cancelOverlap.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function siteThresh = computeThreshold(obj, samplesIn) | ||
%COMPUTETHRESHOLD Compute sitewise threshold for samplesIn | ||
try | ||
siteThresh = jrclust.utils.estimateRMS(samplesIn, 1e5)*obj.hCfg.qqFactor; | ||
siteThresh = int16(jrclust.utils.tryGather(siteThresh)); | ||
catch ME | ||
warning('GPU threshold computation failed: %s (retrying in CPU)', ME.message); | ||
obj.hCfg.useGPU = 0; | ||
siteThresh = int16(jrclust.utils.estimateRMS(jrclust.utils.tryGather(samplesIn), 1e5)*obj.hCfg.qqFactor); | ||
end | ||
end |
Oops, something went wrong.