0001 function [mri] = gui_ge_open(mri,command,parent)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 if ~exist('mri','var'),
0024 mri = mri_toolbox_defaults;
0025 elseif isempty(mri),
0026 mri = mri_toolbox_defaults;
0027 end
0028
0029 if ~exist('command','var'),
0030 command = 'init';
0031 elseif isempty(command),
0032 command = 'init';
0033 end
0034
0035 command = lower(command);
0036
0037 switch command,
0038 case 'init',
0039 if exist('parent','var'),
0040 MRIOpen = INIT(mri,parent);
0041 else
0042 MRIOpen = INIT(mri,'');
0043 end
0044 otherwise,
0045 MRIOpen = get(gcbf,'Userdata');
0046 set(MRIOpen.gui,'Pointer','watch');
0047 end
0048
0049
0050 switch command,
0051
0052 case 'plot',
0053
0054 MRIOpen.mri.plot = 1;
0055 MRIOpen.mri = mri_open(MRIOpen.mri);
0056
0057 case 'return',
0058
0059 MRIOpen.mri.plot = 0;
0060 MRIOpen.mri = mri_open(MRIOpen.mri);
0061
0062 case 'save',
0063
0064 fprintf('\ngui_ge_open: Save As not implemented yet.\n');
0065
0066 otherwise,
0067
0068 end
0069
0070
0071
0072
0073 switch command,
0074 case 'init',
0075 case 'cancel',
0076 GUI.parent = MRIOpen.parent;
0077 mri_updateparent(GUI);
0078 close gcbf;
0079 otherwise,
0080 set(MRIOpen.gui,'Pointer','arrow');
0081 set(MRIOpen.gui,'Userdata',MRIOpen);
0082
0083 mri = mri_updateparent(MRIOpen,0);
0084
0085 if isequal(get(MRIOpen.handles.Bhold,'Value'),0),
0086 close gcbf;
0087 if isfield(MRIOpen,'parent'),
0088 parent = MRIOpen.parent.gui;
0089 else
0090 parent = [];
0091 end
0092 else
0093 parent = MRIOpen.gui;
0094 end
0095 end
0096
0097
0098 return
0099
0100
0101
0102
0103
0104 function [MRIOpen] = INIT(mri,parent)
0105
0106
0107 GUIwidth = 500;
0108 GUIheight = 120;
0109
0110 version = '$Revision: 1.1 $';
0111 name = sprintf('GE File Open [v %s]\n',version(11:15));
0112
0113 GUI = figure('Name',name,'Tag','GE_OPEN',...
0114 'NumberTitle','off',...
0115 'MenuBar','none','Position',[1 1 GUIwidth GUIheight]);
0116 movegui(GUI,'center');
0117
0118 Font.FontName = 'Helvetica';
0119 Font.FontUnits = 'Pixels';
0120 Font.FontSize = 12;
0121 Font.FontWeight = 'normal';
0122 Font.FontAngle = 'normal';
0123
0124
0125
0126
0127 G.Title_data = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0128 'Position',[.01 .75 .17 .2],...
0129 'String','Data Type:','HorizontalAlignment','left');
0130
0131 mri.type = 'GE';
0132 G.PmriType = uicontrol('Tag','PmriType','Parent',GUI,'Style','edit',...
0133 'Units','Normalized',Font, ...
0134 'Position',[.20 .75 .25 .2],...
0135 'String','GE');
0136
0137 G.Title_path = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0138 'Position',[.01 .50 .17 .2],...
0139 'String','Path','HorizontalAlignment','left');
0140 G.EmriPath = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font, ...
0141 'Position',[.20 .50 .58 .2], 'String',mri.path,...
0142 'Callback',strcat('MRIOpen = get(gcbf,''Userdata'');',...
0143 'MRIOpen.mri.path = get(MRIOpen.handles.EmriPath,''String'');',...
0144 'set(gcbf,''Userdata'',MRIOpen); clear MRIOpen;'));
0145
0146 G.Title_file = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0147 'Position',[.01 .25 .17 .2],...
0148 'String','File','HorizontalAlignment','left');
0149 G.EmriFile = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font, ...
0150 'Position',[.20 .25 .58 .2], 'String',mri.file,...
0151 'Callback',strcat('MRIOpen = get(gcbf,''Userdata'');',...
0152 'MRIOpen.mri.file = get(MRIOpen.handles.EmriFile,''String'');',...
0153 'set(gcbf,''Userdata'',MRIOpen); clear MRIOpen;'));
0154
0155 Font.FontWeight = 'bold';
0156
0157
0158 browsecommand = strcat('MRIOpen = get(gcbf,''Userdata'');',...
0159 'cd(MRIOpen.mri.path);',...
0160 '[file, path] = uigetfile(',...
0161 '{''*.MR;*.I*'', ''GE Signa 5.x/LX (*.MR,*.I*)'';', ...
0162 ' ''*.*'', ''All Files (*.*)''},', ...
0163 '''Select first GE file in sequence (eg, E22119S1I1.MR)'');',...
0164 'if ~isequal(path,0), MRIOpen.mri.path = path; end;',...
0165 'if ~isequal(file,0), MRIOpen.mri.file = file; end;',...
0166 'set(MRIOpen.handles.EmriPath,''String'',MRIOpen.mri.path);',...
0167 'set(MRIOpen.handles.EmriFile,''String'',MRIOpen.mri.file);',...
0168 'set(gcbf,''Userdata'',MRIOpen); clear MRIOpen file path;');
0169 G.BmriFile = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized',Font, ...
0170 'Position',[.01 .01 .17 .2], 'String','BROWSE',...
0171 'BackgroundColor',[0.8 0.8 0.0],...
0172 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0173 'Callback', browsecommand );
0174
0175
0176 G.Bplot = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0177 'Position',[.20 .01 .18 .2],...
0178 'String','PLOT','BusyAction','queue',...
0179 'TooltipString','Plot the MRI data and return p struct.',...
0180 'BackgroundColor',[0.0 0.5 0.0],...
0181 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0182 'Callback',strcat('MRIOpen = get(gcbf,''Userdata'');',...
0183 'mri = gui_ge_open(MRIOpen.mri,''plot'');',...
0184 'clear MRIOpen;'));
0185
0186
0187 G.Bsave = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0188 'Position',[.40 .01 .18 .2],'HorizontalAlignment', 'center',...
0189 'String','SAVE AS','TooltipString','MRI File Conversion Tool (not implemented yet)',...
0190 'BusyAction','queue',...
0191 'Visible','on',...
0192 'BackgroundColor',[0.0 0.0 0.75],...
0193 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0194 'Callback',strcat('MRIOpen = get(gcbf,''Userdata'');',...
0195 'mri = gui_ge_open(MRIOpen.mri,''save'');',...
0196 'clear MRIOpen;'));
0197
0198
0199 G.Breturn = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0200 'Position',[.60 .01 .18 .2],...
0201 'String','RETURN','BusyAction','queue',...
0202 'TooltipString','Return p struct to workspace and parent GUI.',...
0203 'BackgroundColor',[0.75 0.0 0.0],...
0204 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0205 'Callback',strcat('MRIOpen = get(gcbf,''Userdata'');',...
0206 'mri = gui_ge_open(MRIOpen.mri,''return'');',...
0207 'clear MRIOpen;'));
0208
0209
0210 G.Bcancel = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0211 'Position',[.80 .01 .18 .2],...
0212 'String','CANCEL','BusyAction','queue',...
0213 'TooltipString','Close, do not return parameters.',...
0214 'BackgroundColor',[0.75 0.0 0.0],...
0215 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0216 'Callback',strcat('MRIOpen = get(gcbf,''Userdata'');',...
0217 'mri = gui_ge_open(MRIOpen.mri,''cancel'');',...
0218 'clear MRIOpen;'));
0219
0220
0221
0222 G.Bhelp = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0223 'Position',[.80 .25 .18 .2],'String','Help','BusyAction','queue',...
0224 'BackgroundColor',[1 1 0],...
0225 'ForegroundColor',[0 0 0], 'HorizontalAlignment', 'center',...
0226 'Callback','doc mri_toolbox;');
0227
0228
0229 G.Bhold = uicontrol('Parent',GUI,'Style','checkbox','Units','Normalized', Font, ...
0230 'Position',[.80 .50 .18 .2],'String','Hold GUI','BusyAction','queue',...
0231 'TooltipString','MRI File Load GUI remains open after ''Plot'' or ''Return'' commands.',...
0232 'Value',mri.hold,'HorizontalAlignment', 'center');
0233
0234
0235
0236 if exist('parent','var'), MRIOpen.parent.gui = parent; end
0237 MRIOpen.gui = GUI;
0238 MRIOpen.handles = G;
0239 MRIOpen.mri = mri;
0240 set(GUI,'Userdata',MRIOpen);
0241 set(GUI,'HandleVisibility','callback');
0242
0243 return