Skip to content

Commit

Permalink
minor changes to some old notebooks;
Browse files Browse the repository at this point in the history
  • Loading branch information
droumis committed Oct 13, 2020
1 parent b7091dc commit bfdd98d
Show file tree
Hide file tree
Showing 23 changed files with 1,552 additions and 19 deletions.
4 changes: 1 addition & 3 deletions DFFunctions/Iterators/singleDayAnal.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
% f().function.loadvariables{:}. Also the function call appends any
% options in the f().function.options{} cell array.
%
% Cerulean City
% .|
% | |
% |'| ._____
Expand All @@ -17,7 +16,6 @@

%{
% Notes:
% - city.alien
% Each function call is for all epochs in a day, and it is assumed that
% the function's first input is the index to the day, then all epochs ([day ep1 ep2..]).
% The second input is a list of exclusion periods [starttime endtime].
Expand Down Expand Up @@ -51,7 +49,7 @@
end
% iterate through the days within each data group
g = 1; % this was intended for multiple epoch filter groups, but isn't currently used?
fprintf(':::::::: single Day iterator (Cerulean City):::::::: \n');
fprintf(':::::::: single Day iterator :::::::: \n');
tmp = [];
fout = cell(numel(unqDays),1);
for d = 1:numel(unqDays) % can use parfor
Expand Down
4 changes: 2 additions & 2 deletions DFFunctions/getLickBout.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
@DKR
%}
output_intervals = 0;
maxILIthresh = .25; % max burst ili threshold in seconds
maxILIthresh = 1; % max burst ili threshold in seconds
minILIthresh = .06; % min burst ili threshold in seconds
minBoutLicks = 3; %filter out bouts with less than boutNum licks
minBoutLicks = 2; %filter out bouts with less than boutNum licks
lick = [];
if ~isempty(varargin)
assign(varargin{:})
Expand Down
105 changes: 101 additions & 4 deletions DFFunctions/load_filter_params.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,20 @@
for s = Fp.params
fprintf('* %s\n', s{1})
switch s{1}
% common

%% ========= rewTrigSWRXP =========
case 'rewTrigSWRXP'
win = [-4 10];
bin = .001;
eventType = 'ca1rippleskons';

case 'dfa_rewTrigSWRXP'
iterator = 'singleDayAnal'; %'singleepochanal';
filtfunction = 'dfa_rewTrigSWRXP';
datatypes = {'ca1rippleskons', 'lick', 'DIO', 'task'};
options = {'win', win, 'bin', bin, 'eventType', eventType};

%% ========= common =========
case 'valid_ntrodes'
% ntAreas = {'ca1', 'mec', 'ref'}; %, 'por', 'v2l', 'sub'};
areas = {{'ca1', 'd'}, {'mec', 'deep'}, {'mec', 'supf'}};
Expand Down Expand Up @@ -72,7 +85,34 @@
'minBoutLicks', minBoutLicks, 'cellfilter', cellFilter, ...
'rippleFilter', rippleFilter};

%% ========= XP-SWR mod 'city.alien' =========
%% ========= SWR iLB vs eLB =========
case 'pctILB'
eventType = 'ca1rippleskons';
% lick burst filter
maxILIthresh = 1; % max burst ili threshold in seconds
minBoutLicks = 2; % filter out bouts with less than boutNum licks
minILIthresh = .06;
stdthresh = [2 3 4];

case 'dfa_pctILB'
iterator = 'singleDayAnal'; %'singleepochanal';
filtfunction = 'dfa_pctILB';
datatypes = {'ca1rippleskons','task', 'lick', 'DIO'};
options = {'eventType', eventType, 'maxILIthresh', maxILIthresh,...
'minBoutLicks', minBoutLicks, 'stdthresh', stdthresh, 'minILIthresh', minILIthresh};

%% ========= XP-SWR mod =========
case 'XPtrigAvgRip'
win = [-4 4];
eventType = 'ca1rippleskons';

case 'dfa_XPtrigAvgRip'
iterator = 'singleDayAnal'; %'singleepochanal';
filtfunction = 'dfa_XPtrigAvgRip';
datatypes = {'ca1rippleskons','task', 'lick', 'DIO'};
options = {'win', win, 'eventType', eventType};


case 'wXPTrigSWR'
% maxTimeSinceRew = 5;
bin = .01;
Expand All @@ -90,20 +130,53 @@
compute_shuffle = 1;
numshuffs = 1000;
maxShift = tmax/2; %ms integer. timemod shift



case 'dfa_lickswrcorr'
% make sure to include a 'ripples' timefilter in the paramset
% func
iterator = 'singleDayAnal'; %'singleepochanal';
filtfunction = 'dfa_lickswrcorr';
datatypes = {'ca1rippleskons','task', 'lick', 'DIO'};
options = {'bin', bin, 'tmax', tmax, 'eventType', eventType, ...
'excShortBin', excShortBin, 'excLongBin', excLongBin, ...
'minILIthresh', minILIthresh, 'maxILIthresh', maxILIthresh, ...
'rmsmincounts', rmsmincounts, 'rmstmax', rmstmax, 'compute_shuffle', ...
compute_shuffle, 'numshuffs', numshuffs, 'shuffOffset', maxShift, ...
'minBoutLicks', minBoutLicks};

case 'XPprepostSWR'
% maxTimeSinceRew = 5;
bin = .01;
tmax = .5;
eventType = 'ca1rippleskons';
minILIthresh = .06; % seconds
maxILIthresh = 1; % seconds
minBoutLicks = 2;
% xcorr / excorr
excShortBin = bin;
excLongBin = .500;
rmsmincounts = 1; % min bin count within rmstamax. otherwise nan
rmstmax = .25; % seconds
% shuf
compute_shuffle = 1;
numshuffs = 1000;
maxShift = tmax/2; %ms integer. timemod shift

case 'dfa_XPprepostSWR'
% make sure to include a 'ripples' timefilter in the paramset
% func
iterator = 'singleDayAnal'; %'singleepochanal';
filtfunction = 'dfa_XPprepostSWR';
datatypes = {'ca1rippleskons','task', 'lick', 'DIO'};
options = {'bin', bin, 'tmax', tmax, 'eventType', eventType, ...
'excShortBin', excShortBin, 'excLongBin', excLongBin, ...
'minILIthresh', minILIthresh, 'maxILIthresh', maxILIthresh, ...
'rmsmincounts', rmsmincounts, 'rmstmax', rmstmax, 'compute_shuffle', ...
compute_shuffle, 'numshuffs', numshuffs, 'shuffOffset', maxShift, ...
'minBoutLicks', minBoutLicks};


%% ========= 'dfa_eventTrigSpiking'=========
case 'lickboutlicks'
% minILIthresh = .06; % seconds
Expand Down Expand Up @@ -164,6 +237,17 @@
win = [1.5 1.5];
LFPtypes = {'eeg'};

%% ========= ripPos
case 'ripPos'
eventType = 'ca1rippleskons';

case 'dfa_ripPos'
iterator = 'singleDayAnal'; %'singleepochanal';
filtfunction = 'dfa_ripPos';
datatypes = {'ca1rippleskons','pos', 'lick'};
options = {'eventType', eventType};


%% ========= EPOCH TETRODE CELL RIPPLE filters
case 'ripples'
eventType = 'ca1rippleskons';
Expand All @@ -177,11 +261,24 @@
'minstdthresh', minstdthresh,'exclusion_dur',exclusion_dur, ...
'minvelocity', minvelocity,'maxvelocity',maxvelocity};

case 'ripples>5'
eventType = 'ca1rippleskons';
consensus_numtets = 2; % minimum # of tets for consensus event detection
minstdthresh = 5; % STD. how big your ripples are
exclusion_dur = .5; % seconds within which consecutive events are eliminated / ignored
minvelocity = 0;
maxvelocity = 4;
timefilter{end+1} = {'getconstimes', '($cons == 1)', ...
'ca1rippleskons', 1,'consensus_numtets',consensus_numtets, ...
'minstdthresh', minstdthresh,'exclusion_dur',exclusion_dur, ...
'minvelocity', minvelocity,'maxvelocity',maxvelocity};


case 'ripples>2'
eventType = 'ca1rippleskons';
consensus_numtets = 2; % minimum # of tets for consensus event detection
minstdthresh = 2; % STD. how big your ripples are
exclusion_dur = .5; % seconds within which consecutive events are eliminated / ignored
exclusion_dur = 0; % seconds within which consecutive events are eliminated / ignored
minvelocity = 0;
maxvelocity = 4;
timefilter{end+1} = {'getconstimes', '($cons == 1)', ...
Expand Down
44 changes: 44 additions & 0 deletions DFFunctions/load_plotting_params.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
end
for s = param_set
switch s{1}
case 'rewTrigSWRXP'
position = [.1 .1 .3 .4];
spikeSz = 10;
spikeAlpha = .5;
win = [-4 10];
Pp.bin = .2;
case 'defaults'
position = [.1 .1 .4 .4];
pwin = [1 1];
Expand All @@ -38,7 +44,45 @@
case 'phaseXcorr'
position = [.1 .1 .5 .5];


%% ========= SWR iLB vs eLB =========
case 'pctILB-pAn-pDay'
position = [.1 .1 .4 .4];
case 'pctILB'
position = [.1 .1 .2 .4];


%% ========= XPmod-SWR=========
case 'XPprepostSWR-pAn-pDay'
position = [.1 .1 .2 .8];
hbins = 50;
preClr = [0.4660 0.6740 0.1880];
postClr = [0.4940 0.1840 0.5560];
case 'XPprepostSWR-pAn'
position = [.1 .1 .4 .3];
hbins = 50;
preClr = [0.4660 0.6740 0.1880];
postClr = [0.4940 0.1840 0.5560];
case 'XPprepostSWR'
position = [.1 .1 .4 .3];
hbins = 50;
preClr = [0.4660 0.6740 0.1880];
postClr = [0.4940 0.1840 0.5560];

case 'XPtrigAvgRip-pAn-pDay'
position = [.1 .1 .3 .8];
win = [-2 2];
case 'XPtrigAvgRip-pAn'
position = [.1 .1 .4 .3];
win = [-2 2];
case 'XPtrigAvgRip'
position = [.1 .1 .4 .3];
win = [-2 2];

case 'ripPos'
position = [.1 .1 .3 .4];
size = 80;

case 'wRxnFullAllAn'
position = [.1 .1 .5 .5];
winSE = [-.5 .5];
Expand Down
8 changes: 8 additions & 0 deletions Functions/check_required.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

function check_required(reqData, vararg)

for s = 1:length(reqData)
if ~any(cellfun(@(x) strcmp(x,reqData{s}), vararg(1:2:end), 'un', 1))
error(sprintf('missing data: %s ', reqData{~ismember(reqData,vararg(1:2:end))}));
end
end
4 changes: 2 additions & 2 deletions Functions/getLickBoutLicks.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
FFPhy
@DR
%}
maxILIthresh = .25; % max burst ili threshold in seconds
maxILIthresh = 1; % max burst ili threshold in seconds
minILIthresh = .06; % min burst ili threshold in seconds
minBoutLicks = 3; %filter out bouts with less than boutNum licks
minBoutLicks = 2; %filter out bouts with less than boutNum licks
lick = [];
if ~isempty(varargin)
assign(varargin{:});
Expand Down
34 changes: 34 additions & 0 deletions Functions/get_dio_output.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function [dioOut, dioOutfields] = get_dio_output(DIO, task, day, eps);

dioOutfields = {'day', 'epoch', 'dioNum', 'dioNumOrig', 'startTime', 'endTime'};
dioOut = [];
for e = 1:length(eps)
epoch = eps(e);
isinput = cellfun(@(x) isequal(x.input,1), DIO{day}{epoch}, 'un', 1);
dioID = cellfun(@(x) str2double(regexp(x.original_id,'\d*','Match')), ...
DIO{day}{epoch}, 'un', 1);
outputdios = task{day}{epoch}.outputdio;
outdioIdx = find(all([ismember(dioID, outputdios)' ~isinput'],2));
for c = 1:length(outdioIdx)
ch = outdioIdx(c);
dioTimeCh = double(DIO{day}{epoch}{ch}.times);
dioValsCh = double(DIO{day}{epoch}{ch}.values);
% dios are Up (1) to Down (0)
while ~isempty(dioValsCh) && dioValsCh(1) == 0
dioValsCh(1) = []; dioTimeCh(1) = [];
end
while ~isempty(dioValsCh) && dioValsCh(end) == 1
dioValsCh(end) = []; dioTimeCh(end) = [];
end
if ~isempty(dioValsCh)
dioVd = [1; find(abs(diff(dioValsCh)))+1];
diotimes = dioTimeCh(dioVd);
dioStEnd = [diotimes(1:2:end) diotimes(2:2:end)];
numDIO = length(dioStEnd(:,1));
dioOut = [dioOut; repmat(day,numDIO,1) repmat(epoch,numDIO,1) ...
repmat(ch,numDIO,1) repmat(outputdios(c),numDIO,1) dioStEnd];
else
continue
end
end
end
2 changes: 2 additions & 0 deletions notebooks/eventtrig_20191117.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
%{
statsfig_20190812: notebook with original spect quantifications
NB 20191117
finalize swr-trig and lick trig results all animals combined
.. continuation of suresplickvsswr_20191116
Expand Down
16 changes: 8 additions & 8 deletions notebooks/xpswrAll_20191105.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

eventType = 'lick'; %lick swr
% run FF
create_filter = 1;
create_filter = 1;k
run_ff = 1;
load_ffdata = 0;

Expand Down Expand Up @@ -59,7 +59,7 @@
ifig = init_plot(showfigs, Pp.position);
days = cell2mat([{F(a).output{1}.index}']);
ndays = size(days,1);
nc = 3;
ncols = 3;
dNormxcZ = {};
for d = 1:ndays
day = days(d,1);
Expand All @@ -71,15 +71,15 @@
nSWRsN = 0;
end
g = [nSWRsN nSWRsN nSWRsN];
sf1 = subaxis(ndays+1, nc, (d-1)*(nc)+1, Pp.posparams{:});
sf1 = subaxis(ndays+1, ncols, (d-1)*(ncols)+1, Pp.posparams{:});
bar(idata.time, idata.normxc, 'FaceColor', g)
xticks([])
% yticks([])
ylim([0 .025])
title(sprintf('%d Bouts %d XP. %d swr', size(idata.boutTimes, 1), length(idata.licks), nSWRs));
ylabel(sprintf('%d', day));
%% z-scored
sf1 = subaxis(ndays+1, nc, (d-1)*(nc)+2, Pp.posparams{:});
sf1 = subaxis(ndays+1, ncols, (d-1)*(ncols)+2, Pp.posparams{:});
dNormxc = idata.smthxc;
dNormxcSh = idata.smthxcSh;
dNormxcZ{d} = (dNormxc - nanmean(dNormxcSh,1)) ./ nanstd(dNormxcSh,[],1);
Expand All @@ -89,7 +89,7 @@
ylim([-10 10])
title(sprintf('%d Bouts %d XP. %d swr', size(idata.boutTimes, 1), length(idata.licks), length(idata.swrLickPhase)));
%% phase
sf2 = subaxis(ndays+1, nc, (d-1)*(nc)+3, Pp.posparams{:});
sf2 = subaxis(ndays+1, ncols, (d-1)*(ncols)+3, Pp.posparams{:});
polarhistogram(idata.swrLickPhase, 20, 'Normalization', 'pdf', 'facecolor', g)
% rticks([])
thetaticks([])
Expand All @@ -100,7 +100,7 @@

end
%% all days normx
subaxis(ndays+1, nc, (nc*(d-1))+4, Pp.posparams{:});
subaxis(ndays+1, ncols, (ncols*(d-1))+4, Pp.posparams{:});
swrXPxc = nanmean(cell2mat({F(a).output{1}.smthxc}'));
bar(idata.time, swrXPxc, 'facecolor', 'b')
ylabel('all');
Expand All @@ -110,14 +110,14 @@
NormxcZsem = sem(NormxcZ,1);
NormxcZmean = mean(NormxcZ,1);

subaxis(ndays+1, nc, (nc*(d-1))+5, Pp.posparams{:});
subaxis(ndays+1, ncols, (ncols*(d-1))+5, Pp.posparams{:});
plot(idata.time, NormxcZmean, 'b')
hold on
fill([idata.time'; flipud(idata.time')],[NormxcZmean'-NormxcZsem';flipud(NormxcZmean'+NormxcZsem')],'k',...
'linestyle','none', 'facealpha', .2);
ylim([-10 10])
%% all days polar
subaxis(ndays+1, nc, (nc*(d-1))+6, Pp.posparams{:});
subaxis(ndays+1, ncols, (ncols*(d-1))+6, Pp.posparams{:});
swrXPph = cell2mat({idata.swrLickPhase}');
polarhistogram(swrXPph, 20, 'Normalization', 'pdf', 'facecolor', 'b')
rlim([0 .8])
Expand Down
Loading

0 comments on commit bfdd98d

Please sign in to comment.