Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions BARRs/BARR_PSTH.m
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@ function BARR_PSTH(plotSave,useState)
if plotRips
% PSTH_ripples = computePSTH(ripples,spikes,'duration',1,'plots', false,'alignment','peaks','zscorePlot',false);
% [PSTH_ripples,PSTH_t] = makePETH(spikes,ripples.timestamps(:,1),[-3 3]);
[PSTH_ripples, PSTH_t] = manualPSTH(spikes, ripples.timestamps(:,1),[-1,1],1/1000);
[PSTH_ripples, PSTH_t] = manualPSTH(spikes, ripples.timestamps(:,1),[-1,1],1/100); %was 1/1000
if runTags
warning('NOT ADJUSTED TO NEW DIMENSIONS');
%warning('NOT ADJUSTED TO NEW DIMENSIONS');
% for k = 1:size(PSTH_ripples,1)
% if ((max(PSTH_ripples(k,91:111))-max(PSTH_ripples(k,1:71))) > 1.5*std(PSTH_ripples(k,:)))
% cell_metrics.tags.Pr = [cell_metrics.tags.Pr spikes.UID(k)];
Expand All @@ -248,9 +248,9 @@ function BARR_PSTH(plotSave,useState)
end
% PSTH_bar = computePSTH(HSEnrem,spikes,'duration',1,'plots', false,'alignment','peaks','zscorePlot',false);
% [PSTH_bar,PSTH_t] = makePETH(spikes,HSEuse.timestamps(:,1),[-3 3]);
[PSTH_bar, PSTH_t] = manualPSTH(spikes, HSEuse.timestamps(:,1),[-1 1],1/1000);
[PSTH_bar, PSTH_t] = manualPSTH(spikes, HSEuse.timestamps(:,1),[-1 1],1/100); %was 1/1000
if runTags
warning('NOT ADJUSTED TO NEW DIMENSIONS');
%warning('NOT ADJUSTED TO NEW DIMENSIONS');
% for k = 1:size(PSTH_bar,1)
% if (mean(PSTH_bar(k,1001:2001))-mean(PSTH_bar(k,1:100))) > 0.3
% cell_metrics.tags.Pb = [cell_metrics.tags.Pb spikes.UID(k)];
Expand Down Expand Up @@ -414,7 +414,7 @@ function BARR_PSTH(plotSave,useState)
shuffled_r = cumsum([shuffled_iri]); %raly had cumsum([0; shuffled_iri]);

[ccg_ripple_barrage_shuf,t_ripple_barrage_shuf] = CCG(cat(1,shuffled_r,t_barrages{1}),cat(1,t_ripple_id{1},2*t_barrage_id{1}),'binSize',binsize,'duration',duration,'norm','rate');
figure(5);plot(t_ripple_barrage_shuf,ccg_ripple_barrage_shuf(:,2,1),'r');hold on;title('ccg barr-SWR'); yline(0,'k--');xlim([-3 3]);
figure(5);plot(t_ripple_barrage_shuf,ccg_ripple_barrage_shuf(:,2,1),'r');hold on;title('ccg barr-SWR shuffle'); yline(0,'k--');xlim([-3 3]);
saveas(gcf,[plotSave 'CCG_shuff.png']);
% Old jitter start
% for it = 1:10000
Expand Down
22 changes: 16 additions & 6 deletions BARRs/detectBARR.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@
% Default: 0
% pareDur: Minimum duration of BARRs kept, in seconds. This should
% generally be kept at or below 0.2. Default: 0.2
% zeroRip: Logical option to zero firing during SWRs. This is
% typically used for sessions containing stimulation (ie
% ripple generation). This seems to be a better option than
% remRip.Default: false
% remRip: Logical option to remove BARRs which overlap with ripples.
% zeroRip: Logical option to remove BARRs which overlap with ripples.
% This seems to be a better option than remRip.
% Default: false
% remRip: Logical option to zero firing during SWRs. This is
% typically used for sessions containing stimulation (ie
% ripple generation). Default: false
% newSpks: Logical option to regenerate spike groups if the regions or
% cell types have been adjusted. Default: false
%
%%%%%%%%%%%%%%%
%%% OUTPUTS %%%
Expand Down Expand Up @@ -101,6 +103,7 @@
addParameter(p, 'pareDur', 0.2, @isnumeric);
addParameter(p, 'zeroRip', true, @islogical);
addParameter(p, 'remRip', false, @islogical);
addParameter(p, 'newSpks', false, @islogical);

parse(p, varargin{:});

Expand All @@ -118,6 +121,7 @@
pareDur = p.Results.pareDur;
zeroRip = p.Results.zeroRip;
remRip = p.Results.remRip;
newSpks = p.Results.newSpks;

%% Check if BARRs have already been detected
basename = basenameFromBasepath(basepath);
Expand All @@ -135,7 +139,7 @@
mkdir([basepath filesep 'Barrage_Files']);
end

pullSpikes('basepath', basepath, 'savePath', [basepath filesep 'Barrage_Files'], 'force', true); %Get region/cell type spike files
pullSpikes('basepath', basepath, 'savePath', [basepath filesep 'Barrage_Files'], 'force', newSpks); %Get region/cell type spike files

if ~exist(strcat(basepath,filesep,'Barrage_Files',filesep,basename,'.CA2pyr.cellinfo.mat'))
disp('No CA2 pyramidal cells detected, exiting');
Expand Down Expand Up @@ -174,6 +178,12 @@
'recordMetrics',true,'remRip',remRip);

HSE = pareBARRs(basepath, HSE, spikes, savePath, unMin, spkNum, pareDur, spkHz, zeroRip, unMax);
%add unitsForDetection parameters
HSE.detectorinfo.Hz = Hz;
HSE.detectorinfo.ft = ft;
HSE.detectorinfo.numEvt = numEvt;
HSE.detectorinfo.savePath = savePath;
save([savePath 'HSE.mat'], 'HSE');

%% Save NeuroScope2 file
BARR_N2(basepath);
Expand Down
9 changes: 9 additions & 0 deletions BARRs/pareBARRs.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,14 @@
HSE.fin = HSE.keep(HSE.NREM(HSE.nonRip));
disp(['Final num: ' num2str(length(HSE.fin))]);
disp(['Num removed: ' num2str(length(HSE.NREM) - length(HSE.fin))]);

%%add parameters
HSE.detectorinfo.numCell = numCell;
HSE.detectorinfo.numSpk = numSpk;
HSE.detectorinfo.pareDur = pareDur;
HSE.detectorinfo.singleHz = singleHz;
HSE.detectorinfo.stim = stim;
HSE.detectorinfo.maxCell = maxCell;

save([savePath 'HSE.mat'], 'HSE');
end
5 changes: 3 additions & 2 deletions BARRs/pullSpikes.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function pullSpikes(varargin)
addParameter(p,'savePath',pwd,@ischar);
addParameter(p,'force',false,@islogical);

parse(p,varargin{:})
parse(p, varargin{:});

basepath = p.Results.basepath;
savePath = p.Results.savePath;
Expand All @@ -27,8 +27,8 @@ function pullSpikes(varargin)
basename = basenameFromBasepath(basepath);

%% Remove old runs if necessary
getFiles = dir();
if force
getFiles = dir();
fun_existsPyr = @(x) (contains(x, 'pyr.cellinfo.mat'));
fun_existsInt = @(x) (contains(x, 'int.cellinfo.mat'));
toDelete = zeros(size(getFiles,1),1);
Expand All @@ -53,6 +53,7 @@ function pullSpikes(varargin)
fun_existsInt = @(x) (contains(x, 'int.cellinfo.mat'));
for j = 1:size(getFiles,1)
if fun_existsPyr(getFiles(j).name)||fun_existsInt(getFiles(j).name)
cd(original);
disp('Region spike structures detected, returning');
return
end
Expand Down
Loading