help > RE: Error importing SPM.mat file
Dec 24, 2014  05:12 AM | Alfonso Nieto-Castanon - Boston University
RE: Error importing SPM.mat file
Hi Xiaozhen,

Sorry for the misunderstanding, the original script that I sent you (in order to modify the SPM.mat files to make all conditions session-specific) was meant to be run just once, not as part of your batch scripts. Running it multiple times ended up creating all of those strange-looking _Session1_Session1_Session1_... condition names (also it would seem that the script was run different number of times for different subjects so your project ends up having different condition names across different subjects which results in the error message that you get). In any way, in your script simply change the lines that read:

  load(spmfile_i,'SPM');
  for nses=1:length(SPM.Sess),
    for ncondition=1:length(SPM.Sess(nses).U),
      SPM.Sess(nses).U(ncondition).name{1}=[SPM.Sess(nses).U(ncondition).name{1}, sprintf('_Session%d',nses)];
    end
  end
  save(spmfile_i,'SPM');

to:

  load(spmfile_i,'SPM');
  for nses=1:length(SPM.Sess),
    for ncondition=1:length(SPM.Sess(nses).U),

      strappend = sprintf('_Session%d',nses);
      newname = [regexprep(SPM.Sess(nses).U(ncondition).name{1},sprintf('(%s)*$',strappend),'') strappend];
      SPM.Sess(nses).U(ncondition).name{1}=newname;    end
  end
  save(spmfile_i,'SPM');

This can be safely run as part of your script (it will remove the unnecessary/problematic "_Session1" strings from your condition names and it will not append additional "_Session1" strings to your condition names if run multiple times)

Hope this helps
Alfonso

Originally posted by Xiaozhen You:
HI Alfonso,
I noticed I could only upload one file at a time.
Here is the matlab script.. :)

Threaded View

TitleAuthorDate
Xiaozhen You Nov 25, 2014
Xiaozhen You Nov 26, 2014
Alfonso Nieto-Castanon Nov 27, 2014
Xiaozhen You Dec 9, 2014
Alfonso Nieto-Castanon Dec 10, 2014
Alfonso Nieto-Castanon Dec 10, 2014
Xiaozhen You Dec 10, 2014
Alfonso Nieto-Castanon Dec 12, 2014
Xiaozhen You Dec 23, 2014
Xiaozhen You Dec 23, 2014
RE: Error importing SPM.mat file
Alfonso Nieto-Castanon Dec 24, 2014
Xiaozhen You Dec 31, 2014
Alfonso Nieto-Castanon Dec 31, 2014
Xiaozhen You Jan 1, 2015
Alfonso Nieto-Castanon Jan 1, 2015
Xiaozhen You Jan 2, 2015
Alfonso Nieto-Castanon Jan 3, 2015
Xiaozhen You Jan 5, 2015
Xiaozhen You Jan 6, 2015
Alfonso Nieto-Castanon Jan 15, 2015
Xiaozhen You Jan 15, 2015
Xiaozhen You Dec 17, 2014
Xiaozhen You Nov 27, 2014
Alfonso Nieto-Castanon Nov 26, 2014