OSCR

Subicular plateaus signal reward locations during goal-directed behavior.

Code ↔ Paper

6 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 6 matches · 2 of them tie a paragraph to a whole file, not to given lines: weak matches, whose lines are not tinted
  1. [1] § RESULTS › Unsupervised clustering organizes plateaus by pre-plateau Vm ↔ plateau_clustering_analysis_v3_anchors.m, lines 226–297 · score 0.77 · global template, t-SNE, plateau clusters, pre Vm, Fisher, silhouette
  2. [2] § METHOD DETAILS › K-means clustering and t-SNE visualization ↔ plateau_clustering_analysis_v3_anchors.m, lines 169–207 · score 0.71 · squared errors, silhouette scores, optimal, 1–6, sum, space
  3. [3] § METHOD DETAILS › Univariate analysis ↔ UnivariateAnalysis.zip/AnalyseTableUnivariateAnalysis.m, the whole file · a weak match · score 0.69 · Mann Whitney, univariate, pre event, plateau events, predicted, occurrence
  4. [4] § RESULTS › Subicular plateau occurrence is shaped by intrinsic and behavioral factors ↔ UnivariateAnalysis.zip/AnalyseTableUnivariateAnalysis.m, the whole file · a weak match · score 0.67 · Mann Whitney, plateau occurrence, pre event, univariate, predictor, variables
  5. [5] § METHOD DETAILS › Univariate analysis ↔ UnivariateAnalysis.zip/CreateTableUnivariateAnalysis.m, lines 1–21 · score 0.65 · plateau ratio, pre event, 20 ms, buffer, univariate, predicted
  6. [6] § METHOD DETAILS › Plateau analysis post reward location shift ↔ plateau-spatial-analysis.zip/analyzePlateauDistributions.m, lines 1–41 · score 0.51 · matched control, reward location, shift, delivered, opposite, bins

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 · 448 lines · 24 KB · CC-BY-4.0 · 2 matches

  1. function plateau_clustering_analysis_v3_anchors(main_folder)
  2. rng(1);
  3. %% ====================================================================
  4. %% SECTION 1: SETUP & CONFIGURATION
  5. %% ====================================================================
  6. if nargin < 1
  7. main_folder = uigetdir('', 'Select Data Folder');
  8. if main_folder == 0, return; end
  9. end
  10. timestamp = datestr(now, 'yyyymmdd_HHMMSS');
  11. save_dir = fullfile(main_folder, ['Clustering_Results_' timestamp]);
  12. if ~exist(save_dir, 'dir'), mkdir(save_dir); end
  13. FigList = struct('h', {}, 'name', {});
  14. % 1.1 Parameters
  15. k_clusters = 2;
  16. n_spatial_bins = 10;
  17. % 1.2 Anchors
  18. UseAnchors.Reward = true;
  19. UseAnchors.SimSpeed = true;
  20. UseAnchors.SimAccel = false;
  21. UseAnchors.ExactSpeed = true;
  22. UseAnchors.ExactAccel = false;
  23. UseAnchors.SpeedCrossUp = true;
  24. % 1.3 Filters
  25. Filter.Context = 'A';
  26. Filter.Zone = 'Both';
  27. Filter.Movement = 'RunOnly';
  28. Filter.PreVmRange = [-0.060, -0.040];
  29. Filter.MinDuration = 0.005;
  30. Filter.Kurtosis = false;
  31. Max_Kurtosis = 5;
  32. % 1.4 Features (Toggle True/False)
  33. FeatureParams.UseLog = true;
  34. UseFeatures.Duration = false;
  35. UseFeatures.MeanVm = false;
  36. UseFeatures.MedianVm = false;
  37. UseFeatures.Area = true;
  38. UseFeatures.MaxAmp = false;
  39. UseFeatures.Skew = false;
  40. UseFeatures.Kurtosis = false;
  41. UseFeatures.PreVm = true;
  42. UseFeatures.SignedDist = false;
  43. UseFeatures.RiseTime = false;
  44. UseFeatures.DecayTime = false;
  45. UseFeatures.TemplateMatch = true;
  46. fprintf('Setup Complete. Loading Data...\n');
  47. %% ====================================================================
  48. %% SECTION 2: DATA LOADING
  49. %% ====================================================================
  50. master_file = fullfile(main_folder, 'Master_Project_Data.mat');
  51. if ~exist(master_file, 'file'), errordlg('Data not found.'); return; end
  52. data = load(master_file);
  53. MasterEvents = data.MasterEvents;
  54. if isfield(data, 'SessionStruct'), SessionStruct=data.SessionStruct; else, SessionStruct=data.data_struct; end
  55. % Ensure SignedDist
  56. if ~ismember('SignedDist', MasterEvents.Properties.VariableNames)
  57. d = MasterEvents.DistToReward; z = lower(string(MasterEvents.ZoneTag));
  58. is_neg = contains(z, 'pre') | contains(z, 'far');
  59. d(is_neg) = -abs(d(is_neg)); MasterEvents.SignedDist = d;
  60. end
  61. % Anchor Mapping
  62. FullAnchorMap = {
  63. 'Reward', 'SignedDist', 'Reward';
  64. 'Sim Speed', 'Dist_similar_speed', 'similar_speed';
  65. 'Sim Accel', 'Dist_similar_accel', 'similar_accel';
  66. 'Exact Speed', 'Dist_exact_speed', 'exact_speed';
  67. 'Exact Accel', 'Dist_exact_accel', 'exact_accel';
  68. 'Speed Cross Up', 'Dist_speed_crossing_up', 'speed_crossing_up'
  69. };
  70. selMask = [UseAnchors.Reward; UseAnchors.SimSpeed; UseAnchors.SimAccel; ...
  71. UseAnchors.ExactSpeed; UseAnchors.ExactAccel; UseAnchors.SpeedCrossUp];
  72. AnchorMap = FullAnchorMap(logical(selMask), :);
  73. % Validate Columns
  74. valid_cols = false(size(AnchorMap,1), 1);
  75. for i=1:size(AnchorMap,1)
  76. if ismember(AnchorMap{i,2}, MasterEvents.Properties.VariableNames), valid_cols(i)=true; end
  77. end
  78. AnchorMap = AnchorMap(valid_cols, :);
  79. % Colors
  80. AncColors = lines(size(AnchorMap,1));
  81. rIdx = find(strcmp(AnchorMap(:,1), 'Reward')); if ~isempty(rIdx), AncColors(rIdx,:) = [0 0 0]; end
  82. % Ensure Features Exist
  83. req_cols = {'Kurtosis','RiseTime','DecayTime','MedianVm','Area','MaxAmp','Skew'};
  84. for r=1:length(req_cols), if ~ismember(req_cols{r}, MasterEvents.Properties.VariableNames), MasterEvents.(req_cols{r}) = nan(height(MasterEvents),1); end; end
  85. if all(isnan(MasterEvents.MedianVm)), MasterEvents.MedianVm = MasterEvents.MeanVm; end
  86. %% ====================================================================
  87. %% SECTION 3: FILTERING & TEMPLATES
  88. %% ====================================================================
  89. if strcmpi(Filter.Context, 'A'), MasterEvents = MasterEvents(strcmpi(MasterEvents.GroupTag, 'A'), :);
  90. elseif strcmpi(Filter.Context, 'B'), MasterEvents = MasterEvents(strcmpi(MasterEvents.GroupTag, 'B'), :); end
  91. if ~isempty(Filter.PreVmRange), pvm = MasterEvents.PreVm; MasterEvents = MasterEvents(pvm >= Filter.PreVmRange(1) & pvm <= Filter.PreVmRange(2), :); end
  92. z = lower(string(MasterEvents.ZoneTag));
  93. if strcmpi(Filter.Zone, 'NearOnly'), MasterEvents = MasterEvents((z == "pre") | (z == "post"), :);
  94. elseif strcmpi(Filter.Zone, 'FarOnly'), MasterEvents = MasterEvents((z == "far"), :); end
  95. s = MasterEvents.Speed; s(isnan(s)) = 0;
  96. if strcmpi(Filter.Movement, 'RunOnly'), MasterEvents = MasterEvents(s >= 0.05, :);
  97. elseif strcmpi(Filter.Movement, 'StopOnly'), MasterEvents = MasterEvents(s < 0.05, :); end
  98. if Filter.MinDuration > 0, MasterEvents = MasterEvents(MasterEvents.Duration >= Filter.MinDuration, :); end
  99. % Kurtosis Filter
  100. if Filter.Kurtosis ==1, MasterEvents = MasterEvents(MasterEvents.Kurtosis <= Max_Kurtosis, :); end
  101. if height(MasterEvents) < k_clusters, errordlg('Not enough events.', 'Error'); return; end
  102. % Templates
  103. norm_len = 100; pre_pad = 0;
  104. augmented_mat = nan(height(MasterEvents), pre_pad + norm_len);
  105. for i = 1:height(MasterEvents)
  106. tr = MasterEvents.Trace{i}; pvm = MasterEvents.PreVm(i);
  107. if length(tr) > 2, body = interp1(linspace(0,1,length(tr)), tr, linspace(0,1,norm_len));
  108. augmented_mat(i, :) = [repmat(pvm, 1, pre_pad), body];
  109. end
  110. end
  111. TemplateTrace = nanmean(augmented_mat, 1);
  112. ShapeScore = zeros(height(MasterEvents), 1);
  113. for i = 1:height(MasterEvents)
  114. if ~any(isnan(augmented_mat(i,:))), R = corrcoef(augmented_mat(i,:), TemplateTrace); ShapeScore(i) = R(1,2); end
  115. end
  116. MasterEvents.TemplateMatch = ShapeScore;
  117. %% ====================================================================
  118. %% SECTION 4: FEATURE EXTRACTION & CLUSTERING
  119. %% ====================================================================
  120. X = []; VarNames = {};
  121. if FeatureParams.UseLog, TF = @(x) log10(x); prefix = 'Log'; else, TF = @(x) x; prefix = ''; end
  122. if UseFeatures.Duration, X=[X, TF(MasterEvents.Duration)]; VarNames{end+1}=[prefix 'Dur']; end
  123. if UseFeatures.MeanVm, X=[X, MasterEvents.MeanVm]; VarNames{end+1}='MeanVm'; end
  124. if UseFeatures.MedianVm, X=[X, MasterEvents.MedianVm]; VarNames{end+1}='MedVm'; end
  125. if UseFeatures.Area, X=[X, TF(MasterEvents.Area)]; VarNames{end+1}=[prefix 'Area']; end
  126. if UseFeatures.MaxAmp, X=[X, MasterEvents.MaxAmp]; VarNames{end+1}='MaxAmp'; end
  127. if UseFeatures.Skew, X=[X, MasterEvents.Skew]; VarNames{end+1}='Skew'; end
  128. if UseFeatures.Kurtosis, X=[X, MasterEvents.Kurtosis]; VarNames{end+1}='Kurt'; end
  129. if UseFeatures.PreVm, X=[X, MasterEvents.PreVm]; VarNames{end+1}='PreVm'; end
  130. if UseFeatures.SignedDist, X=[X, MasterEvents.SignedDist]; VarNames{end+1}='Dist'; end
  131. if UseFeatures.RiseTime, X=[X, MasterEvents.RiseTime]; VarNames{end+1}='Rise'; end
  132. if UseFeatures.DecayTime, X=[X, MasterEvents.DecayTime]; VarNames{end+1}='Decay'; end
  133. if UseFeatures.TemplateMatch, X=[X, MasterEvents.TemplateMatch]; VarNames{end+1}='Shape'; end
  134. if isempty(X), error('No features selected.'); end
  135. bad_rows = any(isnan(X) | isinf(X), 2);
  136. if any(bad_rows), X = X(~bad_rows, :); MasterEvents = MasterEvents(~bad_rows, :); end
  137. X_z = zscore(X); X_z(isnan(X_z)) = 0;
  138. %% ====================================================================
  139. %% SECTION 4.5: EVALUATE OPTIMAL K (NEW TEST)
  140. %% ====================================================================
  141. fprintf('Testing optimal cluster number (k=1 to 6)...\n');
  142. max_k_test = 6;
  143. sse_list = zeros(max_k_test, 1);
  144. sil_list = nan(max_k_test, 1); % Silhouette undefined for k=1
  145. % Loop through k=1 to k=6 to test quality
  146. for k_t = 1:max_k_test
  147. % Run k-means for this k (suppress output)
  148. [idx_t, ~, sumd_t] = kmeans(X_z, k_t, 'Replicates', 3, 'Display', 'off');
  149. sse_list(k_t) = sum(sumd_t); % Sum of Squared Errors (Inertia)
  150. if k_t > 1
  151. s_t = silhouette(X_z, idx_t);
  152. sil_list(k_t) = mean(s_t);
  153. end
  154. end
  155. % Plot the results
  156. f_opt = figure('Name', 'Optimal K Test', 'Color', 'w', 'Position', [200 200 900 400]);
  157. FigList(end+1) = struct('h', f_opt, 'name', 'Optimal_K_Test');
  158. t_opt = tiledlayout(1, 2, 'TileSpacing', 'compact', 'Padding', 'compact');
  159. % Plot 1: Elbow Plot (SSE) - Look for the "bend"
  160. nexttile;
  161. plot(1:max_k_test, sse_list, '-o', 'LineWidth', 2, 'Color', 'k', 'MarkerFaceColor', 'b');
  162. title('Elbow Method (SSE)');
  163. xlabel('Number of Clusters (k)'); ylabel('Sum of Squared Errors');
  164. grid on;
  165. % Plot 2: Silhouette Plot - Look for the highest peak
  166. nexttile;
  167. plot(2:max_k_test, sil_list(2:end), '-o', 'LineWidth', 2, 'Color', 'k', 'MarkerFaceColor', 'r');
  168. title('Silhouette Method');
  169. xlabel('Number of Clusters (k)'); ylabel('Mean Silhouette Score');
  170. yline(0.5, 'g--', 'Good Structure'); % Reference line
  171. grid on;
  172. sgtitle('Determining Optimal Cluster Number');
  173. %%
  174. fprintf('Running K-Means Clustering...\n');
  175. [idx, ~] = kmeans(X_z, k_clusters, 'Replicates', 5);
  176. MasterEvents.Cluster = idx;
  177. cmap = lines(k_clusters);
  178. % Separation Metrics
  179. sil_values = silhouette(X_z, idx); GlobalSeparationIndex = mean(sil_values);
  180. num_vars = size(X_z, 2); FishersRatio = zeros(1, num_vars);
  181. X1 = X_z(idx==1, :); X2 = X_z(idx==2, :);
  182. for v = 1:num_vars, m1=mean(X1(:,v)); m2=mean(X2(:,v)); v1=var(X1(:,v)); v2=var(X2(:,v)); FishersRatio(v)=((m1-m2)^2)/(v1+v2); end
  183. ClusterStats.Silhouette = GlobalSeparationIndex; ClusterStats.FishersRatio = FishersRatio;
  184. %% ====================================================================
  185. %% SECTION 5: BASIC PLOTS (Quality Checks)
  186. %% ====================================================================
  187. % Quality
  188. f_stat = figure('Name', 'Cluster Quality', 'Color', 'w', 'Position', [50 50 1000 500]);
  189. FigList(end+1) = struct('h', f_stat, 'name', 'Cluster_Metrics');
  190. subplot(1, 3, 1); silhouette(X_z, idx); title(sprintf('Separation: %.3f', GlobalSeparationIndex));
  191. subplot(1, 3, [2 3]); bar(FishersRatio); set(gca,'XTick',1:num_vars,'XTickLabel',VarNames,'XTickLabelRotation',45); title('Parameter Importance'); grid on;
  192. % Correlation
  193. f_corr = figure('Name', 'Feature Correlation', 'Color', 'w', 'Position', [100 100 600 500]);
  194. FigList(end+1) = struct('h', f_corr, 'name', 'Feature_Correlation');
  195. heatmap(VarNames, VarNames, corr(X), 'Colormap', jet, 'ColorLimits', [-1 1]);
  196. % Main Vis
  197. f_main = figure('Name','Main Cluster Analysis','Color','w', 'Position', [50 50 1400 700]);
  198. FigList(end+1) = struct('h', f_main, 'name', 'Main_Visualization');
  199. if size(X_z,1) > 2000, samp=randsample(size(X_z,1),2000); else, samp=(1:size(X_z,1))'; end
  200. X_in=X_z(samp,:); idx_tsne=idx(samp); try, Y = tsne(X_in); tsne_success=true; catch, tsne_success=false; end
  201. subplot(2,4,1); if UseFeatures.TemplateMatch, gscatter(MasterEvents.Duration, MasterEvents.TemplateMatch, idx, cmap); ylabel('Shape Score'); else, gscatter(MasterEvents.Duration, MasterEvents.MeanVm, idx, cmap); ylabel('MeanVm'); end; title('Clusters'); grid on; legend('off');
  202. subplot(2,4,[2 3]); cents = zeros(k_clusters, size(X_z,2)); for c=1:k_clusters, cents(c,:) = mean(X_z(idx==c,:),1); end; plot(cents','-o', 'LineWidth', 2); set(gca, 'XTick', 1:numel(VarNames), 'XTickLabel', VarNames); title('Z-Score Profiles'); grid on;
  203. subplot(2,4,4); if tsne_success, gscatter(Y(:,1),Y(:,2),idx_tsne,cmap,'.',10); title('t-SNE (Cluster)'); legend('off'); end
  204. subplot(2,4,5); hold on; edges = linspace(-1,1,20); for c=1:k_clusters, histogram(MasterEvents.SignedDist(idx==c), edges, 'FaceColor', cmap(c,:), 'FaceAlpha', 0.4); end; title('Spatial Dist');
  205. subplot(2,4,8); if tsne_success, [~,~,sid_map] = unique(MasterEvents.SessionID(samp)); scatter(Y(:,1), Y(:,2), 15, sid_map, 'filled', 'MarkerFaceAlpha', 0.7); colormap(gca, turbo); title('t-SNE (Session)'); end
  206. subplot(2,4,6); plot(linspace(0, 1, length(TemplateTrace)), TemplateTrace, 'k', 'LineWidth', 2); title('Global Template'); axis tight;
  207. % Raw Traces
  208. for c = 1:k_clusters
  209. f_trace = figure('Name', sprintf('Cluster %d Raw Traces',c), 'Color', 'w', 'Position', [100 100 800 800]);
  210. FigList(end+1) = struct('h', f_trace, 'name', sprintf('Raw_Traces_Cluster_%d', c));
  211. t = tiledlayout(5,5, 'TileSpacing','none', 'Padding', 'compact');
  212. evs = MasterEvents(MasterEvents.Cluster==c,:);
  213. n_show = min(25, height(evs));
  214. p_idx = randsample(height(evs), n_show);
  215. for i=1:numel(p_idx)
  216. nexttile;
  217. tr = evs.Trace{p_idx(i)};
  218. plot(tr, 'Color', cmap(c,:), 'LineWidth', 1.5);
  219. yline(evs.PreVm(p_idx(i)), 'k:', 'LineWidth', 1);
  220. axis off;
  221. % --- SCALE BAR (Adjusted for 24ms events) ---
  222. if i == numel(p_idx)
  223. hold on;
  224. sr = 20000; % Sampling Rate
  225. x_sec = 0.05; % <--- CHANGED to 50ms (0.05s)
  226. y_volts = 0.02; % 20 mV
  227. % Convert to units
  228. x_len = x_sec * sr;
  229. y_len = y_volts;
  230. % Position: Bottom-Right
  231. yl = ylim; xl = xlim;
  232. x_start = xl(2) - x_len - (diff(xl)*0.1);
  233. y_start = yl(1) + (diff(yl)*0.1);
  234. % Draw L-Bar
  235. plot([x_start, x_start + x_len], [y_start, y_start], 'k-', 'LineWidth', 2);
  236. plot([x_start + x_len, x_start + x_len], [y_start, y_start + y_len], 'k-', 'LineWidth', 2);
  237. % Labels
  238. text(x_start + x_len/2, y_start - (diff(yl)*0.1), '50ms', ...
  239. 'HorizontalAlignment', 'center', 'FontSize', 8, 'FontWeight', 'bold');
  240. text(x_start + x_len + (diff(xl)*0.05), y_start + y_len/2, '20mV', ...
  241. 'Rotation', 90, 'VerticalAlignment', 'middle', 'FontSize', 8, 'FontWeight', 'bold');
  242. end
  243. end
  244. sgtitle(sprintf('Cluster %d Examples (n=%d)', c, n_show));
  245. end
  246. %% ====================================================================
  247. %% SECTION 6: MULTI-ANCHOR SPATIAL ANALYSIS (Normalized)
  248. %% ====================================================================
  249. fprintf('Running Spatial Analysis (Normalized per Session)...\n');
  250. nSess = numel(unique(MasterEvents.SessionID)); uSess = unique(MasterEvents.SessionID);
  251. NewEdges = linspace(-1, 1, n_spatial_bins + 1); NewCenters = (NewEdges(1:end-1) + NewEdges(2:end)) / 2;
  252. mask_near = abs(NewCenters) <= 0.4;
  253. PlotData.Spatial = struct();
  254. for c = 1:k_clusters
  255. ClusEvents = MasterEvents(MasterEvents.Cluster == c, :);
  256. PooledAbs=[]; PooledNorm=[]; SessAbsMean=[]; SessAbsSEM=[]; SessNormMean=[]; SessNormSEM=[];
  257. Stats_Near=nan(nSess, size(AnchorMap,1)); Stats_Far=nan(nSess, size(AnchorMap,1));
  258. AnchorDataStruct = struct();
  259. for a = 1:size(AnchorMap,1)
  260. ancName = AnchorMap{a,1}; colName = AnchorMap{a,2}; occField = AnchorMap{a,3};
  261. SessCurve_Abs = nan(nSess, n_spatial_bins); SessCurve_Norm = nan(nSess, n_spatial_bins);
  262. GlobalNumer = zeros(1, n_spatial_bins); GlobalDenom = zeros(1, n_spatial_bins);
  263. for s = 1:nSess
  264. sid = uSess(s);
  265. sIdx=0; for k=1:length(SessionStruct), tid=SessionStruct(k).SessionID; if iscell(tid), tid=tid{1}; end; if tid==sid, sIdx=k; break; end; end
  266. if sIdx==0, continue; end
  267. S = SessionStruct(sIdx); OccData = [];
  268. if strcmpi(ancName, 'Reward'), if isfield(S, 'Occupancy'), OccData = S.Occupancy; end
  269. else, if isfield(S, 'AnchorOccupancy') && isfield(S.AnchorOccupancy, occField), OccData = S.AnchorOccupancy.(occField); end; end
  270. if isempty(OccData) || ~isstruct(OccData), continue; end
  271. if strcmpi(Filter.Movement, 'RunOnly'), if isfield(OccData, 'Hist_Run'), h=OccData.Hist_Run; else, h=[]; end
  272. else, if isfield(OccData, 'Hist_All'), h=OccData.Hist_All; else, h=[]; end; end
  273. if isempty(h) || sum(h) < 1e-6, continue; end
  274. OldEdges = linspace(-1, 1, length(h) + 1); OldCenters = (OldEdges(1:end-1) + OldEdges(2:end)) / 2;
  275. occ_new = interp1(OldCenters, h, NewCenters, 'linear', 0);
  276. occ_final = occ_new * (mean(diff(NewCenters))/mean(diff(OldCenters)));
  277. GlobalDenom = GlobalDenom + occ_final;
  278. s_evs = ClusEvents(ClusEvents.SessionID == sid, :);
  279. if ~isempty(s_evs)
  280. dists = s_evs.(colName); durs = s_evs.Duration;
  281. valid = ~isnan(dists) & abs(dists) <= 1.0; dists = dists(valid); durs = durs(valid);
  282. [~,~,b] = histcounts(dists, NewEdges);
  283. num = zeros(1, n_spatial_bins); for k_ev=1:length(b), if b(k_ev)>0, num(b(k_ev)) = num(b(k_ev)) + durs(k_ev); end; end
  284. GlobalNumer = GlobalNumer + num;
  285. rate = num ./ max(occ_final, 1e-6);
  286. SessCurve_Abs(s,:) = rate;
  287. if sum(rate)>0, norm_prof = rate/sum(rate); SessCurve_Norm(s,:) = norm_prof;
  288. Stats_Near(s,a) = sum(norm_prof(mask_near)); Stats_Far(s,a) = sum(norm_prof(~mask_near));
  289. else, SessCurve_Norm(s,:) = 0; Stats_Near(s,a)=0; Stats_Far(s,a)=0; end
  290. else
  291. SessCurve_Abs(s,:) = 0; SessCurve_Norm(s,:) = 0; Stats_Near(s,a)=0; Stats_Far(s,a)=0;
  292. end
  293. end
  294. P_Abs = GlobalNumer ./ max(GlobalDenom, 1e-6); if sum(P_Abs)>0, P_Norm = P_Abs / sum(P_Abs); else, P_Norm=P_Abs; end
  295. PooledAbs(:,a)=P_Abs; PooledNorm(:,a)=P_Norm;
  296. SessAbsMean(:,a)=mean(SessCurve_Abs,1,'omitnan'); SessAbsSEM(:,a)=std(SessCurve_Abs,0,1,'omitnan')./sqrt(sum(~isnan(SessCurve_Abs(:,1))));
  297. SessNormMean(:,a)=mean(SessCurve_Norm,1,'omitnan'); SessNormSEM(:,a)=std(SessCurve_Norm,0,1,'omitnan')./sqrt(sum(~isnan(SessCurve_Norm(:,1))));
  298. % SAVE SESSION DATA (RAW & NORM)
  299. AnchorDataStruct(a).Name = ancName;
  300. AnchorDataStruct(a).Raw = SessCurve_Abs; % Absolute Rate (Hz)
  301. AnchorDataStruct(a).Norm = SessCurve_Norm; % Normalized Probability
  302. end
  303. % Plotting
  304. f_comb = figure('Name', sprintf('Cluster %d Spatial', c), 'Color', 'w', 'Position', [50 50 1400 900]);
  305. FigList(end+1) = struct('h', f_comb, 'name', sprintf('Cluster%d_Spatial_Anchors', c));
  306. t = tiledlayout(2, 3, 'TileSpacing', 'compact', 'Padding', 'compact');
  307. sgtitle(sprintf('Cluster %d (%s) - Normalized Stats', c, Filter.Movement));
  308. nexttile; hold on; for a=1:size(AnchorMap,1), plot(NewCenters, PooledNorm(:,a), '-o', 'Color', AncColors(a,:), 'LineWidth', 2); end; title('Pooled Normalized'); xline(0,'k--');
  309. nexttile; hold on; for a=1:size(AnchorMap,1), mu=SessNormMean(:,a)'; se=SessNormSEM(:,a)'; fill([NewCenters fliplr(NewCenters)], [mu+se fliplr(mu-se)], AncColors(a,:), 'FaceAlpha', 0.15, 'EdgeColor', 'none'); plot(NewCenters, mu, 'Color', AncColors(a,:), 'LineWidth', 2); end; title('Avg Normalized (+/- SEM)'); xline(0,'k--');
  310. nexttile; hold on; plot_distribution_scatter(Stats_Near, AncColors, AnchorMap(:,1)); title('Near Anchor Prob'); p_n=perform_stats(Stats_Near); subtitle(sprintf('Friedman p=%.3e',p_n));
  311. nexttile; hold on; plot_distribution_scatter(Stats_Far, AncColors, AnchorMap(:,1)); title('Far Anchor Prob'); p_f=perform_stats(Stats_Far); subtitle(sprintf('Friedman p=%.3e',p_f));
  312. PlotData.Spatial.(sprintf('C%d',c)).PooledAbs = PooledAbs; PlotData.Spatial.(sprintf('C%d',c)).PooledNorm = PooledNorm;
  313. PlotData.Spatial.(sprintf('C%d',c)).StatsNear = Stats_Near; PlotData.Spatial.(sprintf('C%d',c)).StatsFar = Stats_Far;
  314. PlotData.Spatial.(sprintf('C%d',c)).AnchorData = AnchorDataStruct;
  315. end
  316. %% ====================================================================
  317. %% SECTION 7: EXPORT INDIVIDUAL SESSION CURVES TO EXCEL
  318. %% ====================================================================
  319. fprintf('\n--- EXPORTING SESSION CURVES TO EXCEL ---\n');
  320. xlFile = fullfile(save_dir, 'Session_Spatial_Curves.xlsx');
  321. if exist(xlFile, 'file'), delete(xlFile); end
  322. % Get Spatial Axis for Headers
  323. binHeaders = cell(1, n_spatial_bins);
  324. for b=1:n_spatial_bins, binHeaders{b} = sprintf('Bin_%d', b); end
  325. for c = 1:k_clusters
  326. cName = sprintf('C%d', c);
  327. if ~isfield(PlotData.Spatial, cName), continue; end
  328. AData = PlotData.Spatial.(cName).AnchorData;
  329. % Create Tables for Raw and Norm
  330. % Format: SessionID | Reward_Bin1... | Reward_Bin10 | Speed_Bin1...
  331. for a = 1:length(AData)
  332. ancName = AData(a).Name;
  333. rawMat = AData(a).Raw;
  334. normMat = AData(a).Norm;
  335. % Sanitize Anchor Name for Sheet
  336. validName = regexprep(ancName, '[^a-zA-Z0-9]', '');
  337. validName = validName(1:min(10, length(validName))); % Keep short
  338. % Create Tables
  339. T_Raw = array2table([uSess, rawMat], 'VariableNames', [{'SessionID'}, binHeaders]);
  340. T_Norm = array2table([uSess, normMat], 'VariableNames', [{'SessionID'}, binHeaders]);
  341. % Write Sheets
  342. sheetRaw = sprintf('%s_%s_Raw', cName, validName);
  343. sheetNorm = sprintf('%s_%s_Norm', cName, validName);
  344. writetable(T_Raw, xlFile, 'Sheet', sheetRaw);
  345. writetable(T_Norm, xlFile, 'Sheet', sheetNorm);
  346. end
  347. end
  348. fprintf('Excel Export Saved: %s\n', xlFile);
  349. %% ====================================================================
  350. %% SECTION 8: SAVING FIGURES & MAT FILE
  351. %% ====================================================================
  352. fprintf('\n--- SAVING MATLAB DATA ---\n');
  353. for i = 1:length(FigList)
  354. if isvalid(FigList(i).h)
  355. fname = fullfile(save_dir, FigList(i).name);
  356. saveas(FigList(i).h, [fname '.fig']);
  357. exportgraphics(FigList(i).h, [fname '.png'], 'Resolution', 300);
  358. end
  359. end
  360. save(fullfile(save_dir, 'Clustering_Results.mat'), 'MasterEvents', 'X', 'X_z', 'VarNames', 'ClusterStats', 'PlotData', 'Filter', 'idx', 'SessionStruct');
  361. ExportTable = removevars(MasterEvents, {'Trace'});
  362. writetable(ExportTable, fullfile(save_dir, 'Events_With_Clusters.csv'));
  363. save(fullfile(save_dir, 'Plot_Data_Curves.mat'), 'PlotData');
  364. fprintf('Analysis Complete. Results saved in: %s\n', save_dir);
  365. msgbox(['Analysis done! Saved to: ' save_dir]);
  366. end
  367. function p = perform_stats(Mat), valid=~any(isnan(Mat),2); Mat=Mat(valid,:); if sum(valid)>5, p=friedman(Mat,1,'off'); else, p=NaN; end, end
  368. function plot_distribution_scatter(Mat, Colors, Labels), nGrps=size(Mat,2); boxplot(Mat, 'Labels', Labels, 'Colors', 'k', 'Symbol', ''); hold on; for i=1:nGrps, x=i+(rand(size(Mat,1),1)-0.5)*0.2; scatter(x, Mat(:,i), 25, Colors(i,:), 'filled', 'MarkerFaceAlpha', 0.6); m=nanmedian(Mat(:,i)); plot([i-0.25 i+0.25], [m m], 'k-', 'LineWidth', 2); end, grid on; end

plateau_clustering_analysis_v3_anchors.m, under CC-BY-4.0 · at the source

Overview

Authors: Aanchal Bhatia1,2, Mohamed Adel2, Christine Grienberger1,3
  1. Brandeis University, Department of Biology, Waltham, MA 02453, USA
  2. These authors contributed equally
  3. Lead contact
Institutions: Brandeis University (United States)
Journal: Cell reports, volume 45, issue 8, article 117794
Dates: published online 5 August 2026; in print August 2026
Type: Research article · Language: English
License: CC BY-NC
Identifiers: DOI 10.1016/j.celrep.2026.117794 · PMID 42555356 · PMCID PMC13586939 · OpenAlex W7172538736
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: intracellular / patch clamp (modality)
Methods: Spectral & time-frequency, Connectivity, Statistics, Smoothing, state filtering, decompositions, Machine learning, Preprocessing, fMRI & imaging, Single-unit activity, calcium imaging
Keywords: Hippocampus, Burst firing, Subiculum, Reward Learning, Plateau Potentials, Goal-directed Navigation, In Vivo Whole-cell Recordings, Cp: Neuroscience
Topic: Neurobiology and Insect Physiology Research (Cellular and Molecular Neuroscience, Neuroscience), according to OpenAlex
Funding: NINDS NIH HHS (T32 NS007292); National Institute of Neurological Disorders and Stroke (T32 NS007292); A. O. Smith Foundation; National Institutes of Health; National Institute of Mental Health (1DP2 MH136393); NIMH NIH HHS (DP2 MH136393); Richard and Susan Smith Family Foundation
Citations: not cited yet (Europe PMC); 69 references in the paper
Research resources: Mouse: C57BL/6J RRID:IMSR_JAX:000664, MATLAB (2021a, 2023b) RRID:SCR_001622, Graphpad Prism software (version 11.0.2) RRID:SCR_002798

Abstract

The hippocampus is essential for spatial learning, yet how its principal output structure, the subiculum, encodes behaviorally relevant information during navigation remains poorly understood. Because subicular neurons exhibit prominent burst firing, understanding how this bursting arises during behavior is critical. Using in vivo whole-cell recordings from dorsal subiculum neurons in head-fixed mice performing goal-directed navigation, we show that many bursts arise from plateau events. Plateaus were reduced by NMDA receptor blockade, indicating a dependence on synaptic input. Organizing plateaus by membrane potential preceding their onset revealed distinct behavioral associations. Plateaus initiated from hyperpolarized potentials clustered preferentially near reward locations, whereas those initiated from more depolarized potentials were more spatially distributed. Reward-related clustering required a fixed, learned reward location and was dynamically rearranged while learning a new reward location in a familiar environment. Together, these findings identify subicular plateaus as a cellular substrate of hippocampal bursting output, organized by membrane potential state.

Reproduced under the paper's license (CC BY-NC), from the paper cited above.

Repository

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

Zenodo 21177036

License: CC-BY-4.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Languages: MATLAB (3)
Size: 5 files, 3 scripts
Software Heritage: not checked
Found in: the end of the paper
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
25 files
At the source:

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:

  • 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 25 scripts, each with its path and the digest of its content;
  • 6 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.

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 3, 28 September 2026

  • Publisher: n/a → Cell Press

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 3 authors, 8 keywords, 7 funders, 68 references, 3 RRIDs.

Cite

This paper

Bhatia, A., Adel, M., & Grienberger, C. (2026). Subicular plateaus signal reward locations during goal-directed behavior. Cell reports, 45(8), 117794. https://doi.org/10.1016/j.celrep.2026.117794

BibTeX

@article{bhatia2026subicular,
author = {Bhatia, Aanchal and Adel, Mohamed and Grienberger, Christine},
title = {{Subicular plateaus signal reward locations during goal-directed behavior}},
journal = {Cell reports},
year = {2026},
month = aug,
volume = {45},
number = {8},
pages = {117794},
publisher = {Cell Press},
issn = {2211-1247},
doi = {10.1016/j.celrep.2026.117794},
url = {https://doi.org/10.1016/j.celrep.2026.117794},
pmid = {42555356},
pmcid = {PMC13586939}
}

RIS

TY - JOUR
AU - Bhatia, Aanchal
AU - Adel, Mohamed
AU - Grienberger, Christine
TI - Subicular plateaus signal reward locations during goal-directed behavior
T2 - Cell reports
J2 - Cell Rep
PY - 2026
DA - 2026/08/05
VL - 45
IS - 8
SP - 117794
SN - 2211-1247
PB - Cell Press
DO - 10.1016/j.celrep.2026.117794
UR - https://doi.org/10.1016/j.celrep.2026.117794
LA - en
ER -

CSL-JSON

{
"id": "10.1016/j.celrep.2026.117794",
"type": "article-journal",
"title": "Subicular plateaus signal reward locations during goal-directed behavior",
"container-title": "Cell reports",
"author": [
{
"family": "Bhatia",
"given": "Aanchal"
},
{
"family": "Adel",
"given": "Mohamed"
},
{
"family": "Grienberger",
"given": "Christine"
}
],
"container-title-short": "Cell Rep",
"volume": "45",
"issue": "8",
"page": "117794",
"DOI": "10.1016/j.celrep.2026.117794",
"PMID": "42555356",
"PMCID": "PMC13586939",
"ISSN": "2211-1247",
"publisher": "Cell Press",
"URL": "https://doi.org/10.1016/j.celrep.2026.117794",
"language": "en",
"issued": {
"date-parts": [
[
2026,
8,
5
]
]
}
}

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.1002/hipo.70081 [code]
Spatial Organization of Morpho-Electric Subtypes of Pyramidal Neuron in the Subiculum.
Journal: Hippocampus
In common: intracellular / patch clamp, 11 references
[2] doi:10.1016/j.celrep.2026.117388 [code]
An unsuspected physiological role for mGluRIII glutamate receptors in hippocampal area CA1.
Journal: Cell reports
In common: intracellular / patch clamp, 5 references, author Christine Grienberger
[3] doi:10.1038/s41586-026-10537-0 [code]
Sparse-to-dense coding transformation between hippocampal areas CA3 and CA1.
Journal: Nature
In common: 8 references
[4] doi:10.1038/s41467-026-74834-y [code]
Voltage imaging of CA1 pyramidal cells and SST+ interneurons reveals stability and plasticity mechanisms of spatial firing.
Journal: Nature communications
In common: intracellular / patch clamp, 8 references
[5] doi:10.1523/jneurosci.1540-25.2026 [code]
Dendritic Inhibition Terminates Plateau Potentials in CA1 Pyramidal Neurons.
Journal: The Journal of neuroscience : the official journal of the Society for Neuroscience
In common: 8 references
[6] doi:10.7554/elife.108352 [code]
Analysis of dendritic input currents during place field dynamics.
Journal: eLife
In common: 7 references
[7] doi:10.1016/j.celrep.2026.117793 [code]
Clustered inputs engage dendritic nonlinearities and calcium signaling to support efficient place-field formation in CA1 pyramidal neurons.
Journal: Cell reports
In common: 7 references
[8] doi:10.1038/s41467-026-75492-w [code]
Place and behavioral modulation of hippocampal neurons during immobility.
Journal: Nature communications
In common: Statistics and Machine Learning Toolbox, 4 references
[9] doi:10.1038/s41467-026-71503-y [code]
Rapid formation of non-spatial hippocampal representations consistent with behavioral timescale synaptic plasticity is modulated by entorhinal input.
Journal: Nature communications
In common: Statistics and Machine Learning Toolbox, 4 references
[10] doi:10.1126/sciadv.aea1037 [code]
Distinct cortical spatial representations learned along disparate visual pathways.
Journal: Science advances
In common: Statistics and Machine Learning Toolbox, 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.