From 89c90576a551ff5e818d4377877209a403cac844 Mon Sep 17 00:00:00 2001 From: Hannes Mogensen Date: Fri, 16 Jan 2015 15:02:00 +0100 Subject: [PATCH] Automatic update + read raw data again --- panelcomponents/ReImportRawData.m | 14 ++++++++++++++ panels/@InfoPanel/InfoPanel.m | 1 + sensorimotor/classes/ScExperiment.m | 4 ++-- sensorimotor/classes/ScFile.m | 26 ++++++++++++++++---------- 4 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 panelcomponents/ReImportRawData.m diff --git a/panelcomponents/ReImportRawData.m b/panelcomponents/ReImportRawData.m new file mode 100644 index 0000000..82d2da1 --- /dev/null +++ b/panelcomponents/ReImportRawData.m @@ -0,0 +1,14 @@ +classdef ReImportRawData < PanelComponent + methods + function obj = ReImportRawData(panel) + obj@PanelComponent(panel); + end + function populate(obj,mgr) + mgr.newline(20); + mgr.add(sc_ctrl('pushbutton','Read raw data again',@(~,~) obj.read_raw_data_callback()),200); + end + function read_raw_data_callback(obj) + obj.gui.experiment.init(true); + end + end +end \ No newline at end of file diff --git a/panels/@InfoPanel/InfoPanel.m b/panels/@InfoPanel/InfoPanel.m index 4957067..b4edce1 100644 --- a/panels/@InfoPanel/InfoPanel.m +++ b/panels/@InfoPanel/InfoPanel.m @@ -15,6 +15,7 @@ function layout(obj) function setup_components(obj) obj.gui_components.add(AutomaticUpdate(obj)); + obj.gui_components.add(ReImportRawData(obj)); obj.gui_components.add(SaveLoadButton(obj)); obj.gui_components.add(ExperimentOptions(obj)); obj.gui_components.add(SequenceOptions(obj)); diff --git a/sensorimotor/classes/ScExperiment.m b/sensorimotor/classes/ScExperiment.m index db69ca3..594f354 100644 --- a/sensorimotor/classes/ScExperiment.m +++ b/sensorimotor/classes/ScExperiment.m @@ -46,10 +46,10 @@ function sc_clear(obj) end %Populate all children - function init(obj) + function init(obj,varargin) for i=1:obj.n fprintf('reading file: %i out of %i\n',i,obj.n); - obj.get(i).init(); + obj.get(i).init(varargin{:}); end end diff --git a/sensorimotor/classes/ScFile.m b/sensorimotor/classes/ScFile.m index 8921b2f..0d3dfb9 100644 --- a/sensorimotor/classes/ScFile.m +++ b/sensorimotor/classes/ScFile.m @@ -381,20 +381,26 @@ function sc_clear(obj) d = load(obj.filepath,channelname); channelstruct = d.(channelname); if isfield(channelstruct,'values') - signal = ScSignal(obj,channelname,'tag',channelname); - signal.dt = channelstruct.interval; - signal.N = channelstruct.length; %<- sometimes incorrect value from Spike2 - obj.signals.add(signal); - if isempty(strfind(channelname,'patch')) - signal.filter.smoothing_width = 1; - signal.filter.artifact_width = 0; + if ~obj.signals.has('tag',channelname) + signal = ScSignal(obj,channelname,'tag',channelname); + signal.dt = channelstruct.interval; + signal.N = channelstruct.length; %<- sometimes incorrect value from Spike2 + obj.signals.add(signal); + if isempty(strfind(channelname,'patch')) + signal.filter.smoothing_width = 1; + signal.filter.artifact_width = 0; + end end elseif strcmpi(channelname,'TextMark') || ... strcmpi(channelname,'Keyboard') - textchannel = ScTextMark(obj,channelname,'tag',channelname); - obj.textchannels.add(textchannel); + if ~obj.textchannels.has('tag',channelname) + textchannel = ScTextMark(obj,channelname,'tag',channelname); + obj.textchannels.add(textchannel); + end elseif isfield(channelstruct,'times') - obj.stims.add(ScStim(obj,channelname,'tag',channelname)); + if ~obj.stims.has('tag',channelname) + obj.stims.add(ScStim(obj,channelname,'tag',channelname)); + end else msg = sprintf('Warning: Channel %s in file %s did not meet any criteria in %s.\n Go find Hannes if you think this channel should be viewable.', channelname, obj.tag, mfilename); msgbox(msg);