Conserved post-odor dynamics in the olfactory systems of mice and locusts.
The 1 match
- [1] § STAR★Methods › Method details › Odor presentation paradigms ↔ Script_Fig6.m, lines 114–172 · score 0.63 · ani, asa, cin, ep, ieg, mpz
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 · 1,148 lines · 41 KB · CC-BY-4.0 · 1 match
- %% ==================== Figure 6 ====================
- close all; clc; clear;
- fileNameKNN = {'m129_1_2_dataset'; 'm149_3_1_dataset';};
- % Fig6a, b, g, h, i: KNN Classification of mouse glom dataset and average over sessions
- % a/b => fileIter = 2;
- % h => fileIter = 1;
- KNN = 10;
- numTrial = 10;
- for fileIter = 1:length(fileNameKNN)
- clearvars -except fileNameKNN fileIter KNN numTrial
- load([fileNameKNN{fileIter},'\filtData2.mat']);
- if fileIter == 1, numOdor = length(fieldnames(filtData)) - 1;
- else, numOdor = length(fieldnames(filtData));
- end
- for OnOffIter = 1:2
- if OnOffIter == 1
- range = preDuration*fps+1:(preDuration+onDuration)*fps;
- else
- range = (preDuration+onDuration)*fps+1:(afterDuration+preDuration+onDuration)*fps;
- end
- numBinAvg = 1 + 3*(OnOffIter==2);
- % ====== Restructure the dataset ======
- newBlockData = cell(numOdor,1);
- clear tempFiltData2
- names = fieldnames(filtData);
- for i = 1:numOdor
- eval(strcat('tempData = filtData.', names{i+(fileIter==1)},';'));
- tempFiltData = tempData(1:numTrial,range,:);
- iter = ceil(length(range)/numBinAvg);
- tempFiltData2 = zeros(numTrial, iter, size(tempFiltData,3));
- for ii = 1:numBinAvg:length(range)
- try
- tempFiltData2(:,(ii-1)/numBinAvg+1,:) = mean(tempFiltData(:,ii:ii+numBinAvg-1,:),2);
- catch
- tempFiltData2(:,(ii-1)/numBinAvg+1,:) = mean(tempFiltData(:,ii:end,:),2);
- end
- end
- newBlockData{i} = tempFiltData2;
- end
- timeLength = size(tempFiltData2,2);
- % ====== Reshape to units x gloms ======
- allUnits = [];
- clusterAssignment = [];
- for i = 1:numOdor
- unitVector = newBlockData{i};
- tempUnits = reshape(permute(unitVector,[2 1 3]),[],size(unitVector,3));
- allUnits = [allUnits; tempUnits];
- clusterAssignment = [clusterAssignment; i*ones(size(tempUnits,1),1)];
- end
- numUnits = size(allUnits,1);
- % ====== Correlation distance with leave-trial-out block ======
- tempDistMatrix = squareform(pdist(allUnits,'correlation'));
- diagValue = ones(1,numUnits)*10;
- fullDistMatrix = tempDistMatrix + diag(diagValue);
- trialBlock = ones(timeLength)*10;
- trialBlockMatrix = kron(eye(numOdor*numTrial), trialBlock);
- fullDistMatrix = fullDistMatrix + trialBlockMatrix*10;
- % ====== kNN ======
- [~, idx] = sort(fullDistMatrix,2,"ascend");
- colIndices = idx(:,1:KNN);
- clusterTemp = zeros(size(colIndices));
- for nn = 1:KNN
- clusterTemp(:,nn) = clusterAssignment(colIndices(:,nn),1);
- end
- clusterAssignment(:,2) = mode(clusterTemp(:,1:KNN),2);
- clusterAssignment(:,3) = clusterAssignment(:,2) == clusterAssignment(:,1);
- perCorrectCluster = sum(clusterAssignment(:,3)) ./ size(clusterAssignment(:,1),1);
- disp(['Percentage correctly clustered = ', num2str(perCorrectCluster)]);
- % ====== Rearrange + percent ======
- clear resultMatrixTrialPerRow resultMatrix percentMatrix
- resultMatrix = zeros(numOdor,timeLength*numTrial);
- resultMatrixTrialPerRow = zeros(numOdor*numTrial,timeLength);
- percentMatrixAllTrial = zeros(numOdor,numTrial,timeLength);
- percentMatrix = zeros(numOdor+1,timeLength);
- for i = 1:numOdor
- blockIndex = find(clusterAssignment(:,1)==i);
- resultMatrix(i,1:length(blockIndex)) = clusterAssignment(blockIndex,2);
- resultMatrixTrialPerRow((i-1)*numTrial+1:i*numTrial,:) = reshape(resultMatrix(i,:),timeLength,numTrial)';
- tempPercent = clusterAssignment(blockIndex,3);
- percentMatrixTrialPerRow = reshape(tempPercent,timeLength,numTrial)';
- percentMatrixAllTrial(i,:,:) = percentMatrixTrialPerRow;
- percentMatrix(i,:) = mean(percentMatrixTrialPerRow,1);
- end
- percentMatrix(end,:) = mean(percentMatrix(1:numOdor,:),1);
- if fileIter == 1
- smooth = 3 + (OnOffIter==2);
- else
- smooth = 2 + 2*(OnOffIter==2);
- end
- percentMatrix(1:end-1,:) = filtfilt(ones(1,smooth)/smooth,1,percentMatrix(1:end-1,:)')';
- percentMatrix(end,:) = filtfilt(ones(1,smooth)/smooth,1,percentMatrix(end,:));
- % ====== Plot Matrix ======
- figure; color = ColorScheme(numOdor);
- try
- imagesc(resultMatrixTrialPerRow,[0.5 length(odorNames)+0.5]); colormap(color); cbar = colorbar;
- catch
- imagesc(resultMatrixTrialPerRow,[0.5 length(odorList)-0.5]); colormap(color); cbar = colorbar;
- end
- xlim([0.5 timeLength]); xticks(linspace(0.5,timeLength,9));
- if OnOffIter == 1
- xticklabels(linspace(0,onDuration,9));
- xlabel 'Mouse ON, time after odor onset(s)'; title 'ON Prediction';
- else
- xticklabels(linspace(0,afterDuration,9));
- xlabel 'Mouse ITI, time after odor offset (s)'; title 'ITI Prediction';
- end
- yticks(5:10:numOdor*numTrial);
- cbar.Ticks = 1:numOdor;
- if fileIter == 1
- yticklabels({'ace';'eug';'cin';'mpz';'2ep';'ieg';'tcm';'als';'met';'ani';'asa';});
- cbar.TickLabels={'ace';'eug';'cin';'mpz';'2ep';'ieg';'tcm';'als';'met';'ani';'asa';};
- else
- yticklabels({'ace';'msc';'eug';'als'})
- cbar.TickLabels={'ace';'msc';'eug';'als'};
- end
- cbar.Direction = "reverse";
- ylabel('True Label'); axis square;
- % ====== Plot Percentage ======
- if OnOffIter == 1
- timeAxis = preDuration+1/fps : 1/fps : (preDuration+onDuration);
- else
- timeAxis = (preDuration+onDuration)+1/fps : 1/fps : (preDuration+onDuration+afterDuration);
- end
- timeAxis = timeAxis - timeAxis(1);
- timeAxis = timeAxis(1:numBinAvg:end);
- figure; color = ColorScheme(numOdor,0.2); hold on;
- for i = 1:size(percentMatrix,1)-1
- plot(timeAxis(1:size(percentMatrix,2)), percentMatrix(i,:)*100, 'LineStyle','-','LineWidth',2,'Color',color(i,:));
- end
- plot(timeAxis(1:size(percentMatrix,2)), percentMatrix(end,:)*100, 'Color','k','LineWidth',5);
- line([0 (range(end)-range(1))/fps], [1/numOdor*100 1/numOdor*100],'LineStyle',':');
- xlim([0 (range(end)-range(1))/fps]);
- xticks(linspace(0,(range(end)-range(1))/fps,9));
- if OnOffIter == 1
- xticklabels(linspace(0,onDuration,9));
- xlabel 'Mouse ON, time after odor onset (s)'; title 'ON Prediction';
- else
- xticklabels(linspace(0,afterDuration,9));
- xlabel 'Mouse ITI, time after odor offset (s)'; title 'ITI Prediction';
- end
- ylabel 'Classification rate (%)'; axis square;
- end
- end
- % -------- Average Across Sessions for A & B--------------
- fileNameKNN = {
- 'm149_1_2_dataset';
- 'm148_2_1_dataset';
- 'm149_3_1_dataset';
- 'm141_8_1_dataset';
- 'm141_5_1_dataset';
- 'm141_1_1_dataset';
- };
- KNN = 10;
- numTrial = 10;
- totalPercentMatrixON = nan(length(fileNameKNN), 200);
- totalPercentMatrixOFF = nan(length(fileNameKNN), 500);
- commonTimeON = linspace(0, 5, 200);
- commonTimeOFF = linspace(0, 50, 500);
- for fileIter = 1:length(fileNameKNN)
- clearvars -except fileNameKNN fileIter KNN numTrial totalPercentMatrixON totalPercentMatrixOFF commonTimeON commonTimeOFF
- load([fileNameKNN{fileIter},'\filtData2.mat']);
- numOdor = length(fieldnames(filtData));
- names = fieldnames(filtData);
- for OnOffIter = 1:2
- if OnOffIter == 1
- range = preDuration*fps+1:(preDuration+onDuration)*fps;
- else
- range = (preDuration+onDuration)*fps+1:(afterDuration+preDuration+onDuration)*fps;
- end
- numBinAvg = 1 + 3*(OnOffIter==2);
- newBlockData = cell(numOdor,1);
- clear tempFiltData2
- for i = 1:numOdor
- eval(strcat('tempData = filtData.', names{i},';'));
- tempFiltData = tempData(1:numTrial,range,:);
- iter = ceil(length(range)/numBinAvg);
- tempFiltData2 = zeros(numTrial, iter, size(tempFiltData,3));
- for ii = 1:numBinAvg:length(range)
- try
- tempFiltData2(:,(ii-1)/numBinAvg+1,:) = mean(tempFiltData(:,ii:ii+numBinAvg-1,:),2);
- catch
- tempFiltData2(:,(ii-1)/numBinAvg+1,:) = mean(tempFiltData(:,ii:end,:),2);
- end
- end
- newBlockData{i} = tempFiltData2;
- end
- timeLength = size(tempFiltData2,2);
- allUnits = [];
- clusterAssignment = [];
- for i = 1:numOdor
- unitVector = newBlockData{i};
- tempUnits = reshape(permute(unitVector,[2 1 3]),[],size(unitVector,3));
- allUnits = [allUnits; tempUnits];
- clusterAssignment = [clusterAssignment; i*ones(size(tempUnits,1),1)];
- end
- numUnits = size(allUnits,1);
- tempDistMatrix = squareform(pdist(allUnits,'correlation'));
- diagValue = ones(1,numUnits)*10;
- fullDistMatrix = tempDistMatrix + diag(diagValue);
- trialBlock = ones(timeLength)*10;
- trialBlockMatrix = kron(eye(numOdor*numTrial), trialBlock);
- fullDistMatrix = fullDistMatrix + trialBlockMatrix*10;
- [~, idx] = sort(fullDistMatrix,2,"ascend");
- colIndices = idx(:,1:KNN);
- clusterTemp = zeros(size(colIndices));
- for nn = 1:KNN
- clusterTemp(:,nn) = clusterAssignment(colIndices(:,nn),1);
- end
- clusterAssignment(:,2) = mode(clusterTemp(:,1:KNN),2);
- clusterAssignment(:,3) = clusterAssignment(:,2) == clusterAssignment(:,1);
- perCorrectCluster = sum(clusterAssignment(:,3)) ./ size(clusterAssignment(:,1),1);
- disp(['Percentage correctly clustered = ', num2str(perCorrectCluster)]);
- clear resultMatrixTrialPerRow resultMatrix percentMatrix
- resultMatrix = zeros(numOdor,timeLength*numTrial);
- resultMatrixTrialPerRow = zeros(numOdor*numTrial,timeLength);
- percentMatrixAllTrial = zeros(numOdor,numTrial,timeLength);
- percentMatrix = zeros(numOdor+1,timeLength);
- for i = 1:numOdor
- blockIndex = find(clusterAssignment(:,1)==i);
- resultMatrix(i,1:length(blockIndex)) = clusterAssignment(blockIndex,2);
- resultMatrixTrialPerRow((i-1)*numTrial+1:i*numTrial,:) = reshape(resultMatrix(i,:),timeLength,numTrial)';
- tempPercent = clusterAssignment(blockIndex,3);
- percentMatrixTrialPerRow = reshape(tempPercent,timeLength,numTrial)';
- percentMatrixAllTrial(i,:,:) = percentMatrixTrialPerRow;
- percentMatrix(i,:) = mean(percentMatrixTrialPerRow,1);
- end
- percentMatrix(end,:) = mean(percentMatrix(1:numOdor,:),1);
- if OnOffIter == 1, smooth = 2; else, smooth = 4; end
- percentMatrix(1:end-1,:) = filtfilt(ones(1,smooth)/smooth,1,percentMatrix(1:end-1,:)')';
- percentMatrix(end,:) = filtfilt(ones(1,smooth)/smooth,1,percentMatrix(end,:));
- if OnOffIter == 1
- origTimeON = linspace(0,onDuration,length(percentMatrix(end,:)));
- interpCurveON = interp1(origTimeON, percentMatrix(end,:), commonTimeON,'linear');
- totalPercentMatrixON(fileIter,:) = interpCurveON;
- else
- origTimeOFF = linspace(0,afterDuration,length(percentMatrix(end,:)));
- interpCurveOFF = interp1(origTimeOFF, percentMatrix(end,:), commonTimeOFF,'linear');
- totalPercentMatrixOFF(fileIter,:) = interpCurveOFF;
- end
- end
- end
- totalPercentMatrixON(end+1,:) = mean(totalPercentMatrixON, 1,'omitnan');
- totalPercentMatrixOFF(end+1,:) = mean(totalPercentMatrixOFF, 1,'omitnan');
- timeAxisON = linspace(0,onDuration,size(totalPercentMatrixON,2));
- figure; hold on;
- for r = 1:fileIter
- plot(timeAxisON, totalPercentMatrixON(r,:)*100,'Color',[0.7 0.7 0.7],'LineWidth',2);
- end
- plot(timeAxisON, totalPercentMatrixON(end,:)*100,'Color','k','LineWidth',4);
- chanceLevel = 100/numOdor; yline(chanceLevel,':','Chance','LabelHorizontalAlignment','left');
- xlim([0 onDuration]); xticks(linspace(0,onDuration,9)); xticklabels(linspace(0,onDuration,9));
- xlabel('Mouse ON, time after odor onset (s)'); ylabel('Classification rate (%)'); title('ON Prediction (n = 6)'); axis square;
- timeAxisOFF = linspace(0,afterDuration,size(totalPercentMatrixOFF,2));
- figure; hold on;
- for r = 1:fileIter
- plot(timeAxisOFF, totalPercentMatrixOFF(r,:)*100,'Color',[0.7 0.7 0.7],'LineWidth',2);
- end
- plot(timeAxisOFF, totalPercentMatrixOFF(end,:)*100,'Color','k','LineWidth',4);
- chanceLevel = 100/numOdor; yline(chanceLevel,':','Chance','LabelHorizontalAlignment','left');
- xlim([0 afterDuration]); xticks(linspace(0,afterDuration,9)); xticklabels(linspace(0,afterDuration,9));
- xlabel('Mouse ITI, time after odor offset (s)'); ylabel('Classification rate (%)'); title('ITI Prediction (n = 6)'); axis square;
- % ---------- Average Across Session for H -------------
- fileNameKNN = {
- 'm129_1_2_dataset';
- 'm122_4_4_dataset';
- 'm125_1_1_dataset';
- 'm126_1_1_dataset';
- 'm129_3_1_dataset';
- 'm129_4_2_dataset';
- 'm134_6_1_dataset';
- 'm1716_1_1_dataset';
- };
- KNN = 10;
- numTrial = 10;
- totalPercentMatrixON = nan(length(fileNameKNN), 25);
- totalPercentMatrixOFF = nan(length(fileNameKNN), 600);
- commonTimeON = linspace(0, 1, 25);
- commonTimeOFF = linspace(0, 17, 600);
- for fileIter = 1:length(fileNameKNN)
- clearvars -except fileNameKNN fileIter KNN numTrial commonTimeOFF commonTimeON totalPercentMatrixON totalPercentMatrixOFF
- load([fileNameKNN{fileIter},'\filtData2.mat']);
- numOdor = length(fieldnames(filtData)) - 1;
- names = fieldnames(filtData);
- for OnOffIter = 1:2
- if OnOffIter == 1
- range = preDuration*fps+1:(preDuration+onDuration)*fps;
- else
- range = (preDuration+onDuration)*fps+1:(afterDuration+preDuration+onDuration)*fps;
- end
- numBinAvg = 1 + 3*(OnOffIter==2);
- newBlockData = cell(numOdor,1);
- clear tempFiltData2
- for i = 1:numOdor
- eval(strcat('tempData = filtData.', names{i+1},';'));
- tempFiltData = tempData(1:numTrial,range,:);
- iter = ceil(length(range)/numBinAvg);
- tempFiltData2 = zeros(numTrial, iter, size(tempFiltData,3));
- for ii = 1:numBinAvg:length(range)
- try
- tempFiltData2(:,(ii-1)/numBinAvg+1,:) = mean(tempFiltData(:,ii:ii+numBinAvg-1,:),2);
- catch
- tempFiltData2(:,(ii-1)/numBinAvg+1,:) = mean(tempFiltData(:,ii:end,:),2);
- end
- end
- newBlockData{i} = tempFiltData2;
- end
- timeLength = size(tempFiltData2,2);
- allUnits = [];
- clusterAssignment = [];
- for i = 1:numOdor
- unitVector = newBlockData{i};
- tempUnits = reshape(permute(unitVector,[2 1 3]),[],size(unitVector,3));
- allUnits = [allUnits; tempUnits];
- clusterAssignment = [clusterAssignment; i*ones(size(tempUnits,1),1)];
- end
- numUnits = size(allUnits,1);
- tempDistMatrix = squareform(pdist(allUnits,'correlation'));
- diagValue = ones(1,numUnits)*10;
- fullDistMatrix = tempDistMatrix + diag(diagValue);
- trialBlock = ones(timeLength)*10;
- trialBlockMatrix = kron(eye(numOdor*numTrial), trialBlock);
- fullDistMatrix = fullDistMatrix + trialBlockMatrix*10;
- [~, idx] = sort(fullDistMatrix,2,"ascend");
- colIndices = idx(:,1:KNN);
- clusterTemp = zeros(size(colIndices));
- for nn = 1:KNN
- clusterTemp(:,nn) = clusterAssignment(colIndices(:,nn),1);
- end
- clusterAssignment(:,2) = mode(clusterTemp(:,1:KNN),2);
- clusterAssignment(:,3) = clusterAssignment(:,2) == clusterAssignment(:,1);
- perCorrectCluster = sum(clusterAssignment(:,3)) ./ size(clusterAssignment(:,1),1);
- disp(['Percentage correctly clustered = ', num2str(perCorrectCluster)]);
- clear resultMatrixTrialPerRow resultMatrix percentMatrix
- resultMatrix = zeros(numOdor,timeLength*numTrial);
- resultMatrixTrialPerRow = zeros(numOdor*numTrial,timeLength);
- percentMatrixAllTrial = zeros(numOdor,numTrial,timeLength);
- percentMatrix = zeros(numOdor+1,timeLength);
- for i = 1:numOdor
- blockIndex = find(clusterAssignment(:,1)==i);
- resultMatrix(i,1:length(blockIndex)) = clusterAssignment(blockIndex,2);
- resultMatrixTrialPerRow((i-1)*numTrial+1:i*numTrial,:) = reshape(resultMatrix(i,:),timeLength,numTrial)';
- tempPercent = clusterAssignment(blockIndex,3);
- percentMatrixTrialPerRow = reshape(tempPercent,timeLength,numTrial)';
- percentMatrixAllTrial(i,:,:) = percentMatrixTrialPerRow;
- percentMatrix(i,:) = mean(percentMatrixTrialPerRow,1);
- end
- percentMatrix(end,:) = mean(percentMatrix(1:numOdor,:),1);
- if OnOffIter == 1, smooth = 3; else, smooth = 4; end
- percentMatrix(1:end-1,:) = filtfilt(ones(1,smooth)/smooth,1,percentMatrix(1:end-1,:)')';
- percentMatrix(end,:) = filtfilt(ones(1,smooth)/smooth,1,percentMatrix(end,:));
- if OnOffIter == 1
- origTimeON = linspace(0,onDuration,length(percentMatrix(end,:)));
- interpCurveON = interp1(origTimeON, percentMatrix(end,:), commonTimeON,'linear');
- totalPercentMatrixON(fileIter,:) = interpCurveON;
- else
- origTimeOFF = linspace(0,afterDuration,length(percentMatrix(end,:)));
- interpCurveOFF = interp1(origTimeOFF, percentMatrix(end,:), commonTimeOFF,'linear');
- totalPercentMatrixOFF(fileIter,:) = interpCurveOFF;
- end
- end
- end
- totalPercentMatrixON(end+1,:) = mean(totalPercentMatrixON, 1,'omitnan');
- totalPercentMatrixOFF(end+1,:) = mean(totalPercentMatrixOFF, 1,'omitnan');
- timeAxisON = linspace(0,onDuration,size(totalPercentMatrixON,2));
- figure; hold on;
- for r = 1:fileIter
- plot(timeAxisON, totalPercentMatrixON(r,:)*100,'Color',[0.7 0.7 0.7],'LineWidth',2);
- end
- plot(timeAxisON, totalPercentMatrixON(end,:)*100,'Color','k','LineWidth',4);
- chanceLevel = 100/numOdor; yline(chanceLevel,':','Chance','LabelHorizontalAlignment','left');
- xlim([0 onDuration]); xticks(linspace(0,onDuration,5)); xticklabels(linspace(0,onDuration,5));
- xlabel('Mouse ON, time after odor onset (s)'); ylabel('Classification rate (%)'); title('ON Prediction (n = 8)'); axis square;
- timeAxisOFF = linspace(0,afterDuration,size(totalPercentMatrixOFF,2));
- figure; hold on;
- for r = 1:fileIter
- plot(timeAxisOFF, totalPercentMatrixOFF(r,:)*100,'Color',[0.7 0.7 0.7],'LineWidth',2);
- end
- plot(timeAxisOFF, totalPercentMatrixOFF(end,:)*100,'Color','k','LineWidth',4);
- chanceLevel = 100/numOdor; yline(chanceLevel,':','Chance','LabelHorizontalAlignment','left');
- xlim([0 afterDuration]); xticks(linspace(0,afterDuration,9)); xticklabels(linspace(0,afterDuration,9));
- xlabel('Mouse ITI, time after odor offset (s)'); ylabel('Classification rate (%)'); title('ITI Prediction (n = 8)'); axis square;
- %% Fig6c: PCA analysis and ITI classification
- close all; clc; clear
- fileName = 'm149_3_1_dataset\';
- load(strcat(fileName, '\filtData3.mat'));
- odorAbbrev = {'met', 'ace', 'als', 'eug'};
- odorOrder = [2 1 4 3];
- solBlocks = 4:7;
- nOdors = 4;
- nTrials = 10;
- nGlom = size(blockData.block4,3);
- onDuration = 5; preDuration = 2;fps = 16;
- trials = 1:nTrials;
- nbins = nTrials;
- pcDim = 1:3;
- offDuration = 50;
- timeBins = (onDuration+preDuration)*fps+1:fps*(onDuration+preDuration+offDuration);
- [colorMap] = ColorScheme(nOdors);
- medRsp = [];
- for oo = 1:nOdors
- tempName = strcat('filtData.block', num2str(oo));
- currentOdor = eval(tempName);
- temp = squeeze(mean(currentOdor(trials, timeBins,:),2)); %single trial
- medRsp = [medRsp; temp];
- end
- allData = [medRsp];
- [~,data_pca,latent] = pca(allData);
- [v] = latent(pcDim)/sum(latent);
- v1 = round(v(1)*10000)/100;
- v2 = round(v(2)*10000)/100;
- v3 = round(v(3)*10000)/100;
- st1 = strcat('PC', string(pcDim(1)), '(', num2str(v1),'%)');
- st2 = strcat('PC', string(pcDim(2)), '(', num2str(v2),'%)');
- st3 = strcat('PC', string(pcDim(3)), '(', num2str(v3),'%)');
- fff = figure(1);
- set(fff, 'units','normalized','outerposition',[0 0 0.4 0.5])
- hold on; grid on;
- xlabel(st1,'fontsize', 12);
- ylabel(st2,'fontsize', 12);
- zlabel(st3,'fontsize', 12);
- for t = 1:nOdors
- data2 = data_pca(((t-1)*nTrials+1):(nTrials*t), pcDim);
- for tt = trials
- if tt == nTrials
- plot3(data2(tt,1), data2(tt,2), data2(tt,3),...
- 'o', 'Color', colorMap(t,:),...
- 'MarkerFaceColor', colorMap(t,:),...
- 'LineWidth', 2, 'DisplayName',strcat('ITI: ',odorAbbrev{t}),...
- 'LineStyle', 'none', 'MarkerSize',8);
- else
- plot3(data2(tt,1), data2(tt,2), data2(tt,3),...
- 'o', 'Color', colorMap(t,:),...
- 'MarkerFaceColor', colorMap(t,:),...
- 'LineWidth', 2, 'HandleVisibility','off',...
- 'LineStyle', 'none', 'MarkerSize',8);
- end
- hold on;
- end
- end
- legend('Location','eastoutside');
- title({'Filled marker = 55s ITI'});
- axis square;
- %% Fig6d kNN leave-one-out classification for ITI spont activity
- clc; close all;
- k = 20;
- labels = zeros(1, nOdors * nTrials);
- nTrials = 10;
- nPts = zeros(1, nOdors);
- labeltemp = cell(1, nOdors);
- for oo = 1:nOdors
- labels((oo-1)*nTrials+1:oo*nTrials) = oo;
- nPts(oo) = nTrials;
- labeltemp{oo} = strcat('ITI:', odorAbbrev{oo});
- end
- cosDist = squareform(pdist(data_pca(:,1:3),'cosine'));
- nPtsTot = size(data_pca,1);
- classAccur = [];
- pointAccur = [];
- classifClass = zeros(nOdors,nOdors);
- for dd = 1:nPtsTot
- [~, indd] = sort(cosDist(dd,:));
- closePt = indd(2:k+1); %k-number closest points
- closeLabel(dd,1:k) = labels(closePt); %label of closest points
- predictedLabel(dd) = mode(closeLabel(dd,1:k));
- queryLabel = labels(dd); %label of query pt
- compPt = (queryLabel == closeLabel(dd,:)); %accuracy
- pointAccur(dd) = sum(compPt)/length(compPt); %normalized accuracy
- classifClass(queryLabel,predictedLabel(dd)) = classifClass(queryLabel,predictedLabel(dd))+1;
- end
- normclassifClass = classifClass./nPts; % normalized classification
- for dd = 1:nOdors
- classAccur(dd) = mean(pointAccur((oo-1)*nPts+1:oo*nPts));
- end
- classRate = diag(normclassifClass)*100;
- classRateITI = mean(classRate(1:nOdors));
- % Confusion matrix for each increment
- figure;
- imagesc(normclassifClass); hold on;
- cc = colorbar; cc.Label.String = 'P(Classification)';
- % colormap(flipud(gray))
- caxis([0 1])
- cc.Ticks = 0:0.5:1;
- set(gca, 'XTick',1:4,'xticklabel',labeltemp,'YTick',1:4,'yticklabel',labeltemp)
- ylabel('Actual'); xlabel('Predicted')
- axis square
- title({strcat('k-NN Classification: k=',num2str(k)),...
- strcat('ITI Classification Rate:',num2str(classRateITI),'%')})
- %% Fig6d_control kNN leave-one-out classification with shuffled data label
- clc; close all;
- repeat = 1000;
- repeatNormClassifClass = zeros(nOdors,nOdors);
- repeatClassAccur = zeros(repeat,1);
- repeatClassRate = 0;
- for ri = 1 : repeat
- closeLabel_shuf = zeros(nPtsTot, k);
- predictedLabel_shuf = zeros(1, nPtsTot);
- pointAccur_shuf = zeros(1, nPtsTot);
- classifClass_shuf = zeros(nOdors, nOdors);
- shufLabels = labels(randperm(numel(labels))); % shuffled training labels
- for dd = 1:nPtsTot
- [~, indd] = sort(cosDist(dd,:));
- closePt = indd(2:k+1);
- % neighbors use SHUFFLED labels
- closeLabel_shuf(dd,1:k) = shufLabels(closePt);
- predictedLabel_shuf(dd) = mode(closeLabel_shuf(dd,1:k));
- queryLabel = labels(dd); % still true label
- compPt = (queryLabel == closeLabel_shuf(dd,:));
- pointAccur_shuf(dd) = mean(compPt);
- classifClass_shuf(queryLabel, predictedLabel_shuf(dd)) = ...
- classifClass_shuf(queryLabel, predictedLabel_shuf(dd)) + 1;
- end
- normclassifClass_shuf = classifClass_shuf ./ nTrials;
- repeatNormClassifClass = repeatNormClassifClass + normclassifClass_shuf;
- classRate_shuf = diag(normclassifClass_shuf) * 100;
- classRateITI_shuf = mean(classRate_shuf);
- repeatClassAccur(ri) = classRateITI_shuf;
- end
- repeatNormClassifClass = repeatNormClassifClass ./ repeat;
- repeatClassRate = mean(repeatClassAccur);
- repeatClassStd = std(repeatClassAccur);
- fprintf('Repeat %d times with Mean = %.2f%% and STD = %.2f \n', repeat, repeatClassRate , repeatClassStd);
- figure;
- imagesc(normclassifClass_shuf); hold on;
- cc = colorbar; cc.Label.String = 'P(Classification)';
- caxis([0 1])
- cc.Ticks = 0:0.5:1;
- set(gca, 'XTick',1:nOdors,'xticklabel',labeltemp, ...
- 'YTick',1:nOdors,'yticklabel',labeltemp);
- ylabel('Actual'); xlabel('Predicted');
- axis square
- title({sprintf('k-NN Shuffled Classification: k = %d', k), ...
- sprintf('ITI Shuffled Classification Rate (REAL): %.2f %%', classRateITI_shuf)});
- figure; imagesc(repeatNormClassifClass); hold on;
- cc = colorbar; cc.Label.String = 'P(Classification)';
- caxis([0 1])
- cc.Ticks = 0:0.5:1;
- set(gca, 'XTick',1:nOdors,'xticklabel',labeltemp,'YTick',1:nOdors,'yticklabel',labeltemp)
- ylabel('Actual'); xlabel('Predicted')
- axis square
- title({'Fig 6d-control', sprintf('Mean classification rate: %.2f%% (n = %d)', repeatClassRate, repeat)});
- %% ============= Fig6 a/b/h: accuracy and stats comparing datasets ===========================
- clear;
- % SETTINGS
- % datasetDir = 'm129_1_2_dataset'; % Uncomment for Fig6h
- datasetDir = 'm149_3_1_dataset'; % Uncomment for Fig6ab
- KNN = 10;
- numTrial = 10;
- nPerm = 1000;
- qFDR = 0.05;
- useFDR = true;
- doMaxT = true;
- % Load data
- S = load(fullfile(datasetDir,'filtData2.mat'));
- filtData = S.filtData;
- fps = S.fps; preDuration = S.preDuration; onDuration = S.onDuration; afterDuration = S.afterDuration;
- names = fieldnames(filtData);
- odorFields = names;
- numOdor = numel(odorFields);
- stats = struct([]);
- for OnOffIter = 1:2
- % Time window + binning
- if OnOffIter == 1
- range = preDuration*fps+1 : (preDuration+onDuration)*fps;
- numBinAvg = 1; smoothN = 2; durSec = onDuration;
- plotTitle = sprintf('ON Prediction | %s', datasetDir);
- xlab = 'Mouse ON, time after odor onset (s)';
- else
- range = (preDuration+onDuration)*fps+1 : (afterDuration+preDuration+onDuration)*fps;
- numBinAvg = 4; smoothN = 4; durSec = afterDuration;
- plotTitle = sprintf('ITI Prediction | %s', datasetDir);
- xlab = 'Mouse ITI, time after odor offset (s)';
- end
- % Build newBlockData (odor -> trials x timeBins x features)
- newBlockData = cell(numOdor,1);
- for i = 1:numOdor
- tempData = filtData.(odorFields{i});
- tempFiltData = tempData(1:numTrial, range, :);
- iter = ceil(length(range)/numBinAvg);
- tempFiltData2 = zeros(numTrial, iter, size(tempFiltData,3));
- for ii = 1:numBinAvg:length(range)
- b = (ii-1)/numBinAvg + 1;
- try
- tempFiltData2(:,b,:) = mean(tempFiltData(:,ii:ii+numBinAvg-1,:),2);
- catch
- tempFiltData2(:,b,:) = mean(tempFiltData(:,ii:end,:),2);
- end
- end
- newBlockData{i} = tempFiltData2;
- end
- timeLength = size(newBlockData{1},2);
- % Reshape into allUnits + trueLabels
- allUnits = [];
- trueLabels = [];
- for i = 1:numOdor
- unitVector = newBlockData{i};
- tempUnits = reshape(permute(unitVector,[2 1 3]), [], size(unitVector,3));
- allUnits = [allUnits; tempUnits];
- trueLabels = [trueLabels; i*ones(size(tempUnits,1),1)];
- end
- numUnits = size(allUnits,1);
- numGlom = size(allUnits,2)
- rowStd = std(allUnits,0,2);
- zidx = (rowStd == 0);
- if any(zidx)
- allUnits(zidx,:) = allUnits(zidx,:) + 1e-12*randn(sum(zidx), size(allUnits,2));
- end
- % Distance matrix + leave-trial-out blocks
- tempDistMatrix = squareform(pdist(allUnits,'correlation'));
- tempDistMatrix(isnan(tempDistMatrix)) = 1;
- diagValue = ones(1,numUnits)*10;
- fullDistMatrix = tempDistMatrix + diag(diagValue);
- trialBlock = ones(timeLength)*10;
- trialBlockMatrix = kron(eye(numOdor*numTrial), trialBlock);
- fullDistMatrix = fullDistMatrix + trialBlockMatrix*10;
- [~, idx] = sort(fullDistMatrix,2,'ascend');
- colIndices = idx(:,1:KNN);
- % Real decoding
- [real_black, real_perOdor] = compute_percent_per_odor( ...
- trueLabels, colIndices, trueLabels, numOdor, timeLength, numTrial, smoothN);
- % Shuffle null distribution
- shuf_black = zeros(nPerm, timeLength);
- for pi = 1:nPerm
- shufLabels = trueLabels(randperm(numUnits));
- shuf_black(pi,:) = compute_percent_per_odor( ...
- shufLabels, colIndices, trueLabels, numOdor, timeLength, numTrial, smoothN);
- end
- % p-values per time bin + FDR / maxT
- p_point = (sum(shuf_black >= real_black,1) + 1) / (nPerm + 1);
- if useFDR
- sig_fdr = mafdr(p_point,'BHFDR',true) < qFDR;
- else
- sig_fdr = p_point < 0.05/numel(p_point);
- end
- p_maxT = nan(size(p_point));
- sig_maxT = false(size(p_point));
- if doMaxT
- shuf_mu = mean(shuf_black,1);
- shuf_sd = std(shuf_black,0,1) + eps;
- real_z = (real_black - shuf_mu) ./ shuf_sd;
- maxZ = zeros(nPerm,1);
- for pi = 1:nPerm
- z_perm = (shuf_black(pi,:) - shuf_mu) ./ shuf_sd;
- maxZ(pi) = max(z_perm);
- end
- p_maxT = (sum(maxZ >= real_z,1) + 1) / (nPerm + 1);
- sig_maxT = p_maxT < 0.05;
- end
- % Plot
- timeAxis = linspace(0, durSec, timeLength);
- figure; hold on;
- lo = prctile(shuf_black,2.5,1);
- hi = prctile(shuf_black,97.5,1);
- fill([timeAxis fliplr(timeAxis)], [lo*100 fliplr(hi*100)], ...
- [0.7 0.7 0.7], 'FaceAlpha', 0.25, 'EdgeColor', 'none');
- plot(timeAxis, mean(shuf_black,1)*100, 'Color', [0.5 0.5 0.5], 'LineWidth', 2);
- odorColors = ColorScheme(numOdor,0.25);
- for oo = 1:numOdor
- plot(timeAxis, real_perOdor(oo,:)*100, 'LineWidth', 2, 'Color', odorColors(oo,:));
- end
- plot(timeAxis, real_black*100, 'k', 'LineWidth', 5);
- yline(100/numOdor, ':', 'Chance', 'LabelHorizontalAlignment','left');
- xlabel(xlab); ylabel('Classification rate (%)');
- title(sprintf('%s | nPerm=%d', plotTitle, nPerm));
- axis square; box on; xlim([0 durSec]);
- p_for_bar = p_point;
- p_for_bar(~sig_fdr) = 1;
- yl = ylim;
- yBar = yl(1) + 0.05*(yl(2)-yl(1));
- plot_sig_bars(timeAxis, p_for_bar, yBar, 8);
- fprintf('\n=== %s ===\n', plotTitle);
- fprintf('Min pointwise p: %.4g\n', min(p_point));
- fprintf('FDR(q=%.3f) sig bins: %d/%d\n', qFDR, sum(sig_fdr), numel(sig_fdr));
- if doMaxT
- fprintf('MaxT(FWER) sig bins: %d/%d | min p_maxT=%.4g\n', ...
- sum(sig_maxT), numel(sig_maxT), min(p_maxT));
- end
- % store
- stats(OnOffIter).timeAxis = timeAxis;
- stats(OnOffIter).real_perOdor = real_perOdor;
- stats(OnOffIter).real_black = real_black;
- stats(OnOffIter).shuf_black = shuf_black;
- stats(OnOffIter).p_point = p_point;
- stats(OnOffIter).sig_fdr = sig_fdr;
- stats(OnOffIter).p_maxT = p_maxT;
- stats(OnOffIter).sig_maxT = sig_maxT;
- stats(OnOffIter).odorFields = odorFields;
- end
- % ============= Fig6 e/f/i: accuracy and stats comparing datasets ===========================
- clear;
- % % Fig6ef list:
- % fileNameKNN = {
- % 'm149_1_2_dataset';
- % 'm148_2_1_dataset';
- % 'm141_8_1_dataset';
- % 'm141_1_1_dataset';
- % 'm149_3_1_dataset';
- % };
- % Fig6i list:
- fileNameKNN = {
- 'm122_4_4_dataset';
- 'm125_1_1_dataset';
- 'm126_1_1_dataset';
- 'm134_6_1_dataset';
- 'm129_1_2_dataset';
- 'm129_4_2_dataset';
- 'm129_3_1_dataset';
- 'm1716_1_1_dataset';
- };
- OnOffIter = 2; % 1=ON, 2=ITI/OFF, 3=ITI/OFF random structure
- KNN = 10;
- numTrial = 10;
- binSizePts = 5;
- qFDR = 0.05;
- sessColor = [0.55 0.80 0.82];
- semColor = [0.70 0.70 0.70];
- meanColor = [0 0 0];
- chanceColor = [0.55 0.55 0.55];
- pThresh = [0.05, 0.01, 0.001];
- pColors = {[0 0 0]; [0.85 0 0]; [0 0 0.85]};
- % Time for interpolation
- if OnOffIter == 1
- commonTime = linspace(0,5,200);
- xlab = 'Time (s)';
- elseif OnOffIter == 2
- commonTime = linspace(0,50,500);
- xlab = 'Time after odor offset (s)';
- else
- commonTime = linspace(0,17,500);
- xlab = 'Time after odor offset (s)';
- end
- % means across odors by session
- nSess = numel(fileNameKNN);
- nTime = numel(commonTime);
- accSess = nan(nSess, nTime);
- chanceFixed = [];
- for s = 1:nSess
- datasetDir = fileNameKNN{s};
- fprintf('Session %d/%d: %s\n', s, nSess, datasetDir);
- % Load + parse
- S = load(fullfile(datasetDir,'filtData2.mat'));
- filtData = S.filtData;
- fps = S.fps; preDuration = S.preDuration; onDuration = S.onDuration; afterDuration = S.afterDuration;
- names = fieldnames(filtData);
- odorFields = names;
- numOdor = numel(odorFields);
- if isempty(chanceFixed), chanceFixed = 1/numOdor; end
- % Window + binning
- if OnOffIter == 1
- range = preDuration*fps+1 : (preDuration+onDuration)*fps;
- numBinAvg = 1; smoothN = 2; durSec = onDuration;
- else
- range = (preDuration+onDuration)*fps+1 : (afterDuration+preDuration+onDuration)*fps;
- numBinAvg = 4; smoothN = 4; durSec = afterDuration;
- end
- [timeAxis_s, meanTrace_s] = decode_timecurve( ...
- filtData, odorFields, range, fps, numTrial, numBinAvg, KNN, smoothN, durSec);
- accSess(s,:) = interp1(timeAxis_s, meanTrace_s, commonTime, 'linear', 'extrap');
- end
- % STATS: one-sided t-test vs chance + BH-FDR
- [xStat, accStat] = bin_timecourses(commonTime, accSess, binSizePts);
- nBins = numel(xStat);
- p_raw = nan(nBins,1);
- for b = 1:nBins
- y = accStat(:,b);
- y = y(~isnan(y));
- if numel(y) >= 2
- [~, p_raw(b)] = ttest(y, chanceFixed, 'Tail','right');
- end
- end
- sig_fdr = bh_fdr_mask(p_raw, qFDR);
- % Plot
- figure; hold on;
- for s = 1:nSess
- plot(commonTime, accSess(s,:)*100, 'Color', sessColor, 'LineWidth', 2);
- end
- meanAcc = mean(accSess, 1, 'omitnan');
- semAcc = std(accSess, 0, 1, 'omitnan') ./ sqrt(sum(~isnan(accSess),1));
- fill([commonTime fliplr(commonTime)], ...
- [(meanAcc-semAcc)*100 fliplr((meanAcc+semAcc)*100)], ...
- semColor, 'FaceAlpha', 0.6, 'EdgeColor','none');
- plot(commonTime, meanAcc*100, 'Color', meanColor, 'LineWidth', 3.5);
- yline(chanceFixed*100, '--', 'Color', chanceColor, 'LineWidth', 1.3);
- xlabel(xlab);
- ylabel('Classification rate (%)');
- ylim([0 100]);
- xlim([commonTime(1) commonTime(end)]);
- box off;
- yl = ylim;
- yBar = yl(1) + 0.03*diff(yl);
- plot_sig_dots(xStat, p_raw, sig_fdr, yBar, pThresh, pColors, 7.5);
- % Functions for Figure 6 A, B, H
- function [blackLine, perOdor] = compute_percent_per_odor(labelVec, colIndices, trueLabels, ...
- numOdor, timeLength, numTrial, smoothN)
- numUnits = numel(trueLabels);
- KNN = size(colIndices,2);
- clusterTemp = zeros(numUnits, KNN);
- for nn = 1:KNN
- clusterTemp(:,nn) = labelVec(colIndices(:,nn));
- end
- predLabel = mode(clusterTemp,2);
- correct = (predLabel == trueLabels);
- perOdor = zeros(numOdor, timeLength);
- for oo = 1:numOdor
- idx = find(trueLabels == oo);
- tmpMat = reshape(correct(idx), timeLength, numTrial)';
- perOdor(oo,:) = mean(tmpMat,1);
- end
- if smoothN > 1
- for oo = 1:numOdor
- perOdor(oo,:) = filtfilt(ones(1,smoothN)/smoothN, 1, perOdor(oo,:));
- end
- end
- blackLine = mean(perOdor,1);
- end
- function plot_sig_bars(timeAxis, pvals, y, lw)
- if nargin < 4, lw = 6; end
- thr = [0.05, 0.01, 0.001];
- cols = {[0 0 0], [1 0 0], [0 0 1]};
- for k = 1:numel(thr)
- sig = pvals < thr(k);
- d = diff([false sig false]);
- starts = find(d==1);
- ends = find(d==-1) - 1;
- for s = 1:numel(starts)
- i1 = starts(s); i2 = ends(s);
- line([timeAxis(i1) timeAxis(i2)], [y y], ...
- 'Color', cols{k}, 'LineWidth', lw, 'Clipping', 'on');
- end
- end
- end
- % Functions for Figure 6 E, F, I
- function [timeAxis, meanTrace] = decode_timecurve( ...
- filtData, odorFields, range, fps, numTrial, numBinAvg, KNN, smoothN, durSec)
- numOdor = numel(odorFields);
- % bin within range for each odor: trials x timeBins x features
- blockData = cell(numOdor,1);
- for i = 1:numOdor
- tempData = filtData.(odorFields{i});
- temp = tempData(1:numTrial, range, :);
- iter = ceil(length(range)/numBinAvg);
- tempBinned = zeros(numTrial, iter, size(temp,3));
- for ii = 1:numBinAvg:length(range)
- b = (ii-1)/numBinAvg + 1;
- try
- tempBinned(:,b,:) = mean(temp(:,ii:ii+numBinAvg-1,:),2);
- catch
- tempBinned(:,b,:) = mean(temp(:,ii:end,:),2);
- end
- end
- blockData{i} = tempBinned;
- end
- timeLength = size(blockData{1},2);
- % units + labels
- allUnits = [];
- trueLabels = [];
- for i = 1:numOdor
- X = blockData{i};
- U = reshape(permute(X,[2 1 3]), [], size(X,3));
- allUnits = [allUnits; U];
- trueLabels = [trueLabels; i*ones(size(U,1),1)];
- end
- numUnits = size(allUnits,1);
- rowStd = std(allUnits,0,2);
- zidx = (rowStd==0);
- if any(zidx)
- allUnits(zidx,:) = allUnits(zidx,:) + 1e-12*randn(sum(zidx), size(allUnits,2));
- end
- % distance matrix
- distMat = squareform(pdist(allUnits,'correlation'));
- distMat(isnan(distMat)) = 1;
- distMat = distMat + diag(ones(numUnits,1)*10);
- % exclude within-odor same-trial neighbors
- trialBlock = ones(timeLength)*10;
- penalty = kron(eye(numOdor*numTrial), trialBlock);
- distMat = distMat + penalty*10;
- [~, idx] = sort(distMat,2,'ascend');
- nnIdx = idx(:,1:KNN);
- [meanTrace, ~] = compute_percent_per_odor_2( ...
- trueLabels, nnIdx, trueLabels, numOdor, timeLength, numTrial, smoothN);
- timeAxis = linspace(0, durSec, timeLength);
- end
- function [meanTrace, perOdor] = compute_percent_per_odor_2(labelVec, nnIdx, trueLabels, ...
- numOdor, timeLength, numTrial, smoothN)
- numUnits = numel(trueLabels);
- KNN = size(nnIdx,2);
- neigh = zeros(numUnits, KNN);
- for nn = 1:KNN
- neigh(:,nn) = labelVec(nnIdx(:,nn));
- end
- predLabel = mode(neigh,2);
- correct = (predLabel == trueLabels);
- perOdor = zeros(numOdor, timeLength);
- for oo = 1:numOdor
- idx = find(trueLabels == oo);
- tmpMat = reshape(correct(idx), timeLength, numTrial)';
- perOdor(oo,:) = mean(tmpMat,1);
- end
- if smoothN > 1
- for oo = 1:numOdor
- perOdor(oo,:) = filtfilt(ones(1,smoothN)/smoothN, 1, perOdor(oo,:));
- end
- end
- meanTrace = mean(perOdor,1);
- end
- function [xBin, accBin] = bin_timecourses(x, accSess, binSizePts)
- [nSess, nTime] = size(accSess);
- nBins = floor(nTime/binSizePts);
- xT = x(1:nBins*binSizePts);
- accT = accSess(:,1:nBins*binSizePts);
- accR = reshape(accT, nSess, binSizePts, nBins);
- accBin = squeeze(mean(accR,2,'omitnan'));
- xR = reshape(xT, binSizePts, nBins);
- xBin = mean(xR,1,'omitnan')';
- end
- function sig = bh_fdr_mask(p, q)
- sig = false(size(p));
- v = ~isnan(p);
- pv = p(v);
- if isempty(pv), return; end
- [ps, ord] = sort(pv);
- m = numel(ps);
- th = (1:m)'/m*q;
- pass = ps <= th;
- if any(pass)
- kmax = find(pass,1,'last');
- idxValid = find(v);
- sig(idxValid(ord(1:kmax))) = true;
- end
- end
- function plot_sig_dots(x, p_raw, sig_fdr, yBar, pThresh, pColors, markerSize)
- elig = sig_fdr & ~isnan(p_raw);
- for i = 1:numel(x)
- if ~elig(i), continue; end
- if p_raw(i) < pThresh(3)
- c = pColors{3};
- elseif p_raw(i) < pThresh(2)
- c = pColors{2};
- elseif p_raw(i) < pThresh(1)
- c = pColors{1};
- else
- continue
- end
- plot(x(i), yBar, 'o', ...
- 'MarkerFaceColor', c, ...
- 'MarkerEdgeColor', c, ...
- 'MarkerSize', markerSize);
- end
- end
Script_Fig6.m, under CC-BY-4.0 · at the source
Overview
- Department of Molecular and Human Genetics, Baylor College of Medicine, Houston, TX 77030, USA
- Department of Biomedical Engineering, Washington University in St. Louis, St. Louis, MO 63105, USA
- Department of Neuroscience, Baylor College of Medicine, Houston, TX 77030, USA
Abstract
Interpreting chemical information and translating it into ethologically relevant output is a shared challenge of olfactory systems across species, but are olfactory computations conserved across species to overcome these common challenges? To investigate this, we compared neural activity in the locust antennal lobe (AL) and mouse olfactory bulb (OB) both during and after odor presentations. We found that odors activated nearly mutually exclusive neural ensembles during odor presentations (“ON response”) and after the termination of the odor stimulus (“OFF response”). ON and OFF responses evoked by a single odor were anticorrelated with each other. Inverted OFF responses persisted long after odor termination in both AL and OB, and enhanced contrast between odors that were experienced close together in time. Together our results show how post-odor neural activity, relative to odor-evoked activity, is similar across two distinct species, revealing a conserved mechanism for enhancing contrast between odors at the neural level.
Reproduced under the paper's license (CC BY), from the paper cited above.
Repository
Its files are read in the Code ↔ Paper reader above, with 1 match between paragraphs and lines of code.
figshare 31435543
Availability: 1 check, the latest on 30 September 2026: the link answers (HTTP 200)
- 30 September 2026: the link answers (HTTP 200)
8 files
- ColorScheme.m, MATLAB, 90 lines
- ColorScheme2.m, MATLAB, 90 lines
- Script_Fig1.m, MATLAB, 90 lines
- Script_Fig2.m, MATLAB, 501 lines
- Script_Fig3.m, MATLAB, 427 lines
- Script_Fig4.m, MATLAB, 460 lines
- Script_Fig5.m, MATLAB, 670 lines
- Script_Fig6.m, MATLAB, 1,148 lines, 1 match
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:
- 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
- 8 scripts, each with its path and the digest of its content;
- 1 match 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.
Data and code availability
• Locust electrophysiology and mouse calcium imaging data is publicly available at Figshare: https://
Reproduced under the paper's license (CC BY), from the paper cited above.
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, 30 September 2026: the first record
Recorded: type, language, journal, volume, issue, pages, dates, 8 authors, 3 keywords, 7 funders, 61 references, 3 RRIDs.
Cite
This paper
Moss, E. H., Ling, D., Smith, C. L., Deng, F., Kroeger, R., Reimer, J., Raman, B., & Arenkiel, B. R. (2026). Conserved post-odor dynamics in the olfactory systems of mice and locusts. iScience, 29(4), 115373. https://
BibTeX
@article{moss2026conserv
author = {Moss, Elizabeth H. and Ling, Doris and Smith, Cameron L. and Deng, Feiyang and Kroeger, Ryan and Reimer, Jacob and Raman, Baranidharan and Arenkiel, Benjamin R.},
title = {{Conserved post-odor dynamics in the olfactory systems of mice and locusts}},
journal = {iScience},
year = {2026},
month = mar,
volume = {29},
number = {4},
pages = {115373},
publisher = {Elsevier},
issn = {2589-0042},
doi = {10.1016/
url = {https://
pmid = {41971993},
pmcid = {PMC13066794}
}
RIS
TY - JOUR
AU - Moss, Elizabeth H.
AU - Ling, Doris
AU - Smith, Cameron L.
AU - Deng, Feiyang
AU - Kroeger, Ryan
AU - Reimer, Jacob
AU - Raman, Baranidharan
AU - Arenkiel, Benjamin R.
TI - Conserved post-odor dynamics in the olfactory systems of mice and locusts
T2 - iScience
J2 - iScience
PY - 2026
DA - 2026/
VL - 29
IS - 4
SP - 115373
SN - 2589-0042
PB - Elsevier
DO - 10.1016/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1016/
"type": "article-journal",
"title": "Conserved post-odor dynamics in the olfactory systems of mice and locusts",
"container-title": "iScience",
"author": [
{
"family": "Moss",
"given": "Elizabeth H."
},
{
"family": "Ling",
"given": "Doris"
},
{
"family": "Smith",
"given": "Cameron L."
},
{
"family": "Deng",
"given": "Feiyang"
},
{
"family": "Kroeger",
"given": "Ryan"
},
{
"family": "Reimer",
"given": "Jacob"
},
{
"family": "Raman",
"given": "Baranidharan"
},
{
"family": "Arenkiel",
"given": "Benjamin R."
}
],
"container-title-short":
"volume": "29",
"issue": "4",
"page": "115373",
"DOI": "10.1016/
"PMID": "41971993",
"PMCID": "PMC13066794",
"ISSN": "2589-0042",
"publisher": "Elsevier",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
3,
16
]
]
}
}
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.7554/elife.107905 [code]
- Adult-neurogenesis allows for representational stability and flexibility in early olfactory system.Journal: eLifeIn common: 7 references
- [2] doi:10.1038/s41592-026-03023-y
- Isotonic and minimally invasive optical clearing media for live cell imaging ex vivo and in vivo.Journal: Nature methodsIn common: mouse, 5 references
- [3] doi:10.1126/sciadv.aee1002 [code]
- Theta oscillations are an organizational unit of odor processing in the olfactory bulb.Journal: Science advancesIn common: Signal Processing Toolbox, Statistics and Machine Learning Toolbox, 2 references
- [4] doi:10.1038/s41467-026-70356-9
- A topographical organization in the primary olfactory cortex.Journal: Nature communicationsIn common: mouse, 3 references
- [5] doi:10.1016/j.isci.2026.115897 [code]
- Experience and behavior modulate piriform cortex odor representation in freely moving mice.Journal: iScienceIn common: Signal Processing Toolbox, Statistics and Machine Learning Toolbox, mouse, 1 reference
- [6] doi:10.1002/cne.70197
- Anatomical Investigation Reveals a Second Olfactory System in Locusts.Journal: The Journal of comparative neurologyIn common: other, 2 references
- [7] doi:10.1038/s41467-026-71742-z [code]
- Hypercapnia dissociates neuronal and hemodynamic responses impairing neurovascular coupling and functional brain connectivity.Journal: Nature communicationsIn common: Signal Processing Toolbox, Statistics and Machine Learning Toolbox, mouse, 1 reference
- [8] doi:10.7554/elife.110685 [code]
- Sensory adaptation and pupil-linked arousal support flexible evidence accumulation during perceptual decision making.Journal: eLifeIn common: Signal Processing Toolbox, Statistics and Machine Learning Toolbox, 1 reference
- [9] doi:10.1038/s41467-026-71356-5 [code]
- Generalization of fear learning is shaped by inhibitory sensory processing in mice.Journal: Nature communicationsIn common: mouse, 2 references
- [10] doi:10.1126/sciadv.aeg3535 [code]
- Undoing of firing rate adaptation enables invariant population codes.Journal: Science advancesIn common: 2 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.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 1 repository of the authors' code, each at its verified commit and with its license, 8 scripts, and 1 match between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:5929165e1b9d3973…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[.
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.
