⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reho_gui.m

📁 While resting-state fMRI is drawing more and more attention, there has not been a software for its d
💻 M
📖 第 1 页 / 共 4 页
字号:
				fprintf('\nReHo :"%s"\n', handles.Cfg.DataDirs{x, 1});				
		        reho(  handles.Cfg.DataDirs{x, 2}, ...
		                handles.Cfg.ClusterCount, ...
		                handles.Cfg.MaskFile);
				
				%move the file, back-compatible with the HeYong's ReHo 
				theOutputDir=get(handles.edtOutputDir, 'String');
				thePrefix =get(handles.edtPrefix, 'String');
				theDstFile=fullfile(theOutputDir,[thePrefix '_' ...
											GetDirName(handles.Cfg.DataDirs{x, 1}) ] );
				movefile('rehomap.hdr', [theDstFile '.hdr']);		
				movefile('rehomap.img', [theDstFile '.img']);		
				
				%20070504, divide ReHo brain by the mean within the mask
				if strcmpi(handles.Cfg.WantMeanRehoMap, 'Yes')
					theOrigReHoMap =theDstFile;				
					theMeanReHoMap =fullfile(theOutputDir,['m' thePrefix '_' ...
												GetDirName(handles.Cfg.DataDirs{x, 1}) ] );
					theMaskFile =handles.Cfg.MaskFile;
					rest_DivideMeanWithinMask(theOrigReHoMap, theMeanReHoMap, theMaskFile);
				end
			end	
			handles.Performance =cputime -handles.Performance; %Write down the End time , 20070903
			LogPerformance(handles);
		catch	
			rest_misc( 'DisplayLastException');
			errordlg(sprintf('Exception occured: \n\n%s' , lasterr)); 
		end
		rest_waitbar;
		cd(theOldDir);
		set(hObject,'Enable','on', 'BackgroundColor', theOldColor);
		drawnow;
    else
        errordlg('No reho.m ! Please re-install'); 
    end

%%
function edtMaskfile_Callback(hObject, eventdata, handles)
	theMaskfile =get(hObject, 'String');
	if ~isequal(theMaskfile , 0) && rest_misc('GetMatlabVersion')>=7.3,
		theMaskfile =strtrim(theMaskfile);
	end	
	if exist(theMaskfile, 'file')
		handles.Cfg.MaskFile =theMaskfile;
		guidata(hObject, handles);
	else
		errordlg(sprintf('The mask file "%s" does not exist!\n Please re-check it.', theMaskfile));
	end
	
% --- Executes during object creation, after setting all properties.
function edtMaskfile_CreateFcn(hObject, eventdata, handles)
	if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
	    set(hObject,'BackgroundColor','white');
	end


%% --- Executes on button press in btnSelectMask.
function btnSelectMask_Callback(hObject, eventdata, handles)
    [filename, pathname] = uigetfile({'*.img;*.mat', 'All Mask files (*.img; *.mat)'; ...
												'*.mat','MAT masks (*.mat)'; ...
												'*.img', 'ANALYZE masks(*.img)'}, ...
												'Pick a user''s  mask');
    if ~(filename==0)
        handles.Cfg.MaskFile =[pathname filename];
        guidata(hObject,handles);
    elseif ~( exist(handles.Cfg.MaskFile, 'file')==2)
        set(handles.rbtnDefaultMask, 'Value',[1]);        
        set(handles.rbtnUserMask, 'Value',[0]);        
		set(handles.edtMaskfile, 'Enable','off');
        set(handles.btnSelectMask, 'Enable','off');			
		handles.Cfg.MaskFile ='Default';		
		guidata(hObject, handles);
    end    
    UpdateDisplay(handles);

%% --- Select Default mask
function rbtnDefaultMask_Callback(hObject, eventdata, handles)	
	set(handles.btnSelectMask, 'Enable','off');		
    handles.Cfg.MaskFile ='Default';
	guidata(hObject, handles);
    set(handles.rbtnDefaultMask,'Value',1);
	set(handles.rbtnNullMask,'Value',0);
	set(handles.rbtnUserMask,'Value',0);
    
% --- Executes on button press in rbtnNullMask.
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);
		
%% --- Select user defined mask
function rbtnUserMask_Callback(hObject, eventdata, handles)
	set(handles.edtMaskfile,'Enable','on', 'String',handles.Cfg.MaskFile);
	set(handles.btnSelectMask, 'Enable','on');
	set(handles.rbtnDefaultMask,'Value',0);
	set(handles.rbtnNullMask,'Value',0);
	set(handles.rbtnUserMask,'Value',1);
    drawnow;
% --- Executes on button press in rbtn27voxels.
function rbtn27voxels_Callback(hObject, eventdata, handles)
	handles.Cfg.ClusterCount =27;
	guidata(hObject, handles);
    set(handles.rbtn7voxels,'Value',0);
	set(handles.rbtn19voxels,'Value',0);
	set(handles.rbtn27voxels,'Value',1);

% --- Executes on button press in rbtn19voxels.
function rbtn19voxels_Callback(hObject, eventdata, handles)
	handles.Cfg.ClusterCount =19;
	guidata(hObject, handles);
    set(handles.rbtn7voxels,'Value',0);
	set(handles.rbtn19voxels,'Value',1);
	set(handles.rbtn27voxels,'Value',0);
    
% --- Executes on button press in rbtn7voxels.
function rbtn7voxels_Callback(hObject, eventdata, handles)
	handles.Cfg.ClusterCount =7;
	guidata(hObject, handles);    
	set(handles.rbtn7voxels,'Value',1);
	set(handles.rbtn19voxels,'Value',0);
	set(handles.rbtn27voxels,'Value',0);

%% Double-click to show the volumn count of the selected dir
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.figRehoMain, '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.figRehoMain, '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');"
	UpdateDisplay(handles);

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 ReHo 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);
	
%Matlab -v6 compatible, create some frames instead of panels
	
% --- Executes on button press in ckboxFilter.
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



%Divide ReHo brain by the mean within the mask, output: mRehoMap.{hdr/img}
function ckboxDivideMean_Callback(hObject, eventdata, handles)
	if get(hObject,'Value')
		handles.Cfg.WantMeanRehoMap ='Yes';
	else	
		handles.Cfg.WantMeanRehoMap ='No';
	end
	guidata(hObject, handles);
	UpdateDisplay(handles);
	
% ---Manaul Operations, Divide one rehomap by its global mean
function btnDivideMean_Callback(hObject, eventdata, handles)
	theOldColor=get(hObject,'BackgroundColor');		
	set(hObject,'Enable','off', 'BackgroundColor', 'red');
	drawnow;
	try
		[filename, pathname] = uigetfile({'*.img', 'ReHo files (*.img)'}, ...
													'Pick one ReHo 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 dir name to remove the last \ or /		
				pathname = [pathname filesep];
			end
			theOrigReHoMap =[pathname filename];
			theMeanReHoMap =[pathname 'm' filename];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -