function varargout = mdfimport(varargin)
% MDFIMPORT MDF File import tool and function
%% GUIDE generated code edited
% Intercept GUI function for command line operation
if nargin % If arguments past in
if nargin>1 % Could be from command line or GUI
if verLessThan('matlab','8.1') % if GUI - Change to 13b
test= ~isempty(varargin{2}) && ishghandle(varargin{2});
else
test= ~isempty(varargin{2}) && isgraphics(varargin{2});
end
if test
% Its coming from the GUI (on first call or subsequent) , do nothing, gcbo
else
options=parseparameters(varargin);
importdatawithoptions(options);
return
end
else % Just one argument, must be from the command line
options=parseparameters(varargin);
importdatawithoptions(options);
return
end
end
%%
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @mdfimport_OpeningFcn, ...
'gui_OutputFcn', @mdfimport_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin & isstr(varargin{1}) %#ok
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before mdfimport is made visible.
function mdfimport_OpeningFcn(hObject, eventdata, handles, varargin) %#ok
% This function has no output args, see OutputFcn.
handles.output = hObject;
% Set figure name and calculate uibackground color
set(handles.figure1,'Name','MDF File Import');
uibackgroundcolor=get(handles.selectallchannels,'background'); % Get color
% Initialize signal selection panel uicontrols
set(handles.Select_Signals_axes,'color',uibackgroundcolor); % Set axes color
set(handles.MDF_File_Text_Box,'String','No file specified'); % No MDF file selected
set(handles.Selection_File_Text_Box,'String','No file specified'); % No MDF file selected
set(handles.unselectedchannellistbox,'Max',2); % Allow Multi-select
set(handles.selectedchannellistbox,'Max',2); % Allow Multi-select
set(handles.unselectedchannellistbox,'String',[]); % Clear
set(handles.selectedchannellistbox,'String',[]); % Clear
set(handles.unselectedchannellistbox,'Value',[]); % Clear
set(handles.selectedchannellistbox,'Value',[]); % Clear
set(handles.removedevicenames_checkbox,'Value',1); % Initialize to remove names
% Signal import uicontrols
set(handles.Signal_Import_Options_axes,'color',uibackgroundcolor); % Set axes color
% Time vector generation uicontrols
set(handles.Time_Vector_axes,'color',uibackgroundcolor); % Set axes color
set(handles.timevectorchoice1,'Value',1); % Default to use actual times. Select this radion button..
set(handles.timevectorchoice2,'Value',0); % ...and deselect other radio button.
set(handles.selectedrates_listbox,'String',[]); % Clear rates list box
set(handles.selectedrates_listbox,'Value',1); % Initialize selected value (must be>0 for single selection list boxes)
% Initalize data storage values
handles.pathName=pwd; % Set directory to look in to current directory
handles.fullFileName=''; % set to blank
handles.unselectedChannelList=[]; % Clear unselected channel data
handles.selectedChannelList=[]; % Clear selected channel data
handles.channelList=[]; % Clear total channel data
handles.removeDeviceNames=1; % Default is to remove device names
handles.requestedChannelList=''; % Initialize to none
handles.possibleRates=[];
handles.possibleRateIndices=[];
handles.MDFInfo=[];
%handles.timechannel=1; % Default location of time channel
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes mdfimport wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = mdfimport_OutputFcn(hObject, eventdata, handles) %#ok
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes during object creation, after setting all properties.
function unselectedchannellistbox_CreateFcn(hObject, eventdata, handles) %#ok
% hObject handle to unselectedchannellistbox (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in unselectedchannellistbox.
function unselectedchannellistbox_Callback(hObject, eventdata, handles) %#ok
% hObject handle to unselectedchannellistbox (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns unselectedchannellistbox contents as cell array
% contents{get(hObject,'Value')} returns selected item from unselectedchannellistbox
% --- Executes during object creation, after setting all properties.
function selectedchannellistbox_CreateFcn(hObject, eventdata, handles) %#ok
% hObject handle to selectedchannellistbox (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in selectedchannellistbox.
function selectedchannellistbox_Callback(hObject, eventdata, handles) %#ok
% hObject handle to selectedchannellistbox (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns selectedchannellistbox contents as cell array
% contents{get(hObject,'Value')} returns selected item from selectedchannellistbox
% --- Executes on button press in selectchannels.
function selectchannels_Callback(hObject, eventdata, handles) %#ok
% hObject handle to selectchannels (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get selection list
selectedChannelIndices=get(handles.unselectedchannellistbox,'Value');
% Check if there are any selected loaded and any have been unselected
if length(handles.unselectedChannelList)>0 & length(selectedChannelIndices)>0 %#ok
% Update these channels by appending to existing list
handles.selectedChannelList=[handles.selectedChannelList;...
handles.unselectedChannelList(selectedChannelIndices,:)];
% Sort these channels
[dummy,sortIndices]=sort(handles.selectedChannelList(:,1)); % Get sorted names
handles.selectedChannelList=handles.selectedChannelList(sortIndices,:);
% Update channel list box for these channels
updatedNames=processsignalname(handles.selectedChannelList,handles.removeDeviceNames,1);
set(handles.selectedchannellistbox,'String',updatedNames);
% Update channels and list box for other set
handles.unselectedCh