diff --git a/omniplex/LFPAnalysis.m b/omniplex/LFPAnalysis.m index 5b99c2ad..b9c1fabe 100644 --- a/omniplex/LFPAnalysis.m +++ b/omniplex/LFPAnalysis.m @@ -46,7 +46,7 @@ %------------------HIDDEN PROPERTIES----------% properties (SetAccess = protected, GetAccess = public, Hidden = true) %> bandpass frequencies - bpfreq@cell = {[1 4], [5 8], [8 14], [15 30], [30 50], [50 100], [1 250]} + bpfreq@cell = {[1 4], [4 7], [7 14], [15 30], [30 50], [50 100], [1 250]} %> bandpass frequency names bpnames@cell = {'\delta','\theta','\alpha','\beta','\gamma low','\gamma high','all'} end @@ -228,7 +228,6 @@ function toggleSaccadeRealign(ego) ego.reparse; ego.parseSpikes; ego.doPlots = doPlots; - ego.plot('av'); if ego.p.saccadeRealign == true disp('Saccade Realign is now ENABLED...') else @@ -393,8 +392,6 @@ function ftPreProcess(ego, cfg, removeLineNoise) %> @return % =================================================================== function cfg=ftTimeLockAnalysis(ego, cfg, statcfg) - ego.results(1).av = []; - ego.results(1).avstat = []; ft = ego.ft; ft = rmfield(ft,'uniquetrials'); %ft_timelockanalysis > ft_selectdata generates a warning as this is an unofficial field, so remove it here if ~exist('cfg','var') || isempty(cfg); cfg = []; end @@ -404,6 +401,11 @@ function ftPreProcess(ego, cfg, removeLineNoise) if ~isfield(cfg,'removemean'); cfg.removemean = 'no'; end if ~isfield(cfg,'covariance'); cfg.covariance = 'yes'; end cfg.channel = ft.label{ego.selectedLFP}; + ego.results(1).av = []; + if strcmp(cfg.keeptrials, 'yes') + ego.results(1).avstat = []; + ego.results(1).avstatavg = []; + end for i = 1:ego.nSelection cfg.trials = ego.selectedTrials{i}.idx; av{i} = ft_timelockanalysis(cfg, ft); @@ -426,7 +428,7 @@ function ftPreProcess(ego, cfg, removeLineNoise) if isempty(ego.stats); ego.setStats(); end sv = ego.stats; - if isfield(av{1},'trial') %keeptrials was ON + if strcmp(cfg.keeptrials, 'yes') %keeptrials was ON if exist('statcfg','var'); cfg = statcfg; else cfg = []; end cfg.channel = ft.label{ego.selectedLFP}; @@ -1272,7 +1274,7 @@ function select(ego) mrange = ego.measureRange; - mtitle = ['REPARSE ' num2str(ego.LFPs(1).nVars) ' DATA VARIABLES']; + mtitle = [ego.lfpfile ': REPARSE ' num2str(ego.LFPs(1).nVars) ' VARS']; options = {['t|' map{1}],'Choose PLX variables to merge (A, if empty parse all variables independantly):'; ... ['t|' map{2}],'Choose PLX variables to merge (B):'; ... ['t|' map{3}],'Choose PLX variables to merge (C):'; ... @@ -1757,7 +1759,7 @@ function drawAverageLFPs(ego) if isgraphics(ego.plotDestination) h = ego.plotDestination; else - h=figure;figpos(1,[1700 1000]);set(gcf,'Name',[ego.lfpfile ' ' av{1}.label{:}],'Color',[1 1 1]); + h=figure;figpos(1,[1700 1000]);set(gcf,'Name',[ego.lfpfile],'Color',[1 1 1]); end p=panel(h); p.margin = [20 20 10 15]; %left bottom right top diff --git a/omniplex/LFPMeta.m b/omniplex/LFPMeta.m index 06029680..94b95305 100644 --- a/omniplex/LFPMeta.m +++ b/omniplex/LFPMeta.m @@ -54,7 +54,7 @@ end % =================================================================== - %> @brief + %> @brief add LFPAnalysis objects to the meta list %> %> @param %> @return @@ -114,7 +114,7 @@ function add(me,varargin) % =================================================================== - %> @brief + %> @brief plot individual %> %> @param %> @return @@ -158,8 +158,9 @@ function process(me,varargin) me.raw{i}.plotRange = me.plotRange; if am == 1 %timelock - cfg = [];cfg.keeptrials = 'no'; + cfg = [];cfg.keeptrials = 'yes'; me.raw{i}.ftTimeLockAnalysis(cfg); + else me.raw{i}.ftFrequencyAnalysis([],... me.options.tw,... @@ -198,7 +199,10 @@ function run(me,varargin) end metaA{i} = me.raw{i}.results.av{1}; metaB{i} = me.raw{i}.results.av{2}; - + metaA{i}.label = {'LFP'}; %force an homogeneous label name + metaB{i}.label = {'LFP'}; + metaA{i}.dimord = 'chan_time'; + metaB{i}.dimord = 'chan_time'; else metaA{i} = me.raw{i}.(['fq' me.options.method]){1}; @@ -210,21 +214,32 @@ function run(me,varargin) end if am == 1 %timelock - cfg = []; - cfg.channel = 'all'; - cfg.keepindividual = 'no'; - %cfg.latency = me.measureRange; - %cfg.normalizevar = 'N' or 'N-1' (default = 'N-1') - % cfg.method = 'across' (default) or 'within', see below. - % cfg.parameter = string or cell-array indicating which + cfg = []; + cfg.channel = 'all'; + cfg.keepindividual = 'no'; + cfg.parameter = 'avg'; + cfg.method = 'across'; %(default) or 'within', see below. +% cfg.latency = me.measureRange; +% cfg.normalizevar = 'N' or 'N-1' (default = 'N-1') avgA = ft_timelockgrandaverage(cfg, metaA{:}); avgB = ft_timelockgrandaverage(cfg, metaB{:}); else end - - + me.handles.axistabs.Selection = 2; + ho = me.handles.axisall; + delete(ho.Children); + h = uipanel('Parent',ho,'units', 'normalized', 'position', [0 0 1 1]); + ha = axes('Parent',h); + e = analysisCore.var2SE(avgA.var, avgA.dof); + areabar(avgA.time,avgA.avg, e); + hold on + e = analysisCore.var2SE(avgB.var, avgB.dof); + areabar(avgB.time, avgB.avg, e); + xlabel('Time (s)'); + ylabel('Voltage (mV)'); + end end @@ -286,10 +301,34 @@ function save(me, varargin) %> @return % =================================================================== function spawn(me, varargin) + gh = gca; h = figure; figpos(1,[1000 800]); set(h,'Color',[1 1 1]); - hh = copyobj(me.handles.axis2,h); + hh = copyobj(gh,h); + end + + % =================================================================== + %> @brief + %> + %> @param + %> @return + % =================================================================== + function toggleSaccades(me, varargin) + if me.nSites > 0 + firstState = false; + for i = 1 : me.nSites + if i == 1 + me.raw{i}.toggleSaccadeRealign + firstState = me.raw{i}.p.saccadeRealign; %keep our first state saved + else + if firstState ~= me.raw{i}.p.saccadeRealign; %make sure all states will sync to first + me.raw{i}.toggleSaccadeRealign + end + end + + end + end end % =================================================================== @@ -464,6 +503,11 @@ function reset(me,varargin) set(me.handles.list,'Value',1); set(me.handles.list,'String',{''}); end + ho = me.handles.axisind; + delete(ho.Children); + ho = me.handles.axisall; + delete(ho.Children); + me.handles.axistabs.SelectedChild=1; if isfield(me.handles,'axis1') me.handles.axistabs.SelectedChild=2; axes(me.handles.axis2);cla @@ -554,25 +598,26 @@ function makeUI(me) figpos(1,[1600 800]) end me.handles(1).parent = parent; + %make context menu hcmenu = uicontextmenu; - item1 = uimenu(hcmenu,'Label','Reparse','Callback',@me.plot); - item2 = uimenu(hcmenu,'Label','Plot','Callback',@me.plot); - item3 = uimenu(hcmenu,'Label','Remove','Callback',@me.remove); + uimenu(hcmenu,'Label','Reparse (select)','Callback',@me.reparse,'Accelerator','e'); + uimenu(hcmenu,'Label','Plot (select)','Callback',@me.plot,'Accelerator','p'); + uimenu(hcmenu,'Label','Remove (select)','Callback',@me.remove,'Accelerator','r'); + uimenu(hcmenu,'Label','Process (all)','Callback',@me.process,'Separator','on'); + uimenu(hcmenu,'Label','Run (all)','Callback',@me.run); + uimenu(hcmenu,'Label','Toggle Saccade (all)','Callback',@me.toggleSaccades); + uimenu(hcmenu,'Label','Reset (all)','Callback',@me.reset); fs = 10; if ismac [s,c]=system('system_profiler SPDisplaysDataType'); - if s == 0 - if ~isempty(regexpi(c,'Retina LCD')) - fs = 7; - end - end + if s == 0; if ~isempty(regexpi(c,'Retina LCD')); fs = 7; end; end end SansFont = 'Helvetica'; - MonoFont = 'Menlo'; - bgcolor = [0.85 0.85 0.85]; - bgcoloredit = [0.87 0.87 0.87]; + MonoFont = 'Consolas'; + bgcolor = [0.89 0.89 0.89]; + bgcoloredit = [0.9 0.9 0.9]; handles.parent = me.handles.parent; %#ok<*PROP> handles.root = uiextras.BoxPanel('Parent',parent,... @@ -627,13 +672,13 @@ function makeUI(me) 'Tooltip','Remove a single item',... 'Callback',@me.remove,... 'String','Remove'); - handles.plotbutton = uicontrol('Style','pushbutton',... - 'Parent',handles.controls1,... - 'Tag','LMAsavebutton',... - 'FontSize', fs,... - 'Tooltip','Plot data',... - 'Callback',@me.plot,... - 'String','Plot'); +% handles.saccbutton = uicontrol('Style','pushbutton',... +% 'Parent',handles.controls1,... +% 'Tag','LMAsaccbutton',... +% 'FontSize', fs,... +% 'Tooltip','Toggle Saccade Realign',... +% 'Callback',@me.toggleSaccades,... +% 'String','Toggle Saccades'); handles.processbutton = uicontrol('Style','pushbutton',... 'Parent',handles.controls1,... 'Tag','LMArunbutton',... @@ -665,13 +710,13 @@ function makeUI(me) 'FontSize', fs,... 'Callback',@me.setOptions,... 'String','Options'); - handles.max = uicontrol('Style','edit',... - 'Parent',handles.controls1,... - 'Tag','LMAmax',... - 'Tooltip','Cell Max Override',... - 'FontSize', fs,... - 'Callback',@me.editmax,... - 'String','0'); +% handles.max = uicontrol('Style','edit',... +% 'Parent',handles.controls1,... +% 'Tag','LMAmax',... +% 'Tooltip','Cell Max Override',... +% 'FontSize', fs,... +% 'Callback',@me.editmax,... +% 'String','0'); handles.weight = uicontrol('Style','edit',... 'Parent',handles.controls1,... 'Tag','LMAweight',... diff --git a/omniplex/analysisCore.m b/omniplex/analysisCore.m index 1e5171d7..31e30b47 100644 --- a/omniplex/analysisCore.m +++ b/omniplex/analysisCore.m @@ -309,9 +309,9 @@ function showInfo(ego) function optimiseSize(ego) if isa(ego, 'LFPAnalysis') for i = 1: ego.nLFPs - ego.LFPs(i).sample = []; - ego.LFPs(i).data = []; - ego.LFPs(i).time = []; + %ego.LFPs(i).sample = []; + %ego.LFPs(i).data = []; + %ego.LFPs(i).time = []; end ego.results = struct([]); optimiseSize(ego.p); diff --git a/omniplex/plxReader.m b/omniplex/plxReader.m index f6300cb7..d8182b7b 100644 --- a/omniplex/plxReader.m +++ b/omniplex/plxReader.m @@ -435,7 +435,15 @@ function integrateEyeData(ego) %> @return % =================================================================== function handles = infoBox(ego, info) - if feature('HGUsingMatlabClasses');fs = 12;else fs = 14;end + fs = 10; + if ismac + [s,c]=system('system_profiler SPDisplaysDataType'); + if s == 0 + if ~isempty(regexpi(c,'Retina LCD')) + fs = 7; + end + end + end if ~exist('info','var') ego.generateInfo(); info = ego.info; diff --git a/omniplex/spikeAnalysis.m b/omniplex/spikeAnalysis.m index d7368155..bac86af0 100644 --- a/omniplex/spikeAnalysis.m +++ b/omniplex/spikeAnalysis.m @@ -854,6 +854,7 @@ function selectTrials(ego) function plotDensity(ego) if ~isfield(ego.results,'sd'); warning('No Density parsed yet.'); return; end disp('Plotting Density Data...') + fs = get(0,'DefaultAxesFontSize'); sd = ego.results.sd; rate = ego.results.rate; baseline = ego.results.baseline; @@ -861,7 +862,8 @@ function plotDensity(ego) h=figure;set(h,'Color',[1 1 1],'Name',[ego.file ' ' ego.names{ego.selectedUnit}]); if length(sd) <4; figpos(1,[1000 1500]); else figpos(1,[2000 2000]); end p=panel(h); - p.margin = [15 20 10 10]; %left bottom right top + p.fontsize = fs; + p.margin = [12 12 12 6]; %left bottom right top p.pack('v', {3/4 []}) q = p(1); len = ego.nSelection; @@ -927,14 +929,14 @@ function plotDensity(ego) t = [t sprintf(' R%i: %.4g ± %.3g %.3g<>%.3g', j, rate{j}.avg, e, rate{j}.CI(1), rate{j}.CI(2))]; end disp([t sprintf(' | measureRange: %s', num2str(rate{1}.cfg.latency))]); - title(t,'FontSize',13); + title(t); xlabel(['Time (s) [window = ' sd{1}.cfg.winfunc ' ' num2str(sd{1}.cfg.timwin) '] ']); ylabel(yt) set(gcf,'Renderer','OpenGL'); legend(leg); ax=axis; axis([ego.plotRange(1) ego.plotRange(2) ax(3) ax(4)]); - text(ego.plotRange(1),ax(3),blineText,'FontSize',10,'VerticalAlignment','baseline'); + text(ego.plotRange(1),ax(3),blineText,'FontSize',fs+1,'VerticalAlignment','baseline'); set(mh,'yData',[ax(3) ax(3) ax(4) ax(4)]); set(gca,'Layer','top'); end @@ -1122,9 +1124,11 @@ function plotWaveforms(ego,timeWindow) warning('No waveform data present, nothing to plot...') return end - h=figure;figpos(2,[2000 1000]);set(h,'Color',[1 1 1],'Name',[ego.file ' ' ego.names{ego.selectedUnit}]); + fs = get(0,'DefaultAxesFontSize'); + h=figure;figpos(2,[1600 600]);set(h,'Color',[1 1 1],'Name',[ego.file ' ' ego.names{ego.selectedUnit}]); p=panel(h); - p.margin = [20 20 20 20]; %left bottom right top + p.fontsize = fs-1; + p.margin = [10 8 12 8]; %left bottom right top [row,col]=ego.optimalLayout(ego.nSelection); p.pack(col,row); for j = 1:length(ego.selectedTrials) @@ -1157,7 +1161,7 @@ function plotWaveforms(ego,timeWindow) waves = vertcat(waves,w); end end - if ~isempty(waves) + if ~isempty(waves) nwaves = size(waves,1); [a,e]=stderr(waves,'SD'); areabar(time,a,e,[0.7 0.7 0.7],0.75,'r-o','LineWidth',2); @@ -1195,7 +1199,7 @@ function appendTrialNames(ego,hdl,idx) mS2 = mS( mS >= 0 & mS <= ego.measureRange(2)); nMS1 = nMS1 + length(mS1); nMS2 = nMS2 + length(mS2); - plot(mS,y(j),'yo','MarkerFaceColor',[1 1 0],'MarkerSize',4); + plot(mS, y(j), 'ro', 'MarkerFaceColor', 'none', 'MarkerSize', 4); end end end @@ -1205,7 +1209,7 @@ function appendTrialNames(ego,hdl,idx) st = st - st; end yt = 1:length(st); - plot(st,yt,'go','MarkerFaceColor',[0 1 0],'MarkerSize',4); + plot(st, yt, 'go', 'MarkerFaceColor', 'none', 'MarkerSize', 4); end if length(idx) >= 100 fs = 9;