Browse Source

gin commit from DESKTOP-593CF0Q

New files: 4
Modified files: 1
jiyunshin 3 years ago
parent
commit
069e26565a

+ 11 - 200
codes/Electrophysiology analysis/PlotCellAverage.m

@@ -1,231 +1,42 @@
-load('PooledCellsData.mat')
-%% Connected dots - Hit trials
-figure
-
-subplot(121)
-ConnectedDots2 (Control_hit_freq(:,1), Control_hit_freq(:,2)) % Unclear_hit_freq(:,1)])
-%set(gca,'XTickLabel',{'Control (n=41)','hM4Di (n=40)'})
-ylabel('Spike rate (Hz)')
-title('Control')
-[p h] = signrank (Control_hit_freq(:,1), Control_hit_freq(:,2)) % Unclear_hit_freq(:,1)])
-hold on
-text(1.2, 20, ['p = ', num2str(p)]) 
-
-subplot(122)
-ConnectedDots2 (newDREADD_hit_freq(:,1), newDREADD_hit_freq(:,2)) % Unclear_hit_freq(:,1)])
-%set(gca,'XTickLabel',{'Control (n=42)','hM4Di (n=26)'})
-ylabel('Spike rate (Hz)')
-title('hM4Di')
-[p h] = signrank (newDREADD_hit_freq(:,1), newDREADD_hit_freq(:,2)) % Unclear_hit_freq(:,1)])
-hold on
-text(1.2, 20, ['p = ', num2str(p)])  
-ylim([0 25])
+%% Firing rate
 
 figure
-
 subplot(121)
-ConnectedDots2 (Control_hit_burst(:,1), Control_hit_burst(:,2)) % Unclear_hit_burst(:,1)])
-%set(gca,'XTickLabel',{'Control (n=42)','hM4Di (n=26)'})
-ylabel('Burst rate (Hz)')
-title('Control')
-[p h] = signrank (Control_hit_burst(:,1), Control_hit_burst(:,2)) % Unclear_hit_burst(:,1)])
-hold on
-text(1.2, 2, ['p = ', num2str(p)]) 
-
-subplot(122)
-ConnectedDots2 (newDREADD_hit_burst(:,1), newDREADD_hit_burst(:,2)) % Unclear_hit_burst(:,1)])
-%set(gca,'XTickLabel',{'Control (n=42)','hM4Di (n=26)'})
-ylabel('Burst rate (Hz)')
-title('hM4Di')
-[p h] = signrank (newDREADD_hit_burst(:,1), newDREADD_hit_burst(:,2)) % Unclear_hit_burst(:,1)])
-hold on
-text(1.2, 2, ['p = ', num2str(p)])  
-ylim([0 2.5])
+ConnectedDots2 (Control_freq(:,1), Control_freq(:,2)) 
 
-%% Connected Dots - miss trials
-figure
-
-subplot(121)
-ConnectedDots2 (Control_miss_freq(:,1), Control_miss_freq(:,2)) % Unclear_miss_freq(:,1)])
-%set(gca,'XTickLabel',{'Control (n=41)','hM4Di (n=40)'})
 ylabel('Spike rate (Hz)')
 title('Control')
-ylim ([0 25])
-[p h] = signrank (Control_miss_freq(:,1), Control_miss_freq(:,2)) % Unclear_miss_freq(:,1)])
+[p h] = signrank (Control_freq(:,1), Control_freq(:,2)) 
 hold on
 text(1.2, 20, ['p = ', num2str(p)]) 
 
 subplot(122)
-ConnectedDots2 (newDREADD_miss_freq(:,1), newDREADD_miss_freq(:,2)) % Unclear_miss_freq(:,1)])
-%set(gca,'XTickLabel',{'Control (n=42)','hM4Di (n=26)'})
+ConnectedDots2 (DREADD_freq(:,1), DREADD_freq(:,2)) 
 ylabel('Spike rate (Hz)')
 title('hM4Di')
-[p h] = signrank (newDREADD_miss_freq(:,1), newDREADD_miss_freq(:,2)) % Unclear_miss_freq(:,1)])
+[p h] = signrank (DREADD_freq(:,1), DREADD_freq(:,2))
 hold on
 text(1.2, 20, ['p = ', num2str(p)])  
 ylim([0 25])
 
+%% Burst rate
+
 figure
 
 subplot(121)
-ConnectedDots2 (Control_miss_burst(:,1), Control_miss_burst(:,2)) % Unclear_miss_burst(:,1)])
-%set(gca,'XTickLabel',{'Control (n=42)','hM4Di (n=26)'})
+ConnectedDots2 (Control_burst(:,1), Control_burst(:,2)) 
 ylabel('Burst rate (Hz)')
 title('Control')
-ylim([0 2.5])
-[p h] = signrank (Control_miss_burst(:,1), Control_miss_burst(:,2)) % Unclear_miss_burst(:,1)])
+[p h] = signrank (Control_burst(:,1), Control_burst(:,2)) 
 hold on
 text(1.2, 2, ['p = ', num2str(p)]) 
 
 subplot(122)
-ConnectedDots2 (newDREADD_miss_burst(:,1), newDREADD_miss_burst(:,2)) % Unclear_miss_burst(:,1)])
-%set(gca,'XTickLabel',{'Control (n=42)','hM4Di (n=26)'})
+ConnectedDots2 (DREADD_burst(:,1), DREADD_burst(:,2))
 ylabel('Burst rate (Hz)')
 title('hM4Di')
-[p h] = signrank (newDREADD_miss_burst(:,1), newDREADD_miss_burst(:,2)) % Unclear_miss_burst(:,1)])
+[p h] = signrank (DREADD_burst(:,1), DREADD_burst(:,2))
 hold on
 text(1.2, 2, ['p = ', num2str(p)])  
 ylim([0 2.5])
 
-
-%% Difference
-
-Control_hit_freq(:,3) = Control_hit_freq(:,2) - Control_hit_freq(:,1);
-newDREADD_hit_freq(:,3) = newDREADD_hit_freq(:,2) - newDREADD_hit_freq(:,1);
-Unclear_hit_freq(:,3) =Unclear_hit_freq(:,2) - Unclear_hit_freq(:,1);
-
-figure
-subplot(121)
-PlotAllDataPoints (Control_hit_freq(:,3), newDREADD_hit_freq(:,3) )
-set(gca,'XTickLabel',{'Control (n=42)','hM4Di (n=26)'})
-ylabel('Post - Pre')
-title('Spike rate change')
-
-[p h] = ranksum (Control_hit_freq(:,3), newDREADD_hit_freq(:,3))
-
-hold on
-text(1.2, 10, ['p = ', num2str(p)]) 
-
-subplot(122)
-PlotAllDataPoints (abs(Control_hit_freq(:,3)), abs(newDREADD_hit_freq(:,3)) )
-set(gca,'XTickLabel',{'Control (n=42)','hM4Di (n=26)'})
-ylabel('|Post - Pre|')
-title('Spike rate Absolute change')
-
-[p h] = ranksum (abs(Control_hit_freq(:,3)), abs(newDREADD_hit_freq(:,3)))
-
-hold on
-text(1.2, 10, ['p = ', num2str(p)])
-
-% Bursts
-Control_hit_burst(:,3) = Control_hit_burst(:,2) - Control_hit_burst(:,1);
-newDREADD_hit_burst(:,3) = newDREADD_hit_burst(:,2) - newDREADD_hit_burst(:,1);
-Unclear_hit_burst(:,3) =Unclear_hit_burst(:,2) - Unclear_hit_burst(:,1);
-
-
-figure
-subplot(121)
-PlotAllDataPoints (Control_hit_burst(:,3), newDREADD_hit_burst(:,3) )
-set(gca,'XTickLabel',{'Control (n=42)','hM4Di (n=26)'})
-ylabel('Post - Pre')
-title('Burst rate change')
-
-[p h] = ranksum (Control_hit_burst(:,3), newDREADD_hit_burst(:,3))
-
-hold on
-text(1.2, 1, ['p = ', num2str(p)]) 
-
-
-subplot(122)
-PlotAllDataPoints (abs(Control_hit_burst(:,3)), abs(newDREADD_hit_burst(:,3)) )
-set(gca,'XTickLabel',{'Control (n=42)','hM4Di (n=26)'})
-ylabel('|Post - Pre|')
-title('Spike rate Absolute change')
-
-[p h] = ranksum (abs(Control_hit_burst(:,3)), abs(newDREADD_hit_burst(:,3)))
-
-hold on
-text(1.2, 1, ['p = ', num2str(p)]) 
-%% Relative change
-Control_baseline = mean(Control_hit_burst(:,1));
-newDREADD_baseline = mean(newDREADD_hit_burst(:,1));
-
-Control_hit_burst(:,4) = Control_hit_burst(:,3)./Control_baseline;
-newDREADD_hit_burst(:,4) = newDREADD_hit_burst(:,3)./newDREADD_baseline;
-
-[p h] = ranksum (Control_hit_burst(:,4), newDREADD_hit_burst(:,4))
-
-figure
-PlotAllDataPoints (Control_hit_burst(:,4).*100, newDREADD_hit_burst(:,4).*100 )
-set(gca,'XTickLabel',{'Control (n=42)','hM4Di (n=26)'})
-ylabel('Relative change (%)')
-title('Burst')
-
-
-%% Post stim
-figure
-
-subplot(121)
-PlotAllDataPoints (Control_hit_freq(:,2), newDREADD_hit_freq(:,2) )
-set(gca,'XTickLabel',{'Control (n=41)','hM4Di (n=41)'})
-ylabel('Spike rate (Hz)')
-title('Hit - Post stimulation')
-
-[p h] = ranksum (Control_hit_freq(:,2), newDREADD_hit_freq(:,2))
-
-hold on
-text(1.2, 10, ['p = ', num2str(p)]) 
-
-subplot(122)
-PlotAllDataPoints (Control_miss_freq(:,2), newDREADD_miss_freq(:,2) )
-set(gca,'XTickLabel',{'Control (n=18)','hM4Di (n=17)'})
-ylabel('Spike rate (Hz)')
-title('Miss - Post stimulation')
-
-[p h] = ranksum (Control_miss_freq(:,2), newDREADD_miss_freq(:,2))
-
-hold on
-text(1.2, 8, ['p = ', num2str(p)]) 
-ylim([0 25])
-
-%% Bar wit error
-N1 = size(Control_hit_freq,1)
-Control_Avg_hitFreq = nanmean(Control_hit_freq);
-Control_SEM_hitFreq = nanstd(Control_hit_freq,1)./sqrt(N1);
-Control_Avg_hitBurst = nanmean(Control_hit_burst)  ;
-Control_SEM_hitBurst = nanstd(Control_hit_burst,1)./sqrt(N1);
-
-N2 = size(newDREADD_hit_freq,1)
-newDREADD_Avg_hitFreq = nanmean(newDREADD_hit_freq);
-newDREADD_SEM_hitFreq = nanstd(newDREADD_hit_freq,1)./sqrt(N2);
-newDREADD_Avg_hitBurst = nanmean(newDREADD_hit_burst)  ;
-newDREADD_SEM_hitBurst = nanstd(newDREADD_hit_burst,1)./sqrt(N2);
-
-
-% %% Plotting
-figure
-subplot(2,1,1)
-varargout = barwitherr([Control_SEM_hitFreq; newDREADD_SEM_hitFreq],[Control_Avg_hitFreq; newDREADD_Avg_hitFreq])  
-set(gca,'XTickLabel',{'Control (n=41)','hM4Di (n=40)'})
-ylabel('Firing rate (Hz)')
-ylim([0 5])
-
-title('hit trials')
-legend({'preStim', 'postStim'})
-
-subplot(2,1,2)
-varargout = barwitherr([Control_SEM_hitBurst; newDREADD_SEM_hitBurst],[Control_Avg_hitBurst;newDREADD_Avg_hitBurst])  
-set(gca,'XTickLabel',{'Control (n=41)','hM4Di (n=40)'})
-ylabel('Burst rate (Hz)')
-
-
-%% Violin plot
-figure
-violin(Control_hit_burst);
-set(gca, 'XTick',[1,2],'XTickLabel',{'PreStim', 'PostStim'})
-title('Control')
-
-figure
-violin(newDREADD_hit_burst);
-set(gca, 'XTick',[1,2],'XTickLabel',{'PreStim', 'PostStim'})
-title('hM4Di')

+ 21 - 0
codes/Utilities/ConnectedDots2.m

@@ -0,0 +1,21 @@
+function ConnectedDots2(f1,f2)
+
+
+for i=1:numel(f1)
+  
+        plot([1,2],[f1(i),f2(i)],'Marker','o','MarkerSize', 10,'LineStyle','-','Color','k');
+    %end
+    hold on
+end
+
+    hold on
+mean1 = nanmean(f1);
+mean2 = nanmean(f2);
+
+
+plot([0.8 1.2], [mean1 mean1], 'LineWidth', 2, 'Color','g')
+hold on
+plot([1.8 2.2], [mean2 mean2], 'LineWidth', 2,'Color','g')
+ylabel('Firing rate(Hz)');
+xlim([0.5,2.5]);   
+end

+ 48 - 0
codes/Utilities/MultiPanel.m

@@ -0,0 +1,48 @@
+function PanelHandles = MultiPanel(FigureHandle, Dimension, Margins, InterPanelSpacing, LetterSize, PanelLetters, LetterFontSize)
+if ~exist('LetterFontSize', 'var')
+    LetterFontSize = 12;
+end
+
+NumberOfPanelRows = Dimension(1);
+NumberOfPanelColumns = Dimension(2);
+RightMargin = Margins(2);
+LeftMargin = Margins(1);
+TopMargin = Margins(4);
+BottomMargin = Margins(3);
+if sum(LetterSize > 0) % have letter axes size, stuck between other spaces
+    LetterWidth = LetterSize(1);
+    LetterHeight = LetterSize(2);
+else % have letter axes position, overlaying other spaces
+    LetterWidth = 0;
+    LetterHeight = 0;
+    LetterX = LetterSize(1);
+    LetterY = LetterSize(2);
+end
+InterPanelWidth = InterPanelSpacing(1);
+InterPanelHeight = InterPanelSpacing(2);
+PanelWidth = (1 - (LeftMargin + NumberOfPanelColumns*LetterWidth + (NumberOfPanelColumns - 1) * InterPanelWidth + RightMargin)) / NumberOfPanelColumns;
+PanelHeight = (1 - (BottomMargin + (NumberOfPanelRows - 1) * InterPanelHeight + NumberOfPanelRows * LetterHeight + TopMargin)) / NumberOfPanelRows;
+
+PanelHandles = nan(NumberOfPanelRows, NumberOfPanelColumns);
+figure(FigureHandle)
+for Row = 1:NumberOfPanelRows
+    for Column = 1:NumberOfPanelColumns
+        % create panel
+        PanelHandles(Row, Column) = axes('Position', [LeftMargin + LetterWidth + (Column - 1) * (LetterWidth + InterPanelWidth + PanelWidth) ...
+            BottomMargin + (NumberOfPanelRows - Row) * (LetterHeight + InterPanelHeight + PanelHeight) ...
+            PanelWidth PanelHeight]);
+        % put panel letter (if desired)
+        if ~isempty(PanelLetters{Row, Column})
+            if sum(LetterSize > 0)
+                axes('Position', [LeftMargin + (Column - 1) * (LetterWidth + InterPanelWidth + PanelWidth) ...
+                    BottomMargin + PanelHeight + (NumberOfPanelRows - Row) * (LetterHeight + InterPanelHeight + PanelHeight) ...
+                    LetterWidth LetterHeight], 'visible', 'off')
+            else
+                MainAxesPosition = get(PanelHandles(Row, Column), 'Position');
+                axes('Position', [MainAxesPosition(1) + LetterX, MainAxesPosition(2) + MainAxesPosition(4) - LetterY, eps, eps])
+            end
+            set(gca, 'visible', 'off')
+            text(0.5, 0.5, PanelLetters{Row, Column}, 'FontSize', LetterFontSize, 'VerticalAlign', 'middle', 'HorizontalAlign', 'center', 'FontWeight', 'bold')%
+        end
+    end
+end

+ 23 - 0
codes/Utilities/PlotAllDataPoints.m

@@ -0,0 +1,23 @@
+function PlotAllDataPoints(Group1, Group2)
+
+xt = [1:2];                                                         % X-Ticks
+
+lb = [xt'-ones(2,1)*0.2,  xt'+ones(2,1)*0.2]; % Long Bar X
+
+plot(xt(1), Group1, 'ko','MarkerSize', 10)
+hold on
+plot(xt(2), Group2 , 'ro','MarkerSize', 10)
+
+
+dmean = [nanmean(Group1), nanmean(Group2)];
+%dmedian = [median(Group1), median(Group2)];
+
+for k1 = 1:2
+    %plot(lb(k1,:), [1 1]*dmedian(k1), '-k')
+    plot(lb(k1,:), [1 1]*dmean(k1), '-b')
+end
+
+xlim([0.5 2.5])
+
+set(gca, 'XTick', xt, 'XTickLabel', {'Group1','Group2'})
+

+ 24 - 0
codes/Utilities/PlotAllDataPoints3.m

@@ -0,0 +1,24 @@
+function PlotAllDataPoints3(Group1, Group2, Group3)
+
+xt = [1:3];                                                         % X-Ticks
+
+lb = [xt'-ones(3,1)*0.2,  xt'+ones(3,1)*0.2]; % Long Bar X
+
+plot(xt(1), Group1, 'ko','MarkerSize', 10)
+hold on
+plot(xt(2), Group2 , 'ro','MarkerSize', 10)
+
+plot(xt(3), Group3 , 'bo','MarkerSize', 10)
+
+dmean = [mean(Group1), mean(Group2), mean(Group3)];
+dmedian = [median(Group1), median(Group2), median(Group3)];
+
+for k1 = 1:3
+    plot(lb(k1,:), [1 1]*dmedian(k1), '-k')
+    plot(lb(k1,:), [1 1]*dmean(k1), '-b')
+end
+
+xlim([0.5 3.5])
+
+
+