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

📄 bfm_analysis_ui.m

📁 绝对经典,老外制作的功能强大的matlab实现PLS_TOOBOX
💻 M
📖 第 1 页 / 共 5 页
字号:
   progress_hdl = rri_progress_status('','Create','PLS Analysis');

   progress_merge_factor = 1 / (PLSoptions.TotalNumberProfiles * 2); 
   setappdata(progress_hdl,'ProgressScale',progress_merge_factor * 0.2);
   setappdata(progress_hdl,'ProgressStart',0);

   if exist('plslog.m','file')
      switch (PLSoptions.ContrastMethod)
      case 1
         plslog('BfMRI Mean-Centering Analysis');
      case 2
         plslog('BfMRI Old Analysis');
      case 3
         plslog('BfMRI Non-Rotated Analysis');
      case 4
         plslog('BfMRI Behavior Analysis');
      case 5
         plslog('BfMRI Multiblock Analysis');
      end
   end

   switch (PLSoptions.ContrastMethod)
     case {1}
        fmri_pls_analysis(PLSoptions.profiles, [], ...
				   PLSoptions.num_perm, ...
				   PLSoptions.num_boot, ...
				   PLSoptions.Clim, ...
				   PLSoptions.posthoc, ...
				   PLSoptions.save_datamat, ...
                                   PLSoptions.group_analysis, ...
                                   PLSoptions.cond_selection, ...
                                   PLSoptions.behavname, ...
                                   PLSoptions.behavdata, ...
                                   PLSoptions.behavdata_lst, ...
				   PLSoptions.bscan);
     case {2}
        fmri_pls_analysis(PLSoptions.profiles, 'HELMERT', ...
                                   PLSoptions.num_perm, ...
				   PLSoptions.num_boot, ...
				   PLSoptions.Clim, ...
				   PLSoptions.posthoc, ...
				   PLSoptions.save_datamat, ...
                                   PLSoptions.group_analysis, ...
                                   PLSoptions.cond_selection, ...
                                   PLSoptions.behavname, ...
                                   PLSoptions.behavdata, ...
                                   PLSoptions.behavdata_lst, ...
				   PLSoptions.bscan);
     case {3}
        fmri_pls_analysis(PLSoptions.profiles, PLSoptions.ContrastFile, ...
                                   PLSoptions.num_perm, ...
				   PLSoptions.num_boot, ...
				   PLSoptions.Clim, ...
				   PLSoptions.posthoc, ...
				   PLSoptions.save_datamat, ...
                                   PLSoptions.group_analysis, ...
                                   PLSoptions.cond_selection, ...
                                   PLSoptions.behavname, ...
                                   PLSoptions.behavdata, ...
                                   PLSoptions.behavdata_lst, ...
				   PLSoptions.bscan);
     case {4}

        close(progress_hdl);

        fmri_pls_analysis(PLSoptions.profiles, 'BEHAV', ...
                                   PLSoptions.num_perm, ...
				   PLSoptions.num_boot, ...
				   PLSoptions.Clim, ...
				   PLSoptions.posthoc, ...
				   PLSoptions.save_datamat, ...
                                   PLSoptions.group_analysis, ...
                                   PLSoptions.cond_selection, ...
                                   PLSoptions.behavname, ...
                                   PLSoptions.behavdata, ...
                                   PLSoptions.behavdata_lst, ...
				   PLSoptions.bscan);
     case {5}

        close(progress_hdl);

        fmri_pls_analysis(PLSoptions.profiles, 'MULTIBLOCK', ...
                                   PLSoptions.num_perm, ...
				   PLSoptions.num_boot, ...
				   PLSoptions.Clim, ...
				   PLSoptions.posthoc, ...
				   PLSoptions.save_datamat, ...
                                   PLSoptions.group_analysis, ...
                                   PLSoptions.cond_selection, ...
                                   PLSoptions.behavname, ...
                                   PLSoptions.behavdata, ...
                                   PLSoptions.behavdata_lst, ...
				   PLSoptions.bscan);
   end;

   if exist('progress_hdl','var') & ishandle(progress_hdl)
      close(progress_hdl);
   end

   uiresume(gcf);

   return;						% ExecutePLS


%----------------------------------------------------------------------------
function SelectMean;

   if get(findobj(gcf,'Tag','SelectMean'),'Value') == 0		% click itself
      set(findobj(gcf,'Tag','SelectMean'),'Value',1);
   else
%      set(findobj(gcf,'Tag','SelectHelmert'),'Value',0);
      set(findobj(gcf,'Tag','SelectContrastData'),'Value',0);
      set(findobj(gcf,'Tag','SelectBehavData'),'Value',0);
      set(findobj(gcf,'Tag','SelectMultiblockData'),'Value',0);

      set(findobj(gcf,'Tag','ContrastFileEdit'),'BackGroundColor',[0.9 0.9 0.9]);
      set(findobj(gcf,'Tag','ContrastDataLabel'),'Enable','off');
      set(findobj(gcf,'Tag','ContrastFileEdit'),'Enable','off');
      set(findobj(gcf,'Tag','ContrastFileButton'),'Enable','off');

      set(findobj(gcf,'Tag','PosthocDataEdit'),'BackGroundColor',[0.9 0.9 0.9]);
      set(findobj(gcf,'Tag','ModifyBehavdataMenu'),'Enable','off');
      set(findobj(gcf,'Tag','PosthocDataLabel'),'Enable','off');
      set(findobj(gcf,'Tag','PosthocDataEdit'),'Enable','off');
      set(findobj(gcf,'Tag','PosthocDataBn'),'Enable','off');

      set(findobj(gcf,'Tag','ClimEdit'),'BackGroundColor',[0.9 0.9 0.9]);
      set(findobj(gcf,'Tag','ClimLabel'),'Enable','off');
      set(findobj(gcf,'Tag','ClimEdit'),'Enable','off');

      set(findobj(gcf,'Tag','MultiblockDeselectConditionMenu'),'Enable','off');

      num_group = str2num(get(findobj(gcf,'Tag','NumberGroupEdit'), 'String'));
      if num_group > 1
         set(findobj(gcf,'Tag','GroupAnalysisRadiobutton'), 'Value', 1, 'enable', 'inactive');
      else
         set(findobj(gcf,'Tag','GroupAnalysisRadiobutton'), 'Value', 1, 'enable', 'on');
      end

   end

   return;						% SelectMean


%----------------------------------------------------------------------------
function SelectHelmert;

   if get(findobj(gcf,'Tag','SelectHelmert'),'Value') == 0	% click itself
      set(findobj(gcf,'Tag','SelectHelmert'),'Value',1);
   else
      set(findobj(gcf,'Tag','SelectMean'),'Value',0);
      set(findobj(gcf,'Tag','SelectContrastData'),'Value',0);
      set(findobj(gcf,'Tag','SelectBehavData'),'Value',0);
      set(findobj(gcf,'Tag','SelectMultiblockData'),'Value',0);

      set(findobj(gcf,'Tag','ContrastFileEdit'),'BackGroundColor',[0.9 0.9 0.9]);
      set(findobj(gcf,'Tag','ContrastDataLabel'),'Enable','off');
      set(findobj(gcf,'Tag','ContrastFileEdit'),'Enable','off');
      set(findobj(gcf,'Tag','ContrastFileButton'),'Enable','off');

      set(findobj(gcf,'Tag','PosthocDataEdit'),'BackGroundColor',[0.9 0.9 0.9]);
      set(findobj(gcf,'Tag','ModifyBehavdataMenu'),'Enable','off');
      set(findobj(gcf,'Tag','PosthocDataLabel'),'Enable','off');
      set(findobj(gcf,'Tag','PosthocDataEdit'),'Enable','off');
      set(findobj(gcf,'Tag','PosthocDataBn'),'Enable','off');

      set(findobj(gcf,'Tag','ClimEdit'),'BackGroundColor',[0.9 0.9 0.9]);
      set(findobj(gcf,'Tag','ClimLabel'),'Enable','off');
      set(findobj(gcf,'Tag','ClimEdit'),'Enable','off');

      set(findobj(gcf,'Tag','MultiblockDeselectConditionMenu'),'Enable','off');

      num_group = str2num(get(findobj(gcf,'Tag','NumberGroupEdit'), 'String'));
      if num_group > 1
         set(findobj(gcf,'Tag','GroupAnalysisRadiobutton'), 'Value', 1, 'enable', 'inactive');
      else
         set(findobj(gcf,'Tag','GroupAnalysisRadiobutton'), 'Value', 1, 'enable', 'on');
      end

   end

   return;						% SelectHelmert


%----------------------------------------------------------------------------
function SelectContrastData;

   if get(findobj(gcf,'Tag','SelectContrastData'),'Value') == 0	% click itself
      set(findobj(gcf,'Tag','SelectContrastData'),'Value',1);
   else
      set(findobj(gcf,'Tag','SelectMean'),'Value',0);
%      set(findobj(gcf,'Tag','SelectHelmert'),'Value',0);
      set(findobj(gcf,'Tag','SelectBehavData'),'Value',0);
      set(findobj(gcf,'Tag','SelectMultiblockData'),'Value',0);

      set(findobj(gcf,'Tag','ContrastFileEdit'),'BackGroundColor',[1 1 1]);
      set(findobj(gcf,'Tag','ContrastDataLabel'),'Enable','on');
      set(findobj(gcf,'Tag','ContrastFileEdit'),'Enable','on');
      set(findobj(gcf,'Tag','ContrastFileButton'),'Enable','on');

      set(findobj(gcf,'Tag','PosthocDataEdit'),'BackGroundColor',[0.9 0.9 0.9]);
      set(findobj(gcf,'Tag','ModifyBehavdataMenu'),'Enable','off');
      set(findobj(gcf,'Tag','PosthocDataLabel'),'Enable','off');
      set(findobj(gcf,'Tag','PosthocDataEdit'),'Enable','off');
      set(findobj(gcf,'Tag','PosthocDataBn'),'Enable','off');

      set(findobj(gcf,'Tag','ClimEdit'),'BackGroundColor',[0.9 0.9 0.9]);
      set(findobj(gcf,'Tag','ClimLabel'),'Enable','off');
      set(findobj(gcf,'Tag','ClimEdit'),'Enable','off');

      set(findobj(gcf,'Tag','MultiblockDeselectConditionMenu'),'Enable','off');

      set(findobj(gcf,'Tag','GroupAnalysisRadiobutton'), 'Value', 1, 'enable', 'off');
   end

   return;						% SelectContrastData


%----------------------------------------------------------------------------
function SelectBehavData;

   if get(findobj(gcf,'Tag','SelectBehavData'),'Value') == 0	% click itself
      set(findobj(gcf,'Tag','SelectBehavData'),'Value',1);
   else
      set(findobj(gcf,'Tag','SelectMean'),'Value',0);
%      set(findobj(gcf,'Tag','SelectHelmert'),'Value',0);
      set(findobj(gcf,'Tag','SelectContrastData'),'Value',0);
      set(findobj(gcf,'Tag','SelectMultiblockData'),'Value',0);

      set(findobj(gcf,'Tag','ContrastFileEdit'),'BackGroundColor',[0.9 0.9 0.9]);
      set(findobj(gcf,'Tag','ContrastDataLabel'),'Enable','off');
      set(findobj(gcf,'Tag','ContrastFileEdit'),'Enable','off');
      set(findobj(gcf,'Tag','ContrastFileButton'),'Enable','off');

      set(findobj(gcf,'Tag','PosthocDataEdit'),'BackGroundColor',[1 1 1]);
      set(findobj(gcf,'Tag','ModifyBehavdataMenu'),'Enable','on');
      set(findobj(gcf,'Tag','PosthocDataLabel'),'Enable','on');
      set(findobj(gcf,'Tag','PosthocDataEdit'),'Enable','on');
      set(findobj(gcf,'Tag','PosthocDataBn'),'Enable','on');

      num_boot = str2num(get(findobj(gcf,'Tag','NumBootstrapEdit'),'String'));
      if  ~isempty(num_boot) & num_boot ~= 0
         set(findobj(gcf,'Tag','ClimEdit'),'BackGroundColor',[1 1 1]);
         set(findobj(gcf,'Tag','ClimLabel'),'Enable','on');
         set(findobj(gcf,'Tag','ClimEdit'),'Enable','on');
      end

      set(findobj(gcf,'Tag','MultiblockDeselectConditionMenu'),'Enable','off');

      set(findobj(gcf,'Tag','GroupAnalysisRadiobutton'), 'Value', 1, 'enable', 'off');
   end

   return;						% SelectBehavData


%----------------------------------------------------------------------------
function SelectMultiblockData;

   if get(findobj(gcf,'Tag','SelectMultiblockData'),'Value') == 0	% click itself
      set(findobj(gcf,'Tag','SelectMultiblockData'),'Value',1);
   else
      set(findobj(gcf,'Tag','SelectMean'),'Value',0);
%      set(findobj(gcf,'Tag','SelectHelmert'),'Value',0);
      set(findobj(gcf,'Tag','SelectContrastData'),'Value',0);
      set(findobj(gcf,'Tag','SelectBehavData'),'Value',0);

      set(findobj(gcf,'Tag','ContrastFileEdit'),'BackGroundColor',[0.9 0.9 0.9]);
      set(findobj(gcf,'Tag','ContrastDataLabel'),'Enable','off');
      set(findobj(gcf,'Tag','ContrastFileEdit'),'Enable','off');
      set(findobj(gcf,'Tag','ContrastFileButton'),'Enable','off');

      set(findobj(gcf,'Tag','PosthocDataEdit'),'BackGroundColor',[1 1 1]);
      set(findobj(gcf,'Tag','ModifyBehavdataMenu'),'Enable','on');
      set(findobj(gcf,'Tag','PosthocDataLabel'),'Enable','on');
      set(findobj(gcf,'Tag','PosthocDataEdit'),'Enable','on');
      set(findobj(gcf,'Tag','PosthocDataBn'),'Enable','on');

      num_boot = str2num(get(findobj(gcf,'Tag','NumBootstrapEdit'),'String'));
      if  ~isempty(num_boot) & num_boot ~= 0
         set(findobj(gcf,'Tag','ClimEdit'),'BackGroundColor',[1 1 1]);
         set(findobj(gcf,'Tag','ClimLabel'),'Enable','on');
         set(findobj(gcf,'Tag','ClimEdit'),'Enable','on');
      end

      set(findobj(gcf,'Tag','MultiblockDeselectConditionMenu'),'Enable','on');

      set(findobj(gcf,'Tag','GroupAnalysisRadiobutton'), 'Value', 1, 'enable', 'off');
   end

   return;						% SelectMultiblockData


%----------------------------------------------------------------------------
function EditNumBoot

   %  contain behavpls
   %
   if get(findobj(gcf,'Tag','SelectBehavData'),'Value') == 1 | ...
	get(findobj(gcf,'Tag','SelectMultiblockData'),'Value') == 1

      num_boot = str2num(get(findobj(gcf,'Tag','NumBootstrapEdit'),'String'));
      if  ~isempty(num_boot) & num_boot ~= 0
         set(findobj(gcf,'Tag','ClimEdit'),'BackGroundColor',[1 1 1]);
         set(findobj(gcf,'Tag','ClimLabel'),'Enable','on');
         set(findobj(gcf,'Tag','ClimEdit'),'Enable','on');
      else
         set(findobj(gcf,'Tag','ClimEdit'),'BackGroundColor',[0.9 0.9 0.9]);
         set(findobj(gcf,'Tag','ClimLabel'),'Enable','off');
         set(findobj(gcf,'Tag','ClimEdit'),'Enable','off');
      end
   end

   return;						% EditNumBoot


%----------------------------------------------------------------------------
function EditPosthocDataFile

   posthoc_data_file = deblank(strjust(get(gcbo,'String'),'left'));

   set(gcbo,'String',posthoc_data_file);

   if ~isempty(posthoc_data_file)
      if ( exist(posthoc_data_file,'file') == 2 )		% specified file exists
         setappdata(gcf,'posthoc_data_file',posthoc_data_file);
         return;
      end;

      if ( exist(posthoc_data_file,'dir') == 7 )		% it is a directory!
         msg = 'ERROR: The specified file is a direcotry!';
         set(findobj(gcf,'Tag','MessageLine'),'String',msg);
         setappdata(gcf,'posthoc_data_file','');
         return;
      end;
   else
%      msg = 'ERROR: Invalid input file!';
%      set(findobj(gcf,'Tag','MessageLine'),'String',msg);
      setappdata(gcf,'posthoc_data_file','');
      return;
   end;

   return;						% EditPosthocDataFile


%----------------------------------------------------------------------------
function SelectPosthocDataFile

   h = findobj(gcf,'Tag','PosthocDataEdit');

   [filename,pathname]=uigetfile('*.*','Select Posthoc Data File');

   if isequal(filename,0) | isequal(pathname,0)
      return;
   end;

   posthoc_data_file = [pathname, filename];

   set(h,'String',posthoc_data_file);
   set(h,'TooltipString',posthoc_data_file);
   setappdata(gcf,'posthoc_data_file',posthoc_data_file);

   return;						% SelectPosthocDataFile


%----------------------------------------------------------------------------
function status = cExecutePLS()

   status = 0;

   if exist('progress_hdl','var') & ishandle(progress_hdl)
      close(progress_hdl);
   end

   contrast_file = '';

   PLSoptions = getappdata(gcf,'PLSoptions');

   if exist('plslog.m','file')
      switch (PLSoptions.ContrastMethod)
      case 1
         plslog('BfMRI Mean-Centering Analysis');
      case 2
         plslog('BfMRI Old Analysis');
      case 3
         plslog('BfMRI Non-Rotated Analysis');
      case 4
         plslog('BfMRI Behavior Analysis');
      case 5
         plslog('BfMRI Multiblock Analysis');
      end
   end

   switch (PLSoptions.ContrastMethod)
   case 1
      method = 1;			% Mean-Centering Task PLS
      ContrastFile = 'NONE';
   case 3
      method = 2;			% Non-Rotated Task PLS
      ContrastFile = PLSoptions.ContrastFile;
   case 4
      method = 3;			% Behavior PLS
      ContrastFile = 'BEHAV';
   case 5
      method = 4;			% Multiblock PLS
      ContrastFile = 'MULTIBLOCK';
   end

   SessionProfiles = PLSoptions.profiles;
   perm_result_num_perm = PLSoptions.num_perm;
   boot_result_num_boot = PLSoptions.num_boot;
   Clim = PLSoptions.Clim;
   save_datamat = PLSoptions.save_datamat;
   cond_selection = PLSoptions.cond_selection;
   behavname = PLSoptions.behavname;
   behavdata = PLSoptions.behavdata;
   behavdata_lst = PLSoptions.behavdata_lst;
   bscan = PLSoptions.bscan;

   session_files_timestamp = SessionProfiles;
   datamat_files_timestamp = SessionProfiles;

   change_timestamp = 0;

   for i = 1:length(SessionProfiles)
      for j = 1:length(SessionProfiles{i})
         tmp = dir(SessionProfiles{i}{j});
         session_files_timestamp{i}{j} = tmp.date;

         load(SessionProfiles{i}{j},'session_info');

⌨️ 快捷键说明

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