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

📄 rri_changepath_ui.m

📁 绝对经典,老外制作的功能强大的matlab实现PLS_TOOBOX
💻 M
📖 第 1 页 / 共 3 页
字号:
      select_all_file;
   end

%   list_file(selected_dir);

   return;					% update_file_list


%----------------------------------------------------------------------------
function select_a_file;

   file_list_hdl = findobj(gcf,'Tag','FILE_LIST');
   select_a_file_hdl = findobj(gcf,'Tag','SELECT_A_FILE');
   select_all_file_hdl = findobj(gcf,'Tag','SELECT_ALL_FILE');
   old_path_edit_hdl = findobj(gcf,'tag','OldPathEdit');
   new_path_edit_hdl = findobj(gcf,'tag','NewPathEdit');
   select_button_hdl = findobj(gcf,'tag','SELECTButton');
%   set(select_button_hdl,'enable','on');

   curr = pwd;
   if isempty(curr)
      curr = filesep;
   end

   list_file(curr);

   set(old_path_edit_hdl,'string','N/A');
   set(new_path_edit_hdl,'string',curr);
   set(select_a_file_hdl,'value',1);
   set(select_all_file_hdl,'value',0);
   set(file_list_hdl,'max',1);

   old_file = getappdata(gcf,'old_file');

   if ~isempty(old_file)
      listed_file = get(file_list_hdl,'string');
      [tmp1,tmp2,idx]=intersect(old_file,listed_file);
      set(file_list_hdl,'value',idx);
   end

   filename = get(file_list_hdl,'string');
   filename = filename(get(file_list_hdl,'value'));
   filename = filename{1};

   if filename(1) == '['
      set(new_path_edit_hdl,'enable','inactive');
      return;
   end

   set(new_path_edit_hdl,'enable','on');
   old_path = get_old_path(filename);
   set(old_path_edit_hdl,'string',old_path);

   return;					% select_a_file


%----------------------------------------------------------------------------
function select_all_file;

   file_list_hdl = findobj(gcf,'Tag','FILE_LIST');
   select_a_file_hdl = findobj(gcf,'Tag','SELECT_A_FILE');
   select_all_file_hdl = findobj(gcf,'Tag','SELECT_ALL_FILE');
   old_path_edit_hdl = findobj(gcf,'tag','OldPathEdit');
   new_path_edit_hdl = findobj(gcf,'tag','NewPathEdit');
   set(new_path_edit_hdl,'enable','on');
   select_button_hdl = findobj(gcf,'tag','SELECTButton');
%   set(select_button_hdl,'enable','off');

   curr = pwd;
   if isempty(curr)
      curr = filesep;
   end

   num_dir = list_file(curr);

   set(new_path_edit_hdl,'string',curr);
   set(select_a_file_hdl,'value',0);
   set(select_all_file_hdl,'value',1);
   set(file_list_hdl, 'max',2);

   if length(get(file_list_hdl,'string')) > num_dir

      set(file_list_hdl, 'listboxtop',num_dir+1, ...
	'value',(num_dir+1):length(get(file_list_hdl,'string')));
      set(new_path_edit_hdl,'enable','on');
      set(old_path_edit_hdl,'string','Varied');

   else

      set(file_list_hdl, 'listboxtop',1, 'value', []);
      set(new_path_edit_hdl,'enable','inactive');
      set(old_path_edit_hdl,'string','N/A');

   end

   return;					% select_all_file


%----------------------------------------------------------------------------
function select_new_path_edit

   msg = 'Please select a valid PLS data file first';
   uiwait(msgbox(msg,'Error','modal'));

   return;


%----------------------------------------------------------------------------
function delete_fig

    try
       load('pls_profile');
       pls_profile = which('pls_profile.mat');

       rri_changepath_pos = get(gcbf,'position');

       save(pls_profile, '-append', 'rri_changepath_pos');
    catch
    end

   return;					% delete_fig


%----------------------------------------------------------------------------
function old_path = get_old_path(filename)

   old_path = '';

   if ~isempty(findstr('_PETsession.mat', filename))

      load(filename, 'session_info');
      old_path = session_info.pls_data_path;

      return;      

   elseif ~isempty(findstr('_PETdatamat.mat', filename))

      load(filename, 'session_info');
      old_path = session_info.pls_data_path;

      return;      

   elseif ~isempty(findstr('_PETresult.mat', filename))

      load(filename, 'datamat_files');
%      old_path = fileparts(datamat_files{1});
      old_path = rri_fileparts(datamat_files{1});

      return;      

   elseif ~isempty(findstr('_fMRIsession.mat', filename))

      load(filename, 'session_info');
      old_path = session_info.pls_data_path;

      return;      

   elseif ~isempty(findstr('_fMRIdatamat.mat', filename))

      load(filename, 'st_sessionFile');
%      old_path = fileparts(st_sessionFile);
      old_path = rri_fileparts(st_sessionFile);

      return;      

   elseif ~isempty(findstr('_fMRIresult.mat', filename))

      load(filename, 'SessionProfiles');
%      old_path = fileparts(SessionProfiles{1}{1});
      old_path = rri_fileparts(SessionProfiles{1}{1});

      return;      

   elseif ~isempty(findstr('_BfMRIsession.mat', filename))

      load(filename, 'session_info');
      old_path = session_info.pls_data_path;

      return;      

   elseif ~isempty(findstr('_BfMRIdatamat.mat', filename))

      load(filename, 'st_sessionFile');
%      old_path = fileparts(st_sessionFile);
      old_path = rri_fileparts(st_sessionFile);

      return;      

   elseif ~isempty(findstr('_BfMRIresult.mat', filename))

      load(filename, 'SessionProfiles');
%      old_path = fileparts(SessionProfiles{1}{1});
      old_path = rri_fileparts(SessionProfiles{1}{1});

      return;      

   elseif ~isempty(findstr('_ERPsession.mat', filename))

      load(filename, 'session_info');
      old_path = session_info.pls_data_path;

      return;      

   elseif ~isempty(findstr('_ERPdatamat.mat', filename))

      load(filename, 'session_info');
      old_path = session_info.pls_data_path;

      return;      

   elseif ~isempty(findstr('_ERPresult.mat', filename))

      load(filename, 'datamat_files');
%      old_path = fileparts(datamat_files{1});
      old_path = rri_fileparts(datamat_files{1});

      return;

   end

   return;					% get_old_path


%----------------------------------------------------------------------------
function select_save

   systype = '/';
   file_list_hdl = findobj(gcf,'Tag','FILE_LIST');
   select_a_file_hdl = findobj(gcf,'Tag','SELECT_A_FILE');
   select_all_file_hdl = findobj(gcf,'Tag','SELECT_ALL_FILE');
   old_path_edit_hdl = findobj(gcf,'tag','OldPathEdit');
   new_path_edit_hdl = findobj(gcf,'tag','NewPathEdit');
   dir_name = get(file_list_hdl,'user');

   file_list = get(file_list_hdl,'string');
   file_list = file_list(get(file_list_hdl,'value'));

   oldpath = get(old_path_edit_hdl,'string');

   if get(select_all_file_hdl,'value')
      org_oldpath = oldpath;
   end

   newpath = get(new_path_edit_hdl,'string');

   if isempty(newpath)
      msg = 'Please enter new PLS data path';
      uiwait(msgbox(msg,'Error','modal'));
      return;
   end

   newpath = [upper(newpath(1)) newpath(2:end)];

   if length(file_list) > 1
      progress_hdl = rri_progress_ui('initialize', 'Changing PLS path, please wait ...');
   end

   old_pointer = get(gcf,'Pointer');
   set(gcf,'Pointer','watch');

   for i = 1:length(file_list)

      filename = fullfile(dir_name, file_list{i});

      if length(file_list) > 1
         msg = ['Working on file: ', filename];
         rri_progress_ui(progress_hdl, '', msg);
         rri_progress_ui(progress_hdl, '', i/length(file_list));
      end

      if ~isempty(findstr('PETsession.mat', filename))

         load(filename, 'session_info');

         if get(select_all_file_hdl,'value') & strcmp(org_oldpath,'Varied')
            oldpath = session_info.pls_data_path;      
         end
         oldpath = [upper(oldpath(1)) oldpath(2:end)];
         if isempty(findstr(oldpath, filesep))
            if getappdata(gcf,'ispc')
               systype = 'ux2pc';
            else
               systype = 'pc2ux';
            end
         end

%         session_info.pls_data_path = newpath;
         session_info.pls_data_path = ...
            [upper(session_info.pls_data_path(1)) session_info.pls_data_path(2:end)];
         session_info.pls_data_path = ...
               strrep(session_info.pls_data_path,oldpath,newpath);
         if strcmp(systype,'pc2ux')
            session_info.pls_data_path = ...
               strrep(session_info.pls_data_path,'\','/');
         elseif strcmp(systype,'ux2pc')
            session_info.pls_data_path = ...
               strrep(session_info.pls_data_path,'/','\');
         end

         for j = 1:session_info.num_subjects
            session_info.subject{j} = ...
               [upper(session_info.subject{j}(1)) session_info.subject{j}(2:end)];
            session_info.subject{j} = ...
               strrep(session_info.subject{j},oldpath,newpath);
            if strcmp(systype,'pc2ux')
               session_info.subject{j} = ...
                  strrep(session_info.subject{j},'\','/');
            elseif strcmp(systype,'ux2pc')
               session_info.subject{j} = ...
                  strrep(session_info.subject{j},'/','\');
            end
         end

         save(filename,'-append','session_info');

      elseif ~isempty(findstr('PETdatamat.mat', filename))

         load(filename, 'session_info','session_file');

         if get(select_all_file_hdl,'value') & strcmp(org_oldpath,'Varied')
            oldpath = session_info.pls_data_path;
         end
         oldpath = [upper(oldpath(1)) oldpath(2:end)];
         if isempty(findstr(oldpath, filesep))
            if getappdata(gcf,'ispc')
               systype = 'ux2pc';
            else
               systype = 'pc2ux';
            end
         end

         session_info.pls_data_path = ...
            [upper(session_info.pls_data_path(1)) session_info.pls_data_path(2:end)];
         session_info.pls_data_path = ...
               strrep(session_info.pls_data_path,oldpath,newpath);
         if strcmp(systype,'pc2ux')
            session_info.pls_data_path = ...
               strrep(session_info.pls_data_path,'\','/');
         elseif strcmp(systype,'ux2pc')
            session_info.pls_data_path = ...
               strrep(session_info.pls_data_path,'/','\');
         end

         for j = 1:session_info.num_subjects
            session_info.subject{j} = ...
               [upper(session_info.subject{j}(1)) session_info.subject{j}(2:end)];
            session_info.subject{j} = ...
               strrep(session_info.subject{j},oldpath,newpath);
            if strcmp(systype,'pc2ux')
               session_info.subject{j} = ...
                  strrep(session_info.subject{j},'\','/');
            elseif strcmp(systype,'ux2pc')
               session_info.subject{j} = ...
                  strrep(session_info.subject{j},'/','\');
            end
         end

         session_file = ...
            [upper(session_file(1)) session_file(2:end)];
         session_file = strrep(session_file,oldpath,newpath);
         if strcmp(systype,'pc2ux')
            session_file = strrep(session_file,'\','/');
         elseif strcmp(systype,'ux2pc')
            session_file = strrep(session_file,'/','\');
         end

         save(filename,'-append','session_info','session_file');

      elseif ~isempty(findstr('PETresult.mat', filename))

         load(filename, 'datamat_files');

         if get(select_all_file_hdl,'value') & strcmp(org_oldpath,'Varied')
            oldpath = rri_fileparts(datamat_files{1});
         end
         oldpath = [upper(oldpath(1)) oldpath(2:end)];
         if isempty(findstr(oldpath, filesep))
            if getappdata(gcf,'ispc')
               systype = 'ux2pc';
            else
               systype = 'pc2ux';
            end
         end

         for j = 1:length(datamat_files)
            datamat_files{j} = ...
               [upper(datamat_files{j}(1)) datamat_files{j}(2:end)];
            datamat_files{j} = strrep(datamat_files{j},oldpath,newpath);
            if strcmp(systype,'pc2ux')
               datamat_files{j} = strrep(datamat_files{j},'\','/');
            elseif strcmp(systype,'ux2pc')
               datamat_files{j} = strrep(datamat_files{j},'/','\');
            end
         end

         save(filename,'-append','datamat_files');

      elseif ~isempty(findstr('fMRIsession.mat', filename))

         load(filename, 'session_info');

         if get(select_all_file_hdl,'value') & strcmp(org_oldpath,'Varied')
            oldpath = session_info.pls_data_path;
         end
         oldpath = [upper(oldpath(1)) oldpath(2:end)];
         if isempty(findstr(oldpath, filesep))
            if getappdata(gcf,'ispc')
               systype = 'ux2pc';
            else
               systype = 'pc2ux';
            end
         end

         session_info.pls_data_path = ...
            [upper(session_info.pls_data_path(1)) session_info.pls_data_path(2:end)];
         session_info.pls_data_path = ...
               strrep(session_info.pls_data_path,oldpath,newpath);
         if strcmp(systype,'pc2ux')
            session_info.pls_data_path = ...
               strrep(session_info.pls_data_path,'\','/');
         elseif strcmp(systype,'ux2pc')
            session_info.pls_data_path = ...
               strrep(session_info.pls_data_path,'/','\');
         end

         for j = 1:session_info.num_runs
            session_info.run(j).data_path = ...
               [upper(session_info.run(j).data_path(1)) session_info.run(j).data_path(2:end)];
            session_info.run(j).data_path = ...
		strrep(session_info.run(j).data_path,oldpath,newpath);
            if strcmp(systype,'pc2ux')
               session_info.run(j).data_path = ...
                  strrep(session_info.run(j).data_path,'\','/');
            elseif strcmp(systype,'ux2pc')
               session_info.run(j).data_path = ...
                  strrep(session_info.run(j).data_path,'/','\');
            end
         end

         save(filename,'-append','session_info');

      elseif ~isempty(findstr('fMRIdatamat.mat', filename))

         load(filename, 'st_sessionFile');

         if get(select_all_file_hdl,'value') & strcmp(org_oldpath,'Varied')
            oldpath = rri_fileparts(st_sessionFile);
         end
         oldpath = [upper(oldpath(1)) oldpath(2:end)];
         if isempty(findstr(oldpath, filesep))
            if getappdata(gcf,'ispc')
               systype = 'ux2pc';
            else
               systype = 'pc2ux';
            end
         end

         st_sessionFile = ...

⌨️ 快捷键说明

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