|
@@ -30,7 +30,7 @@ for nSubject = 1:9
|
|
|
% Multitags for spike times
|
|
|
group_MultiTagsSpikes = block.openGroup('Spike times multitags');
|
|
|
multiTags_SpikeTimes = group_MultiTagsSpikes.multiTags;
|
|
|
-
|
|
|
+
|
|
|
% If there are no neurons, continue
|
|
|
if(isempty(multiTags_SpikeTimes))
|
|
|
continue;
|
|
@@ -66,8 +66,8 @@ for nSubject = 1:9
|
|
|
dataArray_Waveform = multiTags_SpikeTimes{nDataArray}.features{1}.openData;
|
|
|
% Store waveforms
|
|
|
SPIKES(iNeuron).waveform = dataArray_Waveform.readAllData';
|
|
|
- end
|
|
|
- SPIKES_All = [SPIKES_All,SPIKES];
|
|
|
+ end
|
|
|
+ SPIKES_All = [SPIKES_All,SPIKES];
|
|
|
end
|
|
|
|
|
|
|
|
@@ -102,88 +102,117 @@ FR = SPIKES_All(nExampleNeuron).spikes;
|
|
|
|
|
|
%% Firing rate for a single neuron
|
|
|
c = [];
|
|
|
-fs = -2;
|
|
|
-ls = 24;
|
|
|
+tPre = -2;
|
|
|
+tPost = 24;
|
|
|
binSize = 0.1;
|
|
|
ranTrials = {};
|
|
|
for i = 1:max(FR(:,2))
|
|
|
- for iTrial = [0 1] % 1 - red, 0 - blue
|
|
|
- if mod(i,2) == iTrial % odd - neutral, even - aversiv
|
|
|
+ for iCondition = [0,1] % 1 - aversive, 0 - neutral
|
|
|
+ if(mod(i,2)==iCondition)
|
|
|
spikeTimes = FR(FR(:,2) == i,1);
|
|
|
ranTrials{i} = spikeTimes;
|
|
|
- c = [c iTrial];
|
|
|
- temp = histc(spikeTimes,fs:binSize:ls);
|
|
|
+ % Trial conditions
|
|
|
+ c = [c,iCondition+1];
|
|
|
+ % Binned spikes
|
|
|
+ temp = histc(spikeTimes,tPre:binSize:tPost);
|
|
|
binned{i} = smooth(temp(1:end-1)/binSize,10);
|
|
|
- % we set here bin centers
|
|
|
- bins{i} = (fs+binSize/2):binSize:(ls-binSize/2);
|
|
|
+ % Bin centers
|
|
|
+ bins{i} = (tPre+binSize/2):binSize:(tPost-binSize/2);
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
|
|
|
%% Plot Figure 2
|
|
|
-clear g
|
|
|
fig = figure;
|
|
|
-% FR
|
|
|
-g(1) = gramm( 'x',bins,'y',binned,'color',c );
|
|
|
-n = length(binned);
|
|
|
+fig.Units = 'centimeters';
|
|
|
+fig.Position(2:4) = [5,16,16];
|
|
|
+% Example neuron
|
|
|
+% Firing rate
|
|
|
+strTrialCondition = {'Aversive','Neutral'};
|
|
|
+catTrialCondition = strTrialCondition(c);
|
|
|
+g(1) = gramm('x',bins,'y',binned,'Color',catTrialCondition);
|
|
|
custom_statfun = @(y)([mean(y);
|
|
|
- mean(y) - std(y)/sqrt(17);
|
|
|
- mean(y) + std(y)/sqrt(17)]);
|
|
|
+ mean(y)-std(y)/sqrt(17);
|
|
|
+ mean(y)+std(y)/sqrt(17)]);
|
|
|
g(1).stat_summary('setylim',true,'type',custom_statfun);
|
|
|
-g(1).set_names( 'x','','y','Rate [Hz]');
|
|
|
-g(1).set_layout_options('position',[0.05,0.7,0.9,0.3]);
|
|
|
-g(1).no_legend();
|
|
|
-g(1).axe_property('xlim',[fs 20],'XColor','none');
|
|
|
-% Inset
|
|
|
+g(1).set_names('x','','y','Rate (Hz)','Color','');
|
|
|
+g(1).set_layout_options('position',[0.05,0.7,0.85,0.25],'Legend_Position',[0.16,0.85,0.25,0.15]);
|
|
|
+g(1).set_color_options('map',[1,0,0;0,0,1],'n_color',2,'n_lightness',1);
|
|
|
+g(1).axe_property('XLim',[tPre,tPost],'XTick',[],'YLim',[-1,10.5],'YTick',0:5:10,'XColor','none','YColor','k',...
|
|
|
+ 'FontName','Arial','FontSize',10,'TickDir','out','TickLength',[0.015,0.0250]);
|
|
|
+% Spike shape
|
|
|
g(6) = gramm('x',((1:64)-20)/32,'y',waveform(nExampleNeuron,:));
|
|
|
g(6).geom_line();
|
|
|
-g(6).set_names('x','Time (ms)','y','uV' );
|
|
|
-g(6).set_layout_options('position',[0.1,0.9,0.1,0.1]);
|
|
|
-g(6).set_text_options('base_size',4);
|
|
|
-g(6).set_color_options('chroma',0,'lightness',30);
|
|
|
+g(6).set_names('x','Time (ms)','y','\muV');
|
|
|
+g(6).set_layout_options('position',[0.75,0.85,0.13,0.12]);
|
|
|
+g(6).set_text_options('base_size',4,'interpreter','tex');
|
|
|
+% g(6).set_color_options('chroma',0,'lightness',30);
|
|
|
+g(6).set_color_options('map',[0,0,0],'n_color',1,'n_lightness',1);
|
|
|
g(6).set_line_options('base_size',1);
|
|
|
g(6).no_legend();
|
|
|
-% g(6).axe_property('xlim',[fs 20],'XColor','none');
|
|
|
-% raster
|
|
|
-g(2) = gramm('x',ranTrials,'color',c);
|
|
|
+g(6).axe_property('XLim',[(1-20)/32,(64-20)/32],'XTick',[0,1],'YTick',[0,30],'XColor','k','YColor','k',...
|
|
|
+ 'FontName','Arial','FontSize',7,'TickDir','out','TickLength',[0.08,0.0250]);
|
|
|
+% Raster
|
|
|
+g(2) = gramm('x',ranTrials,'Color',c);
|
|
|
g(2).geom_raster('geom','point');
|
|
|
g(2).set_point_options('base_size',3);
|
|
|
-g(2).set_names('x','Time [s]','y','Trial no. (reordered)');
|
|
|
-g(2).set_layout_options('position',[0.05,0.43,0.9,0.3]);
|
|
|
+g(2).set_names('x','Time (s)','y','Trial no. (reordered)');
|
|
|
+g(2).set_layout_options('position',[0.05,0.4,0.85,0.28]);
|
|
|
+g(2).set_color_options('map',[1,0,0;0,0,1],'n_color',2,'n_lightness',1);
|
|
|
g(2).no_legend();
|
|
|
-g(2).axe_property('xlim',[fs,20],'ylim',[-1,9]);
|
|
|
+g(2).axe_property('XLim',[tPre,tPost],'YLim',[-1,11],'YTick',0:5:10,'XColor','k','YColor','k',...
|
|
|
+ 'FontName','Arial','FontSize',10,'TickDir','out','TickLength',[0.015,0.0250]);
|
|
|
+% Spike sorting quality metrics
|
|
|
% ISI
|
|
|
g(3) = gramm('x',isis);
|
|
|
g(3).stat_bin();
|
|
|
-g(3).set_layout_options('position',[0.05,0.1,0.25,0.3]);
|
|
|
-g(3).set_names('x','Percentage of ISI < 3 ms','y','No. of units');
|
|
|
+g(3).set_layout_options('position',[0.05,0.1,0.25,0.25]);
|
|
|
+g(3).set_names('x','Percentage of ISI < 3 ms','y','No. of neurons');
|
|
|
+g(3).axe_property('XLim',[-0.15,3.7],'YLim',[0,7],'XColor','k','YColor','k',...
|
|
|
+ 'FontName','Arial','FontSize',10,'TickDir','out','TickLength',[0.03,0.0250]);
|
|
|
g(3).set_color_options('hue_range',[155,200]);
|
|
|
-% FR all
|
|
|
+% Firing rate
|
|
|
g(4) = gramm('x',FiringRatesHz);
|
|
|
g(4).stat_bin();
|
|
|
-g(4).set_layout_options('position',[0.38,0.1,0.25,0.3]);
|
|
|
-g(4).set_names('x','Firing rate [Hz]','y','No. of units');
|
|
|
-g(4).axe_property('xlim',[0 20]);
|
|
|
-g(4).set_color_options('hue_range',[155 200]);
|
|
|
+g(4).set_layout_options('position',[0.35,0.1,0.25,0.25]);
|
|
|
+g(4).set_names('x','Firing rate (Hz)','y','No. of neurons');
|
|
|
+g(4).axe_property('XLim',[-0.8 20],'YLim',[0,7],'XColor','k','YColor','k',...
|
|
|
+ 'FontName','Arial','FontSize',10,'TickDir','out','TickLength',[0.03,0.0250]);
|
|
|
+g(4).set_color_options('hue_range',[155,200]);
|
|
|
% SNR
|
|
|
g(5) = gramm('x',snr);
|
|
|
g(5).stat_bin();
|
|
|
-g(5).set_layout_options('position',[0.71,0.1,0.25,0.3]);
|
|
|
+g(5).set_layout_options('position',[0.65,0.1,0.25,0.25]);
|
|
|
g(5).set_names('x','Waveform peak SNR','y','No. of neurons');
|
|
|
-g(5).axe_property('xlim',[0 10]);
|
|
|
-g(5).set_color_options('hue_range',[155 200]);
|
|
|
+g(5).axe_property('XLim',[-0.4,10],'YLim',[0,7],'XColor','k','YColor','k',...
|
|
|
+ 'FontName','Arial','FontSize',10,'TickDir','out','TickLength',[0.03,0.0250]);
|
|
|
+g(5).set_color_options('hue_range',[155,200]);
|
|
|
% Labels
|
|
|
-x = [0,0,0,0.35,0.68];
|
|
|
-y = [0.97,0.7,0.37,0.37,0.37];
|
|
|
-l = ['a','b','c','d','e'];
|
|
|
+x = [0.02,0.02,0.34,0.66];
|
|
|
+y = [0.98,0.35,0.35,0.35];
|
|
|
+l = ['a','b','c','d'];
|
|
|
g(7) = gramm('x',x,'y',y,'label',l);
|
|
|
-g(7).geom_label('Color','k','fontweight','bold');
|
|
|
-g(7).axe_property('XColor','none','YColor','none','xlim',[0,1],...
|
|
|
- 'ylim',[0,1],'Visible','off');
|
|
|
+g(7).geom_label('Color','k','FontWeight','bold','FontName','Arial');
|
|
|
+g(7).axe_property('XColor','none','YColor','none','XLim',[0,1],...
|
|
|
+ 'YLim',[0,1],'Visible','off');
|
|
|
g(7).set_layout_options('position',[0,0,1,1]);
|
|
|
g.draw();
|
|
|
|
|
|
+yPosOffset = g(1).facet_axes_handles.Position(1)-g(3).facet_axes_handles.Position(1);
|
|
|
+for iAx = 3:5
|
|
|
+ g(iAx).facet_axes_handles.Position(1) = g(iAx).facet_axes_handles.Position(1)+yPosOffset;
|
|
|
+end
|
|
|
+% YLabel positions
|
|
|
+for iAx = setdiff(1:7,[6,7])
|
|
|
+ g(iAx).facet_axes_handles.YLabel.Units = 'centimeters';
|
|
|
+ g(iAx).facet_axes_handles.YLabel.Position(1) = -0.8;
|
|
|
+end
|
|
|
+
|
|
|
+g(2).facet_axes_handles.Children(1).MarkerSize = 2.5;
|
|
|
+g(2).facet_axes_handles.Children(2).MarkerSize = 2.5;
|
|
|
+
|
|
|
% Save figure
|
|
|
-print('-dtiff','-r300','fig_2.tiff')
|
|
|
+print('-dpdf','-r600','-painters','Fig2.pdf');
|
|
|
+print('-dpng','-r600','-painters','Fig2.png');
|
|
|
|
|
|
end
|