Skip to content

Commit 2e0ae67

Browse files
authored
Merge pull request #21 from ayalab1/BARR_updates
Barr updates
2 parents 4d2562c + 21c969f commit 2e0ae67

4 files changed

Lines changed: 33 additions & 13 deletions

File tree

BARRs/BARR_PSTH.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ function BARR_PSTH(plotSave,useState)
225225
if plotRips
226226
% PSTH_ripples = computePSTH(ripples,spikes,'duration',1,'plots', false,'alignment','peaks','zscorePlot',false);
227227
% [PSTH_ripples,PSTH_t] = makePETH(spikes,ripples.timestamps(:,1),[-3 3]);
228-
[PSTH_ripples, PSTH_t] = manualPSTH(spikes, ripples.timestamps(:,1),[-1,1],1/1000);
228+
[PSTH_ripples, PSTH_t] = manualPSTH(spikes, ripples.timestamps(:,1),[-1,1],1/100); %was 1/1000
229229
if runTags
230-
warning('NOT ADJUSTED TO NEW DIMENSIONS');
230+
%warning('NOT ADJUSTED TO NEW DIMENSIONS');
231231
% for k = 1:size(PSTH_ripples,1)
232232
% if ((max(PSTH_ripples(k,91:111))-max(PSTH_ripples(k,1:71))) > 1.5*std(PSTH_ripples(k,:)))
233233
% cell_metrics.tags.Pr = [cell_metrics.tags.Pr spikes.UID(k)];
@@ -248,9 +248,9 @@ function BARR_PSTH(plotSave,useState)
248248
end
249249
% PSTH_bar = computePSTH(HSEnrem,spikes,'duration',1,'plots', false,'alignment','peaks','zscorePlot',false);
250250
% [PSTH_bar,PSTH_t] = makePETH(spikes,HSEuse.timestamps(:,1),[-3 3]);
251-
[PSTH_bar, PSTH_t] = manualPSTH(spikes, HSEuse.timestamps(:,1),[-1 1],1/1000);
251+
[PSTH_bar, PSTH_t] = manualPSTH(spikes, HSEuse.timestamps(:,1),[-1 1],1/100); %was 1/1000
252252
if runTags
253-
warning('NOT ADJUSTED TO NEW DIMENSIONS');
253+
%warning('NOT ADJUSTED TO NEW DIMENSIONS');
254254
% for k = 1:size(PSTH_bar,1)
255255
% if (mean(PSTH_bar(k,1001:2001))-mean(PSTH_bar(k,1:100))) > 0.3
256256
% cell_metrics.tags.Pb = [cell_metrics.tags.Pb spikes.UID(k)];
@@ -414,7 +414,7 @@ function BARR_PSTH(plotSave,useState)
414414
shuffled_r = cumsum([shuffled_iri]); %raly had cumsum([0; shuffled_iri]);
415415

416416
[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');
417-
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]);
417+
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]);
418418
saveas(gcf,[plotSave 'CCG_shuff.png']);
419419
% Old jitter start
420420
% for it = 1:10000

BARRs/detectBARR.m

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@
5353
% Default: 0
5454
% pareDur: Minimum duration of BARRs kept, in seconds. This should
5555
% generally be kept at or below 0.2. Default: 0.2
56-
% zeroRip: Logical option to zero firing during SWRs. This is
57-
% typically used for sessions containing stimulation (ie
58-
% ripple generation). This seems to be a better option than
59-
% remRip.Default: false
60-
% remRip: Logical option to remove BARRs which overlap with ripples.
56+
% zeroRip: Logical option to remove BARRs which overlap with ripples.
57+
% This seems to be a better option than remRip.
6158
% Default: false
59+
% remRip: Logical option to zero firing during SWRs. This is
60+
% typically used for sessions containing stimulation (ie
61+
% ripple generation). Default: false
62+
% newSpks: Logical option to regenerate spike groups if the regions or
63+
% cell types have been adjusted. Default: false
6264
%
6365
%%%%%%%%%%%%%%%
6466
%%% OUTPUTS %%%
@@ -101,6 +103,7 @@
101103
addParameter(p, 'pareDur', 0.2, @isnumeric);
102104
addParameter(p, 'zeroRip', true, @islogical);
103105
addParameter(p, 'remRip', false, @islogical);
106+
addParameter(p, 'newSpks', false, @islogical);
104107

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

@@ -118,6 +121,7 @@
118121
pareDur = p.Results.pareDur;
119122
zeroRip = p.Results.zeroRip;
120123
remRip = p.Results.remRip;
124+
newSpks = p.Results.newSpks;
121125

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

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

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

176180
HSE = pareBARRs(basepath, HSE, spikes, savePath, unMin, spkNum, pareDur, spkHz, zeroRip, unMax);
181+
%add unitsForDetection parameters
182+
HSE.detectorinfo.Hz = Hz;
183+
HSE.detectorinfo.ft = ft;
184+
HSE.detectorinfo.numEvt = numEvt;
185+
HSE.detectorinfo.savePath = savePath;
186+
save([savePath 'HSE.mat'], 'HSE');
177187

178188
%% Save NeuroScope2 file
179189
BARR_N2(basepath);

BARRs/pareBARRs.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,14 @@
136136
HSE.fin = HSE.keep(HSE.NREM(HSE.nonRip));
137137
disp(['Final num: ' num2str(length(HSE.fin))]);
138138
disp(['Num removed: ' num2str(length(HSE.NREM) - length(HSE.fin))]);
139+
140+
%%add parameters
141+
HSE.detectorinfo.numCell = numCell;
142+
HSE.detectorinfo.numSpk = numSpk;
143+
HSE.detectorinfo.pareDur = pareDur;
144+
HSE.detectorinfo.singleHz = singleHz;
145+
HSE.detectorinfo.stim = stim;
146+
HSE.detectorinfo.maxCell = maxCell;
147+
139148
save([savePath 'HSE.mat'], 'HSE');
140149
end

BARRs/pullSpikes.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function pullSpikes(varargin)
1616
addParameter(p,'savePath',pwd,@ischar);
1717
addParameter(p,'force',false,@islogical);
1818

19-
parse(p,varargin{:})
19+
parse(p, varargin{:});
2020

2121
basepath = p.Results.basepath;
2222
savePath = p.Results.savePath;
@@ -27,8 +27,8 @@ function pullSpikes(varargin)
2727
basename = basenameFromBasepath(basepath);
2828

2929
%% Remove old runs if necessary
30+
getFiles = dir();
3031
if force
31-
getFiles = dir();
3232
fun_existsPyr = @(x) (contains(x, 'pyr.cellinfo.mat'));
3333
fun_existsInt = @(x) (contains(x, 'int.cellinfo.mat'));
3434
toDelete = zeros(size(getFiles,1),1);
@@ -53,6 +53,7 @@ function pullSpikes(varargin)
5353
fun_existsInt = @(x) (contains(x, 'int.cellinfo.mat'));
5454
for j = 1:size(getFiles,1)
5555
if fun_existsPyr(getFiles(j).name)||fun_existsInt(getFiles(j).name)
56+
cd(original);
5657
disp('Region spike structures detected, returning');
5758
return
5859
end

0 commit comments

Comments
 (0)