0001 function [mri] = gui_avw_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_avw_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('AVW File Open [v %s]\n',version(11:15));
0112
0113 GUI = figure('Name',name,'Tag','AVW_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 = 'Analyze';
0132 G.PmriType = uicontrol('Tag','PmriType','Parent',GUI,'Style','edit',...
0133 'Units','Normalized',Font, ...
0134 'Position',[.20 .75 .25 .2],...
0135 'String',mri.type);
0136
0137 switch mri.orient
0138 case 'auto', mriOrient = 1;
0139 case 'axial unflipped', mriOrient = 2;
0140 case 'coronal unflipped', mriOrient = 3;
0141 case 'sagittal unflipped', mriOrient = 4;
0142 case 'axial flipped', mriOrient = 5;
0143 case 'coronal flipped', mriOrient = 6;
0144 case 'sagittal flipped', mriOrient = 7;
0145 otherwise, mriOrient = 1;
0146 end
0147
0148 G.PmriOrient = uicontrol('Tag','PmriOrient','Parent',GUI,'Style','popupmenu',...
0149 'Units','Normalized',Font, ...
0150 'Position',[.50 .75 .25 .2],...
0151 'TooltipString','Force loading with this orientation, otherwise use auto detection',...
0152 'String',{'auto' 'axial unflipped' 'coronal unflipped' 'sagittal unflipped' ...
0153 'axial flipped' 'coronal flipped' 'sagittal flipped'},'Value',mriOrient,...
0154 'Callback',strcat('MRIOpen = get(gcbf,''Userdata'');',...
0155 'MRIOpen.mri.orient = popupstr(MRIOpen.handles.PmriOrient);',...
0156 'set(gcbf,''Userdata'',MRIOpen); clear MRIOpen;'));
0157
0158 G.Title_path = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0159 'Position',[.01 .50 .17 .2],...
0160 'String','Path','HorizontalAlignment','left');
0161 G.EmriPath = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font, ...
0162 'Position',[.20 .50 .58 .2], 'String',mri.path,...
0163 'Callback',strcat('MRIOpen = get(gcbf,''Userdata'');',...
0164 'MRIOpen.mri.path = get(MRIOpen.handles.EmriPath,''String'');',...
0165 'set(gcbf,''Userdata'',MRIOpen); clear MRIOpen;'));
0166
0167 G.Title_file = uicontrol('Parent',GUI,'Style','text','Units','Normalized',Font, ...
0168 'Position',[.01 .25 .17 .2],...
0169 'String','File','HorizontalAlignment','left');
0170 G.EmriFile = uicontrol('Parent',GUI,'Style','edit','Units','Normalized',Font, ...
0171 'Position',[.20 .25 .58 .2], 'String',mri.file,...
0172 'Callback',strcat('MRIOpen = get(gcbf,''Userdata'');',...
0173 'MRIOpen.mri.file = get(MRIOpen.handles.EmriFile,''String'');',...
0174 'set(gcbf,''Userdata'',MRIOpen); clear MRIOpen;'));
0175
0176 Font.FontWeight = 'bold';
0177
0178
0179 browsecommand = strcat('MRIOpen = get(gcbf,''Userdata'');',...
0180 'cd(MRIOpen.mri.path);',...
0181 '[file, path] = uigetfile(',...
0182 '{''*.hdr;*.img'', ''Analyze Files (*.hdr,*.img)'';', ...
0183 ' ''*.*'', ''All Files (*.*)''},', ...
0184 '''Select MRI File'');',...
0185 'if ~isequal(path,0), MRIOpen.mri.path = path; end;',...
0186 'if ~isequal(file,0), MRIOpen.mri.file = file; end;',...
0187 'set(MRIOpen.handles.EmriPath,''String'',MRIOpen.mri.path);',...
0188 'set(MRIOpen.handles.EmriFile,''String'',MRIOpen.mri.file);',...
0189 'if ~isempty(findstr(file,''.hdr'')) | ~isempty(findstr(file,''.img'')), ',...
0190 'set(MRIOpen.handles.PmriType,''Value'',1); ',...
0191 'MRIOpen.mri.type = popupstr(MRIOpen.handles.PmriType);',...
0192 'else, ',...
0193 'set(MRIOpen.handles.PmriType,''Value'',3); ',...
0194 'MRIOpen.mri.type = popupstr(MRIOpen.handles.PmriType);',...
0195 'end;',...
0196 'set(gcbf,''Userdata'',MRIOpen); clear MRIOpen file path;');
0197 G.BmriFile = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized',Font, ...
0198 'Position',[.01 .01 .17 .2], 'String','BROWSE',...
0199 'BackgroundColor',[0.8 0.8 0.0],...
0200 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0201 'Callback', browsecommand );
0202
0203
0204 G.Bplot = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0205 'Position',[.20 .01 .18 .2],...
0206 'String','PLOT','BusyAction','queue',...
0207 'TooltipString','Plot the MRI data and return p struct.',...
0208 'BackgroundColor',[0.0 0.5 0.0],...
0209 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0210 'Callback',strcat('MRIOpen = get(gcbf,''Userdata'');',...
0211 'mri = gui_avw_open(MRIOpen.mri,''plot'');',...
0212 'clear MRIOpen;'));
0213
0214
0215 G.Bsave = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0216 'Position',[.40 .01 .18 .2],'HorizontalAlignment', 'center',...
0217 'String','SAVE AS','TooltipString','MRI File Conversion Tool (not implemented yet)',...
0218 'BusyAction','queue',...
0219 'Visible','on',...
0220 'BackgroundColor',[0.0 0.0 0.75],...
0221 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0222 'Callback',strcat('MRIOpen = get(gcbf,''Userdata'');',...
0223 'mri = gui_avw_open(MRIOpen.mri,''save'');',...
0224 'clear MRIOpen;'));
0225
0226
0227 G.Breturn = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0228 'Position',[.60 .01 .18 .2],...
0229 'String','RETURN','BusyAction','queue',...
0230 'TooltipString','Return p struct to workspace and parent GUI.',...
0231 'BackgroundColor',[0.75 0.0 0.0],...
0232 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0233 'Callback',strcat('MRIOpen = get(gcbf,''Userdata'');',...
0234 'mri = gui_avw_open(MRIOpen.mri,''return'');',...
0235 'clear MRIOpen;'));
0236
0237
0238 G.Bcancel = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0239 'Position',[.80 .01 .18 .2],...
0240 'String','CANCEL','BusyAction','queue',...
0241 'TooltipString','Close, do not return parameters.',...
0242 'BackgroundColor',[0.75 0.0 0.0],...
0243 'ForegroundColor', [1 1 1], 'HorizontalAlignment', 'center',...
0244 'Callback',strcat('MRIOpen = get(gcbf,''Userdata'');',...
0245 'mri = gui_avw_open(MRIOpen.mri,''cancel'');',...
0246 'clear MRIOpen;'));
0247
0248
0249
0250 G.Bhelp = uicontrol('Parent',GUI,'Style','pushbutton','Units','Normalized', Font, ...
0251 'Position',[.80 .25 .18 .2],'String','Help','BusyAction','queue',...
0252 'BackgroundColor',[1 1 0],...
0253 'ForegroundColor',[0 0 0], 'HorizontalAlignment', 'center',...
0254 'Callback','doc mri_toolbox;');
0255
0256
0257 G.Bhold = uicontrol('Parent',GUI,'Style','checkbox','Units','Normalized', Font, ...
0258 'Position',[.80 .50 .18 .2],'String','Hold GUI','BusyAction','queue',...
0259 'TooltipString','MRI File Load GUI remains open after ''Plot'' or ''Return'' commands.',...
0260 'Value',mri.hold,'HorizontalAlignment', 'center');
0261
0262
0263
0264 if exist('parent','var'), MRIOpen.parent.gui = parent; end
0265 MRIOpen.gui = GUI;
0266 MRIOpen.handles = G;
0267 MRIOpen.mri = mri;
0268 set(GUI,'Userdata',MRIOpen);
0269 set(GUI,'HandleVisibility','callback');
0270
0271 return