OSCR

Dentate gyrus interneurons modulate winner-take-all network dynamics in freely behaving mice.

Code ↔ Paper

40 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 40 matches · 17 of them tie a paragraph to a whole file, not to given lines: weak matches, whose lines are not tinted
  1. [1] § STAR METHODS › METHOD DETAILS › DG circuit model ↔ dendritic_somatic_transfer.py, lines 93–215 · score 0.96 · dendritic somatic transfer, NMDA voltage dependence, somatic voltage, v_soma, dendritic integration, GABA conductances
  2. [2] § STAR METHODS › METHOD DETAILS › DG circuit model ↔ optogenetic_experiment.py, lines 106–156 · score 0.96 · transduction failure rate, fiber tip, Light induced activation, log normal distribution, activation probability, light intensity
  3. [3] § STAR METHODS › METHOD DETAILS › DG circuit model ↔ DG_circuit_dendritic_somatic_transfer.py, lines 417–467 · score 0.93 · hilar region, Connection probabilities, dendritic inhibition, molecular layer, local connections, granule cell
  4. [4] § STAR METHODS › METHOD DETAILS › DG circuit model ↔ dendritic_somatic_network_clamp.py, lines 241–359 · score 0.92 · dendritic somatic transfer, NMDA voltage dependence, dendritic voltage, NMDA fraction, GABA conductances, membrane
  5. [5] § STAR METHODS › METHOD DETAILS › Putative monosynaptic connections ↔ buzcodeAddOns/MonoSyn/burstCCG.m, the whole file · a weak match · score 0.89 · inter spike intervals, Spike transmission probability, presynaptic spike, spike trains, 4 ms, 0.8 ms
  6. [6] § STAR METHODS › METHOD DETAILS › Putative monosynaptic connections ↔ buzcodeAddOns/MonoSyn/analyzeMonoSyn.m, the whole file · a weak match · score 0.85 · inter spike intervals, Spike transmission probability, putatively connected, 4 ms, 0.8 ms, subtracted
  7. [7] § STAR METHODS › METHOD DETAILS › Cell classification ↔ buzcodeAddOns/CellClassification/trainSVMpvssst.m, the whole file · a weak match · score 0.84 · Classification Learner App, cross validation, fold, AB, kernel, CV2
  8. [8] § STAR METHODS › METHOD DETAILS › Cell classification ↔ buzcodeAddOns/CellClassification/trainSVMpvsst.m, the whole file · a weak match · score 0.84 · Classification Learner App, cross validation, fold, AB, kernel, CV2
  9. [9] § STAR METHODS › METHOD DETAILS › Cell classification ↔ buzcodeAddOns/CellClassification/YutaClassifier.m, the whole file · a weak match · score 0.83 · principal components, maximum waveform, firing rate ratios, granule cell, labelling, derivative
  10. [10] § STAR METHODS › METHOD DETAILS › Spatial tuning ↔ buzcodeAddOns/PlaceFields/get_placeFieldsLinear.m, lines 155–216 · score 0.81 · Spatial coherence, Spatial tuning, place field, firing rate peak, SI, Bits
  11. [11] § STAR METHODS › METHOD DETAILS › Behavior ↔ buzcodeAddOns/makeRadialMazeMaps.m, the whole file · a weak match · score 0.80 · radial arm maze, rewarded arms, firing rate maps, minute, cm, Behavior
  12. [12] § STAR METHODS › METHOD DETAILS › Spatial tuning ↔ buzcodeAddOns/PlaceFields/get_placeFieldsOF.m, lines 167–232 · score 0.79 · Spatial coherence, Spatial tuning, place field, firing rate peak, Bits, median
  13. [13] § STAR METHODS › METHOD DETAILS › DG circuit model ↔ statistical_testing.py, lines 558–632 · score 0.77 · activation probability, optogenetic drive, light intensity, optogenetic stimulation, target population, Opsin expression
  14. [14] § STAR METHODS › METHOD DETAILS › LFP analysis ↔ buzcodeAddOns/LFP_analysis/DGlayerProfile.m, lines 1–74 · score 0.76 · 5–15 Hz, theta gamma, 125 ms, comodulogram, profiles, CSD
  15. [15] § STAR METHODS › METHOD DETAILS › Generalized linear model (peer prediction) ↔ buzcodeAddOns/PeerPrediction/peerPredictOpto1sec.m, lines 64–190 · score 0.76 · generalized linear model, peer, fitglm, predicted, R2, interactions
  16. [16] § STAR METHODS › METHOD DETAILS › Generalized linear model (peer prediction) ↔ buzcodeAddOns/PeerPrediction/CrossValidationAssemblyPrediction.m, the whole file · a weak match · score 0.75 · generalized linear model, Binned spike trains, peer, root, predicted, validation
  17. [17] § STAR METHODS › METHOD DETAILS › Behavior ↔ buzcodeAddOns/Behavior/OptitrackBehav.m, the whole file · a weak match · score 0.74 · rewarded arms, radial arm, radial maze, barrier, solenoid, cm
  18. [18] § STAR METHODS › METHOD DETAILS › DG circuit model ↔ DG_protocol.py, lines 2523–2649 · score 0.72 · standard deviation, paradoxical excitation, synaptic weight, optogenetic stimulation, opsin expressing, unchanged
  19. [19] § Results › Supervised classification of DG cells into four types based on physiological criteria ↔ DG_IN_Figures_final.m, lines 458–511 · score 0.69 · spike asymmetry, ACG rise, spike width, S1d, CV2, wake
  20. [20] § STAR METHODS › METHOD DETAILS › LFP analysis ↔ DG_IN_Ephys/DG_IN_LFP_Scripts.m, lines 165–249 · score 0.68 · theta gamma comodulogram, CSD, component, profiles, troughs, bands
  21. [21] § Results › Spatial tuning properties of DG cells ↔ buzcodeAddOns/PlaceFields/get_placeFieldsLinear.m, lines 155–216 · score 0.68 · spatial coherence, spatial tuning, place fields, SI, track, linear
  22. [22] § STAR METHODS › METHOD DETAILS › Cell classification ↔ DG_IN_Figures_final.m, lines 545–595 · score 0.66 · anatomical location, ground truth, granule cell, waking, SVM, waveforms
  23. [23] § Results › Identification of dentate interneurons with extracellular electrophysiology and optotagging ↔ DG_IN_Figures_final.m, lines 3203–3290 · score 0.64 · ChR2, eNpHR, PV Cre, SST Cre, mice, classes
  24. [24] § Results › Mechanisms of paradoxical activation upon DG interneuron stimulation ↔ buzcodeAddOns/PeerPrediction/peerPredictOpto1sec.m, lines 64–190 · score 0.64 · peer prediction, generalized linear models, GLMs, onset, trained, validation
  25. [25] § Results › Spatial tuning properties of DG cells ↔ buzcodeAddOns/PlaceFields/get_placeFieldsOF.m, lines 167–232 · score 0.63 · spatial coherence, spatial tuning, place fields, properties, behavioral, cells
  26. [26] § Results › Mechanisms of paradoxical activation upon DG interneuron stimulation ↔ DG_IN_Figures_final.m, lines 63–121 · score 0.61 · PV Cre mice, SST Cre mice, eNpHR, S6e, SVM, trained
  27. [27] § STAR METHODS › METHOD DETAILS › LFP analysis ↔ buzcodeAddOns/EventDetection/DetectDSpikes_v4.m, lines 1–99 · score 0.60 · 2–50 Hz, molecular layer, hilus, DS2, filtered, threshold
  28. [28] § STAR METHODS › METHOD DETAILS › LFP analysis ↔ buzcodeAddOns/EventDetection/DetectDSpikes_v5.m, lines 1–102 · score 0.60 · 2–50 Hz, molecular layer, hilus, DS2, filtered, threshold
  29. [29] § STAR METHODS › METHOD DETAILS › Opto-tagging and optogenetic manipulations ↔ buzcodeAddOns/Utilities/findAmbiguous.m, the whole file · a weak match · score 0.59 · ambiguous response, modulation ratio, stim, firing rate, Opto, classified
  30. [30] § STAR METHODS › METHOD DETAILS › Surgical Procedures ↔ DG_circuit_optogenetic_optimization.py, lines 2719–2853 · score 0.59 · theta oscillation, theta phase, Diagnostic, depth, parallel, amplitude
  31. [31] § STAR METHODS › METHOD DETAILS › Putative monosynaptic connections ↔ buzcodeAddOns/analysis/monosynapticPairs/bz_GetMonoSynapticallyConnected.m, the whole file · a weak match · score 0.59 · monosynaptic connections, Poisson, CCG, detection, ms, predictor
  32. [32] § Results › Synaptic connectivity in the DG network ↔ buzcodeAddOns/MonoSyn/analyzeMonoLTP.m, the whole file · a weak match · score 0.58 · synaptic strength, transmission probability, spike transmission, brain, putative, excitatory
  33. [33] § Results › Mechanisms of paradoxical activation upon DG interneuron stimulation ↔ buzcodeAddOns/PeerPrediction/CrossValidationAssemblyPrediction.m, the whole file · a weak match · score 0.57 · peer prediction, generalized linear models, validation, trained, spike, cells
  34. [34] § STAR METHODS › METHOD DETAILS › Opto-tagging and optogenetic manipulations ↔ buzcodeAddOns/Optogenetics/reclassifyOptoResponses2.m, the whole file · a weak match · score 0.56 · half rise, standard deviation, ambiguous, Opto, firing rate, classified
  35. [35] § STAR METHODS › METHOD DETAILS › Opto-tagging and optogenetic manipulations ↔ buzcodeAddOns/Utilities/findAmbiguous.m, the whole file · a weak match · score 0.54 · eNpHR, standard deviation, ambiguous, firing rate, Opto, opsin
  36. [36] § Results › Synaptic connectivity in the DG network ↔ buzcodeAddOns/analysis/monosynapticPairs/bz_GetMonoSynapticallyConnected.m, the whole file · a weak match · score 0.54 · monosynaptic connections, synaptic connectivity, likelihoods, CCG, synapses, network
  37. [37] § Results › Supervised classification of DG cells into four types based on physiological criteria ↔ buzcodeAddOns/CellClassification/trainSVMpvssst.m, the whole file · a weak match · score 0.53 · cross validation, accuracy, fold, CV2, trained, rise
  38. [38] § STAR METHODS › METHOD DETAILS › Putative monosynaptic connections ↔ buzcodeAddOns/analysis/monosynapticPairs/bz_fitPoissPlasticity.m, lines 1–30 · score 0.53 · monosynaptic connections, Poisson, timescale, postsynaptic, cross, binning
  39. [39] § STAR METHODS › METHOD DETAILS › Sleep scoring ↔ buzcodeAddOns/detectors/detectStates/SleepScoreMaster/ClusterStates_DetermineStates.m, the whole file · a weak match · score 0.53 · quiet wake, scoring, Sleep, NREM, theta
  40. [40] § STAR METHODS › METHOD DETAILS › Firing rate distribution equality ↔ DG_IN_Figures_final.m, lines 2790–2840 · score 0.53 · Lorenz curve, S8a, CV, Gini, 1–2, DG

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

MATLAB · 3,691 lines · 144 KB · no license · 5 matches

  1. %% README
  2. % Download and install 'https://github.com/buzsakilab/buzcode'. Then
  3. % download this repository. Add all folders and subfolders to your matlab
  4. % path.
  5. %
  6. % Download data from 'https://buzsakilab.nyumc.org/datasets/' to a folder
  7. % on your computer and replace basedir (example 'Z:\Buzsakilabspace\LabShare\HainmuellerT\')
  8. % below with the the folder name. Run all scripts under 'preparations'
  9. % before trying to create any of the figures.
  10. %
  11. % [ ] CHANGE 'basedir' TO THE FOLDER WHERE YOU DOWNLOADED THE DATA
  12. basedir = 'Z:\buzsakilab\Buzsakilabspace\LabShare\HainmuellerT';
  13. %% Prepare handle and batch_metrics
  14. % Animal selection
  15. basedir = 'Z:\buzsakilab\Buzsakilabspace\LabShare\HainmuellerT\';
  16. ChRmice = {'SST2','SST4','YutaMouse20','YutaMouse21','YutaMouse37','YutaMouse38',...
  17. 'YutaMouse39','YutaMouse40','PV1','PV3','PV5','PV16','PV18','PV19','PV21','PV29'}; % PV16 1:1, PV18, PV23, SST6 1:3, SST7, others pure, PV28 thalamic injection
  18. HRmice = {'PV13','PV22','SST3','SST5'}; % 'PV20',
  19. linear = {'PV19','PV21','YutaMouse21','YutaMouse29'}; % Linear probe mice
  20. WTmice = {'TH10','TH11','TH12','TH13','TH14','TH15'}; % TH17 once downloaded
  21. animals = cat(2,ChRmice,HRmice,WTmice);
  22. % Querry for numbers of units meeting different criteria
  23. querryCells(1).tag = 'nDG';
  24. querryCells(1).include = struct('brainRegion','DG');
  25. querryFiles = {'DS','.DS2.events.mat'};
  26. handle = makeDShandle('basedir',basedir,'animals',animals,...
  27. 'querryCells',querryCells,'querryFiles',querryFiles);
  28. handle = handle([handle(:).hasDS] & [handle(:).hasMetrics]);
  29. % Load batch
  30. batch_metrics = LoadCellMetricBatch('basepaths',{handle(:).basepath});
  31. % Run Waveform and ACG quality metrics
  32. batch_metrics = get_waveformACGquality('metrics',batch_metrics,'save_results',false);
  33. % TODO: Rerun opto-tagging assignments
  34. % batch_metrics = reclassifyOptoResponses(batch_metrics,'maxHalfRise',.005);
  35. % Rerun Yuta Classifier on final cell selection
  36. batch_metrics = YutaClassWrapper(batch_metrics); % rng initialized, should be deterministic
  37. % Add monosyn curation status to batch_metrics
  38. batch_metrics.monoSynManual = ismember(batch_metrics.batchIDs,...
  39. find([handle(:).monoSynManual]))*1; % *1 to make double
  40. % Refine peaks for DS2 (% TODO: incorporate this somewhere else)
  41. batch_metrics = refinePeaks(batch_metrics);
  42. % % TODO: New version of excluding ambiguous & 0.1 Hz criterion for HR (Rev1)
  43. batch_metrics = reclassifyOptoResponses2(batch_metrics); % Added 12/16/2025
  44. % batch_metrics = addAmbiguousResponse(batch_metrics); % Added 11/14/2025
  45. batch_metrics = add_evtPeakActivation(batch_metrics,'opto_10ms','InEvent',[0.0005 .01]);
  46. batch_metrics = add_evtPeakActivation(batch_metrics,'opto_1sec','InEvent',[.05 .95]);
  47. % Sort fields in alphabetical order
  48. batch_metrics = orderfields(batch_metrics);
  49. clear basedir ChRmice HRmice WTmice linear animals querryCells querryFiles
  50. %% Make 'standard' SVM based on all PV-Cre and SST-Cre mice
  51. % Make table for classifier learning
  52. exclude = struct('putativeCellType',repmat({'Unknown'},1,4),...
  53. 'tags',repmat({{'InverseSpike','Bad'}},1,4));
  54. include = struct('putativeCellType',{'','','Granule Cell','Mossy Cell'},...
  55. 'groundTruthClassification',{'PV+','SST+','',''},...
  56. 'brainRegion','DG','geneticLine','Cre',...); % ...
  57. 'labels','eNpHR'); %-- Toggle this line for HR classifier control Fig S6e
  58. % Shorthand, will pick up PV-Cre and SST-Cre -- matlab automatically repeats singular entries
  59. % Get features
  60. fields = {'cv2','acg_tau_rise','troughToPeak','ab_ratio','firingRate','ds2amplitude','wakeNREMratio'};
  61. for ff = 1:length(fields)
  62. Tbl{ff} = get_metricfield(batch_metrics,fields{ff},...
  63. 'include',include,'exclude',exclude,'tukeyFence',Inf);
  64. end
  65. Tbl = cat(2,Tbl{:});
  66. Tbl = Tbl(:,[1:2:end-1 end]);
  67. Tbl = array2table(Tbl,'VariableNames',[fields,{'labels'}]);
  68. % Retrain SVM from classification learner
  69. % 250126 -- optimizable SVM, 10-fold cv
  70. % '>> classificationLearner' run 'optimizableSVM' and 'ExportModel'
  71. rng(0); % Initialize RNG for reproducibility
  72. [SVMecoc, validationAccuracy, partitionedModel] = trainSVMpvsst(Tbl); % - use this to add posterior fit
  73. SVM = SVMecoc.ClassificationSVM;
  74. fprintf('Validation accuracy %.2f%%\n',validationAccuracy*100)
  75. % Get predictions for high-certainty confusion matrix only
  76. % [labels,~,~,scoreProb] = resubPredict(SVM);
  77. % isHQ = max(scoreProb,[],2)>.5;
  78. % response = Tbl.labels;
  79. % Perform cross-validation
  80. % partitionedModel = crossval(SVM, 'KFold', 10);
  81. % Compute validation predictions
  82. [labels, ~, ~, scoreProb] = kfoldPredict(partitionedModel);
  83. isHQ = max(scoreProb,[],2)>.5;
  84. response = Tbl.labels;
  85. % All predictions
  86. figure;
  87. cm = confusionchart(response, labels);
  88. cm.RowSummary = 'row-normalized';
  89. cm.ColumnSummary = 'column-normalized';
  90. title('All classifications');
  91. % High-certainty predictions, only
  92. figure;
  93. cm = confusionchart(response(isHQ), labels(isHQ));
  94. cm.RowSummary = 'row-normalized';
  95. cm.ColumnSummary = 'column-normalized';
  96. title('High-certainty classifications');
  97. clear cm labels score pbscore scoreProb SVMecoc Tbl ff fields include exclude...
  98. validationAccuracy response labels scoreProb isHQ cm partitionedModel
  99. %% Classify batch_metrics with SVM classifier (keep all cells, set non-classifiable DG to 'Unknown')
  100. % Load batch metrics first
  101. clear AllTbl
  102. celltype = {'PV interneuron','SST interneuron','Granule Cell','Mossy Cell','Unknown'};
  103. % Remove cells with inverse spikes or bad waveforms
  104. [~, classIDs] = select_cells(batch_metrics,...
  105. 'include',struct('brainRegion',{'DG'}),...
  106. 'exclude',struct('putativeCellType',{'Unknown'},'tags',{{'InverseSpike','Bad'}}));
  107. class_metrics = batch_metrics;
  108. isDG = contains(class_metrics.brainRegion,'DG');
  109. isGood = false(1,length(batch_metrics.UID));
  110. isGood(classIDs) = true;
  111. %isGood = ~contains(class_metrics.tags,{{'InverseSpike','Bad'}}) & ~contains(class_metrics.putativeCellType,'Unknown');
  112. % Get features
  113. fields = {'cv2','acg_tau_rise','troughToPeak','ab_ratio','firingRate','ds2amplitude','wakeNREMratio'};
  114. for ff = 1:length(fields)
  115. AllTbl{ff} = class_metrics.(fields{ff});
  116. end
  117. % Assemble data into table
  118. AllTbl = array2table(cat(1,AllTbl{:})','VariableNames',fields);
  119. % Set rng for deterministic outcome
  120. rng(0);
  121. % Run Classifier
  122. [labels,~,~,scoreProb] = predict(SVM,AllTbl);
  123. % Set labels with posterior prob < 50% to 'Unknown'
  124. labels(max(scoreProb,[],2)<.5) = 5;
  125. % Set DG labels with bad waveforms to 'Unknown'
  126. labels(isDG & ~isGood) = 5;
  127. for ll = 1:5
  128. theseIDs = find(labels'==ll & isDG);
  129. for n = theseIDs
  130. class_metrics.putativeCellType{n} = celltype{ll};
  131. end
  132. end
  133. clear ll n theseIDs labels AllTbl scoreProb fields classIDs celltype ff isDG isGood
  134. %% Get synaptic parameters for each connected pair
  135. % TODO: Correct cell-type determination
  136. % TODO: Make analysis for each CELL (connectivity rates) and each PAIR
  137. % (mono_analysis)
  138. reanalyze = false;
  139. mono_analysis = getMonoConnAnalysis(class_metrics,'reanalyze',reanalyze);
  140. clear reanalyze;
  141. %% Connected and non-connected simultaneously recorded pairs and connection rates (class metrics)
  142. % Create in- and exclude structure
  143. %criteria = struct('batchIDs',{[5 15]}); % SUBSELECT DATASETS HERE!
  144. labels = {'PV','SST','GC','MC','MEC PYR','PVo','SSTo'};
  145. include = struct('putativeCellType',{'PV interneuron','SST interneuron',...
  146. 'Granule Cell','Mossy Cell','Pyramidal Cell','',''},...
  147. 'brainRegion',{'DG','DG','DG','DG','ENTm','DG','DG'},...
  148. 'groundTruthClassification',{'','','','','','PV+','SST+'},...
  149. 'monoSynManual',1);
  150. exclude = struct('groundTruthClassification',{'','','+','+','+','',''});
  151. % Get the connectivity data (rates and pair global IDs)
  152. mono_res = getMonoConnRates(class_metrics,'include',include,'exclude',exclude);
  153. fprintf('Table rows = pre\n')
  154. array2table(sum(mono_res.nEcon,3),'RowNames',labels,'VariableNames',labels)
  155. fprintf('Table rows = pre(%%)\n')
  156. confrct = round(sum(mono_res.nEcon,3)./sum(mono_res.nEtotal,3)*100,2);
  157. array2table(confrct,'RowNames',labels,'VariableNames',labels)
  158. % Make heatmap
  159. figure('position',[100 100 220 175]); heatmap(log10(confrct(1:5,1:5)));
  160. colormap(bwyr); caxis([-1 .5]); % For color
  161. figure('position',[100 100 220 175]); heatmap(confrct(1:5,1:5)); % For values
  162. clear labels include exclude tbl
  163. %% Converging and non-converging pairs
  164. % Create in- and exclude structure
  165. %criteria = struct('batchIDs',{[5 15]}); % SUBSELECT DATASETS HERE!
  166. labels = {'PV','SST','GC','MC','MEC PYR','PVo','SSTo'};
  167. include = struct('putativeCellType',{'PV interneuron','SST interneuron',...
  168. 'Granule Cell','Mossy Cell','Pyramidal Cell','',''},...
  169. 'brainRegion',{'DG','DG','DG','DG','ENTm','DG','DG'},...
  170. 'groundTruthClassification',{'','','','','','PV+','SST+'},...
  171. 'monoSynManual',1);
  172. exclude = struct('groundTruthClassification',{'','','+','+','+','',''});
  173. % Get the connectivity data (rates and pair global IDs)
  174. convg_res = getConvergingPairs(class_metrics,'include',include,'exclude',exclude);
  175. % fprintf('Table rows = pre\n')
  176. % array2table(sum(mono_res.nEcon,3),'RowNames',labels,'VariableNames',labels)
  177. %
  178. % fprintf('Table rows = pre(%%)\n')
  179. % array2table((sum(mono_res.nEcon,3)./sum(mono_res.nEtotal,3)*100),...
  180. % 'RowNames',labels,'VariableNames',labels)
  181. clear labels include exclude
  182. %% Load place fields (Figure 4)
  183. linear = load_LinearBatch(batch_metrics);
  184. openfield = load_OpenfieldBatch(batch_metrics);
  185. radial = load_RadialBatch(batch_metrics);
  186. %% Lii/iii separate connected and non-connected simultaneously recorded pairs and connection rates (class metrics)
  187. % Separate for MEC Lii and Liii
  188. %
  189. % Create in- and exclude structure
  190. %criteria = struct('batchIDs',{[5 15]}); % SUBSELECT DATASETS HERE!
  191. labels = {'PV','SST','GC','MC','PYR2','PYR3','PVo','SSTo'};
  192. include = struct('putativeCellType',{'PV interneuron','SST interneuron',...
  193. 'Granule Cell','Mossy Cell','Pyramidal Cell','Pyramidal Cell','',''},...
  194. 'brainRegion',{'DG','DG','DG','DG','ENTm2','ENTm3','DG','DG'},...
  195. 'groundTruthClassification',{'','','','','','','PV+','SST+'},...
  196. 'monoSynManual',1);
  197. exclude = struct('groundTruthClassification',{'','','+','+','+','+','',''});
  198. % Get the connectivity data (rates and pair global IDs)
  199. mono_res_l23 = getMonoConnRates(class_metrics,'include',include,'exclude',exclude);
  200. fprintf('Table rows = pre\n')
  201. array2table(sum(mono_res_l23.nEcon,3),'RowNames',labels,'VariableNames',labels)
  202. fprintf('Table rows = pre(%%)\n')
  203. confrct = round(sum(mono_res_l23.nEcon,3)./sum(mono_res_l23.nEtotal,3)*100,2);
  204. array2table(confrct,'RowNames',labels,'VariableNames',labels)
  205. % Make heatmap
  206. figure('position',[100 100 250 205]); heatmap(log10(confrct(1:6,1:6)));
  207. colormap(bwyr); caxis([-1 .5]); % For color
  208. %xticklabels(labels(1:6)); xtickangle(45);
  209. figure('position',[100 100 250 205]); heatmap(confrct(1:6,1:6)); % For values
  210. clear labels include exclude tbl
  211. %% Figure 1
  212. %% 1c(1) Single cell example opto response & ACG (eNpHR - PV)
  213. % Load cell_metrics, spikes, opto_1sec
  214. session = 'PV22_240308';
  215. color = [.56 .39 .93];
  216. UID = 47; %PV22_240308-UID 47-20ms
  217. printfig = true;
  218. % Load stuff
  219. basepath = local2remote(session);
  220. basename = bz_BasenameFromBasepath(basepath);
  221. cell_metrics = load_cellmetrics_TH('basepath',basepath);
  222. spikes = load_spikes_TH('basepath',basepath);
  223. load([basepath,filesep,basename,'.opto_20ms.manipulation.mat'],'opto_20ms');
  224. % ACG
  225. acgT = cell_metrics.general.ccg_time;
  226. acgBinSz = mean(diff(acgT));
  227. acgEdg = [acgT-acgBinSz/2; acgT(end)+acgBinSz/2]';
  228. % Plot ACG
  229. f1 = figure('position',[200 200 400 200]);
  230. subplot(1,2,1); hold on;
  231. histogram('BinEdges',acgEdg,'BinCounts',...
  232. cell_metrics.general.ccg(:,UID,UID),...
  233. 'FaceColor',color,'FaceAlpha',1,'LineStyle','none');
  234. title(sprintf('%s (%i)',cell_metrics.putativeCellType{UID},UID));
  235. xlabel('Time (s)');
  236. yticks([]);
  237. % Plot Raster
  238. subplot(1,2,2);
  239. bz_eventRasterplot(spikes,opto_20ms.timestamps(1:10000,:),UID,'periEvtWdw',.02,...
  240. 'color',color,'subsample',5);
  241. sgtitle(cell_metrics.general.basename);
  242. % Save figure if desired
  243. if printfig
  244. pos = get(f1,'Position');
  245. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  246. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  247. print(f1,sprintf('%s-UID %i-20ms',cell_metrics.general.basename,UID),'-dpdf','-r0')
  248. end
  249. clear acgT acgBinSz acgEdg color UID printfig pos f1 session basepath basename...
  250. cell_metrics spikes opto_20ms
  251. %% 1c(2) Single cell example opto response & ACG (ChR - SST)
  252. % Load cell_metrics, spikes, opto_1sec
  253. session = 'YutaMouse20_140325';
  254. color = [0 .72 .53];
  255. UID = 6; % YutaMouse20-140325-UID 6-10ms
  256. printfig = true;
  257. % Load stuff
  258. basepath = strrep(local2remote(session),'_','-'); % bugfix, yuta sessions have '-'
  259. basename = bz_BasenameFromBasepath(basepath);
  260. cell_metrics = load_cellmetrics_TH('basepath',basepath);
  261. spikes = load_spikes_TH('basepath',basepath);
  262. load([basepath,filesep,basename,'.opto_10ms.manipulation.mat'],'opto_10ms');
  263. % ACG
  264. acgT = cell_metrics.general.ccg_time;
  265. acgBinSz = mean(diff(acgT));
  266. acgEdg = [acgT-acgBinSz/2; acgT(end)+acgBinSz/2]';
  267. % Plot ACG
  268. f1 = figure('position',[200 200 400 200]);
  269. subplot(1,2,1); hold on;
  270. histogram('BinEdges',acgEdg,'BinCounts',...
  271. cell_metrics.general.ccg(:,UID,UID),...
  272. 'FaceColor',color,'FaceAlpha',1,'LineStyle','none');
  273. title(sprintf('%s (%i)',cell_metrics.putativeCellType{UID},UID));
  274. xlabel('Time (s)');
  275. yticks([]);
  276. % Plot Raster
  277. subplot(1,2,2);
  278. bz_eventRasterplot(spikes,opto_10ms.timestamps,UID,'periEvtWdw',.02,...
  279. 'color',color,'subsample',5);
  280. sgtitle(cell_metrics.general.basename);
  281. % Save figure if desired
  282. if printfig
  283. pos = get(f1,'Position');
  284. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  285. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  286. print(f1,sprintf('%s-UID %i-10ms',cell_metrics.general.basename,UID),'-dpdf','-r0')
  287. end
  288. clear acgT acgBinSz acgEdg color UID printfig pos f1 session cell_metrics basepath...
  289. spikes opto_10ms
  290. %% 1d PSTH for PV/SST ChR/eNpHR responses 10/20 ms pulses
  291. baseline = [-Inf -.002]; % [-Inf 0] standard, [4 40] for freq
  292. minRate = 0; minPrctile = 1; % Minimum percentile of bins during baseline above minRate
  293. nGr = 4;
  294. printfig = false;
  295. % EVENT SELECTION
  296. type = 'manipulations'; % Manipulations, events
  297. field = {'opto_20ms','opto_20ms','opto_10ms','opto_10ms'};
  298. sortCriterion = '_modulationIndex'; % '_modulationSD' (default) or '_peakFreq' for chirp
  299. % CELL SELECTION
  300. labels = {'PV-eNpHR','SST-eNpHR','PV-ChR','SST-ChR'};
  301. include = struct('groundTruthClassification',{'PV+','SST+','PV+','SST+'},...
  302. 'labels',{'eNpHR','eNpHR','ChR2','ChR2'},...
  303. 'brainRegion',{'DG','DG','DG','DG'});
  304. exclude = struct('putativeCellType',repmat({'Unknown'},1,nGr),...
  305. 'tags',repmat({{'InverseSpike','Bad'}},1,nGr));
  306. % PLOT
  307. f1 = figure('position',[200 20 130 165*nGr]); % Same abs height
  308. for gr = 1:4
  309. subplot(4,1,gr);
  310. plot_psth(batch_metrics,field{gr},'type',type,'labels',labels(gr),...
  311. 'include',include(gr),'exclude',exclude(gr),...
  312. 'colors',[0 0 0],'minRate',minRate,'minPrctile',minPrctile,...
  313. 'sortCriterion',sortCriterion,'baseline',baseline,'SDrange',[-5 5],...
  314. 'x_units','ms');
  315. end
  316. % Save figure if desired
  317. if printfig
  318. pos = get(f1,'Position');
  319. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  320. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  321. print(f1,'Opto_pulse_psth.pdf','-dpdf','-r0')
  322. end
  323. clear include exclude nGr gr field type labels minRate minPrctile baseline...
  324. sortCriterion printfig f1 pos colors
  325. %% 1e Waveforms superimposed
  326. include = struct('putativeCellType',{'','','Granule Cell','Mossy Cell'},...
  327. 'groundTruthClassification',{'PV+','SST+','',''},...
  328. 'brainRegion',{'DG','DG','DG','DG'});
  329. exclude = struct('putativeCellType',repmat({'Unknown'},1,4),...
  330. 'tags',repmat({{'InverseSpike','Bad'}},1,4),...
  331. 'groundTruthClassification',{'~','~','+','+'});
  332. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7];
  333. printfig = false;
  334. % Get z-scored waveforms for all cells:
  335. stdTS = batch_metrics.waveforms.time{1};
  336. for n = length(class_metrics.UID):-1:1
  337. % Get z-scored waveforms with standard timestamps
  338. waveforms(n,:) = zscore(interp1(batch_metrics.waveforms.time{n},...
  339. batch_metrics.waveforms.filt{n},stdTS));
  340. % % Filtered waveforms in microvolt
  341. % waveforms(n,:) = interp1(class_metrics.waveforms.time{n},...
  342. % class_metrics.waveforms.filt{n},stdTS);
  343. end
  344. % Plot all mean waveforms and SEM
  345. f1 = figure('position',[100 100 170 200]); hold on
  346. %figure('position',[100 100 800 200]); -- Toggle this for separate plots
  347. for ct = 1:length(include)
  348. % subplot(1,length(sel),ct);-- Toggle this for separate plots
  349. [~,cellIDs] = select_cells(batch_metrics,'include',include(ct),...
  350. 'exclude',exclude(ct));
  351. shadedErrorBar(stdTS, nanmean(waveforms(cellIDs,:)),...
  352. std(waveforms(cellIDs,:))./sqrt(length(cellIDs)),...
  353. 'lineProps',{'color',colors(ct,:)});
  354. % Label with N;
  355. %unitstr = sprintf('N = %i',length(cellIDs));
  356. %text(prctile(stdTS,10),-3.5,unitstr,'Color','k');
  357. %title(labels{sel(ct)});
  358. xlabel('Time (ms)');
  359. xlim([min(stdTS) max(stdTS)]);
  360. ylim([-4 2]);
  361. if ct == 1; ylabel('Amplitude (normalized)'); else; yticks([]); end
  362. end
  363. % Save figure if desired
  364. if printfig
  365. pos = get(f1,'Position');
  366. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  367. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  368. print(f1,'Spike-waveforms.pdf','-dpdf','-r0')
  369. end
  370. clear waveforms stdTS sel ct n cellIDs include exclude printfig f1 colors pos
  371. %% 1f,h, S1d-h ACG rise time, CV2, spike width (troughtopeak), spike Asymmetry (AB)
  372. printfig = false;
  373. % Parameter selection
  374. fields = {'troughToPeak','acg_tau_rise','cv2','ab_ratio',...
  375. 'firingRate','ds2amplitude','wakeNREMratio'}; % 1e-h
  376. transformations = {'','log10','','','log10','','log2'}; % 1e-h
  377. % Cell selection
  378. labels = {'PV+','SST+','GC','MC'};
  379. include = struct('putativeCellType',{'','','Granule Cell','Mossy Cell'},...
  380. 'groundTruthClassification',{'PV+','SST+','',''},...
  381. 'brainRegion',{'DG','DG','DG','DG'});
  382. exclude = struct('putativeCellType',repmat({'Unknown'},1,4),...
  383. 'tags',repmat({{'InverseSpike','Bad'}},1,4),...
  384. 'groundTruthClassification',{'','','+','+'});
  385. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7];
  386. % Plot
  387. f1 = figure('position',[50 450 155*length(fields) 115]); % Same aspect ratio
  388. %f1 = figure('position',[50 450 240*length(fields) 190]); % Same aspect ratio
  389. for ff = 1:length(fields)
  390. figure(f1);
  391. subplot(1,length(fields),ff);
  392. [~,~,values] = plot_metricfield(batch_metrics, fields{ff},'labels',labels,...
  393. 'include',include,'exclude',exclude,'tukeyFence',3,...
  394. 'colors',colors,'transformation',transformations{ff});
  395. set(gca,'fontsize',6);
  396. fprintf('\nDG statistics for %s:\n',fields{ff});
  397. %kruskalwallisNdunns(catuneven(values,NaN),labels);
  398. onewayGroupTest(catuneven(values,NaN),labels);
  399. % Nested glmm statistics
  400. fprintf('\nDG mixed-effects model statistics for %s:\n',fields{ff});
  401. valTbl = get_metricfieldTbl(class_metrics, fields{ff}, 'include',include,...
  402. 'exclude',exclude, 'labels',labels, 'transformation',transformations{ff});
  403. glme_stats(valTbl)
  404. fprintf('\n ====================================== \n\n');
  405. end
  406. % Save figure if desired
  407. if printfig
  408. pos = get(f1,'Position');
  409. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  410. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  411. print(f1,'Fig1fhS1d-h_CellParameters.pdf','-dpdf','-r0')
  412. end
  413. clear include exclude thiscriteria values field transformation sel f1 printfig...
  414. pos ff fields labels transformations
  415. %% 1g ACG superimposed
  416. include = struct('putativeCellType',{'','','Granule Cell','Mossy Cell'},...
  417. 'groundTruthClassification',{'PV+','SST+','',''},...
  418. 'brainRegion',{'DG','DG','DG','DG'});
  419. exclude = struct('putativeCellType',repmat({'Unknown'},1,4),...
  420. 'tags',repmat({{'InverseSpike','Bad'}},1,4),...
  421. 'groundTruthClassification',{'~','~','+','+'});
  422. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7];
  423. % Get z-scored waveforms for all cells:
  424. ccgts = batch_metrics.general.batch{1}.acgs.log10;
  425. acgs = batch_metrics.acg.log10_rate'; % .log10_rate = peak normalized, .log10 = firing rate (Hz)
  426. % Plot all mean waveforms and SEM
  427. figure('position',[100 100 200 200]); hold on
  428. %figure('position',[100 100 800 200]); -- Toggle this for separate plots
  429. for ct = 1:length(include)
  430. % subplot(1,length(sel),ct);-- Toggle this for separate plots
  431. [~,cellIDs] = select_cells(batch_metrics,'include',include(ct),...
  432. 'exclude',exclude(ct));
  433. shadedErrorBar(ccgts, nanmean(acgs(cellIDs,:)),...
  434. std(acgs(cellIDs,:))./sqrt(length(cellIDs)),...
  435. 'lineProps',{'color',colors(ct,:)});
  436. set(gca,'XScale','log');
  437. xlabel('Time (s)');
  438. xlim([0 1]);
  439. end
  440. clear waveforms stdTS sel ct n cellIDs include exclude colors ccgts acgs
  441. %% 1i TSNE for SVM classified metrics (Include Unknown)
  442. % To change TSNE parameters in cell explorer, console '>> edit CellExplorer_Preferences'
  443. fields = {'cv2','acg_tau_rise','troughToPeak','ab_ratio','firingRate','ds2amplitude','wakeNREMratio'};
  444. % MANU: firing irregularity (CV2), autocorrelogram (ACG) rise time, spike width, anatomical location, waveform asymmetry and firing rate
  445. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; .7 .7 .7; .56 .39 .93; 0 .72 .53];
  446. % Cell selection
  447. include = struct(...
  448. 'putativeCellType',{'PV interneuron','SST interneuron','Granule Cell','Mossy Cell','Unknown','',''},...
  449. 'groundTruthClassification',{'','','','','','PV+','SST+'});
  450. [include.brainRegion] = deal('DG');
  451. [include.geneticLine] = deal('Cre'); % 'Cre' for Fig1j, 'Wild type' For supplementary Fig1
  452. % Remove Inverse spike and Bad waveform metrics
  453. plot_metrics = select_cells(class_metrics,...
  454. 'include',struct('brainRegion','DG'),...
  455. 'exclude',struct('tags',{{'Bad','InverseSpike'}}));
  456. clear values
  457. for ff = length(fields):-1:1
  458. values(:,ff) = plot_metrics.(fields{ff});
  459. end
  460. Y = tsne(values,'standardize',true);
  461. % Bugfix: Remove cells from batch that don't have all features
  462. plot_metrics.tags((any(isnan(values),2))) = {'incomplete'};
  463. plot_metrics = select_cells(plot_metrics,'exclude',struct('tags','incomplete'));
  464. figure('position',[100 100 280 260]); hold on
  465. for ct = 1:length(include)
  466. [~,cellIDs] = select_cells(plot_metrics,'include',include(ct));
  467. if any(ct==[6 7])
  468. % Use different markers for ChR and HR
  469. chrIDs = intersect(find(contains(plot_metrics.labels,'ChR')),cellIDs);
  470. hrIDs = intersect(find(contains(plot_metrics.labels,'eNpHR')),cellIDs);
  471. scatter(Y(chrIDs,1),Y(chrIDs,2),36,colors(ct,:),'+',...
  472. 'LineWidth',.5,'MarkerFaceAlpha',1);
  473. scatter(Y(hrIDs,1),Y(hrIDs,2),36,colors(ct,:),'x',...
  474. 'LineWidth',.5,'MarkerFaceAlpha',1);
  475. else
  476. scatter(Y(cellIDs,1),Y(cellIDs,2),12,colors(ct,:),'o',...
  477. 'filled','MarkerFaceAlpha',.25);
  478. end
  479. end
  480. clear fields values sel include exclude ct markers cellIDs chrIDs colors hrIDs...
  481. plot_metrics Y
  482. %% Supplementary Fig1b: Burst-index vs. ACG-tau (PC-IN classification)
  483. % Peter CE IN criteria: acg_tau_decay > 30ms; acg_tau_rise>3; troughToPeak <= 0.425ms
  484. fields = {'troughToPeak','acg_tau_rise','acg_tau_decay'}; % 'acg_tau_rise','acg_tau_decay','burstIndex_Royer2012';
  485. colors = [.46 .29 .83; 0 .72 .53]; % Opto only
  486. % Basic cell selection criteria
  487. include = struct('brainRegion',{'DG'});
  488. exclude = struct('tags',{{'Bad','InverseSpike'}},'putativeCellType','Unknown');
  489. f1 = figure('position',[200 200 330 350]);
  490. % PC AND INTERNEURONS (DG ONLY)
  491. include.putativeCellType = 'Cell';
  492. [~,PCids] = select_cells(batch_metrics,'include',include,'exclude',exclude);
  493. % scatter(batch_metrics.(fields{1})(selected), batch_metrics.(fields{2})(selected), 10,...
  494. % 'ro','filled','MarkerFaceAlpha',.2);
  495. scatter3(batch_metrics.(fields{1})(PCids), batch_metrics.(fields{3})(PCids),...
  496. batch_metrics.(fields{2})(PCids), 10, 'ro','filled','MarkerFaceAlpha',.2);
  497. hold on
  498. include.putativeCellType = 'Interneuron';
  499. [~,INids] = select_cells(batch_metrics,'include',include,'exclude',exclude);
  500. % scatter(batch_metrics.(fields{1})(selected), batch_metrics.(fields{2})(selected), 10,...
  501. % 'bo','filled','MarkerFaceAlpha',.2);
  502. scatter3(batch_metrics.(fields{1})(INids), batch_metrics.(fields{3})(INids),...
  503. batch_metrics.(fields{2})(INids), 10, 'bo','filled','MarkerFaceAlpha',.2);
  504. % OPTO TYPES
  505. include.putativeCellType = '';
  506. include.groundTruthClassification = 'PV+';
  507. [~,PVids] = select_cells(batch_metrics,'include',include,'exclude',exclude);
  508. %scatter(batch_metrics.(fields{1})(selected), batch_metrics.(fields{2})(selected),100,'k+');
  509. scatter3(batch_metrics.(fields{1})(PVids), batch_metrics.(fields{3})(PVids),...
  510. batch_metrics.(fields{2})(PVids), 50, colors(1,:), '+');
  511. include.groundTruthClassification = 'SST+';
  512. [~,SSTids] = select_cells(batch_metrics,'include',include,'exclude',exclude);
  513. %scatter(batch_metrics.(fields{1})(selected), batch_metrics.(fields{2})(selected),100,'kx');
  514. scatter3(batch_metrics.(fields{1})(SSTids), batch_metrics.(fields{3})(SSTids),...
  515. batch_metrics.(fields{2})(SSTids), 50, colors(2,:), '+');
  516. set(gca,'Yscale','log');
  517. set(gca,'Zscale','log');
  518. set(f1,'renderer','painters');
  519. xlabel('Spike-half-width (ms)');
  520. ylabel('ACG decay-constant (ms)');
  521. zlabel('ACG rise-constant (ms)');
  522. clear pcind inind
  523. % PIE CHARTS
  524. figure('position',[100 50 600 300]);
  525. subplot(1,2,1);
  526. pie([length(intersect(PVids,INids)) length(intersect(PVids,PCids))]);
  527. ax = gca;
  528. ax.Colormap = [0 0 1; 1 0 0];
  529. title('PV-Cre Opto+')
  530. subplot(1,2,2);
  531. pie([length(intersect(SSTids,INids)) length(intersect(SSTids,PCids))]);
  532. ax = gca;
  533. ax.Colormap = [0 0 1; 1 0 0];
  534. title('SST-Cre Opto+')
  535. legend({'Interneuron','Principal Cell'});
  536. fprintf('N PV cells: %i, N SST cells: %i\n',length(PVids),length(SSTids))
  537. clear include exclude criteria PVids SSTids PCids INids colors ax f1 fields
  538. %% Supplementary Fig 1c: GC/MC classification
  539. % Run YutClassifier (see preparations above)
  540. %% Supplementary Fig 1i: TSNE WT only
  541. % See Fig 1i above
  542. %% Figure 2
  543. %% 2a Overall Firing rates for class_metrics (violin)
  544. % + GLME stats (20251206)
  545. % + Split IN plots (opto vs. non-opto)
  546. % Plot parameters
  547. fields = {'firingRate'};
  548. transformations = {'log10'}; % set to {''} for mean +/- SEM values in console
  549. printfig = false;
  550. % Cell selection
  551. labels = {'PV','SST','GC','MC','PV+','SST+',};
  552. include = struct('putativeCellType',{'PV interneuron','SST interneuron',...
  553. 'Granule Cell','Mossy Cell','',''},'groundTruthClassification',{'','','','','PV+','SST+'});
  554. [include.brainRegion] = deal('DG');
  555. exclude = struct('tags',{{'Bad','InverseSpike'}});
  556. criteria = struct('UID',repmat({[0 Inf]},1,6));
  557. %[criteria.radialRatePeak] = deal([1 Inf]); % Specific exclusion criteria here
  558. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; .56 .39 .93; 0 .72 .53];
  559. for ff = 1:length(fields)
  560. % PLOTTING
  561. fi{ff} = figure('position',[200*ff 450 115 115]); % Same aspect ratio
  562. [~, valMtrx, ~] = plot_metricfield(class_metrics,fields{ff},...
  563. 'include',include,'exclude',exclude,'criteria',criteria,...
  564. 'transformation',transformations{ff},'tukeyFence',3,'labels',labels,...
  565. 'colors',colors,'splitgroups',[5 1; 6 2]);
  566. set(gca,'fontsize',6);
  567. % Save figure
  568. if printfig
  569. pos = get(fi{ff},'Position');
  570. set(fi{ff},'PaperPositionMode','Auto','PaperUnits','points',...
  571. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  572. print(fi{ff},sprintf('%s_svm_opto.pdf',fields{ff}),'-dpdf','-r0')
  573. end
  574. % ANOVA for SVM classified neurons
  575. fprintf('\nDG statistics for %s, SVM types:\n',fields{ff});
  576. %kruskalwallisNdunns(valMtrx(:,1:4),labels(1:4));
  577. onewayGroupTest(valMtrx(:,1:4),labels(1:4));
  578. % ANOVA for optotagged cells only
  579. if ~all(isnan(valMtrx(:,5:6)),'all')
  580. fprintf('\nDG statistics for %s, opto vs GC/MC:\n',fields{ff});
  581. onewayGroupTest(valMtrx(:,[5 6 3 4]),labels([5 6 3 4]));
  582. %kruskalwallisNdunns(valMtrx(:,[5 6 3 4]),labels([5 6 3 4]));
  583. end
  584. % LMM nested data stats
  585. valTbl = get_metricfieldTbl(class_metrics, fields{ff}, 'include',include,...
  586. 'exclude',exclude, 'criteria',criteria, 'labels',labels);
  587. glme_stats(valTbl)
  588. end
  589. % Print mean +/- SEM values in console
  590. for ct = 1:6
  591. % fprintf('%s firing rate: %.2f +/- %.2f (mean +/- STD)\n',labels{ct},...
  592. % nanmean(valMtrx(:,ct)), nanstd(valMtrx(:,ct)))
  593. fprintf('%s firing rate: Median %.2f (%.2f - %.2f IQR)\n',labels{ct},...
  594. 10.^nanmedian(valMtrx(:,ct)), 10.^prctile(valMtrx(:,ct),25), 10.^prctile(valMtrx(:,ct),75))
  595. end
  596. clear include exclude criteria valGrp valMtrx valCell fields transformation...
  597. sel fi printfig ff colors labels pos transformations
  598. %% 2b Incl Run/Rest Brain state dependent firing rates class_metrics (PSTH + boxplot)
  599. printfig = false;
  600. % Create in- and exclude structure
  601. labels = {'PV','SST','GC','MC'};
  602. limrate = [50 25 1.5 4]; % Hard coding here, no easy fix...
  603. include = struct('putativeCellType',{'PV interneuron','SST interneuron','Granule Cell','Mossy Cell'},...
  604. 'brainRegion',{'DG','DG','DG','DG'});
  605. exclude = struct('putativeCellType',repmat({'Unknown'},1,4),...
  606. 'tags',repmat({{'InverseSpike','Bad'}},1,4));
  607. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7];
  608. f1 = figure('position',[100 100 1250 200]);
  609. for ct = 1:4
  610. [~,cellIDs] = select_cells(class_metrics,'include',include(ct),'exclude',exclude(ct));
  611. rates = cat(1,class_metrics.firingRateRun(cellIDs),class_metrics.firingRateWake(cellIDs),...
  612. class_metrics.firingRateNREM(cellIDs),class_metrics.firingRateREM(cellIDs));
  613. rates = rates(:,~any(isnan(rates),1));
  614. figure(f1)
  615. ax(ct) = subplot(1,4,ct); hold(ax(ct),'on');
  616. % Make rates heatmap in background
  617. [~,order] = sort(rates(1,:));
  618. imagesc(1:4, linspace(0, limrate(ct), size(rates,2)), rates(:,order)');
  619. colormap(bwyr);
  620. colorbar
  621. clim([0 limrate(ct)]);
  622. % Plot boxes
  623. boxplot(rates','symbol', '');
  624. h = findobj('LineStyle','--'); set(h, 'LineStyle','-');
  625. h = findobj(gca,'Tag','Box');
  626. for j=1:length(h)
  627. patch(get(h(j),'XData'),get(h(j),'YData'),colors(ct,:),'FaceAlpha',.7);
  628. end
  629. % Markup
  630. title(labels{ct});
  631. ylabel('Firing Rate (Hz)');
  632. xticklabels({'Run','Quiet','NREM','REM'});
  633. xtickangle(45);
  634. ylim([0 limrate(ct)]);
  635. % Stats (repeated measures ANOVA on ranks)
  636. fprintf([labels{ct} '\n'])
  637. onewayGroupTest(rates',{'Run','Quiet','NREM','REM'});
  638. end
  639. if printfig
  640. pos = get(f1,'Position');
  641. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  642. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  643. print(f1,sprintf('StateRates_psth.pdf'),'-dpdf','-r0')
  644. end
  645. clear ct h field j rates f1 wi order pos printfig ax cellIDs colors exclude include labels
  646. %% Suppl 2a,b: NREM-Wake, REM-Wake ratios
  647. % Plot parameters
  648. fields = {'NREMwakeRatio','REMwakeRatio'};
  649. transformations = {'log2','log2'};
  650. printfig = false;
  651. % Cell selection
  652. labels = {'PV','SST','GC','MC','PV+','SST+',};
  653. include = struct('putativeCellType',{'PV interneuron','SST interneuron',...
  654. 'Granule Cell','Mossy Cell','',''},'groundTruthClassification',{'','','','','PV+','SST+'});
  655. [include.brainRegion] = deal('DG');
  656. exclude = struct('tags',{{'Bad','InverseSpike'}});
  657. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; .56 .39 .93; 0 .72 .53];
  658. for ff = 1:length(fields)
  659. % PLOTTING
  660. fi{ff} = figure('position',[200*ff 450 135 135]); % Same aspect ratio
  661. [~, valMtrx, ~] = plot_metricfield(class_metrics,fields{ff},...
  662. 'include',include,'exclude',exclude,...
  663. 'transformation',transformations{ff},'tukeyFence',3,'labels',labels,...
  664. 'colors',colors,'markercolors',[repmat([.2 .2 .2],6,1)],... % 'markercolors',[repmat([.2 .2 .2],4,1); colors([1 2],:)]
  665. 'splitgroups',[5 1; 6 2]);
  666. set(gca,'fontsize',6);
  667. plot([0 length(include)+1],[0 0],':','color',[.5 .5 .5]);
  668. % Save figure
  669. if printfig
  670. pos = get(fi{ff},'Position');
  671. set(fi{ff},'PaperPositionMode','Auto','PaperUnits','points',...
  672. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  673. print(fi{ff},sprintf('%s_svm_opto.pdf',fields{ff}),'-dpdf','-r0')
  674. end
  675. % ANOVA for SVM classified neurons
  676. fprintf('\nDG statistics for %s, SVM types:\n',fields{ff});
  677. onewayGroupTest(valMtrx(:,1:4),labels(1:4));
  678. % ANOVA for optotagged cells only
  679. if ~all(isnan(valMtrx(:,5:6)),'all')
  680. fprintf('\nDG statistics for %s, opto vs GC/MC:\n',fields{ff});
  681. onewayGroupTest(valMtrx(:,[5 6 3 4]),labels([5 6 3 4]));
  682. end
  683. % LMM nested data stats
  684. valTbl = get_metricfieldTbl(class_metrics, fields{ff}, 'include',include,...
  685. 'exclude',exclude, 'labels',labels);
  686. glme_stats(valTbl)
  687. end
  688. clear include exclude criteria valGrp valMtrx valCell fields transformation...
  689. sel fi printfig ff colors labels pos transformations valTbl
  690. %% Figure 3
  691. %% 3a Plot all inputs to given target w/ place fields
  692. post = 8570; % Global ID (get e.g. from connectivity plot below)
  693. pairs = class_metrics.putativeConnections.excitatory(...
  694. class_metrics.putativeConnections.excitatory(:,2) == post,:);
  695. printfig = false;
  696. for pp = 1:size(pairs,1)
  697. f1 = figure('position',[10*pp+100 200 500 700]);
  698. plot_pairWplacefields(pairs(pp,1),pairs(pp,2),class_metrics);
  699. drawnow;
  700. % Save figure
  701. if printfig
  702. pos = get(f1,'Position');
  703. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  704. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  705. print(f1,sprintf('%i-%i_connExample.pdf',pairs(pp,1),pairs(pp,2)),'-dpdf','-r0')
  706. end
  707. end
  708. clear post pairs fs pos
  709. %% 3b Plot probe layout w/ classified units, connections, etc
  710. makeConnectivityPlot(class_metrics,'batchID',97,'showIDs',''); % 'global','local'
  711. %% 3c CCG PSTH
  712. % TODO: Milliseconds and % for transmission probability
  713. % TODO: class_metrics.general.batch{1, 1}.ccg , .ccg_times could be used
  714. % instead getting around the whole mono_analysis thing!
  715. pairlabels = {'GC-PV','GC-SST','MC-PV','MC-SST','MEC-PV','MEC-SST'};
  716. prelabels = {'GC','MC','MEC'};
  717. postlabels = {'PV','SST'};
  718. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; 1 0 0; 0 0 1];
  719. printfig = true;
  720. preinclude = struct('putativeCellType',{'Granule Cell','Mossy Cell','Pyramidal Cell'},...
  721. 'brainRegion',{'DG','DG','ENTm'});
  722. postinclude = struct('putativeCellType',{'PV','SST'},'brainRegion',{'DG','DG'}); % Consider adding opto types extra
  723. % Sanity check, local ID's must be identical for pairs
  724. globIDs = class_metrics.putativeConnections.excitatory;
  725. locIDs = class_metrics.UID(class_metrics.putativeConnections.excitatory);
  726. if ~all(globIDs == mono_analysis.UIDs,'all')
  727. warning('Mismatch between batch_metrics and mono_analysis, do not continue!');
  728. return
  729. end
  730. f1 = figure('Position',[100 10 150 980]); hold on; sp = 0;
  731. % Plot PSTH
  732. for pre = 1:length(preinclude)
  733. [~,presel] = select_cells(class_metrics,'include',preinclude(pre));
  734. for post = 1:length(postinclude)
  735. sp = sp+1;
  736. % Get PSTH
  737. [~,postsel] = select_cells(class_metrics,'include',postinclude(post));
  738. isRightPair = ismember(globIDs(:,1),presel) & ismember(globIDs(:,2),postsel);
  739. values = mono_analysis.latency_allspk(isRightPair);
  740. [~,order] = sort(values,'ascend');
  741. PairIDs = find(isRightPair);
  742. thisccg = 100*(mono_analysis.CCG_allspk(PairIDs(order),:) -...
  743. mono_analysis.pred_allspk(PairIDs(order),:)); % Convert to percent
  744. ccgts = mono_analysis.ccgTimeStamps * 1000; % Convert to ms
  745. subplot(6,1,sp);
  746. plim = [-1 2];
  747. % Plot PSTH
  748. imagesc(ccgts, linspace(plim(1), plim(2), size(thisccg,1)), thisccg);
  749. set(gca,'YDir','normal')
  750. xlim([-2 6]);
  751. xlabel('Time (ms)');
  752. colormap(bwyr);
  753. clim([plim(1) plim(2)]);
  754. % Overlay mean +/- SEM
  755. shadedErrorBar(ccgts, nanmean(thisccg,1), nanstd(thisccg,[],1)./sqrt(size(thisccg,1)),...
  756. 'lineProps',{'-','color',[0 0 0]});
  757. % Label with N;
  758. text(prctile(.002,55), plim(1)+ (plim(2)-plim(1))/10,...
  759. sprintf('N = %i',size(thisccg,1)),'Color','k')
  760. ylabel('Transm prob (%)')
  761. title(pairlabels{sp});
  762. drawnow
  763. end
  764. end
  765. % Save figure if desired
  766. if printfig
  767. pos = get(f1,'Position');
  768. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  769. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  770. print(f1,'MonoSynCCG_psth.pdf','-dpdf','-r0')
  771. end
  772. clear globIDs locIDs pre post presel postsel iRightPair f1 sp values ccgts colors...
  773. isRightPair order PairIDs pairlabels plim postinclude postlabels preinclude...
  774. prelabels thisccg f1 pos printfig
  775. %% 3d PV and SST input fractions and stats (svm and opto separately!)
  776. % Run section 'Get connected and non-connected...' above (preparations) first!
  777. % TODO: Consider: Opto+ cells should be separate plot (supplement) as the fractions
  778. % of pairs per session depends on the number of post in session, ergo not
  779. % same distribution
  780. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; 1 0 0; 0 0 1];
  781. printfig = false;
  782. % Include only sessions w/ manually corrected monosynaptic connections
  783. % Technically unnecesary, this is already tested when mono_res are created
  784. nEcon = mono_res.nEcon(:,:,mono_res.monoSynManual);
  785. nEtotal = mono_res.nEtotal(:,:,mono_res.monoSynManual);
  786. % Plot MEC,GC,MC connections to svm PV/SST IN
  787. EinRates = nEcon([3 4 5],[1 2],:)./nEtotal([3 4 5],[1 2],:) * 100;
  788. EinRatesPl = reshape(permute(EinRates,[2 1 3]),6,[]);
  789. % Rates for GC,MC connections to opto PV/SST IN
  790. oEinRates = nEcon([3 4],[6 7],:)./nEtotal([3 4],[6 7],:) * 100;
  791. oEinRatesPl = reshape(permute(oEinRates,[2 1 3]),4,[]);
  792. % Get numbers for console
  793. EconTot = sum(nEcon,3);
  794. Etot = sum(nEtotal,3);
  795. ErateTot = EconTot./Etot *100;
  796. % MAIN FIGURE (3d)
  797. f1 = figure('position',[100 50 190 220]);
  798. % Violin plots
  799. distributionPlot(mat2cell(EinRatesPl,ones(6,1)),...
  800. 'color',mat2cell(colors([3 3 4 4 5 5],:),ones(6,1)),'showMM',6,'distWidth',.9,...
  801. 'addSpread',0,'histOpt',1,'divFactor',2,'FaceAlpha',.5);%,'histOri','left','widthDiv',[2 1]);
  802. plotSpread(mat2cell(EinRatesPl,ones(6,1)),...
  803. 'spreadFcn',{'lin',10},'spreadWidth',.9,...
  804. 'distributionColors',{[0 0 0]},...%mat2cell(colors([3 3 4 4],:),ones(4,1)),...
  805. 'distributionMarkerSize',5,'distributionMarkerAlpha',.5,'binWidth',.05);
  806. plotSpread(mat2cell(oEinRatesPl,ones(4,1)),...
  807. 'spreadFcn',{'lin',10},'spreadWidth',.9,...
  808. 'distributionColors',{[0 0 0]},...%mat2cell(colors([3 3 4 4],:),ones(4,1)),...
  809. 'distributionMarkerSize',2,'distributionMarkerAlpha',.5,...
  810. 'binWidth',.05,'distributionMarkers','+');
  811. xticks(1:6);
  812. xticklabels({'GC-DGPV','GC-DGSST','MC-DGPV','MC-DGSST','MEC-DGPV','MEC-DGSST'});
  813. xtickangle(45);
  814. ylim([0 55]);
  815. ylabel('% connected');
  816. % SEPARATE FIGURE OPTO ONLY FOR SUPPLEMENT (S3d)
  817. f2 = figure('position',[100 50 140 220]);
  818. % Violin plots
  819. distributionPlot(mat2cell(oEinRatesPl,ones(4,1)),...
  820. 'color',mat2cell(colors([3 3 4 4],:),ones(4,1)),'showMM',6,'distWidth',.9,...
  821. 'addSpread',0,'histOpt',1,'divFactor',2,'FaceAlpha',.5);
  822. plotSpread(mat2cell(oEinRatesPl,ones(4,1)),...
  823. 'spreadFcn',{'lin',10},'spreadWidth',.9,...
  824. 'distributionColors',{[0 0 0]},...%mat2cell(colors([3 3 4 4],:),ones(4,1)),...
  825. 'distributionMarkerSize',2,'distributionMarkerAlpha',.5,...
  826. 'binWidth',.05,'distributionMarkers','+');
  827. xticks(1:4);
  828. xticklabels({'GC-DGPV','GC-DGSST','MC-DGPV','MC-DGSST'});
  829. xtickangle(45);
  830. ylim([0 55]);
  831. ylabel('% connected');
  832. % STATS FOR SVM CELL TYPES
  833. % Print total con/total numbers and stats (ranksum) in console
  834. fprintf('GC to DG-PV: %i/%i (%.2f%%), to DG-SST %i/%i (%.2f%%)\n',...
  835. EconTot(3,1),Etot(3,1),ErateTot(3,1),EconTot(3,2),Etot(3,2),ErateTot(3,2));
  836. pvals(1) = unpairedSampleTest(EinRatesPl(1,:),EinRatesPl(2,:),'labels',{'PV','SST'},'verbose',true);
  837. fprintf('MC to DG-PV: %i/%i (%.2f%%), to DG-SST %i/%i (%.2f%%)\n',...
  838. EconTot(4,1),Etot(4,1),ErateTot(4,1),EconTot(4,2),Etot(4,2),ErateTot(4,2));
  839. pvals(2) = unpairedSampleTest(EinRatesPl(3,:),EinRatesPl(4,:),'labels',{'PV','SST'},'verbose',true);
  840. fprintf('MEC to DG-PV: %i/%i (%.2f%%), to DG-SST %i/%i (%.2f%%)\n',...
  841. EconTot(5,1),Etot(5,1),ErateTot(5,1),EconTot(5,2),Etot(5,2),ErateTot(5,2));
  842. pvals(3) = unpairedSampleTest(EinRatesPl(5,:),EinRatesPl(6,:),'labels',{'PV','SST'},'verbose',true);
  843. % Multiple-comparison correction
  844. pvals = multCompCorr(pvals,'method','Dunn-Sidak');
  845. fprintf('Corrected p-values (Dunn-Sidak)\nGC PV vs. SST: %.4g\nMC PV vs. SST: %.4g\nMEC PV vs. SST: %.4g\n',pvals)
  846. clear pvals
  847. % STATS FOR OPTO-TAGGED CELL TYPES
  848. fprintf('Opto: GC to DG-PV: %i/%i (%.2f%%), to DG-SST %i/%i (%.2f%%)\n',...
  849. EconTot(3,6),Etot(3,6),ErateTot(3,6),EconTot(3,7),Etot(3,7),ErateTot(3,7));
  850. pvals(1) = unpairedSampleTest(oEinRatesPl(1,:),oEinRatesPl(2,:),'labels',{'PV','SST'},'verbose',true); % [sic!], EinRates is only 4 categories
  851. fprintf('Opto: MC to DG-PV: %i/%i (%.2f%%), to DG-SST %i/%i (%.2f%%)\n',...
  852. EconTot(4,6),Etot(4,6),ErateTot(4,6),EconTot(4,7),Etot(4,7),ErateTot(4,7));
  853. pvals(2) = unpairedSampleTest(oEinRatesPl(3,:),oEinRatesPl(4,:),'labels',{'PV','SST'},'verbose',true);
  854. % Multiple-comparison correction (opto)
  855. pvals = multCompCorr(pvals,'method','Dunn-Sidak');
  856. fprintf('Corrected p-values (Dunn-Sidak) opto\nGC PV vs. SST: %.4g\nMC PV vs. SST: %.4g\n',pvals)
  857. % SAVE FIGURE
  858. if printfig
  859. pos = get(f1,'Position');
  860. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  861. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  862. print(f1,'ConnectivityRates.pdf','-dpdf','-r0')
  863. pos = get(f2,'Position');
  864. set(f2,'PaperPositionMode','Auto','PaperUnits','points',...
  865. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  866. print(f2,'ConnectivityRatesOptoOnly.pdf','-dpdf','-r0')
  867. end
  868. clear EconTot Etot ErateTot EinRates EinRatesPl nEcon nEtotal f1 pos printfig...
  869. pvals f2
  870. %% 3e, S3e: Synaptic latencies
  871. % TODO: Make function to load synaptic results aligned w/ batch_metrics,
  872. % for now just do sanity check.
  873. printfig = false;
  874. field = 'latency_allspk'; % 'peak_allspk','latency_allspk'
  875. ylims = [0 5]; %[0 .005],[0 .4]
  876. ylab = 'Latency (ms)'; %'Latency (s)','Transm prob'
  877. labels = {'GC-PV','GC-SST','MC-PV','MC-SST','MEC-PV','MEC-SST'}; % 'o' = opto! --
  878. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; 1 0 0; 0 0 1];
  879. preinclude = struct(...
  880. 'putativeCellType',{'Granule Cell','Mossy Cell','Pyramidal Cell'},...
  881. 'brainRegion',{'DG','DG','ENTm'});
  882. postinclude = struct(...
  883. 'putativeCellType',{'PV','SST','',''},...
  884. 'brainRegion',{'DG','DG','DG','DG'},...
  885. 'groundTruthClassification',{'','','PV+','SST+'});
  886. % Sanity check, local ID's must be identical for pairs
  887. globIDs = class_metrics.putativeConnections.excitatory;
  888. locIDs = class_metrics.UID(class_metrics.putativeConnections.excitatory);
  889. if ~all(globIDs == mono_analysis.UIDs,'all')
  890. warning('Mismatch between batch_metrics and mono_analysis, do not continue!');
  891. return
  892. end
  893. % Get latencies for desired pair types
  894. for pre = 1:length(preinclude)
  895. [~,presel] = select_cells(class_metrics,'include',preinclude(pre));
  896. for post = 1:length(postinclude)
  897. [~,postsel] = select_cells(class_metrics,'include',postinclude(post));
  898. isRightPair = ismember(globIDs(:,1),presel) & ismember(globIDs(:,2),postsel);
  899. values{pre,post} = mono_analysis.(field)(isRightPair)*1000;
  900. end
  901. end
  902. % FIGURE (SVM)
  903. f1 = figure('position',[100 50 250 300]);
  904. plotSpread(mat2cell(catuneven(reshape(values(:,[1 2])',6,1),NaN)',ones(6,1)),...
  905. 'spreadFcn',{'xp',[]},'spreadWidth',.9,'distributionMarkerAlpha',.3,... %'spreadFcn',{'lin',75}
  906. 'distributionColors',{[0 0 0]},...
  907. 'distributionMarkerSize',5,'binWidth',.05);
  908. plotSpread(mat2cell(catuneven(reshape(values(:,[3 4])',6,1),NaN)',ones(6,1)),...
  909. 'spreadFcn',{'xp',[]},'spreadWidth',.9,'distributionMarkerAlpha',.3,... % 'spreadFcn',{'lin',10}
  910. 'distributionColors',{[0 0 0]},...
  911. 'distributionMarkerSize',4,'binWidth',.05,'distributionMarkers','+');
  912. customErrorBar(catuneven(reshape(values(:,[1 2])',6,1),NaN), 'errtype','STD',...
  913. 'colors',colors([3 3 4 4 5 5],:), 'MarkerSize',100, 'alpha',.8, 'LineWidth',1.5);
  914. xticklabels(labels);
  915. xtickangle(45);
  916. ylim(ylims);
  917. ylabel(ylab);
  918. % FIGURE (OPTO) - S3e
  919. f2 = figure('position',[100 50 180 300]);
  920. plotSpread(mat2cell(catuneven(reshape(values([1 2],[3 4])',4,1),NaN)',ones(4,1)),...
  921. 'spreadFcn',{'xp',[]},'spreadWidth',.9,'distributionMarkerAlpha',.3,... % 'spreadFcn',{'lin',10}
  922. 'distributionColors',{[0 0 0]},...
  923. 'distributionMarkerSize',4,'binWidth',.05,'distributionMarkers','+');
  924. customErrorBar(catuneven(reshape(values([1 2],[3 4])',4,1),NaN), 'errtype','STD',...
  925. 'colors',colors([3 3 4 4],:), 'MarkerSize',100, 'alpha',.8, 'LineWidth',1.5);
  926. xticklabels(labels);
  927. xtickangle(45);
  928. ylim(ylims);
  929. ylabel(ylab);
  930. % STATS
  931. % Print mean +/- STD in console per cell type
  932. fprintf('%s values:\n',field);
  933. for pre = 1:length(preinclude)
  934. for post = [1 2]
  935. fprintf('%s: %.2f +/- %.2f\n',labels{post+(pre-1)*2},...
  936. nanmean(values{pre,post}), nanstd(values{pre,post}))
  937. end
  938. end
  939. % Separate ANOVA for opto and SVM identified interneurons!
  940. fprintf('\nDG statistics for %s, SVM types:\n',field);
  941. kruskalwallisNdunns(catuneven(reshape(values(:,[1 2])',6,1),NaN),labels);
  942. fprintf('\nDG statistics for %s, opto vs GC/MC:\n',field);
  943. kruskalwallisNdunns(catuneven(reshape(values([1 2],[3 4])',4,1),NaN),...
  944. labels(1:4)); % Exclude [3] pre, there are no opto in MEC mice
  945. % Save figure if desired
  946. if printfig
  947. pos = get(f1,'Position');
  948. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  949. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  950. print(f1,'Fig3e_SynapticLatencies.pdf','-dpdf','-r0')
  951. pos = get(f2,'Position');
  952. set(f2,'PaperPositionMode','Auto','PaperUnits','points',...
  953. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  954. print(f2,'FigS3e_SynapticLatencies_opto.pdf','-dpdf','-r0')
  955. end
  956. clear locIDs globIDs presel postsel preinclude postinclude labels isRightPair...
  957. values f1 post pre printfig pos f1 isRightPair colors labels postinclude...
  958. preinclude ylab ylims field
  959. %% 3f, S3f: Transmission probability
  960. % TODO: Make function to load synaptic results aligned w/ batch_metrics,
  961. % for now just do sanity check.
  962. field = 'peak_allspk'; % 'peak_allspk','latency_allspk'
  963. ylims = [-3 -.5]; %[0 .005],[0 .4]
  964. ylab = 'Transm prob (%)'; %'Latency (s)','Transm prob'
  965. labels = {'GC-PV','GC-SST','MC-PV','MC-SST','MEC-PV','MEC-SST'}; % 'o' = opto! --
  966. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; 1 0 0; 0 0 1];
  967. printfig = true;
  968. preinclude = struct(...
  969. 'putativeCellType',{'Granule Cell','Mossy Cell','Pyramidal Cell'},...
  970. 'brainRegion',{'DG','DG','ENTm'});
  971. postinclude = struct(...
  972. 'putativeCellType',{'PV','SST','',''},...
  973. 'brainRegion',{'DG','DG','DG','DG'},...
  974. 'groundTruthClassification',{'','','PV+','SST+'});
  975. % Sanity check, local ID's must be identical for pairs
  976. globIDs = class_metrics.putativeConnections.excitatory;
  977. locIDs = class_metrics.UID(class_metrics.putativeConnections.excitatory);
  978. if ~all(globIDs == mono_analysis.UIDs,'all')
  979. warning('Mismatch between batch_metrics and mono_analysis, do not continue!');
  980. return
  981. end
  982. % Get Transmission probabilities for desired pair types
  983. for pre = 1:length(preinclude)
  984. [~,presel] = select_cells(class_metrics,'include',preinclude(pre));
  985. for post = 1:length(postinclude)
  986. [~,postsel] = select_cells(class_metrics,'include',postinclude(post));
  987. isRightPair = ismember(globIDs(:,1),presel) & ismember(globIDs(:,2),postsel);
  988. % Get log10 values
  989. theseVal = log10(mono_analysis.(field)(isRightPair));
  990. theseVal = real(theseVal(~isnan(theseVal) & ~isinf(theseVal) & ~imag(theseVal)>0));
  991. values{pre,post} = theseVal;
  992. clear theseVal
  993. end
  994. end
  995. % FIGURE (SVM)
  996. f1 = figure('position',[100 50 190 220]);
  997. plotSpread(mat2cell(catuneven(reshape(values(:,[1 2])',6,1),NaN)',ones(6,1)),...
  998. 'spreadFcn',{'xp',[]},'spreadWidth',.9,'distributionMarkerAlpha',.3,...
  999. 'distributionColors',{[0 0 0]},...
  1000. 'distributionMarkerSize',5,'binWidth',.05);
  1001. plotSpread(mat2cell(catuneven(reshape(values(:,[3 4])',6,1),NaN)',ones(6,1)),...
  1002. 'spreadFcn',{'xp',[]},'spreadWidth',.9,'distributionMarkerAlpha',.3,... % 'spreadFcn',{'lin',10}
  1003. 'distributionColors',{[0 0 0]},...
  1004. 'distributionMarkerSize',4,'binWidth',.05,'distributionMarkers','+');
  1005. customErrorBar(catuneven(reshape(values(:,[1 2])',6,1),NaN), 'errtype','STD',...
  1006. 'colors',colors([3 3 4 4 5 5],:), 'MarkerSize',100, 'alpha',.8, 'LineWidth',1.5);
  1007. yticks([-3 -2 -1]);
  1008. yticklabels([.1 1 10]);
  1009. xticklabels(labels);
  1010. xtickangle(45);
  1011. ylim(ylims);
  1012. ylabel(ylab);
  1013. % FIGURE (OPTO)
  1014. f2 = figure('position',[100 50 125 220]);
  1015. plotSpread(mat2cell(catuneven(reshape(values([1 2],[3 4])',4,1),NaN)',ones(4,1)),...
  1016. 'spreadFcn',{'xp',[]},'spreadWidth',.9,'distributionMarkerAlpha',.3,... % 'spreadFcn',{'lin',10}
  1017. 'distributionColors',{[0 0 0]},...
  1018. 'distributionMarkerSize',4,'binWidth',.05,'distributionMarkers','+');
  1019. customErrorBar(catuneven(reshape(values([1 2],[3 4])',4,1),NaN), 'errtype','STD',...
  1020. 'colors',colors([3 3 4 4 5 5],:), 'MarkerSize',100, 'alpha',.8, 'LineWidth',1.5);
  1021. yticks([-3 -2 -1]);
  1022. yticklabels([.1 1 10]);
  1023. xticklabels(labels);
  1024. xtickangle(45);
  1025. ylim(ylims);
  1026. ylabel(ylab);
  1027. % Print mean +/- STD in console per cell type
  1028. fprintf('%s values:\n',field);
  1029. for pre = 1:length(preinclude)
  1030. for post = [1 2]
  1031. fprintf('%s: %.2f +/- %.2f\n',labels{post+(pre-1)*2},...
  1032. 100*nanmean(10.^values{pre,post}), 100*nanstd(10.^values{pre,post}))
  1033. end
  1034. end
  1035. % Separate ANOVA for opto and SVM identified interneurons!
  1036. fprintf('\nDG statistics for %s, SVM types:\n',field);
  1037. kruskalwallisNdunns(catuneven(reshape(values(:,[1 2])',6,1),NaN),labels);
  1038. fprintf('\nDG statistics for %s, opto vs GC/MC:\n',field);
  1039. kruskalwallisNdunns(catuneven(reshape(values([1 2],[3 4])',4,1),NaN),...
  1040. labels(1:4)); % Exclude [3] pre, there are no opto in MEC mice
  1041. % Save figure if desired
  1042. if printfig
  1043. pos = get(f1,'Position');
  1044. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  1045. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1046. print(f1,'Fig3f_TransmissionProbabilities.pdf','-dpdf','-r0')
  1047. pos = get(f2,'Position');
  1048. set(f2,'PaperPositionMode','Auto','PaperUnits','points',...
  1049. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1050. print(f2,'FigS3f_TransmissionProbabilities_opto.pdf','-dpdf','-r0')
  1051. end
  1052. clear locIDs globIDs presel postsel preinclude postinclude labels isRightPair...
  1053. values f1 post pre printfig pos f1 isRightPair colors labels postinclude...
  1054. preinclude ylab ylims field
  1055. %% 3g, S3g: Synaptic facilitation
  1056. burstSpk = 2; % 2 or 3, normalized to first
  1057. ylims = [-3 3]; %[0 .005],[0 .4]
  1058. ylab = 'Facilitation'; %'Latency (s)','Transm prob'
  1059. labels = {'GC-PV','GC-SST','MC-PV','MC-SST','MEC-PV','MEC-SST'}; % 'o' = opto! --
  1060. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; 1 0 0; 0 0 1];
  1061. printfig = false;
  1062. preinclude = struct(...
  1063. 'putativeCellType',{'Granule Cell','Mossy Cell','Pyramidal Cell'},...
  1064. 'brainRegion',{'DG','DG','ENTm'});
  1065. postinclude = struct(...
  1066. 'putativeCellType',{'PV','SST','',''},...
  1067. 'brainRegion',{'DG','DG','DG','DG'},...
  1068. 'groundTruthClassification',{'','','PV+','SST+'});
  1069. % Sanity check, local ID's must be identical for pairs
  1070. globIDs = class_metrics.putativeConnections.excitatory;
  1071. locIDs = class_metrics.UID(class_metrics.putativeConnections.excitatory);
  1072. if ~all(globIDs == mono_analysis.UIDs,'all')
  1073. warning('Mismatch between batch_metrics and mono_analysis, do not continue!');
  1074. return
  1075. end
  1076. % Get facilitation for desired pair types
  1077. for pre = 1:length(preinclude)
  1078. [~,presel] = select_cells(class_metrics,'include',preinclude(pre));
  1079. for post = 1:length(postinclude)
  1080. [~,postsel] = select_cells(class_metrics,'include',postinclude(post));
  1081. isRightPair = ismember(globIDs(:,1),presel) & ismember(globIDs(:,2),postsel);
  1082. % Calculate facilitation
  1083. rawTransm{pre,post,1} = mono_analysis.peak(isRightPair,1);
  1084. rawTransm{pre,post,2} = mono_analysis.peak(isRightPair,burstSpk);
  1085. theseval = rawTransm{pre,post,2}./rawTransm{pre,post,1};
  1086. theseval = theseval(theseval>0 & ~isinf(theseval)); % Remove negative transm prob
  1087. values{pre,post} = log2(theseval); % log2 transformation
  1088. end
  1089. end
  1090. % FIGURE 3G (SVM)
  1091. f1 = figure('position',[100 50 190 220]);
  1092. plot([0 7],[0 0],':','Color',[.5 .5 .5]);
  1093. plotSpread(mat2cell(catuneven(reshape(values(:,[1 2])',6,1),NaN)',ones(6,1)),...
  1094. 'spreadFcn',{'xp',[]},'spreadWidth',.9,...
  1095. 'distributionColors',[.5 .5 .5],'distributionMarkerSize',1,...
  1096. 'distributionMarkerAlpha',.5,'distributionMarkers','o');
  1097. plotSpread(mat2cell(catuneven(reshape(values(:,[3 4])',6,1),NaN)',ones(6,1)),...
  1098. 'spreadFcn',{'xp',[]},'spreadWidth',.9,...
  1099. 'distributionColors',[.5 .5 .5],...
  1100. 'distributionMarkerSize',4,'binWidth',.05,'distributionMarkers','+');
  1101. customErrorBar(catuneven(reshape(values(:,[1 2])',6,1),NaN), 'errtype','STD',...
  1102. 'colors',colors([3 3 4 4 5 5],:), 'MarkerSize',100, 'alpha',.8, 'LineWidth',1.5);
  1103. xticklabels(labels);
  1104. xtickangle(45);
  1105. ylim(ylims);
  1106. yticks(ylims(1):ylims(2));
  1107. yticklabels(round(2.^(ylims(1):ylims(2)),3));
  1108. ylabel(ylab);
  1109. % FIGURE S3G (Opto)
  1110. f2 = figure('position',[100 50 125 220]);
  1111. plot([0 5],[0 0],':','Color',[.5 .5 .5]);
  1112. plotSpread(mat2cell(catuneven(reshape(values([1 2],[3 4])',4,1),NaN)',ones(4,1)),...
  1113. 'spreadFcn',{'xp',[]},'spreadWidth',.9,...
  1114. 'distributionColors',[.5 .5 .5],...
  1115. 'distributionMarkerSize',4,'binWidth',.05,'distributionMarkers','+');
  1116. customErrorBar(catuneven(reshape(values([1 2],[3 4])',4,1),NaN), 'errtype','STD',...
  1117. 'colors',colors([3 3 4 4],:), 'MarkerSize',100, 'alpha',.8, 'LineWidth',1.5);
  1118. xticklabels(labels(1:4));
  1119. xtickangle(45);
  1120. ylim(ylims);
  1121. yticks(ylims(1):ylims(2));
  1122. yticklabels(round(2.^(ylims(1):ylims(2)),3));
  1123. ylabel(ylab);
  1124. % STATS
  1125. % Separate ANOVA for opto and SVM identified interneurons!
  1126. fprintf('\nDG statistics for facilitation spike no %i, SVM types:',burstSpk);
  1127. kruskalwallisNdunns(catuneven(reshape(values(:,[1 2])',6,1),NaN),labels);
  1128. fprintf('\nDG statistics for facilitation spike no %i, opto vs GC/MC:',burstSpk);
  1129. kruskalwallisNdunns(catuneven(reshape(values([1 2],[3 4])',4,1),NaN),...
  1130. labels(1:4)); % Exclude [3] pre, there are no opto in MEC mice
  1131. % Pairwise comparisons for faciliation degree
  1132. fprintf('\n\nSVM cell types:');
  1133. for pre = 1:3
  1134. for post = [1 2]
  1135. if length(rawTransm{pre,post,1})<2; continue; end
  1136. fprintf('\n%s, pairwise comparison spike 1 vs. %i:\n',...
  1137. labels{2*(pre-1)+post},burstSpk)
  1138. pval = pairedSampleTest(rawTransm{pre,post,1},rawTransm{pre,post,2},...
  1139. 'labels',{'spike1',sprintf('spike%i',burstSpk)},'verbose',true);
  1140. % pvals = 1 - (1 - pvals) .^ N; Dunn-Sidak
  1141. fprintf('Corrected p (Dunn-Sidak): %.4g\n',1 - (1-pval)^5);
  1142. end
  1143. end
  1144. % Pairwise comparisons for faciliation (opto only)
  1145. fprintf('\n\nOpto cell types:');
  1146. for pre = 1:2
  1147. for post = [3 4]
  1148. if length(rawTransm{pre,post,1})<2; continue; end
  1149. fprintf('\n%s, pairwise comparison spike 1 vs. %i (opto):\n',...
  1150. labels{2*(pre-1)+post-2},burstSpk)
  1151. pval = pairedSampleTest(rawTransm{pre,post,1},rawTransm{pre,post,2},...
  1152. 'labels',{'spike1',sprintf('spike%i',burstSpk)},'verbose',true);
  1153. fprintf('Corrected p (Dunn-Sidak): %.4g\n',1 - (1-pval)^4);
  1154. end
  1155. end
  1156. % Save figure if desired
  1157. if printfig
  1158. pos = get(f1,'Position');
  1159. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  1160. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1161. print(f1,'Fig3g_SynapticFacilitationLog2.pdf','-dpdf','-r0')
  1162. pos = get(f2,'Position');
  1163. set(f2,'PaperPositionMode','Auto','PaperUnits','points',...
  1164. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1165. print(f2,'FigS3g_SynapticFacilitationLog2_opto.pdf','-dpdf','-r0')
  1166. end
  1167. clear locIDs globIDs presel postsel preinclude postinclude labels isRightPair...
  1168. values f1 post pre ylab ylims pval pp rawTransm theseval
  1169. %% S3a: Synaptic facilitation (CCG)
  1170. prelabels = {'GC','MC','MEC'};
  1171. postlabels = {'PV','SST'};
  1172. printfig = true;
  1173. preinclude = struct('putativeCellType',{'Granule Cell','Mossy Cell','Pyramidal Cell'},...
  1174. 'brainRegion',{'DG','DG','ENTm'});
  1175. postinclude = struct('putativeCellType',{'PV','SST'},'brainRegion',{'DG','DG'}); % Consider adding opto types extra
  1176. % Sanity check, local ID's must be identical for pairs
  1177. globIDs = class_metrics.putativeConnections.excitatory;
  1178. locIDs = class_metrics.UID(class_metrics.putativeConnections.excitatory);
  1179. if ~all(globIDs == mono_analysis.UIDs,'all')
  1180. warning('Mismatch between batch_metrics and mono_analysis, do not continue!');
  1181. return
  1182. end
  1183. f1 = figure('Position',[100 10 500 980]); hold on; sp = 0;
  1184. % Plot PSTH
  1185. for pre = 1:length(preinclude)
  1186. [~,presel] = select_cells(class_metrics,'include',preinclude(pre));
  1187. for post = 1:length(postinclude)
  1188. % Get Proper IDs
  1189. [~,postsel] = select_cells(class_metrics,'include',postinclude(post));
  1190. isRightPair = ismember(globIDs(:,1),presel) & ismember(globIDs(:,2),postsel);
  1191. values = mono_analysis.peak(isRightPair);
  1192. [~,order] = sort(values,'ascend');
  1193. PairIDs = find(isRightPair);
  1194. for bb = 1:3
  1195. sp = sp+1;
  1196. thisccg = (mono_analysis.CCG(PairIDs(order),:,bb) -...
  1197. mono_analysis.pred(PairIDs(order),:,bb)) .* 100; % Convert to percent
  1198. ccgts = mono_analysis.ccgTimeStamps * 1e3; % Convert to ms
  1199. subplot(6,3,sp);
  1200. plim = [-1 3];
  1201. % Plot PSTH
  1202. imagesc(ccgts, linspace(plim(1), plim(2), size(thisccg,1)), thisccg);
  1203. set(gca,'YDir','normal')
  1204. xlim([-2 6]);
  1205. xlabel('Time (ms)');
  1206. colormap(bwyr);
  1207. clim([plim(1) plim(2)]);
  1208. % Overlay mean +/- SEM
  1209. shadedErrorBar(ccgts, nanmean(thisccg,1), nanstd(thisccg,[],1)./sqrt(size(thisccg,1)),...
  1210. 'lineProps',{'-','color',[0 0 0]});
  1211. % Label with N;
  1212. text(prctile(.002,55), plim(1)+ (plim(2)-plim(1))/10,...
  1213. sprintf('N = %i',size(thisccg,1)),'Color','k')
  1214. ylabel('Transm prob (%)')
  1215. drawnow
  1216. end
  1217. end
  1218. end
  1219. % Save figure if desired
  1220. if printfig
  1221. pos = get(f1,'Position');
  1222. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  1223. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1224. print(f1,'Burst_transmission_psth.pdf','-dpdf','-r0')
  1225. end
  1226. clear globIDs locIDs pre post presel postsel iRightPair f1 sp values...
  1227. printfig pos f1 ccgts thisccg isRightPair order PairIDs plim...
  1228. postinclude postlabels preinclude prelabels bb
  1229. %% S3b: Connectivity table
  1230. confrct = round(sum(mono_res.nEcon,3)./sum(mono_res.nEtotal,3)*100,2);
  1231. array2table(confrct,'RowNames',labels,'VariableNames',labels)
  1232. % Make heatmap
  1233. figure('position',[100 100 220 175]); heatmap(log10(confrct(1:5,1:5)));
  1234. colormap(bwyr); caxis([-1 .5]); % For color
  1235. figure('position',[100 100 220 175]); heatmap(confrct(1:5,1:5)); % For values
  1236. % Plot raw numbers / table to console for text
  1237. fprintf('Number connected pairs, rows = pre, columns = post\n')
  1238. array2table(sum(mono_res.nEcon,3),'RowNames',labels,'VariableNames',labels)
  1239. fprintf('Total number simult recorded pairs, rows = pre, columns = post\n')
  1240. array2table(sum(mono_res.nEtotal,3),'RowNames',labels,'VariableNames',labels)
  1241. %% S3c: Facilitation over initial strength
  1242. burstSpk = 2; % 2 or 3, normalized to first
  1243. labels = {'PV','SST','GC','MC','MEC PC'}; % 'o' = opto! --
  1244. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; 1 0 0; 0 0 1];
  1245. printfig = true;
  1246. preinclude = struct(...
  1247. 'putativeCellType',{'Granule Cell','Mossy Cell','Pyramidal Cell'},...
  1248. 'brainRegion',{'DG','DG','ENTm'});
  1249. postinclude = struct(...
  1250. 'putativeCellType',{'PV','SST'},...
  1251. 'brainRegion',{'DG','DG'},...
  1252. 'groundTruthClassification',{'',''});
  1253. % Sanity check, local ID's must be identical for pairs
  1254. globIDs = class_metrics.putativeConnections.excitatory;
  1255. locIDs = class_metrics.UID(class_metrics.putativeConnections.excitatory);
  1256. if ~all(globIDs == mono_analysis.UIDs,'all')
  1257. warning('Mismatch between batch_metrics and mono_analysis, do not continue!');
  1258. return
  1259. end
  1260. % Get facilitation for desired pair types
  1261. f1 = figure('position',[100 100 300 500]);
  1262. for pre = 1:length(preinclude)
  1263. [~,presel] = select_cells(class_metrics,'include',preinclude(pre));
  1264. for post = 1:length(postinclude)
  1265. [~,postsel] = select_cells(class_metrics,'include',postinclude(post));
  1266. isRightPair = ismember(globIDs(:,1),presel) & ismember(globIDs(:,2),postsel);
  1267. % Calculate facilitation
  1268. rawTransm{pre,post,1} = mono_analysis.peak(isRightPair,1);
  1269. rawTransm{pre,post,2} = mono_analysis.peak(isRightPair,burstSpk);
  1270. theseval = rawTransm{pre,post,2}./rawTransm{pre,post,1};
  1271. init{pre,post} = rawTransm{pre,post,1}(theseval>0 & ~isinf(theseval));
  1272. theseval = theseval(theseval>0 & ~isinf(theseval)); % Remove negative transm prob
  1273. fac{pre,post} = log2(theseval); % log2 transformation
  1274. % Scatterplot initial strength vs facilitation
  1275. subplot(3,2,post + (pre-1)*2); hold on
  1276. scatter(init{pre,post}, fac{pre,post}, 4, colors(pre+2,:),...
  1277. 'o','filled','MarkerFaceAlpha',.3);
  1278. title(sprintf('%s-%s',labels{pre+2},labels{post}));
  1279. % Pearson's R & Linear regression
  1280. if ~isempty(init{pre,post})
  1281. % Linear regression
  1282. mxx = max(init{pre,post});
  1283. mny = min(fac{pre,post});
  1284. P = polyfit(init{pre,post},fac{pre,post},1); % m=P(1), b=P(2),
  1285. plot([0 mxx], [P(2) P(2)+P(1)*mxx],'k:');
  1286. % Pearson's R
  1287. [R,pval] = corr(init{pre,post}, fac{pre,post});
  1288. text(.5*mxx, .7*mny, sprintf(...
  1289. 'R = %.2f\np = %.2g',R,pval),'FontSize',8);
  1290. fprintf('%s-%s: R = %.2f p = %.3g, N = %i\n',labels{pre+2},...
  1291. labels{post},R,pval,length(init{pre,post}))
  1292. end
  1293. end
  1294. end
  1295. % Save figure if desired
  1296. if printfig
  1297. pos = get(f1,'Position');
  1298. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  1299. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1300. print(f1,'Facilitation_vs_initialStrength.pdf','-dpdf','-r0')
  1301. end
  1302. clear locIDs globIDs presel postsel preinclude postinclude labels isRightPair...
  1303. values f1 post pre ylab ylims pval pp rawTransm theseval init fac...
  1304. printfig pos f1
  1305. %% S3d-g: Opto only
  1306. % -- see above for 3d-g
  1307. %% Figure 4
  1308. %% Load place fields:
  1309. linear = load_LinearBatch(batch_metrics);
  1310. openfield = load_OpenfieldBatch(batch_metrics);
  1311. radial = load_RadialBatch(batch_metrics);
  1312. %% 4a(1) Linear place field examples
  1313. [~,UIDs] = select_cells(class_metrics,'include',...
  1314. struct('putativeCellType','SST interneuron','groundTruthClassification',{'SST+'}),...
  1315. 'criteria',struct('SIsec1D',[0 Inf]));
  1316. color = [0 .72 .53]; % [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7]
  1317. printfig = false;
  1318. %UIDs = 5521; printfig = true; % Example on the figure, comment out to cycle through others
  1319. for n = 1:length(UIDs)
  1320. batchID = class_metrics.batchIDs(UIDs(n));
  1321. localUID = class_metrics.UID(UIDs(n));
  1322. basepath = class_metrics.general.path{batchID};
  1323. placefields = get_placeFieldsLinear('basepath',basepath);
  1324. f1 = figure('position',[200 200 180 300]); %f1 = figure('position',[200 200 160 350]);
  1325. subplot(2,1,1);
  1326. plot_ACG(class_metrics,UIDs(n),'color',color);
  1327. subplot(2,1,2);
  1328. plot_placefield1D(localUID, placefields, 'xdim','distance');
  1329. title(sprintf('%s-UID%i',class_metrics.sessionName{UIDs(n)},localUID));
  1330. drawnow
  1331. end
  1332. % Save figure
  1333. if printfig
  1334. pos = get(f1,'Position');
  1335. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  1336. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1337. print(f1,sprintf('LinearPFexample-%s-UID%i.pdf',...
  1338. class_metrics.sessionName{UIDs(n)},localUID),'-dpdf','-r0')
  1339. end
  1340. clear basepath radial batchID localUID f1 pos printfig UIDs color placefields n
  1341. %% 4a(2) + S4a-c Linear Spatial tuning parameters
  1342. % Plot parameters
  1343. fields = {'SIspk1D','SIsec1D','SpCoh1D','SesStab1D'}; %3b-c -- CONSIDER ADDING Min peak rate to criteria
  1344. transformations = {'log10','log10','',''};
  1345. printfig = true;
  1346. % Cell selection
  1347. labels = {'PV','SST','GC','MC','PV+','SST+',};
  1348. include = struct('putativeCellType',{'PV interneuron','SST interneuron',...
  1349. 'Granule Cell','Mossy Cell','',''},'groundTruthClassification',{'','','','','PV+','SST+'});
  1350. exclude = struct('tags',{{'Bad','InverseSpike'}},'putativeCellType',{'Unknown'});
  1351. criteria = struct('linearRateMean',repmat({[.5 Inf]},1,6));
  1352. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; .56 .39 .93; 0 .72 .53];
  1353. fi = figure('position',[125 450 145*length(fields) 125]);
  1354. for ff = 1:length(fields)
  1355. % PLOTTING
  1356. figure(fi);
  1357. subplot(1,length(fields),ff);
  1358. [~, valMtrx, ~] = plot_metricfield(class_metrics,fields{ff},...
  1359. 'include',include,'exclude',exclude,'criteria',criteria,...
  1360. 'transformation',transformations{ff},'tukeyFence',3,'labels',labels,...
  1361. 'colors',colors,'splitgroups',[5 1; 6 2]);
  1362. set(gca,'fontsize',6);
  1363. % ANOVA for SVM classified neurons
  1364. fprintf('\nDG statistics for %s, SVM types:',fields{ff});
  1365. kruskalwallisNdunns(valMtrx(:,1:4),labels(1:4));
  1366. % ANOVA for optotagged cells only
  1367. if ~all(isnan(valMtrx(:,5:6)),'all')
  1368. fprintf('\nDG statistics for %s, opto vs GC/MC:',fields{ff});
  1369. kruskalwallisNdunns(valMtrx(:,[5 6 3 4]),labels([5 6 3 4]));
  1370. end
  1371. % LMM nested data stats (SVM & Opto separately)
  1372. valTbl = get_metricfieldTbl(class_metrics, fields{ff}, 'include',include,...
  1373. 'exclude',exclude, 'criteria',criteria, 'labels',labels,...
  1374. 'transformation',transformations{ff});
  1375. %glme_stats(valTbl)
  1376. fprintf('\nDG LMM statistics for %s, SVM types:',fields{ff});
  1377. isSVM = cellfun(@(x) (any(x=={'PV','SST','GC','MC'})), table2cell(valTbl(:,2)));
  1378. thisTbl = valTbl(isSVM,:);
  1379. thisTbl.Group = removecats(thisTbl.Group); % Remove unused categories
  1380. glme_stats(thisTbl);
  1381. fprintf('\nDG LMM statistics for %s, opto vs GC/MC:',fields{ff});
  1382. isOpto = cellfun(@(x) (any(x=={'PV+','SST+','GC','MC'})), table2cell(valTbl(:,2)));
  1383. thisTbl = valTbl(isOpto,:);
  1384. thisTbl.Group = removecats(thisTbl.Group); % Remove unused categories
  1385. glme_stats(thisTbl);
  1386. end
  1387. % Save figure
  1388. if printfig
  1389. pos = get(fi,'Position');
  1390. set(fi,'PaperPositionMode','Auto','PaperUnits','points',...
  1391. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1392. print(fi,'Fig4a_Linear_spatialparams_svm_opto.pdf','-dpdf','-r0')
  1393. end
  1394. clear include exclude criteria valGrp valMtrx valCell fields transformation...
  1395. sel fi printfig ff colors labels pos transformations valTbl isSVM isOpto thisTbl
  1396. %% 4b(1) Radial place field examples
  1397. [~,UIDs] = select_cells(class_metrics,'include',...
  1398. struct('putativeCellType','PV interneuron'),...%'groundTruthClassification',{'SST+'}),...
  1399. 'criteria',struct('SIsecRadial',[0 Inf]));
  1400. color = [.56 .39 .93]; % [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7]
  1401. printfig = false;
  1402. UIDs = 5985; printfig = true; % Example on the figure, comment out to cycle through others
  1403. for n = 1:length(UIDs)
  1404. batchID = class_metrics.batchIDs(UIDs(n));
  1405. localUID = class_metrics.UID(UIDs(n));
  1406. basepath = class_metrics.general.path{batchID};
  1407. placefields = get_placeFieldsRadial('basepath',basepath);
  1408. f1 = figure('position',[200 200 180 350]);
  1409. subplot(2,1,1);
  1410. plot_ACG(class_metrics,UIDs(n),'color',color);
  1411. subplot(2,1,2);
  1412. plot_placefieldRAD(localUID,placefields);
  1413. title(sprintf('%s-UID%i',class_metrics.sessionName{UIDs(n)},localUID));
  1414. drawnow
  1415. end
  1416. % Save figure
  1417. if printfig
  1418. pos = get(f1,'Position');
  1419. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  1420. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1421. print(f1,sprintf('RadialPFexample-%s-UID%i.pdf',...
  1422. class_metrics.sessionName{UIDs(n)},localUID),'-dpdf','-r0')
  1423. end
  1424. clear basepath radial batchID localUID f1 pos printfig UIDs color placefields n
  1425. %% 4b(2) + S4d-f Radial Spatial tuning parameters
  1426. % Plot parameters
  1427. fields = {'SIspkRadial','SIsecRadial','SpCohRadial','SesStabRadial'};
  1428. transformations = {'log10','log10','',''};
  1429. printfig = false;
  1430. % Cell selection
  1431. labels = {'PV','SST','GC','MC','PV+','SST+',};
  1432. include = struct('putativeCellType',{'PV interneuron','SST interneuron',...
  1433. 'Granule Cell','Mossy Cell','',''},'groundTruthClassification',{'','','','','PV+','SST+'});
  1434. exclude = struct('tags',{{'Bad','InverseSpike'}},'putativeCellType',{'Unknown'});
  1435. criteria = struct('radialRateMean',repmat({[.5 Inf]},1,6));
  1436. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; .56 .39 .93; 0 .72 .53];
  1437. fi = figure('position',[125 450 145*length(fields) 125]);
  1438. for ff = 1:length(fields)
  1439. % PLOTTING
  1440. figure(fi);
  1441. subplot(1,length(fields),ff);
  1442. [~, valMtrx, ~] = plot_metricfield(class_metrics,fields{ff},...
  1443. 'include',include,'exclude',exclude,'criteria',criteria,...
  1444. 'transformation',transformations{ff},'tukeyFence',3,'labels',labels,...
  1445. 'colors',colors,'overlaygroups',[5 1; 6 2]);
  1446. set(gca,'fontsize',6);
  1447. % ANOVA for SVM classified neurons
  1448. fprintf('\nDG statistics for %s, SVM types:',fields{ff});
  1449. kruskalwallisNdunns(valMtrx(:,1:4),labels(1:4));
  1450. % ANOVA for optotagged cells only
  1451. if ~all(isnan(valMtrx(:,5:6)),'all')
  1452. fprintf('\nDG statistics for %s, opto vs GC/MC:',fields{ff});
  1453. kruskalwallisNdunns(valMtrx(:,[5 6 3 4]),labels([5 6 3 4]));
  1454. end
  1455. % LMM nested data stats (SVM & Opto separately)
  1456. valTbl = get_metricfieldTbl(class_metrics, fields{ff}, 'include',include,...
  1457. 'exclude',exclude, 'criteria',criteria, 'labels',labels,...
  1458. 'transformation',transformations{ff});
  1459. %glme_stats(valTbl)
  1460. fprintf('\nDG LMM statistics for %s, SVM types:',fields{ff});
  1461. isSVM = cellfun(@(x) (any(x=={'PV','SST','GC','MC'})), table2cell(valTbl(:,2)));
  1462. thisTbl = valTbl(isSVM,:);
  1463. thisTbl.Group = removecats(thisTbl.Group); % Remove unused categories
  1464. glme_stats(thisTbl);
  1465. end
  1466. % Save figure
  1467. if printfig
  1468. pos = get(fi,'Position');
  1469. set(fi,'PaperPositionMode','Auto','PaperUnits','points',...
  1470. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1471. print(fi,'Fig4b_Radial_spatialparams_svm_opto.pdf','-dpdf','-r0')
  1472. end
  1473. clear include exclude criteria valGrp valMtrx valCell fields transformation...
  1474. sel fi printfig ff colors labels pos transformations isSVM isOpto thisTbl valTbl
  1475. %% 4c(1) Openfield place field examples
  1476. [~,UIDs] = select_cells(class_metrics,'include',...
  1477. struct('putativeCellType','Mossy Cell'),...%'groundTruthClassification',{'SST+'}),...
  1478. 'criteria',struct('openfieldRatePeak',[1 Inf]));
  1479. color = [.9 0 .7]; % [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7]
  1480. printfig = false;
  1481. UIDs = 3292; printfig = true; % Example on the figure, comment out to cycle through others
  1482. for n = 1%:length(UIDs)
  1483. batchID = class_metrics.batchIDs(UIDs(n));
  1484. localUID = class_metrics.UID(UIDs(n));
  1485. basepath = class_metrics.general.path{batchID};
  1486. placefields = get_placeFieldsOF('basepath',basepath);
  1487. f1 = figure('position',[200 200 180 350]);
  1488. subplot(2,1,1);
  1489. plot_ACG(class_metrics,UIDs(n),'color',color);
  1490. subplot(2,1,2);
  1491. plot_placefield2D(localUID,placefields);
  1492. title(sprintf('%s-UID%i',class_metrics.sessionName{UIDs(n)},localUID));
  1493. drawnow
  1494. end
  1495. % Save figure
  1496. if printfig
  1497. pos = get(f1,'Position');
  1498. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  1499. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1500. print(f1,sprintf('OpenfieldPFexample-%s-UID%i.pdf',...
  1501. class_metrics.sessionName{UIDs(n)},localUID),'-dpdf','-r0')
  1502. end
  1503. clear basepath radial batchID localUID f1 pos printfig UIDs color placefields n
  1504. %% 4c(2) + S4g-i Openfield Spatial tuning parameters
  1505. % Plot parameters
  1506. fields = {'SIspk2D','SIsec2D','SpCoh2D','SesStab2D'}; %3b-c -- CONSIDER ADDING Min peak rate to criteria
  1507. transformations = {'log10','log10','',''};
  1508. printfig = false;
  1509. % Cell selection
  1510. labels = {'PV','SST','GC','MC','PV+','SST+',};
  1511. include = struct('putativeCellType',{'PV interneuron','SST interneuron',...
  1512. 'Granule Cell','Mossy Cell','',''},'groundTruthClassification',{'','','','','PV+','SST+'});
  1513. exclude = struct('tags',{{'Bad','InverseSpike'}},'putativeCellType',{'Unknown'});
  1514. criteria = struct('openfieldRateMean',repmat({[.5 Inf]},1,6));
  1515. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; .56 .39 .93; 0 .72 .53];
  1516. fi = figure('position',[125 450 145*length(fields) 125]);
  1517. for ff = 1:length(fields)
  1518. % PLOTTING
  1519. figure(fi);
  1520. subplot(1,length(fields),ff);
  1521. [~, valMtrx, ~] = plot_metricfield(class_metrics,fields{ff},...
  1522. 'include',include,'exclude',exclude,'criteria',criteria,...
  1523. 'transformation',transformations{ff},'tukeyFence',3,'labels',labels,...
  1524. 'colors',colors,'splitgroups',[5 1; 6 2]);
  1525. set(gca,'fontsize',6);
  1526. % ANOVA for SVM classified neurons
  1527. fprintf('\nDG statistics for %s, SVM types:',fields{ff});
  1528. kruskalwallisNdunns(valMtrx(:,1:4),labels(1:4));
  1529. % ANOVA for optotagged cells only
  1530. if ~all(isnan(valMtrx(:,5:6)),'all')
  1531. fprintf('\nDG statistics for %s, opto vs GC/MC:',fields{ff});
  1532. kruskalwallisNdunns(valMtrx(:,[5 6 3 4]),labels([5 6 3 4]));
  1533. end
  1534. % LMM nested data stats (SVM & Opto separately)
  1535. valTbl = get_metricfieldTbl(class_metrics, fields{ff}, 'include',include,...
  1536. 'exclude',exclude, 'criteria',criteria, 'labels',labels,...
  1537. 'transformation',transformations{ff});
  1538. %glme_stats(valTbl)
  1539. fprintf('\nDG LMM statistics for %s, SVM types:',fields{ff});
  1540. isSVM = cellfun(@(x) (any(x=={'PV','SST','GC','MC'})), table2cell(valTbl(:,2)));
  1541. thisTbl = valTbl(isSVM,:);
  1542. thisTbl.Group = removecats(thisTbl.Group); % Remove unused categories
  1543. glme_stats(thisTbl);
  1544. fprintf('\nDG LMM statistics for %s, opto vs GC/MC:',fields{ff});
  1545. isOpto = cellfun(@(x) (any(x=={'PV+','SST+','GC','MC'})), table2cell(valTbl(:,2)));
  1546. thisTbl = valTbl(isOpto,:);
  1547. thisTbl.Group = removecats(thisTbl.Group); % Remove unused categories
  1548. glme_stats(thisTbl);
  1549. end
  1550. % Save figure
  1551. if printfig
  1552. pos = get(fi,'Position');
  1553. set(fi,'PaperPositionMode','Auto','PaperUnits','points',...
  1554. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1555. print(fi,'Fig4c_Openfield_spatialparams_svm_opto.pdf','-dpdf','-r0')
  1556. end
  1557. clear include exclude criteria valGrp valMtrx valCell fields transformation...
  1558. sel fi printfig ff colors labels pos transformations isSVM isOpto thisTbl valTbl
  1559. %% 4d: Place fields of converging pre synaptic partners on same post
  1560. pre = 4; % 3 = GC, 4 = MC, 5 = MEC PC
  1561. post = 1; % 1 = PV, 2 = SST (svm)
  1562. fieldtype = 'linear'; % 'linear','radial','openfield'
  1563. minpre = 8; % minimum number of converging partners
  1564. minrate = 1;
  1565. ratetype = 'firingRatePeak'; % 'firingRatePeak','firingRateMean'
  1566. cell_types = {'PV','SST','Granule','Mossy','Pyramidal'}; % Do not use 3-5 as post!
  1567. printfig = false;
  1568. goodPost = find(contains(class_metrics.putativeCellType,cell_types{post})' &...
  1569. mono_res.nEinInd(:,pre) >= minpre);
  1570. % pairs = class_metrics.putativeConnections.excitatory(...
  1571. % class_metrics.putativeConnections.excitatory(:,2) == post,:);
  1572. for po = 1:length(goodPost)
  1573. clear placefields
  1574. postLocID = class_metrics.UID(goodPost(po));
  1575. pairs = mono_res.EinInd{goodPost(po),pre};
  1576. batchID = class_metrics.batchIDs(goodPost(po));
  1577. metPath = [class_metrics.general.basepaths{batchID},filesep,...
  1578. class_metrics.general.basenames{batchID} '.' fieldtype '.firingRateMap.mat'];
  1579. % Load stuff
  1580. if isfile(metPath); placefields = load(metPath,'linear'); placefields = placefields.linear; end
  1581. % Continue if no placefields exist
  1582. if ~exist('placefields','var'); continue; end
  1583. % Remove pairs with low rates
  1584. preLocIDs = class_metrics.UID(pairs(:,1));
  1585. isGoodPre = any(placefields.(ratetype)(:,preLocIDs) > minrate, 1);
  1586. pairs = pairs(isGoodPre, :);
  1587. preLocIDs = preLocIDs(isGoodPre);
  1588. % Continue if no placefields left
  1589. if size(pairs,1) < minpre; continue; end
  1590. f1 = figure('position',[50 50 300 65*size(pairs,1)]);
  1591. for pr = 1:size(pairs,1)
  1592. subplot(size(pairs,1),2,1 + (pr-1)*2);
  1593. plot_placefield1D(preLocIDs(pr), placefields,'xdim','distance');
  1594. xlabel('');
  1595. set(gca,'FontSize',6);
  1596. title(sprintf('%s %i',class_metrics.putativeCellType{pairs(pr,1)},pairs(pr,1)));
  1597. end
  1598. % Post: Linear PF
  1599. subplot(size(pairs,1),2,2);
  1600. plot_placefield1D(postLocID, placefields, 'xdim', 'distance')
  1601. title(sprintf('%s %i',class_metrics.putativeCellType{goodPost(po)},goodPost(po)));
  1602. xlabel('');
  1603. set(gca,'FontSize',6);
  1604. set(gcf,'Renderer','Painters');
  1605. drawnow
  1606. % Save figure
  1607. if printfig
  1608. pos = get(f1,'Position');
  1609. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  1610. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1611. print(f1,sprintf('%i-_inputPlacefieldExample.pdf',goodPost(pp)),'-dpdf','-r0')
  1612. end
  1613. end
  1614. clear post pairs fs pos cell_types pre printfig pos f1 pr po thisPre...
  1615. batchID linpath radpath ofpath minrate ratetypes fieldtype goodPost...
  1616. metPath minpre postLocID preLocIDs ratetype placefields isGoodPre
  1617. %% 4e Histogram converging pair numbers per cell
  1618. cell_types = {'PV','SST','Granule','Mossy','Pyramidal'}; % Do not use 3-5 as post!
  1619. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; 1 0 0; 0 0 1];
  1620. printfig = true;
  1621. hct = [];
  1622. f1 = figure('position',[100 100 600 250]);
  1623. for post = [1 2]
  1624. subplot(1,2,post); hold on
  1625. for pre = [4 3 5]
  1626. isGoodPost{post} = find(contains(class_metrics.putativeCellType, cell_types{post}));
  1627. %frct(end+1,:) = 100*histcounts(mono_res.nEinInd(isGoodPost,pre),0:22)./length(find(isGoodPost));
  1628. hct(end+1,:) = histcounts(mono_res.nEinInd(isGoodPost{post},pre),0:22);
  1629. histogram('BinEdges',(0:22), 'BinCounts',hct(end,:),...
  1630. 'FaceColor',colors(pre,:),'EdgeColor',colors(pre,:),'FaceAlpha',.5);
  1631. end
  1632. set(gca,'YScale','log');
  1633. ylabel('N pairs');
  1634. xlabel('Partners per cell');
  1635. set(gca,'FontSize',12);
  1636. if printfig
  1637. pos = get(f1,'Position');
  1638. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  1639. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1640. print(f1,sprintf('NpresynPartnerHist.pdf'),'-dpdf','-r0')
  1641. end
  1642. end
  1643. for pre = [3 4 5]
  1644. [~,p] = unpairedSampleTest(mono_res.nEinInd(isGoodPost{1},pre),...
  1645. mono_res.nEinInd(isGoodPost{2},pre),'labels',{'PV','SST'},'verbose',true);
  1646. %fprintf('%s: PV vs. SST (N input per cell), p = %.4g\n',cell_types{pre},p)
  1647. end
  1648. clear hct isGoodPost cell_types pre post f1 pos p pre
  1649. %% 4f: Place-field correlations between converging presynaptic cells
  1650. % Run section 'Get converging...' above (preparations)
  1651. % first! It runs through all sessions, but non-manual mono res are excluded
  1652. % by 'include' criteria for both connected and unconnected pairs!
  1653. % 1=PV(svm), 2=SST(svm), 3=GC, 4=MC, 5=MEC-PYR, 6=PV(opto), 7=SST(opto)
  1654. labels = {'PV','SST','GC','MC','MEC PYR','PVo','SSTo'};
  1655. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; 1 0 0; 0 0 1];
  1656. printfig = false;
  1657. placefields = {linear,radial,openfield};
  1658. pflabels = {'Linear','Radial','Openfield'};
  1659. maxndots = 1000; % Downsample number of dots for distribution plots
  1660. % Use peak rate (i.e. in place field)
  1661. minrate = 1;
  1662. ratetype = 'peakrates'; % 'meanrates','peakrates'
  1663. pvals = NaN(3,5,7);
  1664. for pre = [3 4 5] % 3 = GC, 4 = MC
  1665. fprintf('\n%s:\n',labels{pre}) % For stats
  1666. for post = [1 2 6 7] % 1,2 PV/SST (svm), 6,7 PV/SST (opto)
  1667. for beh = [1 2 3] % Linear, Radial, Openfield
  1668. ConvCorr{beh,post} = get_PlacefieldCorrelations(convg_res.Econv{pre,post},...
  1669. placefields{beh},'minrate',minrate,'ratetype',ratetype);
  1670. NonConvCorr{beh,post} = get_PlacefieldCorrelations(convg_res.Enoconv{pre,post},...
  1671. placefields{beh},'minrate',minrate,'ratetype',ratetype);
  1672. % Print stats
  1673. fprintf('%s - %s, %s:\n',labels{pre},labels{post},pflabels{beh});
  1674. try
  1675. [~,pvals(beh,pre,post)] = unpairedSampleTest(...
  1676. ConvCorr{beh,post},NonConvCorr{beh,post},...
  1677. 'labels',{'convg','not convg'},'verbose',true);
  1678. end
  1679. end
  1680. end
  1681. % Two-half violin plot
  1682. % Downsample dots
  1683. for beh = 1:3
  1684. for post = 1:7
  1685. if length(NonConvCorr{beh,post})>maxndots
  1686. NonConvCorrPl{beh,post} = randsample(NonConvCorr{beh,post},maxndots);
  1687. else
  1688. NonConvCorrPl{beh,post} = NonConvCorr{beh,post};
  1689. end
  1690. if length(ConvCorr{beh,post})>maxndots
  1691. ConvCorrPl{beh,post} = randsample(ConvCorr{beh,post},maxndots);
  1692. else
  1693. ConvCorrPl{beh,post} = ConvCorr{beh,post};
  1694. end
  1695. end
  1696. end
  1697. % Controls (non-connected SVM pairs)
  1698. f1 = figure('position',[200 100 200 200]); hold on;
  1699. % Plot non-connected pair correlations (left half)
  1700. % NoConnCorr{behavior type, cell type (1=PV,2=SST,6=optoPV,7=optoSST)}
  1701. plotSpread(reshape(NonConvCorrPl([1 2 3],[1 2]),1,6),'spreadFcn',{'lin',8},...
  1702. 'spreadWidth',.9,'distributionColors',[.5 .5 .5],'distributionMarkerSize',1,...
  1703. 'spreadOri','left','distributionMarkerAlpha',.5,'distributionMarkers','o');
  1704. distributionPlot(reshape(NonConvCorr([1 2 3],[1 2]),1,6),...
  1705. 'histOri','left','color',[0 0 0],'widthDiv',[2 1],'showMM',6,...
  1706. 'FaceAlpha',.5,'divFactor',2);
  1707. % Connected opto Pairs (add as + on same plot)
  1708. plotSpread(reshape(ConvCorrPl([1 2 3],[6 7]),1,6),'spreadFcn',{'lin',8},... % [sic!], use wider (10) spread here 2/2 lower n datapoints
  1709. 'spreadWidth',.9,'distributionColors',[.5 .5 .5],'distributionMarkerSize',3,...
  1710. 'spreadOri','right','distributionMarkers','+');
  1711. % Connected SVM pairs
  1712. plotSpread(reshape(ConvCorrPl([1 2 3],[1 2]),1,6),'spreadFcn',{'lin',8},... % [sic!], use wider (10) spread here 2/2 lower n datapoints
  1713. 'spreadWidth',.9,'distributionColors',[.5 .5 .5],'distributionMarkerSize',1,...
  1714. 'spreadOri','right','distributionMarkerAlpha',.5,'distributionMarkers','o');
  1715. distributionPlot(reshape(ConvCorr([1 2 3],[1 2]),1,6),...
  1716. 'histOri','right','color',colors(pre,:),'widthDiv',[2 2],'showMM',6,...
  1717. 'FaceAlpha',.5,'divFactor',2);
  1718. ylabel('Placefield corr (R)');
  1719. ylim([-1 1]);
  1720. xticklabels({'PV Lin','PV Rad','PV OF','SST Lin','SST Rad','SST OF'});
  1721. xtickangle(45);
  1722. % Save figure
  1723. if printfig
  1724. pos = get(f1,'Position');
  1725. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  1726. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1727. print(f1,sprintf('Fig3-%s-pairs-placefieldcorr.pdf',labels{pre}),'-dpdf','-r0')
  1728. end
  1729. end
  1730. % Dunn-Sidak Corrected p-values
  1731. %pvals = reshape(HolmBonferroniCorr(pvals(:)'),size(pvals));
  1732. pvals = multCompCorr(pvals,'method','Dunn-Sidak');
  1733. for pre = [3 4 5]
  1734. for post = [1 2 6 7]
  1735. for beh = [1 2 3]
  1736. fprintf('%s-%s: %s, p = %.4f\n',labels{pre},labels{post},...
  1737. pflabels{beh},pvals(beh,pre,post));
  1738. end
  1739. end
  1740. end
  1741. clear f1 minrate placefields ratetype pre post labels colors printfig pflabels...
  1742. ConvCorr NonConvCorr NonConvCorrPl ConvCorrPl pvals
  1743. %% S4j-l: Spatial coding properties of GC and MC recruiting PV or SST IN
  1744. % Cell selection etc.
  1745. fields = {'SIspk1D','SIspkRadial','SIspk2D'};%,'SIsecRadial','SpCohRadial','SesStabRadial'};
  1746. critfields = {'linearRateMean','radialRateMean','openfieldRateMean'};
  1747. transformation = 'log10';
  1748. printfig = true;
  1749. % Cell selection
  1750. labels = {'GC->PV','GC->SST','MC->PV','MC->SST'};
  1751. include = struct('putativeCellType',{'Granule Cell','Granule Cell','Mossy Cell','Mossy Cell'},...
  1752. 'groundTruthClassification',{'','','',''},'targets',{'PV','SST','PV','SST'});
  1753. exclude = struct('tags',{{'Bad','InverseSpike'}},'putativeCellType',{'Unknown'});
  1754. colors = [.83 .78 .46; .83 .78 .46; .9 0 .7; .9 0 .7];
  1755. % Create plot metrics, add .targetsSST and .targetsPV as metric tags
  1756. M = class_metrics;
  1757. econ = M.putativeConnections.excitatory;
  1758. for n = 1:length(M.UID)
  1759. targets = econ(econ(:,1)==n, 2);
  1760. M.targets{n} = {''};
  1761. if any(contains(M.putativeCellType(targets),'SST'))
  1762. M.targets{n} = cat(2, M.targets{n}, {'SST'});
  1763. end
  1764. if any(contains(M.putativeCellType(targets),'PV'))
  1765. M.targets{n} = cat(2, M.targets{n}, {'PV'});
  1766. %cat(2,metrics.groundTruthClassification{id},{thislabel{id}});
  1767. end
  1768. % M.targetsSST(n) = any(contains(M.putativeCellType(targets),'SST'));
  1769. % M.targetsPV(n) = any(contains(M.putativeCellType(targets),'PV'));
  1770. end
  1771. % PLOT
  1772. fi = figure('position',[125 450 105*length(fields) 125]);
  1773. for ff = 1:length(fields)
  1774. figure(fi);
  1775. subplot(1,length(fields),ff)
  1776. criteria = struct(critfields{ff},[.5 Inf]);
  1777. [~, valMtrx, ~] = plot_metricfield(M, fields{ff},...
  1778. 'include',include,'exclude',exclude, 'criteria',criteria,...
  1779. 'transformation',transformation,'tukeyFence',3,'labels',labels,...
  1780. 'colors',colors);
  1781. set(gca,'fontsize',6);
  1782. set(gca,'YLim',[-2 1]);
  1783. yticks([-2 -1 0 1]);
  1784. yticklabels([.01 .1 1 10]);
  1785. ylabel('SI (bits/spike)');
  1786. % ANOVA for SVM classified neurons
  1787. fprintf('\nDG statistics for %s, SVM types:',fields{ff});
  1788. kruskalwallisNdunns(valMtrx,labels);
  1789. end
  1790. % Save figure
  1791. if printfig
  1792. pos = get(fi,'Position');
  1793. set(fi,'PaperPositionMode','Auto','PaperUnits','points',...
  1794. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1795. print(fi,'SI_spk_PV_SST_targeting_cells.pdf','-dpdf','-r0')
  1796. end
  1797. clear M n targets econ valMtrx fi fields printfig include exclude criteria...
  1798. colors transformation labels ff critfields
  1799. %% Figure 5
  1800. %% 5c DS PSTH including LII PYR
  1801. labels = {'MECii PYR','DG pPV','DG pSST','DG GC','DG MC'};
  1802. colors = [1 0 0; .56 .39 .93; .28 1 .7; .9 .9 .47; .9 0 .7];
  1803. type = 'events'; % Manipulations, events
  1804. field = 'DS2'; % 'DS2','CA3ripples'
  1805. minRate = 0; minPrctile = 50; % Minimum percentile of bins during baseline above minRate
  1806. printfig = false;
  1807. % Create in- and exclude structure
  1808. % include = struct('putativeCellType',{'Pyramidal Cell','Narrow Interneuron',...
  1809. % 'Wide Interneuron','Granule Cell','Mossy Cell'},...
  1810. % 'brainRegion',{'ENTm2','DG','DG','DG','DG'});
  1811. include = struct('putativeCellType',{'Pyramidal Cell','PV interneuron',...
  1812. 'SST interneuron','Granule Cell','Mossy Cell'},...
  1813. 'brainRegion',{'ENTm2','DG','DG','DG','DG'});
  1814. exclude = struct('tags',{{'Bad','InverseSpike'}},'putativeCellType',{'Unknown'});
  1815. % DG plot
  1816. %sel = 1:length(include); % 1:4
  1817. f1 = figure('position',[200 20 180 180*length(include)]);
  1818. [psth, psthNorm, ccgts] = plot_psth(class_metrics,field,'type',type,'labels',labels,...
  1819. 'include',include,'exclude',exclude,...%'criteria',criteria(sel)
  1820. 'orientation','column','SDrange',[-3 3],...
  1821. 'colors',[0 0 0],'minRate',minRate,'minPrctile',minPrctile);
  1822. if printfig
  1823. pos = get(f1,'Position');
  1824. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  1825. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1826. print(f1,sprintf('DS2_response.pdf'),'-dpdf','-r0')
  1827. end
  1828. f1 = figure('position',[400 20 200 200]);
  1829. for cc = 1:length(include) % Use order of peak delay instead?
  1830. shadedErrorBar(1e3*ccgts, nanmean(psthNorm{cc},1)-1.5*cc, nanstd(psthNorm{cc},[],1)./...
  1831. sqrt(size(psthNorm{cc},1)),'lineProps',{'-','color',colors(cc,:)});
  1832. % shadedErrorBar(ts, [0 diff(nanmean(psthNorm{cc},1))]-1*cc, nanstd(psthNorm{cc},[],1)./...
  1833. % sqrt(size(psthNorm{cc},1)),'lineProps',{'-','color',colors(cc,:)});
  1834. end
  1835. xlim([-50 50]);
  1836. xlabel('Time (ms)');
  1837. if printfig
  1838. pos = get(f1,'Position');
  1839. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  1840. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1841. print(f1,sprintf('DS2_response_mean50ms.pdf'),'-dpdf','-r0')
  1842. end
  1843. clear include exclude f1 f2 printfig field pos sel type ds ts psth psthNorm...
  1844. ccgts minPrctile cc colors labels minRate
  1845. %% 5d Incl MEC: DS2_modulationPeakResponseTime
  1846. % Plot parameters
  1847. fields = {'DS2_modulationPeakResponseTime'}; % DS2_modulationSD
  1848. transformations = {''}; % -- set 'divFactor' in distribution plot to "1" for peakResponse time!
  1849. printfig = false;
  1850. % Cell selection
  1851. labels = {'MECii PC','PV','SST','GC','MC','PV+','SST+'};
  1852. include = struct('putativeCellType',{'Pyramidal Cell','PV interneuron','SST interneuron',...
  1853. 'Granule Cell','Mossy Cell','',''},...
  1854. 'groundTruthClassification',{'','','','','','PV+','SST+'},...
  1855. 'brainRegion',{'ENTm2','DG','DG','DG','DG','DG','DG'});
  1856. exclude = struct('tags',{{'Bad','InverseSpike'}});
  1857. criteria = struct('DS2_modulationRatio',[1.5 Inf]);
  1858. colors = [1 0 0; .56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; .56 .39 .93; 0 .72 .53];
  1859. for ff = 1:length(fields)
  1860. % PLOTTING
  1861. fi{ff} = figure('position',[200*ff 450 150 130]); % Same aspect ratio
  1862. [~, valMtrx, ~] = plot_metricfield(class_metrics,fields{ff},...
  1863. 'include',include,'exclude',exclude,'criteria',criteria,...
  1864. 'transformation',transformations{ff},'tukeyFence',3,'labels',labels,...
  1865. 'colors',colors,'splitgroups',[6 2; 7 3],'plottype','violin',...
  1866. 'divFactor',1);
  1867. set(gca,'fontsize',6);
  1868. xlim([.25 5.75]);
  1869. % Save figure
  1870. if printfig
  1871. pos = get(fi{ff},'Position');
  1872. set(fi{ff},'PaperPositionMode','Auto','PaperUnits','points',...
  1873. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1874. print(fi{ff},sprintf('Fig5d_%s_svm_opto.pdf',fields{ff}),'-dpdf','-r0')
  1875. end
  1876. % ANOVA for SVM classified neurons
  1877. fprintf('\nDG statistics for %s, SVM types:',fields{ff});
  1878. kruskalwallisNdunns(valMtrx(:,1:5), labels(1:5));
  1879. % ANOVA for optotagged cells only
  1880. if ~all(isnan(valMtrx(:,5:6)),'all')
  1881. fprintf('\nDG statistics for %s, opto vs GC/MC:',fields{ff});
  1882. kruskalwallisNdunns(valMtrx(:,[1 6 7 4 5]), labels([1 6 7 4 5]));
  1883. end
  1884. % LMM nested data stats (SVM & Opto separately)
  1885. valTbl = get_metricfieldTbl(class_metrics, fields{ff}, 'include',include,...
  1886. 'exclude',exclude, 'criteria',criteria, 'labels',labels);
  1887. %glme_stats(valTbl)
  1888. fprintf('\nDG LMM statistics for %s, SVM types:',fields{ff});
  1889. isSVM = cellfun(@(x) (any(x=={'PV','SST','MECii PC','GC','MC'})), table2cell(valTbl(:,2)));
  1890. thisTbl = valTbl(isSVM,:);
  1891. thisTbl.Group = removecats(thisTbl.Group); % Remove unused categories
  1892. glme_stats(thisTbl);
  1893. fprintf('\nDG LMM statistics for %s, opto vs GC/MC:',fields{ff});
  1894. isOpto = cellfun(@(x) (any(x=={'PV+','SST+','MECii PC','GC','MC'})), table2cell(valTbl(:,2)));
  1895. thisTbl = valTbl(isOpto,:);
  1896. thisTbl.Group = removecats(thisTbl.Group); % Remove unused categories
  1897. glme_stats(thisTbl);
  1898. end
  1899. % Plot numbers to console
  1900. fprintf('\nLatency to Dentate Spike (ms)\n');
  1901. for ct = 1:length(include)
  1902. % fprintf('%s firing rate: %.2f +/- %.2f (mean +/- STD)\n',labels{ct},...
  1903. % nanmean(valMtrx(:,ct)), nanstd(valMtrx(:,ct)))
  1904. fprintf('%s Latency: Median %.2f (%.2f - %.2f IQR)\n',labels{ct},...
  1905. 1e3*nanmedian(valMtrx(:,ct)), 1e3*prctile(valMtrx(:,ct),25),...
  1906. 1e3*prctile(valMtrx(:,ct),75))
  1907. end
  1908. clear include exclude criteria valGrp valMtrx valCell fields transformation...
  1909. sel fi printfig ff colors labels pos transformations valTbl thisTbl isSVM isOpto
  1910. %% 5e Incl MEC: DS2_modulationRatio
  1911. % Plot parameters
  1912. fields = {'DS2_modulationRatio'}; % DS2_modulationSD
  1913. transformations = {'log2'}; % -- set 'divFactor' in distribution plot to "1" for peakResponse time!
  1914. printfig = true;
  1915. % Cell selection
  1916. labels = {'MECii PC','PV','SST','GC','MC','PV+','SST+'};
  1917. include = struct('putativeCellType',{'Pyramidal Cell','PV interneuron','SST interneuron',...
  1918. 'Granule Cell','Mossy Cell','',''},...
  1919. 'groundTruthClassification',{'','','','','','PV+','SST+'},...
  1920. 'brainRegion',{'ENTm2','DG','DG','DG','DG','DG','DG'});
  1921. exclude = struct('tags',{{'Bad','InverseSpike'}});
  1922. criteria = struct('UID',[0 Inf]);
  1923. %[criteria.radialRatePeak] = deal([1 Inf]); % Specific exclusion criteria here
  1924. colors = [1 0 0; .56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; .56 .39 .93; 0 .72 .53];
  1925. for ff = 1:length(fields)
  1926. % PLOTTING
  1927. fi{ff} = figure('position',[200*ff 450 150 130]); % Same aspect ratio
  1928. [~, valMtrx, ~] = plot_metricfield(class_metrics,fields{ff},...
  1929. 'include',include,'exclude',exclude,'criteria',criteria,...
  1930. 'transformation',transformations{ff},'tukeyFence',3,'labels',labels,...
  1931. 'colors',colors,'splitgroups',[6 2; 7 3],'plottype','violin',...
  1932. 'divFactor',1);
  1933. set(gca,'fontsize',6);
  1934. xlim([.25 5.75]);
  1935. % Save figure
  1936. if printfig
  1937. pos = get(fi{ff},'Position');
  1938. set(fi{ff},'PaperPositionMode','Auto','PaperUnits','points',...
  1939. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  1940. print(fi{ff},sprintf('Fig5e_%s_svm_opto.pdf',fields{ff}),'-dpdf','-r0')
  1941. end
  1942. % ANOVA for SVM classified neurons
  1943. fprintf('\nDG statistics for %s, SVM types:',fields{ff});
  1944. kruskalwallisNdunns(valMtrx(:,1:5), labels(1:5));
  1945. % ANOVA for optotagged cells only
  1946. if ~all(isnan(valMtrx(:,5:6)),'all')
  1947. fprintf('\nDG statistics for %s, opto vs GC/MC:',fields{ff});
  1948. kruskalwallisNdunns(valMtrx(:,[1 6 7 4 5]), labels([1 6 7 4 5]));
  1949. end
  1950. % LMM nested data stats (SVM & Opto separately)
  1951. valTbl = get_metricfieldTbl(class_metrics, fields{ff}, 'include',include,...
  1952. 'exclude',exclude, 'criteria',criteria, 'labels',labels,...
  1953. 'transformation',transformations{ff});
  1954. %glme_stats(valTbl)
  1955. fprintf('\nDG LMM statistics for %s, SVM types:',fields{ff});
  1956. isSVM = cellfun(@(x) (any(x=={'PV','SST','MECii PC','GC','MC'})), table2cell(valTbl(:,2)));
  1957. thisTbl = valTbl(isSVM,:);
  1958. thisTbl.Group = removecats(thisTbl.Group); % Remove unused categories
  1959. glme_stats(thisTbl);
  1960. fprintf('\nDG LMM statistics for %s, opto vs GC/MC:',fields{ff});
  1961. isOpto = cellfun(@(x) (any(x=={'PV+','SST+','MECii PC','GC','MC'})), table2cell(valTbl(:,2)));
  1962. thisTbl = valTbl(isOpto,:);
  1963. thisTbl.Group = removecats(thisTbl.Group); % Remove unused categories
  1964. glme_stats(thisTbl);
  1965. end
  1966. clear include exclude criteria valGrp valMtrx valCell fields transformation...
  1967. sel fi printfig ff colors labels pos transformations
  1968. %% 5c-f DS rate responses to opto manipulations
  1969. % Control in / out of stim DS
  1970. % ts = randsample(DS2.timestamps(:,1),2000);
  1971. % ts2 = DS2.timestamps(InIntervals(DS2.timestamps(:,1),opto_1sec.timestamps),1);
  1972. % ts3 = DS2.peaks(InIntervals(DS2.peaks(:,1),opto_1sec.timestamps));
  1973. % bz_multishankEventCSD(ts,'window',[-.1 .1]);
  1974. ChRmice = {'SST2','SST4','YutaMouse20','YutaMouse21','YutaMouse37','YutaMouse38',...
  1975. 'YutaMouse39','YutaMouse40','PV1','PV3','PV5','PV16','PV18','PV19','PV21','PV29'};
  1976. HRmice = {'PV13','PV22','SST3','SST5'};
  1977. n = 0;
  1978. minPrctile = 10; % Minimum fraction of bins that is >0
  1979. evname = 'DS2'; % 'DS2','CA3ripples','ripples'
  1980. opsins = {'ChR2','eNpHR'};
  1981. lines = {'PV','SST'};
  1982. % GET DATA
  1983. clear results
  1984. for ds = 1:length(handle)
  1985. basename = handle(ds).basename;
  1986. basepath = handle(ds).basepath;
  1987. if isfile(fullfile(basepath,filesep,[basename '.' evname '.events.mat'])) &&...
  1988. isfile(fullfile(basepath,filesep,[basename '.opto_1sec.manipulation.mat']))
  1989. evt = load(fullfile(basepath,filesep,[basename '.' evname '.events.mat']),evname);
  1990. evt = evt.(evname);
  1991. load(fullfile(basepath,filesep,[basename '.opto_1sec.manipulation.mat']))
  1992. [thisCCG, PSTHts] = CCG({opto_1sec.timestamps(:,1),evt.peaks},[],...
  1993. 'binSize',.05,'duration',4,'norm','rate');
  1994. if ~prctile(thisCCG(:,1,2),100-minPrctile) > 0
  1995. % Exclude session if little or no DS detected.
  1996. continue
  1997. end
  1998. n = n+1;
  1999. results(n).name = basename;
  2000. results(n).PSTH = thisCCG(:,1,2);
  2001. results(n).ts = PSTHts;
  2002. results(n).stimrate = mean(thisCCG(InIntervals(PSTHts,[0 1]),1,2));
  2003. results(n).baserate = mean(thisCCG(~InIntervals(PSTHts,[0 1]),1,2));
  2004. results(n).pctchg = results(n).stimrate / results(n).baserate;
  2005. % Get genetic Line
  2006. if contains(handle(ds).basename,'PV')
  2007. results(n).geneticLine = 'PV-Cre';
  2008. else
  2009. results(n).geneticLine = 'SST-Cre';
  2010. end
  2011. % Get opsin
  2012. if any(strcmp(handle(ds).animal, ChRmice))
  2013. results(n).opsin = 'ChR2';
  2014. elseif any(strcmp(handle(ds).animal, HRmice))
  2015. results(n).opsin = 'eNpHR';
  2016. end
  2017. else
  2018. fprintf('%s does not have all files, continue...\n',basename);
  2019. end
  2020. end
  2021. % PLOT FIGURE
  2022. figure('position',[200 50 270 800]);
  2023. for op = 1:2
  2024. for li = 1:2
  2025. isSes = contains({results.geneticLine},lines{li}) &...
  2026. contains({results.opsin},opsins{op});
  2027. allPSTH = cat(2,results(isSes).PSTH);
  2028. plID = 1 + 3*(li-1) + 6*(op-1);
  2029. subplot(4, 3, plID:plID+1)
  2030. hold on;
  2031. % Baseline normalization / zscoring
  2032. isBsl = InIntervals(results(1).ts,[-1 0]); % Assume uniform timestamps
  2033. allPSTHz = (allPSTH - mean(allPSTH(isBsl,:),1)) ./ std(allPSTH(isBsl,:),[],1);
  2034. % PSTH (BSL-ZSCORED) & TIMECOURSE (HZ)
  2035. imagesc(results(1).ts, linspace(0,1,size(allPSTHz,1)), allPSTHz'); % Keeping y-range simple 0-1 Hz is a good range
  2036. colormap(bwyr);%'hot');
  2037. caxis([-4 4]);
  2038. set(gca,'YDir','normal')
  2039. % Overlay mean (Hz)
  2040. %plot(results(1).ts, mean(allPSTH,2), 'k', 'lineWidth',1);
  2041. shadedErrorBar(results(1).ts, mean(allPSTH,2), std(allPSTH,[],2)./sqrt(length(find(isSes))));
  2042. % Label with N;
  2043. unitstr = sprintf('N = %i',length(find(isSes)));
  2044. text(prctile(results(1).ts,70), .1, unitstr,'Color','k') % gn-gn/15
  2045. title(sprintf('%s-%2',lines{li},opsins{op}));
  2046. xlabel('Time from Stim (s)');
  2047. xlim([-1 2]);
  2048. ylabel(sprintf('%s rate (Hz)',evname));
  2049. % BOXPLOTS
  2050. subplot(4,3,plID+2);
  2051. hold on;
  2052. plot(cat(1,[results(isSes).baserate],[results(isSes).stimrate]),'color',[0 0 0 .5],'LineWidth',1);
  2053. boxplot(cat(1,[results(isSes).baserate],[results(isSes).stimrate])','symbol', '');
  2054. xticklabels({'Pre','Stim'});
  2055. ylim([0 1]);
  2056. % STATISTICS
  2057. fprintf('%s - %s, opto 1 sec DS rate\n',lines{li},opsins{op});
  2058. pairedSampleTest([results(isSes).baserate],[results(isSes).stimrate],...
  2059. 'labels',{'Baseline','Stim'},'verbose',true);
  2060. changes{op,li} = 100*[results(isSes).pctchg];
  2061. end
  2062. end
  2063. % ChR reduction numbers & comparison (text)
  2064. fprintf('\nPV-ChR DS rate stim/bsl: %.2f +/- %.2f; SST-ChR DS rate stim/bsl: %.2f +/- %.2f\n',...
  2065. nanmean(changes{1,1}), nanstd(changes{1,1}), nanmean(changes{1,2}), nanstd(changes{1,2}));
  2066. unpairedSampleTest(changes{1,1},changes{1,2},'verbose',true);
  2067. clear PSTHts n thisCCG Epath sess DS2 pulses mouse a animals Ebase sf subf...
  2068. allPSTH ChRmice HRmice li op lines opsins allPSTHz basename basepath...
  2069. ds evname evt isBsl isSes minPrctile opto_1sec plID unitstr changes
  2070. %% Supplementary 5a(1) theta CSD
  2071. % DS and Theta CSD, see LFP_analysis/LFP_scripts and Analysis/LFP folder in
  2072. % each dataset for code and figures, respectively.
  2073. %% Supplementary 5a(2) Theta-gamma CFC
  2074. % see LFP_analysis/LFP_scripts
  2075. % Load session.mat and Analysis/LFP/.THetaGammaCFC.mat e.g. from
  2076. % TH15_220706
  2077. spkg = [5 11 12];
  2078. figure('position',[100 100 1400 300]); hold on
  2079. for sh = 1:length(spkg)
  2080. cfcg = CFC.comod(:,:,session.extracellular.spikeGroups.channels{spkg(sh)});
  2081. cfcg = reshape(cfcg,size(cfcg,1),[]);
  2082. subplot(1,length(spkg),sh);
  2083. contourf(CFC.amp_bincenters, 1:size(cfcg,2), flipud(cfcg'), 40, 'LineColor','none');
  2084. colormap(jet);
  2085. clim([0 1e-3]);
  2086. end
  2087. clear shanks sh
  2088. %% Supplementary 5b: DS2 modulation Lii vs. Liii MEC
  2089. type = 'events'; % Manipulations, events
  2090. field = 'DS2'; % 'DS2','CA3ripples'
  2091. metrics = class_metrics; % batch_metrics;
  2092. minRate = 0; minPrctile = 50; % Minimum percentile of bins during baseline above minRate
  2093. printfig = false;
  2094. % Create in- and exclude structure
  2095. include = struct('brainRegion',{'ENTm2','ENTm2','ENTm3','ENTm3'},...
  2096. 'putativeCellType',{'Pyramidal','Interneuron','Pyramidal','Interneuron'});
  2097. labels = {'Lii PYR','Lii IN','Liii PYR','Liii IN'};
  2098. colors = [1 0 0; 0 0 1; 1 1 0; 0 1 1];
  2099. sel = 1:length(include); % 1:4
  2100. % include = struct('putativeCellType',cell_types,'groundTruthClassification',incl_opto);
  2101. % exclude = struct('groundTruthClassification',excl_opto);
  2102. % PSTH
  2103. f1 = figure('position',[200 20 150 180*length(sel)]);
  2104. plot_psth(metrics,field,'type',type,'labels',labels(sel),...
  2105. 'include',include(sel),...%'exclude',exclude(sel),'criteria',criteria(sel),...
  2106. 'orientation','column','SDrange',[-3 3],'overlay',true,...
  2107. 'colors',[0 0 0],'minRate',minRate,'minPrctile',minPrctile); %colors(sel,:)
  2108. if printfig
  2109. pos = get(f1,'Position');
  2110. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  2111. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  2112. print(f1,sprintf('DS2_response_MEC.pdf'),'-dpdf','-r0')
  2113. end
  2114. % PIE CHARTS
  2115. f2 = figure('position',[400 20 200 180*length(sel)]);
  2116. plot_response_piechart(metrics,'field','DS2','labels',labels(sel),'alpha',.001,...
  2117. 'include',include(sel));%,'exclude',exclude(sel),'criteria',criteria(sel));
  2118. if printfig
  2119. pos = get(f2,'Position');
  2120. set(f2,'PaperPositionMode','Auto','PaperUnits','points',...
  2121. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  2122. print(f2,sprintf('DS2_response_MECpie.pdf'),'-dpdf','-r0')
  2123. end
  2124. clear include exclude f1 f2 printfig field pos sel type ds ts psth psthNorm metrics
  2125. %% Supplementary 5c: MEC brain-state-dependent firing rates
  2126. printfig = false;
  2127. % Create in- and exclude structure
  2128. labels = {'MECii PC','MECii IN','MECiii PC','MECiii IN'};
  2129. %limrate = [8 40 8 40]; % Hard coding here, no easy fix...
  2130. %limrate = [-.5 1.2; -.5 2; -.5 1.2; -.5 2]; Log10
  2131. limrate = [0 8; 0 40; 0 8; 0 40]; % Linear
  2132. include = struct('brainRegion',{'ENTm2','ENTm2','ENTm3','ENTm3'},...
  2133. 'putativeCellType',{'Pyramidal','Interneuron','Pyramidal','Interneuron'});
  2134. exclude = struct('putativeCellType',repmat({'Unknown'},1,4),...
  2135. 'tags',repmat({{'InverseSpike','Bad'}},1,4));
  2136. colors = [1 0 0; 0 0 1; 1 0 0; 0 0 1];
  2137. f1 = figure('position',[100 100 1250 200]);
  2138. for ct = 1:4
  2139. [~,cellIDs] = select_cells(class_metrics,'include',include(ct),'exclude',exclude(ct));
  2140. rates = cat(1, class_metrics.firingRateWake(cellIDs),...
  2141. class_metrics.firingRateNREM(cellIDs), class_metrics.firingRateREM(cellIDs));
  2142. % rates = log10(rates);
  2143. rates = rates(:,~any(isnan(rates),1));
  2144. figure(f1)
  2145. ax(ct) = subplot(1,4,ct); hold(ax(ct),'on');
  2146. % Make rates heatmap in background
  2147. [~,order] = sort(rates(1,:));
  2148. imagesc(1:3, linspace(limrate(ct,1), limrate(ct,2), size(rates,2)), rates(:,order)');
  2149. colormap(bwyr);
  2150. colorbar
  2151. %clim([0 prctile(rates(:),98)]);
  2152. clim([limrate(ct,1) limrate(ct,2)]);
  2153. % % Plot lines
  2154. % plot(rates,'color',[0 0 0 .1],'LineWidth',.3);
  2155. % Plot boxes
  2156. boxplot(rates','symbol', '');
  2157. h = findobj('LineStyle','--'); set(h, 'LineStyle','-');
  2158. h = findobj(gca,'Tag','Box');
  2159. for j=1:length(h)
  2160. patch(get(h(j),'XData'),get(h(j),'YData'),colors(ct,:),'FaceAlpha',.7);
  2161. end
  2162. % Markup
  2163. title(labels{ct});
  2164. ylabel('Firing Rate (Hz)');
  2165. % yticklabels('');
  2166. xticklabels({'Wake','NREM','REM'});
  2167. xtickangle(45);
  2168. ylim([limrate(ct,1) limrate(ct,2)]);
  2169. % else
  2170. % % subplot(1,4,ct-4);
  2171. % % Just add lines for opto-positive cells
  2172. % plot(ax(ct-4),rates,'color',[colors(ct,:) .25],'LineWidth',.5);
  2173. % end
  2174. % Stats (repeated measures ANOVA on ranks)
  2175. fprintf([labels{ct} '\n'])
  2176. kruskalwallisNdunns(rates',{'Wake','NREM','REM'});
  2177. % TODO: Log transform and repeated measures
  2178. %rates = rates(:,~any(rates == 0,1)); % Remove zeros to avoid prob w/ log transform
  2179. %rates = log10(rates);
  2180. %rates = array2table(rates','VariableNames',{'Wake','NREM','REM'});
  2181. %anovan(rates);
  2182. end
  2183. if printfig
  2184. pos = get(f1,'Position');
  2185. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  2186. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  2187. print(f1,sprintf('StateRates_psth.pdf'),'-dpdf','-r0')
  2188. end
  2189. clear ct h field j rates f1 wi order pos printfig ax cellIDs colors exclude...
  2190. include labels limrate
  2191. %% Figure 6
  2192. %% 6a,c PSTH 1 sec pulses - row-wise, all, include direct-activated cells
  2193. % TODO: Run class_metrics = reclassifyOptoResponses2(class_metrics); prior
  2194. % to this! -- make sure addAmbiguousResponse was run
  2195. type = 'manipulations'; % Manipulations, events
  2196. field = 'opto_1sec'; %'opto_chirp_freq','opto_1sec'
  2197. sortCriterion = '_modulationSD'; % '_modulationSD' (default) or '_peakFreq' for chirp
  2198. baseline = [-Inf -.005]; % [-Inf 0] standard, [4 40] for freq
  2199. lines = {'PV-Cre','SST-Cre'};
  2200. opsins = {'eNpHR','ChR2'};%'eNpHR' 'ChR2'
  2201. printfig = true;
  2202. minRate = 0; minPrctile = 1; % Minimum percentile of bins during baseline above minRate
  2203. % Create in- and exclude structure
  2204. %labels = {'PV','SST','GC','MC'};
  2205. include = struct('putativeCellType',{'','PV interneuron','SST interneuron',...
  2206. 'Granule Cell','Mossy Cell'}, 'brainRegion','DG',...
  2207. 'groundTruthClassification',cat(2,{'+'},repmat({''},1,4)));
  2208. exclude = struct('groundTruthClassification',cat(2,{''},repmat({{'+','~'}},1,4)),... % {{'+'}},{{'+','~'}}
  2209. 'tags',repmat({{'Bad','InverseSpike'}},1,5),'putativeCellType',repmat({'Unknown'},1,5));
  2210. % Plot
  2211. f1 = figure('position',[200 200 600 550]);
  2212. for op = 1:2
  2213. [include.labels] = deal(opsins{op});
  2214. for li = 1:2
  2215. [include.geneticLine] = deal(lines{li});
  2216. for ct = 1:5
  2217. subplot(4,5,ct + 5*(li-1) + 10*(op-1));
  2218. plot_psth(class_metrics,field,'type',type,'labels',{''},...%labels(ct),...
  2219. 'include',include(ct),'exclude',exclude(ct),...
  2220. 'colors',[0 0 0],'minRate',minRate,'minPrctile',minPrctile,... %'colors',colors(sel,:)
  2221. 'sortCriterion',sortCriterion,'baseline',baseline,'shadedErrorBar',false);
  2222. if ~(op == 2 && li == 2); xlabel(''); end
  2223. if ~(ct == 1); ylabel(''); end
  2224. end
  2225. end
  2226. end
  2227. % Save figure
  2228. if printfig
  2229. pos = get(f1,'Position');
  2230. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  2231. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  2232. print(f1, '1secPSTH_all.pdf','-dpdf','-r0')
  2233. end
  2234. clear include exclude f1 f2 printfig field pos sel type ds ts psth psthNorm ct li op...
  2235. lines opsins include exclude minRate minPrctile sortCriterion
  2236. %% 6b,d Firing rate ratio during / pre 1 sec pulses (PV vs. SST)
  2237. fields = {'opto_1sec_modulationRatio'}; % 4c,d 'DS2_modulationSD','opto_1sec_modulationSD','opto_1sec_modulationIndex'
  2238. transformations = {'log2'}; % 4c,d -- set 'divFactor' in distribution plot to "1" for peakResponse time!
  2239. opsin = 'eNpHR'; % 'eNpHR' for b), 'ChR' for d)
  2240. printfig = false;
  2241. % Create in- and exclude structure
  2242. labels = {'PV-Cre','SST-Cre'};
  2243. statlabels = cat(1,strcat({'PV','SST','GC','MC'},'-',labels{1}),...
  2244. strcat({'PV','SST','GC','MC'},'-',labels{2}));
  2245. include = struct('putativeCellType',{'PV','PV','SST','SST',...
  2246. 'Granule','Granule','Mossy','Mossy'});
  2247. [include(1:2:end).geneticLine] = deal('PV-Cre');
  2248. [include(2:2:end).geneticLine] = deal('SST-Cre');
  2249. [include.labels] = deal(opsin);
  2250. exclude = struct('groundTruthClassification',{{'+','~'}},...
  2251. 'tags',{{'Bad','InverseSpike'}},'putativeCellType',{'Unknown'});
  2252. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; .56 .39 .93; 0 .72 .53];
  2253. for ff = 1:length(fields)
  2254. % Plotting
  2255. f1 = figure('position',[200*ff 450 200 230]); % Same aspect ratio
  2256. hold on
  2257. [~, valMtrx, ~] = plot_metricfield(class_metrics,fields{ff},...
  2258. 'include',include,'exclude',exclude,...
  2259. 'transformation',transformations{ff},'tukeyFence',3,'labels',repmat(labels,1,4),...
  2260. 'colors',colors([1 1 2 2 3 3 4 4],:),'plottype','violin',...
  2261. 'divFactor',1);
  2262. % Zero-line
  2263. plot([0 length(include)+1],[0 0],':','color',[.5 .5 .5]);
  2264. % Statistics
  2265. fprintf('\nDG statistics for %s, SVM types:',fields{ff});
  2266. kruskalwallisNdunns(valMtrx,strcat(repmat(...
  2267. {'PV-Cre:','SST-Cre:'},1,4),{include.putativeCellType}));
  2268. % LMM nested data stats (SVM & Opto separately)
  2269. valTbl = get_metricfieldTbl(class_metrics, fields{ff}, 'include',include,...
  2270. 'exclude',exclude, 'labels',statlabels(:), 'transformation',transformations{ff});
  2271. %glme_stats(valTbl)
  2272. fprintf('\nDG LMM statistics for %s:',fields{ff});
  2273. glme_stats(valTbl);
  2274. end
  2275. if printfig
  2276. pos = get(f1,'Position');
  2277. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  2278. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  2279. print(f1,sprintf('Fig6b+d_%s_1sec_ratioViolin.pdf',opsin),'-dpdf','-r0')
  2280. end
  2281. clear include exclude thiscriteria values fields transformations valCell...
  2282. valGrp valMtrx ff opsin colors labels f1 pos
  2283. %% 6e,f + S8a-d: 1 sec single-trial Lorenz Curves, gini-diff & CV
  2284. % Create in- and exclude structure
  2285. printfig = false;
  2286. labels = {'PV-HR','SST-HR','PV-ChR','SST-ChR'};
  2287. include = struct('putativeCellType',{'PV interneuron','SST interneuron',...
  2288. 'Granule Cell','Mossy Cell'});
  2289. %exclude = struct('groundTruthClassification',{{'+'},{'+'},{'+'},{'+'}});
  2290. exclude = struct('groundTruthClassification',{{'+','~'}},...
  2291. 'tags',{{'Bad','InverseSpike'}},'putativeCellType',{'Unknown'});
  2292. lines = {'PV-Cre','SST-Cre'};
  2293. opsins = {'eNpHR','ChR2'};
  2294. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; .56 .39 .93; 0 .72 .53];
  2295. fields = {'gini','CV'}; % For errorbar plots (diff stim vs bsl)
  2296. % Get Lorenz curves, gini, CV
  2297. if ~exist('LorRes','var') % Takes long to load
  2298. for li = [1 2] % PV-Cre / SST-Cre
  2299. [include.geneticLine] = deal(lines{li});
  2300. for op = [1 2] % eNpHR / ChR
  2301. [include.labels] = deal(opsins{op});
  2302. fprintf('%s, %s\n',lines{li},opsins{op});
  2303. LorRes{li,op} = get_1sec_Lorenz_Curves(class_metrics,...
  2304. 'include',include,'exclude',exclude,'show_results',false,...
  2305. 'minNspikes',1, 'minNcells',4);
  2306. end
  2307. end
  2308. end
  2309. % LORENZ CURVES
  2310. f1= figure('position',[100 100 500 450]); hold on;
  2311. for li = 1:2
  2312. for op = 1:2
  2313. for ct = 1:length(include)
  2314. subplot(4,length(include),ct + (op-1)*length(include) + (li-1)*2*length(include))
  2315. % Plot eNpHR results
  2316. plot([0 100],[0 1],':','color',[.5 .5 .5]);
  2317. nSess = length(find(LorRes{li,op}.nCells(:,ct)>0));
  2318. shadedErrorBar(1:100, nanmean(LorRes{li,op}.MeanLorenzCurveNorm(:,:,ct,1),1),...
  2319. nanstd(LorRes{li,1}.MeanLorenzCurveNorm(:,:,ct,1),1)./sqrt(nSess),...
  2320. 'lineprops',{'color',colors(ct,:)});
  2321. shadedErrorBar(1:100, nanmean(LorRes{li,op}.MeanLorenzCurveNorm(:,:,ct,2),1),...
  2322. nanstd(LorRes{li,1}.MeanLorenzCurveNorm(:,:,ct,2),1)./sqrt(nSess),...
  2323. 'lineprops',{'color',[.5 .5 .5]});
  2324. text(10,.8,sprintf('%s\n%s',lines{li},opsins{op}),'FontSize',8);
  2325. drawnow
  2326. end
  2327. end
  2328. end
  2329. % Save figure
  2330. if printfig
  2331. pos = get(f1,'Position');
  2332. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  2333. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  2334. print(f1,'Fig_6e_S7a_LorenzCurves.pdf','-dpdf','-r0')
  2335. end
  2336. % PLOT GINI, CV, ETC
  2337. for ff = 1:2
  2338. % GET VALUES
  2339. stvals = cat(1, LorRes{1,1}.(fields{ff})(:,:,1), LorRes{2,1}.(fields{ff})(:,:,1),...
  2340. LorRes{1,2}.(fields{ff})(:,:,1), LorRes{2,2}.(fields{ff})(:,:,1)); % To sort by condition, cat(2,... and omit reshape
  2341. blvals = cat(1, LorRes{1,1}.(fields{ff})(:,:,2), LorRes{2,1}.(fields{ff})(:,:,2),...
  2342. LorRes{1,2}.(fields{ff})(:,:,2), LorRes{2,2}.(fields{ff})(:,:,2));
  2343. stvals = reshape(stvals, size(LorRes{1,1}.gini,1), length(include)*length(lines)*length(opsins));
  2344. blvals = reshape(blvals, size(LorRes{1,1}.gini,1), length(include)*length(lines)*length(opsins));
  2345. % RAW VALUES (DUAL VIOLIN PLOTS)
  2346. figure('position',[100 100 500 150]); hold on;
  2347. % baseline (left, grey)
  2348. plotSpread(blvals,'spreadFcn',{'lin',10},...
  2349. 'spreadWidth',.9,'distributionColors',[.5 .5 .5],'distributionMarkerSize',3,...
  2350. 'spreadOri','left','distributionMarkerAlpha',.5,'distributionMarkers','o');
  2351. distributionPlot(blvals,'histOri','left','color',[0 0 0],...
  2352. 'widthDiv',[2 1],'showMM',6,'FaceAlpha',.5);
  2353. % Stim (right)
  2354. plotSpread(stvals,'spreadFcn',{'lin',10},... % [sic!], use wider (10) spread here 2/2 lower n datapoints
  2355. 'spreadWidth',.9,'distributionColors',[.5 .5 .5],'distributionMarkerSize',3,...
  2356. 'spreadOri','right','distributionMarkerAlpha',.5,'distributionMarkers','o');
  2357. distributionPlot(stvals,'histOri','right','color',num2cell(colors([1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4],:),2),...
  2358. 'widthDiv',[2 2],'showMM',6,'FaceAlpha',.5);
  2359. %ylim([.4 1.1]);
  2360. ylabel(fields{ff});
  2361. % STIM-BSL DELTA PLOT
  2362. f1 = figure('position',[100 100 400 250]); hold on;
  2363. % distributionPlot(stvals-blvals,'showMM',6,'FaceAlpha',.5,'histOpt',1,'divFactor',1,...
  2364. % 'color',num2cell(colors([1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4],:),2));
  2365. plot([0 size(stvals,2)+1],[0 0],'--','Color',[.5 .5 .5]); % Zero line
  2366. plotSpread(stvals-blvals,'spreadFcn',{'lin',5},...
  2367. 'spreadWidth',.9,'distributionColors',[0 0 0],'distributionMarkerSize',4,...
  2368. 'distributionMarkerAlpha',1,'distributionMarkers','o');
  2369. customErrorBar(stvals-blvals, 'errtype','STD', 'alpha',.7,...
  2370. 'markerSize',100, 'LineWidth',1.2,...
  2371. 'colors',colors([1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4],:));
  2372. xlim([0 size(stvals,2)+1]);
  2373. %ylim([-.3 .4]);
  2374. ylabel(sprintf('%s (stim-bsl)',fields{ff}));
  2375. xticklabels(repmat(labels,1,4));
  2376. xtickangle(45);
  2377. % Save figure
  2378. if printfig
  2379. pos = get(f1,'Position');
  2380. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  2381. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  2382. print(f1,sprintf('Opto_1sec_%s_change.pdf',fields{ff}),'-dpdf','-r0')
  2383. end
  2384. % STATISTICS
  2385. for ct = 1:length(include)
  2386. clear blvals stvals groupVals
  2387. % Statistics @console
  2388. fprintf('\n%s:',include(ct).putativeCellType)
  2389. fprintf('\n%s (raw p):\n',fields{ff}) % For statistics in console
  2390. for li = 1:2
  2391. for op = 1:2
  2392. blvals(:,li,op) = LorRes{li,op}.(fields{ff})(:,ct,2); % nSess x nGroup(ct) x [1 (stim) 2 (bsl)]
  2393. stvals(:,li,op) = LorRes{li,op}.(fields{ff})(:,ct,1);
  2394. try
  2395. pvals(ct,li,op) = pairedSampleTest(blvals(:,li,op), stvals(:,li,op),...
  2396. 'labels',{'baseline','stim'},'verbose',true);
  2397. catch
  2398. pvals(ct,li,op) = NaN;
  2399. fprintf('\n');
  2400. end
  2401. end
  2402. end
  2403. % ANOVA
  2404. groupVals = reshape(stvals-blvals, size(stvals,1), size(stvals,2)*size(stvals,3));
  2405. fprintf('%s ANOVA:\n',fields{ff})
  2406. kruskalwallisNdunns(groupVals, labels);
  2407. end
  2408. % Multi-Comparison Corrected p-values
  2409. padj = multCompCorr(pvals,'method','Dunn-Sidak'); % 'Holm-Bonferroni', 'Dunn-Sidak'
  2410. fprintf('%s (adjusted p-values):\n',fields{ff});
  2411. for op = [1 2]
  2412. for li = [1 2]
  2413. for ct = 1:length(include)
  2414. fprintf('%s-%s: %s (stim vs. bsl), p = %.4g\n',lines{li}, opsins{op},...
  2415. include(ct).putativeCellType, padj(ct,li,op));
  2416. end
  2417. end
  2418. end
  2419. end
  2420. clear labels include exclude lines opsins li ct op f1 f2 colors color...
  2421. limrate pvals ncolors labels baseMLD stimMLD isGoodID baserates blvals...
  2422. stimrates stvals f1 fields ff pos nSess printfig
  2423. %% 6g + S6k: Scatter baseline vs. stim rates & Correlation
  2424. % Create in- and exclude structure
  2425. labels = {'PV','SST','GC','MC'};
  2426. include = struct('putativeCellType',{'PV interneuron','SST interneuron',...
  2427. 'Granule Cell','Mossy Cell'});
  2428. %exclude = struct('groundTruthClassification',{{'+'},{'+'},{'+'},{'+'}});
  2429. exclude = struct('groundTruthClassification',{{'+','~'}},...
  2430. 'tags',{{'Bad','InverseSpike'}},'putativeCellType',{'Unknown'});
  2431. lines = {'PV-Cre','SST-Cre'};
  2432. opsins = {'eNpHR','ChR2'};
  2433. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; .56 .39 .93; 0 .72 .53];
  2434. printfig = true;
  2435. f1 = figure('position',[100 150 600 600]);
  2436. % Plot Lorenz curves
  2437. for li = [1 2] % PV-Cre / SST-Cre
  2438. [include.geneticLine] = deal(lines{li});
  2439. for op = [1 2] % eNpHR / ChR
  2440. [include.labels] = deal(opsins{op});
  2441. for ct = 1:length(include)
  2442. [~,baserates{ct,li,op},~] = get_metricfield(class_metrics,...
  2443. 'firingRate',... % 'firingRate', opto_1sec_baseRate
  2444. 'include',include(ct),'exclude',exclude,'omitnan',false,...
  2445. 'tukeyFence',Inf);
  2446. [~,stimrates{ct,li,op},~] = get_metricfield(class_metrics,...
  2447. 'opto_1sec_modulationRatio','include',include(ct),...
  2448. 'exclude',exclude,'omitnan',false,'tukeyFence',Inf);
  2449. stimrates{ct,li,op} = stimrates{ct,li,op}.* baserates{ct,li,op};
  2450. baserates{ct,li,op} = baserates{ct,li,op}(...
  2451. ~isnan(stimrates{ct,li,op}) & ~isinf(stimrates{ct,li,op}));
  2452. stimrates{ct,li,op} = stimrates{ct,li,op}(...
  2453. ~isnan(stimrates{ct,li,op}) & ~isinf(stimrates{ct,li,op}));
  2454. % PLOT Rate scatter
  2455. figure(f1);
  2456. subplot(4,4,op+(ct-1)*4+(li-1)*2); hold on
  2457. title(sprintf('%s %s, %s',labels{ct},lines{li},opsins{op}))
  2458. scatter(baserates{ct,li,op},stimrates{ct,li,op},...
  2459. 3, colors(ct,:), 'o', 'filled', 'MarkerFaceAlpha',.5);
  2460. set(gca,'XScale','log');
  2461. set(gca,'YScale','log');
  2462. xlim([1e-3 1e2])
  2463. ylim([1e-3 1e2])
  2464. if ct == 4; xlabel('Bsl Rate (log)'); end
  2465. if li==1 & op == 1; ylabel('Stim Rate (log)'); end
  2466. set(gca,'fontsize',10);
  2467. drawnow
  2468. clear plotrates baseplot stimplot
  2469. if ~isempty(baserates{ct,li,op})
  2470. [R,pval] = corr(baserates{ct,li,op}, stimrates{ct,li,op});
  2471. text(1e-2,1e-2,sprintf(...
  2472. 'R = %.2f\np = %.2g',R,pval),'FontSize',10);
  2473. fprintf('%s-%s, %s: R = %.2f p = %.4g, N = %i\n',lines{li},...
  2474. opsins{op},labels{ct},R,pval,length(baserates{ct,li,op}))
  2475. end
  2476. end
  2477. end
  2478. end
  2479. % Save figure
  2480. if printfig
  2481. pos = get(f1,'Position');
  2482. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  2483. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  2484. print(f1,'Fig6g_FigS8g_BslStimRateScatter.pdf','-dpdf','-r0')
  2485. end
  2486. clear labels include exclude lines opsins li ct op f1 f2 colors color...
  2487. limrate pvals ncolors labels baseMLD stimMLD isGoodID baserates blvals...
  2488. stimrates stvals
  2489. %% Suppl 6a Examples of direct and indirect light-responsive cells
  2490. % direct: PV3_230502 UID 108 (pPV, PV+); indirect: PV1_230426, UID 4 (MC)
  2491. % Load cell_metrics, spikes, opto_1sec
  2492. color = colors(1,:); % 4=MC, 1 = pPV
  2493. UID = 108;
  2494. printfig = true;
  2495. % ACG
  2496. acgT = cell_metrics.general.ccg_time;
  2497. acgBinSz = mean(diff(acgT));
  2498. acgEdg = [acgT-acgBinSz/2; acgT(end)+acgBinSz/2]';
  2499. % Plot ACG
  2500. f1 = figure('position',[200 200 400 215]);
  2501. subplot(1,2,1); hold on;
  2502. histogram('BinEdges',acgEdg,'BinCounts',...
  2503. cell_metrics.general.ccg(:,UID,UID),...
  2504. 'FaceColor',color,'FaceAlpha',1,'LineStyle','none');
  2505. title(sprintf('%s (%i)',cell_metrics.putativeCellType{UID},UID));
  2506. xlabel('Time (s)');
  2507. % Plot Raster
  2508. subplot(1,2,2);
  2509. bz_eventRasterplot(spikes,opto_1sec.timestamps(1:200,:),UID,'periEvtWdw',.5,...
  2510. 'color',color,'subsample',5);
  2511. sgtitle(cell_metrics.general.basename);
  2512. % Save figure if desired
  2513. if printfig
  2514. pos = get(f1,'Position');
  2515. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  2516. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  2517. print(f1,sprintf('%s-UID %i',cell_metrics.general.basename,UID),'-dpdf','-r0')
  2518. end
  2519. clear acgT acgBinSz acgEdg color UID printfig pos f1
  2520. %% Suppl 6b: 10 ms - 1 sec side by side w/ correlations
  2521. geneticLine = '';%'PV-Cre';
  2522. opsin = 'ChR2'; % 'eNpHR','ChR2'
  2523. field = 'opto_10ms';
  2524. labels = {'rapid','delayed pPV','delayed pSST','delayed pGC','delayed pMC'};
  2525. nGr = 5;
  2526. printfig = true;
  2527. % EVENT SELECTION
  2528. type = 'manipulations'; % Manipulations, events
  2529. sortCriterion = '_modulationIndex'; % '_modulationSD' '_modulationIndex'(default) or '_peakFreq' for chirp
  2530. % CELL SELECTION
  2531. include = struct('putativeCellType',{'','PV interneuron','SST interneuron',...
  2532. 'Granule Cell','Mossy Cell'}, 'brainRegion',repmat({'DG'},1,nGr),...
  2533. 'groundTruthClassification',{{'+'},{''},{''},{''},{''}},...
  2534. 'labels',repmat({opsin},1,nGr),'geneticLine',repmat({geneticLine},1,nGr));
  2535. exclude = struct('putativeCellType',repmat({'Unknown'},1,nGr),...
  2536. 'tags',repmat({{'InverseSpike','Bad'}},1,nGr), 'groundTruthClassification',...
  2537. {{},{'+','~'},{'+','~'},{'+','~'},{'+','~'}});
  2538. % {{},{'+'},{'+'},{'+'},{'+'}});
  2539. criteria = struct('UID',repmat({[0 Inf]},1,nGr),...
  2540. 'opto_1sec_modulationSignificanceLevelevt',repmat({[0 .01]},1,nGr),...
  2541. 'opto_1sec_modulationRatio',repmat({[1.1 Inf]},1,nGr));
  2542. % Get timestamps
  2543. for b = 1:length(class_metrics.general.batch)
  2544. if isfield(class_metrics.general.batch{b},'manipulations') &...
  2545. isfield(class_metrics.general.batch{b}.manipulations,field)
  2546. %hasfield(b) = isfield(metrics.general.batch{b}.(type),field);
  2547. tss = class_metrics.general.batch{b}.manipulations.(field).x_bins;
  2548. tsl = class_metrics.general.batch{b}.manipulations.opto_1sec.x_bins; % ASSUME 1 sec is in all opto recordings
  2549. end
  2550. end
  2551. % PLOT
  2552. f1 = figure('position',[200 20 650 145*nGr]); % Same abs height
  2553. for gr = 1:nGr
  2554. % Get PSTHs
  2555. [short_psth, ~, sUIDs] = extract_psth(class_metrics, field, 'type',type,...
  2556. 'include',include(gr),'exclude',exclude(gr),'criteria',criteria(gr),...
  2557. 'sortCriterion',sortCriterion);
  2558. [long_psth, ~, lUIDs] = extract_psth(class_metrics, 'opto_1sec', 'type',type,...
  2559. 'include',include(gr),'exclude',exclude(gr),'criteria',criteria(gr),...
  2560. 'sortCriterion',sortCriterion);
  2561. % Match IDs between plots
  2562. overlap = intersect(sUIDs, lUIDs);
  2563. [~,lLoc] = ismember(sUIDs,lUIDs);
  2564. lLoc = lLoc(lLoc>0);
  2565. % Plot Short PSTH
  2566. subplot(5,4,[4*(gr-1)+1 4*(gr-1)+2]);
  2567. display_psth(short_psth(ismember(sUIDs,overlap),:),'ts',tss*1e3,...
  2568. 'minPrctile',0,'x_units','ms','minSD',.5);
  2569. xlim([-10 30]);
  2570. % Plot Long PSTH
  2571. subplot(5,4,4*(gr-1)+3);
  2572. display_psth(long_psth(lLoc,:),'ts',tsl,'x_units','s',...
  2573. 'minPrctile',0,'minSD',.5); % Take out long-only entries
  2574. % Plot Modulation-Ratio correlations
  2575. subplot(5,4,4*(gr-1)+4);
  2576. % Rank-order correlations
  2577. sranks = tiedrank(class_metrics.([field sortCriterion])(overlap));
  2578. lranks = tiedrank(class_metrics.(['opto_1sec' sortCriterion])(overlap));
  2579. isvalid = ~isnan(sranks) & ~isnan(lranks);
  2580. N(gr) = length(find(isvalid));
  2581. scatterWreg(sranks(isvalid)',lranks(isvalid)');
  2582. if gr == nGr; xlabel('Rank 5 ms'); end
  2583. ylabel('Rank 1 sec');
  2584. [R(gr),pRank(gr)] = corr(sranks(isvalid)',lranks(isvalid)');
  2585. end
  2586. % Save figure if desired
  2587. if printfig
  2588. pos = get(f1,'Position');
  2589. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  2590. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  2591. print(f1,'FigS6b_Opto_shortVSlong.pdf','-dpdf','-r0')
  2592. end
  2593. % Multi-comparison correction for correlation p-values to console
  2594. pRanks = multCompCorr(pRank,'method','Dunn-Sidak');
  2595. for gr = 1:nGr
  2596. fprintf('%s: N = %i, R = %.2f, p(raw) = %.4g, p(Dunn-Sidak) = %.4g\n',...
  2597. labels{gr}, N(gr), R(gr), pRank(gr), pRanks(gr));
  2598. end
  2599. clear include exclude nGr gr field type labels minRate minPrctile baseline...
  2600. sortCriterion printfig f1 pos colors R labels pRank pRanks lranks sranks...
  2601. long_psth short_psth tsl tss N
  2602. %% Suppl 6c Pie-Chart 1 sec pulses - row-wise, all
  2603. lines = {'PV-Cre','SST-Cre'};
  2604. opsins = {'eNpHR','ChR2'};%'eNpHR' 'ChR2'
  2605. printfig = true;
  2606. % Create in- and exclude structure
  2607. %labels = {'PV','SST','GC','MC'};
  2608. include = struct('putativeCellType',{'PV interneuron','SST interneuron',...
  2609. 'Granule Cell','Mossy Cell'},'brainRegion','DG');
  2610. exclude = struct('groundTruthClassification',{{'+','~'}},...
  2611. 'tags',{{'Bad','InverseSpike'}},'putativeCellType',{'Unknown'});
  2612. % Plot
  2613. f1 = figure('position',[200 200 700 700]);
  2614. for op = 1:2
  2615. [include.labels] = deal(opsins{op});
  2616. for li = 1:2
  2617. [include.geneticLine] = deal(lines{li});
  2618. for ct = 1:4
  2619. subplot(4,4,ct + 4*(li-1) + 8*(op-1));
  2620. plot_response_piechart(class_metrics,'labels',{''},'alpha',.01,...
  2621. 'signfield','_modulationSignificanceLevelevt','minchange',.1,...
  2622. 'include',include(ct),'exclude',exclude);
  2623. drawnow
  2624. end
  2625. end
  2626. end
  2627. % Save figure
  2628. if printfig
  2629. pos = get(f1,'Position');
  2630. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  2631. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  2632. print(f1,'FigS6c_ChR_eNpHR_1sec_piechart.pdf','-dpdf','-r0')
  2633. end
  2634. clear include exclude f1 f2 printfig field pos sel type ds ts psth psthNorm ct li op...
  2635. lines opsins include exclude
  2636. %% Suppl 6d,f: Classification of direct- and indirect responding cells
  2637. % For S6d, run this with metrics classified on all PV and SST data
  2638. % (see below for instructions for eNpHR trained classifier control).
  2639. % General
  2640. labels = {'PV','SST','GC','MC'};
  2641. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7];
  2642. printfig = true;
  2643. % CELL SELECTION
  2644. classinclude = struct('putativeCellType',{'PV interneuron','SST interneuron','Granule Cell','Mossy Cell'},...
  2645. 'labels',repmat({'ChR2'},1,4),'brainRegion',repmat({'DG'},1,4));
  2646. trueinclude = struct('putativeCellType',{'','','Granule Cell','Mossy Cell'},...
  2647. 'groundTruthClassification',{{'PV+'},{'SST+'},{''},{''}},...
  2648. 'labels',repmat({'ChR2'},1,4),'brainRegion',repmat({'DG'},1,4));
  2649. exclude = struct('putativeCellType',{'Unknown'},'tags',{{'InverseSpike','Bad'}});
  2650. % GET TRAINING AND CLASSIFIER LABELS
  2651. trueLbl = NaN(1,length(batch_metrics.UID));
  2652. classLbl = NaN(1,length(class_metrics.UID));
  2653. for ii = 4:-1:1 % Do reverse to make sure opto+ can overwrite classifier results (1 MC opto+ in PV mice).
  2654. [~,selected] = select_cells(batch_metrics,'include',trueinclude(ii),...
  2655. 'exclude',exclude);
  2656. trueLbl(selected) = ii;
  2657. end
  2658. for ii = 4:-1:1
  2659. [~,selected] = select_cells(class_metrics,'include',classinclude(ii),...
  2660. 'exclude',exclude);
  2661. classLbl(selected) = ii;
  2662. end
  2663. % Make confusion matrix
  2664. figure; cm = confusionchart(confusionmat(...
  2665. trueLbl,classLbl),{'1 PV','2 SST','3 GC','4 MC'});
  2666. cm.RowSummary = 'row-normalized';
  2667. cm.ColumnSummary = 'column-normalized';
  2668. % PIE CHART FOR 10ms AND 1 sec RESPONSIVE CELLS
  2669. [~,ChRpv] = select_cells(batch_metrics,'include',trueinclude(1),'exclude',exclude);
  2670. [~,ChRsst] = select_cells(batch_metrics,'include',trueinclude(2),'exclude',exclude);
  2671. % Cells w/ pos response during 1 sec stimulus (PV- and SST-ChR2 mice, respectively)
  2672. [~,pv1secResp] = select_cells(class_metrics,...
  2673. 'include',struct('brainRegion',{'DG'},'labels',{'ChR2'},'geneticLine',{'PV-Cre'}),...
  2674. 'exclude',struct('groundTruthClassification',{{'+','~'}},'putativeCellType',{'Unknown'},...
  2675. 'tags',{{'InverseSpike','Bad'}}),...
  2676. 'criteria',struct('opto_1sec_modulationSignificanceLevel',[0 .01],...
  2677. 'opto_1sec_modulationRatio',[1.1 Inf]));
  2678. [~,sst1secResp] = select_cells(class_metrics,...
  2679. 'include',struct('brainRegion',{'DG'},'labels',{'ChR2'},'geneticLine',{'SST-Cre'}),...
  2680. 'exclude',struct('groundTruthClassification',{{'+','~'}},...
  2681. 'putativeCellType',{'Unknown'},'tags',{{'InverseSpike','Bad'}}),...
  2682. 'criteria',struct('opto_1sec_modulationSignificanceLevel',[0 .01],...
  2683. 'opto_1sec_modulationRatio',[1.1 Inf]));
  2684. % Make pie chart w/ labels
  2685. f1 = figure('position',[200 200 300 300]);
  2686. groups = {ChRpv,ChRsst,pv1secResp,sst1secResp};
  2687. titles = {'PV-Cre direct','SST-Cre direct','PV-Cre indirect','SST-Cre indirect'};
  2688. for gr = 1:4
  2689. subplot(2,2,gr);
  2690. theselbl = classLbl(groups{gr});
  2691. theselbl = theselbl(~isnan(theselbl));
  2692. Ncells = histcounts(theselbl,[.5 1.5 2.5 3.5 4.5]);
  2693. pie(Ncells);%,labels);
  2694. ax = gca; ax.Colormap = colors;
  2695. title(titles{gr},'FontSize',8);
  2696. fprintf('%s: %s: %i/%i, %s: %i/%i, %s: %i/%i, %s: %i/%i\n',titles{gr},...
  2697. labels{1},Ncells(1),sum(Ncells),labels{2},Ncells(2),sum(Ncells),...
  2698. labels{3},Ncells(3),sum(Ncells),labels{4},Ncells(4),sum(Ncells))
  2699. end
  2700. % Save figure
  2701. if printfig
  2702. pos = get(f1,'Position');
  2703. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  2704. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  2705. print(f1,'1sec_direct_indirect_Pie.pdf','-dpdf','-r0')
  2706. end
  2707. clear colors labels classinclude ChRpv ChRsst sst1secResp pv1secResp classLbl trueLbl...
  2708. groups title pos printfig f1 theselbl Ncells ax cellIDs chrIDs sstIDs
  2709. %% Suppl 6e: eNpHR -> ChR cross validation
  2710. % Re-run classifier training (DG_IN_Scripts/Make table for classifier
  2711. % learning and include 'labels',{'eNpHR'} in include criteria for PV+ and
  2712. % SST+ cells. Apply SVM across full dataset (include all cells).
  2713. % Then run the section above (Fig 6d,f, 'Classification of direct and indirect
  2714. % responding cells').
  2715. %% Suppl 6g,h: opto_1sec_modulationPeakResponseTime, spikeJitter
  2716. field = 'opto_1sec_modulationPeakResponseTime'; % 'opto_1sec_modulationPeakResponseTime','opto_1sec_spikeJitter' 'opto_1sec_peak_ratio'
  2717. thisYlabel = 'Peak Response Time (s)'; % 'Peak Response Time (s)', 'Spike jitter (s)'
  2718. labels = {'rapid','PV','SST','GC','MC'};
  2719. transformation = ''; % '', 'log2', 'log10'
  2720. printfig = true;
  2721. nGr = 5;
  2722. include = struct('putativeCellType',{'','PV interneuron','SST interneuron',...
  2723. 'Granule Cell','Mossy Cell'}, 'brainRegion',repmat({'DG'},1,nGr),...
  2724. 'groundTruthClassification',{{'+'},{''},{''},{''},{''}},...
  2725. 'labels',repmat({'ChR2'},1,5));
  2726. exclude = struct('groundTruthClassification',{{},{'+','~'},{'+','~'},{'+','~'},{'+','~'}},...
  2727. 'putativeCellType',repmat({'Unknown'},1,5),...
  2728. 'tags',repmat({{'InverseSpike','Bad'}},1,nGr));
  2729. criteria = struct('opto_1sec_modulationSignificanceLevelevt',...
  2730. {[0 1],[0 .01],[0 .01],[0 .01],[0 .01]},...
  2731. 'opto_1sec_modulationRatio',{[-Inf Inf],[1.1 Inf],[1.1 Inf],[1.1 Inf],[1.1 Inf]});
  2732. colors = {[1 .2 .2],[.56 .39 .93], [0 .72 .53], [.83 .78 .46], [.9 0 .7]};
  2733. [valGrp, valMtrx, valCell] = get_metricfield(class_metrics,field,...
  2734. 'include',include, 'exclude',exclude, 'criteria',criteria,...
  2735. 'transformation',transformation, 'tukeyFence',3);
  2736. % Plotting
  2737. f1 = figure('position',[200 450 140 170]); % Same aspect ratio
  2738. hold on
  2739. % Plot spread for SVM classified cell types
  2740. plotSpread(valGrp(:,1),'distributionIdx',...
  2741. valGrp(:,2),'spreadFcn',{'xp',[]},'spreadWidth',.9,...
  2742. 'distributionColors',[0 0 0],...
  2743. 'distributionMarkerSize',1,'binWidth',.05);
  2744. % Plot only svm classified cell types as violin plots
  2745. distributionPlot(valCell,'color',colors,...
  2746. 'showMM',6,'distWidth',.9,'addSpread',0,'histOpt',1,'divFactor',1,...
  2747. 'FaceAlpha',.5);
  2748. xticklabels(labels);
  2749. xtickangle(45);
  2750. ylabel(thisYlabel); % 'Peak Response Time (s)', 'Spike jitter (s)'
  2751. ylim([-.5 1.5]); % [-.5 1.5] For peak response time, [-.1 .4] for jitter
  2752. % % Stats
  2753. fprintf('Direct vs. indirect excited cells ChR2\n');
  2754. kruskalwallisNdunns(valMtrx,labels);
  2755. % Save figure
  2756. if printfig
  2757. pos = get(f1,'Position');
  2758. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  2759. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  2760. print(f1,sprintf('%s_direct_vs_indirect.pdf',field),'-dpdf','-r0')
  2761. end
  2762. clear valCell valGrp include exclude criteria field printfig pos f1 nGr colors...
  2763. labels thisYlabel transformation valMtrx
  2764. %% Suppl 6i,j: Peer-prediction opto_1sec
  2765. % CELL SELECTION
  2766. nGr = 5;
  2767. labels = {'rapid','PV','SST','GC','MC'};
  2768. include = struct('putativeCellType',{'','PV interneuron','SST interneuron',...
  2769. 'Granule Cell','Mossy Cell'}, 'brainRegion',repmat({'DG'},1,nGr),...
  2770. 'groundTruthClassification',{{'+'},{''},{''},{''},{''}},...
  2771. 'labels',repmat({'ChR2'},1,5));
  2772. exclude = struct('groundTruthClassification',{{},{'+','~'},{'+','~'},{'+','~'},{'+','~'}},...
  2773. 'putativeCellType',repmat({'Unknown'},1,5),...
  2774. 'tags',repmat({{'InverseSpike','Bad'}},1,nGr));
  2775. criteria = struct('opto_1sec_modulationSignificanceLevelevt',...
  2776. {[0 1],[0 .01],[0 .01],[0 .01],[0 .01]},...
  2777. 'opto_1sec_modulationRatio',{[-Inf Inf],[1.1 Inf],[1.1 Inf],[1.1 Inf],[1.1 Inf]});
  2778. %'opto_1sec_modulationRatio',{[-Inf Inf],[1.1 Inf],[1.1 Inf],[1.1 Inf],[1.1 Inf]});
  2779. RsqThr = 0; % Min adjusted Rsq on training data for inclusion -- was 0.25 on 1/31/2026
  2780. colors = {[1 .2 .2],[.56 .39 .93], [0 .72 .53], [.83 .78 .46], [.9 0 .7]};
  2781. % PEER PREDICTION
  2782. if ~exist('peerpred','var')
  2783. peerpred = peerPredictOpto1sec(class_metrics, 'include',include,...
  2784. 'exclude',exclude, 'criteria',criteria, 'binsz',.25); %.02
  2785. end
  2786. % Extract fit quality values
  2787. errfield = 'MSE'; % 'R', 'Rsq', 'MSE'
  2788. valMtrx = peerpred.(['val' errfield]);
  2789. stimMtrx = peerpred.(['stim' errfield]);
  2790. % Get training Rsq and exclude below threshold
  2791. RsqTrng = -Inf(size(peerpred.Glm));
  2792. for gr = 1:5
  2793. for n = 1:size(peerpred.Glm,2)
  2794. if ~isempty(peerpred.Glm{gr,n})
  2795. RsqTrng(gr,n) = peerpred.Glm{gr,n}.Rsquared.Adjusted;
  2796. end
  2797. end
  2798. valMtrx{gr} = valMtrx{gr}(RsqTrng(gr,:) > RsqThr);
  2799. stimMtrx{gr} = stimMtrx{gr}(RsqTrng(gr,:) > RsqThr);
  2800. end
  2801. valMtrx = cellfun(@sqrt, valMtrx, 'UniformOutput',false);
  2802. stimMtrx = cellfun(@sqrt, stimMtrx, 'UniformOutput',false);
  2803. valMtrx = cellfun(@log10, valMtrx, 'UniformOutput',false);
  2804. stimMtrx = cellfun(@log10, stimMtrx, 'UniformOutput',false);
  2805. for gr = 1:5
  2806. [~,isoutlierVal] = tukeyOutlierRemoval(valMtrx{gr},3);
  2807. [~,isoutlierStim] = tukeyOutlierRemoval(stimMtrx{gr},3);
  2808. % Remove major outliers
  2809. valMtrx{gr} = valMtrx{gr}(~isoutlierVal & ~isoutlierStim);
  2810. stimMtrx{gr} = stimMtrx{gr}(~isoutlierVal & ~isoutlierStim);
  2811. end
  2812. % PLOT LOG MSE (VIOLIN PLOTS)
  2813. f1 = figure('position',[200 450 280 220]); % Same aspect ratio
  2814. hold on
  2815. valGrp = cell2groupedvector(valMtrx);
  2816. stimGrp = cell2groupedvector(stimMtrx);
  2817. plotSpread(valGrp(:,1),'distributionIdx',...
  2818. (valGrp(:,2)-1)*2+1,'spreadFcn',{'lin',10},'spreadWidth',.9,...
  2819. 'distributionColors',[0 0 0],...
  2820. 'distributionMarkerSize',1,'binWidth',.05);
  2821. plotSpread(stimGrp(:,1),'distributionIdx',...
  2822. stimGrp(:,2)*2,'spreadFcn',{'lin',10},'spreadWidth',.9,...
  2823. 'distributionColors',[0 0 0],...
  2824. 'distributionMarkerSize',1,'binWidth',.05);
  2825. % Plot direct and indirect responding cell's peer prediction quality
  2826. combMtrx = cat(1,valMtrx,stimMtrx);
  2827. distributionPlot(combMtrx,'color',{[1 .2 .2],[1 .2 .2],[.56 .39 .93],[.56 .39 .93],...
  2828. [0 .72 .53],[0 .72 .53],[.83 .78 .46],[.83 .78 .46],[.9 0 .7],[.9 0 .7]},...
  2829. 'showMM',6,'distWidth',.9,'addSpread',0,'histOpt',1,'divFactor',1,...
  2830. 'FaceAlpha',.5);
  2831. xticks([1.5 3.5 5.5 7.5 9.5]);
  2832. xticklabels({'rapid','PV','SST','GC','MC'});
  2833. xtickangle(45);
  2834. ylabel(['Log' errfield ' validation']);
  2835. ylim([-1 3]);
  2836. % PLOT LOG MSE DIFFERENCE VAL TO STIM
  2837. f4 = figure('position',[200 450 140 170]); % Same aspect ratio
  2838. hold on
  2839. diffMtrx = cellfun(@minus, stimMtrx, valMtrx, 'UniformOutput',false);
  2840. diffGrp = cell2groupedvector(diffMtrx);
  2841. plotSpread(diffGrp(:,1),'distributionIdx',...
  2842. diffGrp(:,2),'spreadFcn',{'lin',10},'spreadWidth',.9,...
  2843. 'distributionColors',[0 0 0],...
  2844. 'distributionMarkerSize',1,'binWidth',.05);
  2845. % Plot direct and indirect responding cell's peer prediction quality
  2846. distributionPlot(diffMtrx,'color',{[1 .2 .2],[.56 .39 .93],[0 .72 .53],[.83 .78 .46],[.9 0 .7]},...
  2847. 'showMM',6,'distWidth',.9,'addSpread',0,'histOpt',1,'divFactor',1,...
  2848. 'FaceAlpha',.5);
  2849. xticklabels({'rapid','PV','SST','GC','MC'});
  2850. xtickangle(45);
  2851. ylabel(['Log' errfield ' difference (Stim-Val)']);
  2852. %ylim([-1 3]);
  2853. % Stats (error difference)
  2854. fprintf('Direct vs. indirect excited cells ChR2, prediction error difference');
  2855. kruskalwallisNdunns(catuneven(diffMtrx,NaN),labels);
  2856. % CORRELATION PLOTS (Actual rate / predicted rate during stim and
  2857. % validation).
  2858. f2 = figure('position',[100 100 950 350]); hold on;
  2859. for gr = 1:5
  2860. %Plot Stim data
  2861. subplot(2, 5, gr);
  2862. stimActual = real(log10(peerpred.stimActual{gr}(RsqTrng(gr,:) > RsqThr)));
  2863. stimPred = real(log10(peerpred.stimPred{gr}(RsqTrng(gr,:) > RsqThr)));
  2864. scatterWreg(stimActual,stimPred,'MarkerSz',8,'MarkerSymbol','o',...
  2865. 'MarkerFaceAlpha',.5,'MarkerFaceColor',colors{gr});
  2866. xlabel('Stim Observed'); ylabel('Stim Predicted');
  2867. xlim([-3 2]); ylim([-3 2]);
  2868. xticks([-3:2]); yticks([-3:2]);
  2869. xticklabels([.001 .01 .1 1 10 100]);
  2870. yticklabels([.001 .01 .1 1 10 100]);
  2871. xtickangle(45);
  2872. [R(gr,1),p(gr,1)] = corr(stimActual,stimPred);
  2873. N(gr,1) = length(stimActual);
  2874. % Plot Validation data
  2875. subplot(2, 5, gr+5);
  2876. valActual = real(log10(peerpred.valActual{gr}(RsqTrng(gr,:) > RsqThr)));
  2877. valPred = real(log10(peerpred.valPred{gr}(RsqTrng(gr,:) > RsqThr)));
  2878. scatterWreg(valActual,valPred,'MarkerSz',8,'MarkerSymbol','o',...
  2879. 'MarkerFaceAlpha',.5,'MarkerFaceColor',colors{gr});
  2880. xlabel('Validation Observed'); ylabel('Validation Predicted');
  2881. xlim([-3 2]); ylim([-3 2]);
  2882. xticks([-3:2]); yticks([-3:2]);
  2883. xticklabels([.001 .01 .1 1 10 100]);
  2884. yticklabels([.001 .01 .1 1 10 100]);
  2885. xtickangle(45);
  2886. [R(gr,2),p(gr,2)] = corr(valActual,valPred);
  2887. N(gr,2) = length(valActual);
  2888. end
  2889. % Plot corrected p-values:
  2890. pcorr = multCompCorr(p,'method','Dunn-Sidak');
  2891. fprintf('\nActivity correlation bsl-stim\n');
  2892. for gr = 1:5
  2893. fprintf('%s, validation: N = %i, R = %.2f, p(raw) = %.4g, p(corr) = %.4g\n',...
  2894. labels{gr},N(gr,2),R(gr,2),p(gr,2),pcorr(gr,2))
  2895. fprintf('%s, stim: N = %i, R = %.2f, p(raw) = %.4g, p(corr) = %.4g\n',...
  2896. labels{gr},N(gr,1),R(gr,1),p(gr,1),pcorr(gr,1))
  2897. end
  2898. clear include exclude criteria valGrp stimGrp valMtrx stimMtrx gr R R2 p n...
  2899. colors errfield f1 f2 f3 f4 nGr RsqThr RsqTrng stimActual stimPred valActual valPred...
  2900. actualRatio predRatio combMtrx diffMtrx diffGrp labels isoutlierStim isoutlierVal...
  2901. pcorr transformation N
  2902. %% Supplementary Figure 8
  2903. %% Suppl 8a-c: Lorenz curves, gini differences, CV differences
  2904. % Run Fig 6e,f code above
  2905. %% Suppl 8d-f: Spike-subsample control for Lorenz curves, gini differences, CV differences
  2906. % Create in- and exclude structure
  2907. printfig = true;
  2908. labels = {'PV-HR','SST-HR','PV-ChR','SST-ChR'};
  2909. include = struct('putativeCellType',{'PV interneuron','SST interneuron',...
  2910. 'Granule Cell','Mossy Cell'});
  2911. %exclude = struct('groundTruthClassification',{{'+'},{'+'},{'+'},{'+'}});
  2912. exclude = struct('groundTruthClassification',{{'+','~'}},...
  2913. 'tags',{{'Bad','InverseSpike'}},'putativeCellType',{'Unknown'});
  2914. lines = {'PV-Cre','SST-Cre'};
  2915. opsins = {'eNpHR','ChR2'};
  2916. colors = [.56 .39 .93; 0 .72 .53; .83 .78 .46; .9 0 .7; .56 .39 .93; 0 .72 .53];
  2917. fields = {'gini','CV'}; % For errorbar plots (diff stim vs bsl)
  2918. % Get Lorenz curves, gini, CV
  2919. if ~exist('LorRes','var') % Takes long to load
  2920. for li = [1 2] % PV-Cre / SST-Cre
  2921. [include.geneticLine] = deal(lines{li});
  2922. for op = [1 2] % eNpHR / ChR
  2923. [include.labels] = deal(opsins{op});
  2924. fprintf('%s, %s\n',lines{li},opsins{op});
  2925. LorRes{li,op} = get_1sec_Lorenz_Curves_rateMatch(class_metrics,...
  2926. 'include',include,'exclude',exclude,'show_results',false,...
  2927. 'minNspikes',1, 'minNcells',4);
  2928. end
  2929. end
  2930. end
  2931. % LORENZ CURVES
  2932. f1= figure('position',[100 100 500 450]); hold on;
  2933. for li = 1:2
  2934. for op = 1:2
  2935. for ct = 1:length(include)
  2936. subplot(4,length(include),ct + (op-1)*length(include) + (li-1)*2*length(include))
  2937. % Plot eNpHR results
  2938. plot([0 100],[0 1],':','color',[.5 .5 .5]);
  2939. nSess = length(find(LorRes{li,op}.nCells(:,ct)>0));
  2940. shadedErrorBar(1:100, nanmean(LorRes{li,op}.MeanLorenzCurveNorm(:,:,ct,1),1),...
  2941. nanstd(LorRes{li,1}.MeanLorenzCurveNorm(:,:,ct,1),1)./sqrt(nSess),...
  2942. 'lineprops',{'color',colors(ct,:)});
  2943. shadedErrorBar(1:100, nanmean(LorRes{li,op}.MeanLorenzCurveNorm(:,:,ct,2),1),...
  2944. nanstd(LorRes{li,1}.MeanLorenzCurveNorm(:,:,ct,2),1)./sqrt(nSess),...
  2945. 'lineprops',{'color',[.5 .5 .5]});
  2946. text(10,.8,sprintf('%s\n%s',lines{li},opsins{op}),'FontSize',8);
  2947. drawnow
  2948. end
  2949. end
  2950. end
  2951. % Save figure
  2952. if printfig
  2953. pos = get(f1,'Position');
  2954. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  2955. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  2956. print(f1,'SpikeNoControl_LorenzCurves.pdf','-dpdf','-r0')
  2957. end
  2958. % PLOT GINI, CV, ETC
  2959. for ff = 1:2
  2960. % GET VALUES
  2961. stvals = cat(1, LorRes{1,1}.(fields{ff})(:,:,1), LorRes{2,1}.(fields{ff})(:,:,1),...
  2962. LorRes{1,2}.(fields{ff})(:,:,1), LorRes{2,2}.(fields{ff})(:,:,1)); % To sort by condition, cat(2,... and omit reshape
  2963. blvals = cat(1, LorRes{1,1}.(fields{ff})(:,:,2), LorRes{2,1}.(fields{ff})(:,:,2),...
  2964. LorRes{1,2}.(fields{ff})(:,:,2), LorRes{2,2}.(fields{ff})(:,:,2));
  2965. stvals = reshape(stvals, size(LorRes{1,1}.gini,1), length(include)*length(lines)*length(opsins));
  2966. blvals = reshape(blvals, size(LorRes{1,1}.gini,1), length(include)*length(lines)*length(opsins));
  2967. % RAW VALUES (DUAL VIOLIN PLOTS)
  2968. figure('position',[100 100 500 150]); hold on;
  2969. % baseline (left, grey)
  2970. plotSpread(blvals,'spreadFcn',{'lin',10},...
  2971. 'spreadWidth',.9,'distributionColors',[.5 .5 .5],'distributionMarkerSize',3,...
  2972. 'spreadOri','left','distributionMarkerAlpha',.5,'distributionMarkers','o');
  2973. distributionPlot(blvals,'histOri','left','color',[0 0 0],...
  2974. 'widthDiv',[2 1],'showMM',6,'FaceAlpha',.5);
  2975. % Stim (right)
  2976. plotSpread(stvals,'spreadFcn',{'lin',10},... % [sic!], use wider (10) spread here 2/2 lower n datapoints
  2977. 'spreadWidth',.9,'distributionColors',[.5 .5 .5],'distributionMarkerSize',3,...
  2978. 'spreadOri','right','distributionMarkerAlpha',.5,'distributionMarkers','o');
  2979. distributionPlot(stvals,'histOri','right','color',num2cell(colors([1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4],:),2),...
  2980. 'widthDiv',[2 2],'showMM',6,'FaceAlpha',.5);
  2981. %ylim([.4 1.1]);
  2982. ylabel(fields{ff});
  2983. % STIM-BSL DELTA PLOT
  2984. f1 = figure('position',[100 100 400 250]); hold on;
  2985. % distributionPlot(stvals-blvals,'showMM',6,'FaceAlpha',.5,'histOpt',1,'divFactor',1,...
  2986. % 'color',num2cell(colors([1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4],:),2));
  2987. plot([0 size(stvals,2)+1],[0 0],'--','Color',[.5 .5 .5]); % Zero line
  2988. plotSpread(stvals-blvals,'spreadFcn',{'lin',5},...
  2989. 'spreadWidth',.9,'distributionColors',[0 0 0],'distributionMarkerSize',4,...
  2990. 'distributionMarkerAlpha',1,'distributionMarkers','o');
  2991. customErrorBar(stvals-blvals, 'errtype','STD', 'alpha',.7,...
  2992. 'markerSize',100, 'LineWidth',1.2,...
  2993. 'colors',colors([1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4],:));
  2994. xlim([0 size(stvals,2)+1]);
  2995. %ylim([-.3 .4]);
  2996. ylabel(sprintf('%s (stim-bsl)',fields{ff}));
  2997. xticklabels(repmat(labels,1,4));
  2998. xtickangle(45);
  2999. % Save figure
  3000. if printfig
  3001. pos = get(f1,'Position');
  3002. set(f1,'PaperPositionMode','Auto','PaperUnits','points',...
  3003. 'PaperSize',[pos(3), pos(4)],'Renderer','Painters')
  3004. print(f1,sprintf('SpikeNoControl_Opto_1sec_%s_change.pdf',fields{ff}),'-dpdf','-r0')
  3005. end
  3006. % STATISTICS
  3007. for ct = 1:length(include)
  3008. clear blvals stvals groupVals
  3009. % Statistics @console
  3010. fprintf('\n%s:',include(ct).putativeCellType)
  3011. fprintf('\n%s (raw p):\n',fields{ff}) % For statistics in console
  3012. for li = 1:2
  3013. for op = 1:2
  3014. blvals(:,li,op) = LorRes{li,op}.(fields{ff})(:,ct,2); % nSess x nGroup(ct) x [1 (stim) 2 (bsl)]
  3015. stvals(:,li,op) = LorRes{li,op}.(fields{ff})(:,ct,1);
  3016. try
  3017. pvals(ct,li,op) = pairedSampleTest(blvals(:,li,op), stvals(:,li,op),...
  3018. 'labels',{'baseline','stim'},'verbose',true);
  3019. catch
  3020. pvals(ct,li,op) = NaN;
  3021. fprintf('\n');
  3022. end
  3023. end
  3024. end
  3025. % ANOVA
  3026. groupVals = reshape(stvals-blvals, size(stvals,1), size(stvals,2)*size(stvals,3));
  3027. fprintf('%s ANOVA:\n',fields{ff})
  3028. kruskalwallisNdunns(groupVals, labels);
  3029. end
  3030. % Multi-Comparison Corrected p-values
  3031. padj = multCompCorr(pvals,'method','Dunn-Sidak'); % 'Holm-Bonferroni', 'Dunn-Sidak'
  3032. fprintf('%s (adjusted p-values):\n',fields{ff});
  3033. for op = [1 2]
  3034. for li = [1 2]
  3035. for ct = 1:length(include)
  3036. fprintf('%s-%s: %s (stim vs. bsl), p = %.4g\n',lines{li}, opsins{op},...
  3037. include(ct).putativeCellType, padj(ct,li,op));
  3038. end
  3039. end
  3040. end
  3041. end
  3042. clear labels include exclude lines opsins li ct op f1 f2 colors color...
  3043. limrate pvals ncolors labels baseMLD stimMLD isGoodID baserates blvals...
  3044. stimrates stvals f1 fields ff pos nSess printfig statlabels valTbl groupVals padj
  3045. %% Suppl 8d: Baseline vs. Stim firing rate correlations
  3046. % Runf FIg 6g code above

DG_IN_Figures_final.m at commit 1566f35, no license · at the source

Overview

Authors: Thomas Hainmueller1,2,3, Elisabeth A. Heynold1,4, Nicholas Paleologos1, Ivan G. Raikov4, Ivan Soltesz4, György Buzsáki1,5,6
  1. Neuroscience Institute, New York University Langone Medical Center, New York, NY 10016, USA
  2. Department of Psychiatry, New York University Langone Medical Center, New York, NY 10016, USA
  3. Department of Psychiatry and Behavioral Sciences, Stanford University School of Medicine, Palo Alto, CA 94305, USA
  4. Department of Neurosurgery, Stanford University School of Medicine, Palo Alto, CA 94305, USA
  5. Department of Neurology, New York University Langone Medical Center, New York, NY 10016, USA
  6. Lead contact
Institutions: NYU Langone Health (United States); Stanford University (United States); Stanford Medicine (United States)
Journal: Neuron, volume 114, issue 17, pages 3280-3294.e7
Dates: published online 20 April 2026; in print 2 September 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1016/j.neuron.2026.03.034 · PMID 42013854 · PMCID PMC13186253 · OpenAlex W4411053555
Open access: green, a free copy (OpenAlex)
Status: code verified
Categories: mouse (organism), systems (subfield)
Methods: Spectral & time-frequency, Statistics, Smoothing, state filtering, decompositions, Machine learning, Connectivity, fMRI & imaging, Single-unit activity, calcium imaging, Physiology & signal measures
Keywords: Somatostatin, Hippocampus, Sleep, Parvalbumin, Interneuron, dentate gyrus, Theta, Optogenetics, Dentate Spikes
MeSH: Dentate Gyrus*, Interneurons*, Nerve Net*, Action Potentials, Animals, Male, Mice, Mice, Inbred C57BL, Mice, Transgenic, Mossy Fibers, Hippocampal, Optogenetics, Parvalbumins, Somatostatin (* major topic)
Topic: Neural dynamics and brain function (Cognitive Neuroscience, Neuroscience), according to OpenAlex
Funding: NIMH NIH HHS (R01 MH139216, R01 MH122391); NINDS NIH HHS (U19 NS107616, RF1 NS133381, R01 NS142069); Brain &amp;amp; Behavior Research Foundation (32940); German Research Foundation; Finding A Cure for Epilepsy and Seizures; National Institute of Neurological Disorders and Stroke; National Alliance for Research on Schizophrenia and Depression; National Institute of Mental Health
Citations: cited by 3 papers (Europe PMC); 93 references in the paper

Abstract

The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.

Repositories

Its files are read in the Code ↔ Paper reader above, with 40 matches between paragraphs and lines of code.

ThomasHainmueller/HainmuellerHeynold_et_al_2025

License: none: the authors keep all their rights
State: the link answers, verified on 29 September 2026
Evidence: files inventoried
Commit: 1566f35fc1522f1cefd7a3f59b85e76a9925df3d, 22 March 2026
Languages: MATLAB (595), C (1)
Size: 662 files, 596 scripts
Software Heritage: not archived
Found in: “Data and code availability”
Holds: README, tests
Not found: license file, CITATION.cff, environment file, continuous integration, documentation
Tools: Statistics and Machine Learning Toolbox (122 files), Signal Processing Toolbox (67 files), Image Processing Toolbox (19 files), Optimization Toolbox (5 files), shadedErrorBar (5 files), Parallel Computing Toolbox (4 files), CircStat (3 files), boundedline (2 files), EEGLAB (2 files), Chronux (1 file), Curve Fitting Toolbox (1 file)
Availability: 1 check, the latest on 29 September 2026: the link answers
  • 29 September 2026: the link answers
597 files

soltesz-lab/DG-Interneurons

License: GPL-3.0
State: the link answers, verified on 29 September 2026
Evidence: files inventoried
Commit: 160ca41868460bbf0770ff6e842b2da10d2b8eed, 16 March 2026
Languages: Python (28)
Size: 31 files, 28 scripts
Software Heritage: not archived
Found in: “Data and code availability”
Holds: README, license file, tests
Not found: CITATION.cff, environment file, continuous integration, documentation
Tools: NumPy (25 files), PyTorch (23 files), Matplotlib (18 files), SciPy (15 files), h5py (6 files), seaborn (5 files), pandas (4 files), NetworkX (1 file), scikit-learn (1 file)
Availability: 1 check, the latest on 29 September 2026: the link answers
  • 29 September 2026: the link answers
30 files

The paper's code and data availability statement is in the Data section.

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 2 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 624 scripts, each with its path and the digest of its content;
  • 40 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

No dataset and no data link were found in the paper.

Code and data availability statement

The paper has a code and data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

Read it in the paper: doi.org/10.1016/j.neuron.2026.03.034.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 29 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 6 authors, 9 keywords, 13 MeSH terms, 8 funders, 91 references.

Cite

This paper

Hainmueller, T., Heynold, E. A., Paleologos, N., Raikov, I. G., Soltesz, I., & Buzsáki, G. (2026). Dentate gyrus interneurons modulate winner-take-all network dynamics in freely behaving mice. Neuron, 114(17), 3280-3294.e7. https://doi.org/10.1016/j.neuron.2026.03.034

BibTeX

@article{hainmueller2026dentate,
author = {Hainmueller, Thomas and Heynold, Elisabeth A. and Paleologos, Nicholas and Raikov, Ivan G. and Soltesz, Ivan and Buzsáki, György},
title = {{Dentate gyrus interneurons modulate winner-take-all network dynamics in freely behaving mice}},
journal = {Neuron},
year = {2026},
month = apr,
volume = {114},
number = {17},
pages = {3280--3294.e7},
publisher = {Cell Press},
issn = {0896-6273},
doi = {10.1016/j.neuron.2026.03.034},
url = {https://doi.org/10.1016/j.neuron.2026.03.034},
pmid = {42013854},
pmcid = {PMC13186253}
}

RIS

TY - JOUR
AU - Hainmueller, Thomas
AU - Heynold, Elisabeth A.
AU - Paleologos, Nicholas
AU - Raikov, Ivan G.
AU - Soltesz, Ivan
AU - Buzsáki, György
TI - Dentate gyrus interneurons modulate winner-take-all network dynamics in freely behaving mice
T2 - Neuron
J2 - Neuron
PY - 2026
DA - 2026/04/20
VL - 114
IS - 17
SP - 3280
EP - 3294.e7
SN - 0896-6273
PB - Cell Press
DO - 10.1016/j.neuron.2026.03.034
UR - https://doi.org/10.1016/j.neuron.2026.03.034
LA - en
ER -

CSL-JSON

{
"id": "10.1016/j.neuron.2026.03.034",
"type": "article-journal",
"title": "Dentate gyrus interneurons modulate winner-take-all network dynamics in freely behaving mice",
"container-title": "Neuron",
"author": [
{
"family": "Hainmueller",
"given": "Thomas"
},
{
"family": "Heynold",
"given": "Elisabeth A."
},
{
"family": "Paleologos",
"given": "Nicholas"
},
{
"family": "Raikov",
"given": "Ivan G."
},
{
"family": "Soltesz",
"given": "Ivan"
},
{
"family": "Buzsáki",
"given": "György"
}
],
"container-title-short": "Neuron",
"volume": "114",
"issue": "17",
"page": "3280-3294.e7",
"DOI": "10.1016/j.neuron.2026.03.034",
"PMID": "42013854",
"PMCID": "PMC13186253",
"ISSN": "0896-6273",
"publisher": "Cell Press",
"URL": "https://doi.org/10.1016/j.neuron.2026.03.034",
"language": "en",
"issued": {
"date-parts": [
[
2026,
4,
20
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1523/jneurosci.2001-25.2026 [code]
Dynamics of Dentate Gyrus Place Cells and Dentate Spikes during Spatial and Nonspatial Changes in Environments.
Journal: The Journal of neuroscience : the official journal of the Society for Neuroscience
In common: Chronux, CircStat, Curve Fitting Toolbox, 9 other tools, systems, 11 references
[2] doi:10.1016/j.celrep.2026.117646 [code]
Medial entorhinal-hippocampal desynchronization parallels the emergence of memory impairment in a mouse model of Alzheimer's disease pathology.
Journal: Cell reports
In common: Chronux, boundedline, CircStat, 11 other tools, systems, mouse, 4 references
[3] doi:10.1038/s41593-026-02357-2 [code]
Experience reorganizes content-specific memory traces in macaques.
Journal: Nature neuroscience
In common: Chronux, boundedline, CircStat, 13 other tools, 3 references
[4] doi:10.1038/s41467-026-75347-4 [code]
Sleep reveals dynamics integrating and segregating movement and stimulus representations in V1.
Journal: Nature communications
In common: Chronux, boundedline, CircStat, 13 other tools, systems, mouse, 2 references
[5] doi:10.1038/s41467-026-73106-z [code]
Respiratory pauses highlight sleep architecture in mice.
Journal: Nature communications
In common: Chronux, boundedline, CircStat, 11 other tools, mouse, 2 references
[6] doi:10.64898/2026.03.12.710517 [code]
Cortical excitability inversely modulates fMRI connectivity via low-frequency neuronal coupling
Journal: bioRxiv (preprint)
In common: Chronux, shadedErrorBar, CircStat, 11 other tools, systems, 1 reference
[7] doi:10.1016/j.patter.2026.101590 [code]
Density-based longitudinal neuron tracking in high-density electrophysiological recordings.
Journal: Patterns (New York, N.Y.)
In common: shadedErrorBar, CircStat, Optimization Toolbox, 11 other tools, 2 references
[8] doi:10.1038/s41593-026-02388-9 [code]
Hippocampal CA3 connectomics reveals a gradient of mossy fiber inputs and selective feedforward inhibition onto pyramidal cells.
Journal: Nature neuroscience
In common: NetworkX, PyTorch, seaborn, 5 other tools, systems, mouse, 7 references
[9] doi:10.1126/sciadv.aeh7220 [code]
Central complex representations of self-movement are sufficient to compute wind direction in flight.
Journal: Science advances
In common: shadedErrorBar, CircStat, Curve Fitting Toolbox, 11 other tools
[10] doi:10.1038/s41467-026-76581-6 [code]
Thalamocortical bursts encode reward contingencies and drive associative learning.
Journal: Nature communications
In common: CircStat, Curve Fitting Toolbox, h5py, 8 other tools, systems, mouse, 3 references

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.