📄 fc_gui.m
字号:
set(handles.rbtnNullMask,'Value',0);
set(handles.rbtnUserMask,'Value',1);
drawnow;
function rbtnNullMask_Callback(hObject, eventdata, handles)
set(handles.edtMaskfile, 'Enable','off', 'String','Don''t use any Mask');
set(handles.btnSelectMask, 'Enable','off');
drawnow;
handles.Cfg.MaskFile ='';
guidata(hObject, handles);
set(handles.rbtnDefaultMask,'Value',0);
set(handles.rbtnNullMask,'Value',1);
set(handles.rbtnUserMask,'Value',0);
function listDataDirs_Callback(hObject, eventdata, handles)
theIndex =get(hObject, 'Value');
if isempty(theIndex) || theIndex<1,
msgbox(sprintf('Nothing added.\n\nYou must add some diretories containing only paired {hdr/img} files first'), ...
'REST' ,'help');
return;
end
if strcmp(get(handles.figFCMain, 'SelectionType'), 'open') %when double click
msgbox(sprintf('%s \t\nhas\t %d\t volumes\n\nTotal: %d Data Directories' , ...
handles.Cfg.DataDirs{theIndex, 1} , ...
handles.Cfg.DataDirs{theIndex, 2} , ...
size(handles.Cfg.DataDirs,1)), ...
'Volume count in selected dir' ,'help');
end
function listDataDirs_KeyPressFcn(hObject, eventdata, handles)
%Delete the selected item when 'Del' is pressed
key =get(handles.figFCMain, 'currentkey');
if seqmatch({key},{'delete', 'backspace'})
DeleteSelectedDataDir(hObject, eventdata,handles);
end
function DeleteSelectedDataDir(hObject, eventdata, handles)
theIndex =get(handles.listDataDirs, 'Value');
if prod(size(handles.Cfg.DataDirs))==0 ...
|| size(handles.Cfg.DataDirs, 1)==0 ...
|| theIndex>size(handles.Cfg.DataDirs, 1),
return;
end
theDir =handles.Cfg.DataDirs{theIndex, 1};
theVolumnCount=handles.Cfg.DataDirs{theIndex, 2};
tmpMsg=sprintf('Delete\n\n "%s" \nVolumn Count :%d ?', theDir, theVolumnCount);
if strcmp(questdlg(tmpMsg, 'Delete confirmation'), 'Yes')
if theIndex>1,
set(handles.listDataDirs, 'Value', theIndex-1);
end
handles.Cfg.DataDirs(theIndex, :)=[];
if size(handles.Cfg.DataDirs, 1)==0
handles.Cfg.DataDirs={};
end
guidata(hObject, handles);
UpdateDisplay(handles);
end
function ClearDataDirectories(hObject, eventdata, handles)
if prod(size(handles.Cfg.DataDirs))==0 ...
|| size(handles.Cfg.DataDirs, 1)==0,
return;
end
tmpMsg=sprintf('Attention!\n\n\nDelete all data directories?');
if strcmpi(questdlg(tmpMsg, 'Clear confirmation'), 'Yes'),
handles.Cfg.DataDirs(:)=[];
if prod(size(handles.Cfg.DataDirs))==0,
handles.Cfg.DataDirs={};
end
guidata(hObject, handles);
UpdateDisplay(handles);
end
function listDataDirs_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edtPrefix_Callback(hObject, eventdata, handles)
%nothing need to do, because I get the prefix when I need. Look at line 229 "thePrefix =get(handles.edtPrefix, 'String');"
function edtPrefix_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edtOutputDir_Callback(hObject, eventdata, handles)
theDir =get(hObject, 'String');
SetOutputDir(hObject,handles, theDir);
function edtOutputDir_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function btnSelectOutputDir_Callback(hObject, eventdata, handles)
theDir =handles.Cfg.OutputDir;
theDir =uigetdir(theDir, 'Please select the data directory to compute functional connectivity map: ');
if ~isequal(theDir, 0)
SetOutputDir(hObject,handles, theDir);
end
function SetOutputDir(hObject, handles, ADir)
if 7==exist(ADir,'dir')
handles.Cfg.OutputDir =ADir;
guidata(hObject, handles);
UpdateDisplay(handles);
end
function Result=GetDirName(ADir)
if isempty(ADir), Result=ADir; return; end
theDir =ADir;
if strcmp(theDir(end),filesep)==1
theDir=theDir(1:end-1);
end
[tmp,Result]=fileparts(theDir);
function ckboxFilter_Callback(hObject, eventdata, handles)
if get(hObject,'Value')
handles.Filter.UseFilter ='Yes';
else
handles.Filter.UseFilter ='No';
end
guidata(hObject, handles);
UpdateDisplay(handles);
function edtBandLow_Callback(hObject, eventdata, handles)
handles.Filter.BandLow =str2double(get(hObject,'String'));
guidata(hObject, handles);
function edtBandLow_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edtBandHigh_Callback(hObject, eventdata, handles)
handles.Filter.BandHigh =str2double(get(hObject,'String'));
guidata(hObject, handles);
function edtBandHigh_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function ckboxRetrend_Callback(hObject, eventdata, handles)
if get(hObject,'Value')
handles.Filter.Retrend ='Yes';
else
handles.Filter.Retrend ='No';
end
guidata(hObject, handles);
UpdateDisplay(handles);
function edtSamplePeriod_Callback(hObject, eventdata, handles)
handles.Filter.SamplePeriod =str2double(get(hObject,'String'));
guidata(hObject, handles);
function edtSamplePeriod_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function ckboxFisherZ_Callback(hObject, eventdata, handles)
if get(hObject,'Value')
handles.Cfg.WantFisherZMap ='Yes';
else
handles.Cfg.WantFisherZMap ='No';
end
guidata(hObject, handles);
UpdateDisplay(handles);
function btnFisherZ_Callback(hObject, eventdata, handles)
theOldColor=get(hObject,'BackgroundColor');
set(hObject,'Enable','off', 'BackgroundColor', 'red');
drawnow;
try
[filename, pathname] = uigetfile({'*.img', 'functional connectivity files (*.img)'}, ...
'Pick one functional connectivity map');
if (filename~=0)% not canceled
if strcmpi(filename(end-3:end), '.img')%revise filename to remove extension
filename = filename(1:end-4);
end
if ~strcmpi(pathname(end), filesep)%revise filename to remove extension
pathname = [pathname filesep];
end
theOrigFCMap =[pathname filename];
theFisherZMap =[pathname 'z' filename];
theMaskFile =handles.Cfg.MaskFile;
rest_Corr2FisherZ(theOrigFCMap, theFisherZMap, theMaskFile);
msgbox(sprintf('functional connectivity brain "%s.{hdr/img}" \nhas been transformed to Fisher Z-score map in the specified mask.\t\n\nSave to "%s.{hdr/img}"\n' , ...
theOrigFCMap, theFisherZMap), ...
'Fisher Z-score transformation within mask successfully' ,'help');
end
catch
rest_misc( 'DisplayLastException');
end
set(hObject,'Enable','on', 'BackgroundColor', theOldColor);
drawnow;
function btnBandPass_Callback(hObject, eventdata, handles)
theOldColor=get(hObject,'BackgroundColor');
set(hObject,'Enable','off', 'BackgroundColor', 'red');
drawnow;
try
%Band pass filter
if strcmpi(handles.Filter.UseFilter, 'Yes')
BandPass(hObject, handles);
msgbox('Ideal Band Pass filter Over.',...
'Filter successfully' ,'help');
else
errordlg(sprintf('You didn''t select option "Band Pass". \n\nPlease slect first.'));
end
UpdateDisplay(handles);
catch
rest_misc( 'DisplayLastException');
end
rest_waitbar;
set(hObject,'Enable','on', 'BackgroundColor', theOldColor);
drawnow;
function InitFrames(hObject,handles)
offsetY =83+50; %dawnsong, 20070504, add for the divide by the mask mean, the Y of Edit "OutPut Diectory"
%dawnsong, 20070905, add Covariable for functional connectivities
% for Matlab 6.5 compatible, draw a panel
uicontrol(handles.figFCMain, 'Style','Frame','Position',[2 offsetY+92 433 1]);%bottom
uicontrol(handles.figFCMain, 'Style','Frame','Position',[2 offsetY+136 433 1]);%Covariables horz line
%uicontrol(handles.figFCMain, 'Style','Frame','Position',[90 offsetY+202 343 1]);%Mask Bottom line
uicontrol(handles.figFCMain, 'Style','Frame','Position',[2 offsetY+227 433 1]);%Middle, mask top line
uicontrol(handles.figFCMain, 'Style','Frame','Position',[90 offsetY+137 1 90]);%Middle, mask left line
uicontrol(handles.figFCMain, 'Style','Frame','Position',[2 offsetY+92 1 290]); %Input left line
uicontrol(handles.figFCMain, 'Style','Frame','Position',[435 offsetY+92 1 290]);%Input right line
uicontrol(handles.figFCMain, 'Style','Frame','Position',[2 offsetY+382 433 1]); %Input top line
uicontrol(handles.figFCMain,'Style','Text','Position',[142 offsetY+378 180 14],...
'String','Input Parameters');
uicontrol(handles.figFCMain,'Style','Text','Position',[208 offsetY+222 40 14],...
'String','Mask');
uicontrol(handles.figFCMain,'Style','Text','Position',[20 offsetY+222 50 14],...
'String','Set ROI', 'FontWeight', 'normal','FontSize', 10,'ForegroundColor', 'red');
uicontrol(handles.figFCMain, 'Style','Frame','Position',[2 offsetY+393 433 1]);
uicontrol(handles.figFCMain, 'Style','Frame','Position',[435 offsetY+393 1 50]);
uicontrol(handles.figFCMain, 'Style','Frame','Position',[2 offsetY+393 1 50]);
uicontrol(handles.figFCMain, 'Style','Frame','Position',[2 offsetY+443 433 1]);
uicontrol(handles.figFCMain,'Style','Text','Position',[142 offsetY+438 180 14],...
'String','Option: Ideal Band Pass Filter');
uicontrol(handles.figFCMain, 'Style','Frame','Position',[2 offsetY+458 433 1]);
uicontrol(handles.figFCMain, 'Style','Frame','Position',[435 offsetY+458 1 50]);
uicontrol(handles.figFCMain, 'Style','Frame','Position',[2 offsetY+458 1 50]);
uicontrol(handles.figFCMain, 'Style','Frame','Position',[2 offsetY+508 433 1]);
uicontrol(handles.figFCMain,'Style','Text','Position',[142 offsetY+498 180 14],...
'String','Option: Remove Linear Trend');
%I insert the area for covariables between Input and Output areas.
offsetY = offsetY -50;
uicontrol(handles.figFCMain, 'Style','Frame','Position',[2 offsetY+94 433 1]);
uicontrol(handles.figFCMain, 'Style','Frame','Position',[2 offsetY-8 433 1]);
uicontrol(handles.figFCMain, 'Style','Frame','Position',[2 offsetY-8 1 102]);
uicontrol(handles.figFCMain, 'Style','Frame','Position',[435 offsetY-8 1 102]);
uicontrol(handles.figFCMain,'Style','Text','Position',[142 offsetY+88 180 14],...
'String','Output Parameters');
%20070506, Add manual operation button groups like SPM
uicontrol(handles.figFCMain, 'Style','Frame','Position',[2 offsetY-25 433 1]);
uicontrol(handles.figFCMain,'Style','Text','Position',[152 offsetY-30 140 14],...
'String','Manual Operations');
function InitControlProperties(hObject, handles)
%for Linux compatible 20070507 dawnsong
% --- FIGURE -------------------------------------
set(handles.figFCMain,...
'Units', 'pixels', ...
'Position', [20 5 440 645], ...
'Name', 'fc_gui', ...
'MenuBar', 'none', ...
'NumberTitle', 'off', ...
'Color', get(0,'DefaultUicontrolBackgroundColor'));
% --- STATIC TEXTS -------------------------------------
set(handles.txtLogo, ...
'Style', 'text', ...
'Units', 'pixels', ...
'Position', [16 186 260 30], ...
'FontSize', 16, ...
'FontWeight', 'bold', ...
'String', 'Functional Connectivity');
set(handles.txtLongName, ...
'Style', 'text', ...
'Units', 'pixels', ...
'Position', [10 400 65 30], ...
'FontSize', 10, ...
'FontWeight', 'bold', ...
'Enable', 'on', ...
'Visible', 'off', ...
'String', sprintf('ROI Definition'));
set(handles.txtOutputDir, ...
'Style', 'text', ...
'Units', 'pixels', ...
'Position', [8 109 80 21], ...
'String', 'Directory:');
set(handles.txtInputDir, ...
'Style', 'text', ...
'Units', 'pixels', ...
'Position', [7 370 80 21], ...
'String', 'Data Directory:');
set(handles.txtPrefix, ...
'Style', 'text', ...
'Units', 'pixels', ...
'Position', [9 140 80 21], ...
'String', 'Prefix:');
set(handles.txtResultFilename, ...
'Style', 'text', ...
'Units', 'pixels', ...
'Position', [227 148 200 16], ...
'HorizontalAlignment','left' , ...
'String', 'Result: Prefix_DirectoryName.{hdr/img}');
set(handles.txtBandSep, ...
'Style', 'text', ...
'Units', 'pixels', ...
'Position', [146 516 25 51], ...
'FontSize', 28, ...
'String', '~');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -