Hi all, I am encountering a similar error with spmregister, although it is a bit different. When my startup.m is configured to add the SPM2 paths, spmregister works without issue. However, when my startup.m uses either the SPM5 or 8 paths, it fails with the following error:
Welcome to MATLAB >> >> >> >> >> >> >> >> >> /usr/pubsw/common/spm/spm8/spm_coreg.m >> >> >> >> >> INFO: Assuming RAS coordinate system >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> using ./tmp.bbregister.6451/spmregister/refvol.spmregister.img as the target image >> using ./tmp.bbregister.6451/spmregister/movvol.spmregister.img as the source image >> >> >> >> >> >> >> ??? Undefined function or method 'spm_vol_ana' for input arguments of type 'char'. Error in ==> spm_vol>subfunc at 94 if isempty(n), V = spm_vol_ana(p); Error in ==> spm_vol>subfunc1 at 63 v = subfunc(P(i,:)); Error in ==> spm_vol>subfunc2 at 52 V = subfunc1(P); Error in ==> spm_vol at 38 V = subfunc2(P); >> ??? Undefined function or variable 'VG'. >> >> >> ??? Undefined function or method 'spm_vol_ana' for input arguments of type 'char'. Error in ==> spm_vol>subfunc at 94 if isempty(n), V = spm_vol_ana(p); Error in ==> spm_vol>subfunc1 at 63 v = subfunc(P(i,:)); Error in ==> spm_vol>subfunc2 at 52 V = subfunc1(P); Error in ==> spm_vol at 38 V = subfunc2(P); >> ??? Undefined function or variable 'VF'. >> >> INFO: ignore warnings about scalefactor >> >> determining coregistration parameters... >> >> >> ERROR: spm_coreg >> ??? Undefined function or variable 'x'. >> Finished after 0.029568 sec >> >> Parameters >> ??? Undefined function or variable 'x'. >> >> >> >> >> ??? Undefined function or variable 'x'. >> >> Using spm_get_space ??? Undefined variable "VF" or class "VF.fname". >> >> >> ERROR: matlab exited with errors ERROR: spm_coreg /usr/pubsw/common/spm/spm8/spm_coreg.m We analyze using SPM8, so I'd prefer not to have to switch my startup.m to the SPM2 paths every time I want to register a subject. Thanks for your help! Andy Chindhuri Selvadurai wrote: > Hello, > > Changing the spm path to spm5 did not fix the problem. > > Command line: bbregister --s RMCON051 --mov ../bold/009/f.nii --reg > ../bold/register.dat > --init-spm --bold > > Scripts directory: /space/ventzl/36/users/RespMon12C/scripts > > SUBJECTS_DIR: /space/ventzl/36/users/RespMon12C/subjects > > terminal output: > > vantz:chinsel[102] nmrenv > -------- freesurfer-Linux-centos4_x86_64-stable-v4.5.0-20100311 -------- > Setting up environment for FreeSurfer/FS-FAST (and FSL) > FREESURFER_HOME /usr/local/freesurfer/stable4 > FSFAST_HOME /usr/local/freesurfer/stable4/fsfast > FSF_OUTPUT_FORMAT nii > SUBJECTS_DIR /space/ventzl/36/users/RespMon12C/subjects > MNI_DIR /usr/local/freesurfer/stable4/mni > FSL_DIR /usr/pubsw/packages/fsl/current > [vantz:scripts] (nmr-std-env) pwd > /autofs/space/ventzl_036/users/RespMon12C/scripts > [vantz:scripts] (nmr-std-env) ./ bbregister.bash > ./: Permission denied. > [vantz:scripts] (nmr-std-env) ./bbregister.bash > Log file is ../bold/register.dat.log > Thu Oct 7 10:07:04 EDT 2010 > > setenv SUBJECTS_DIR /space/ventzl/36/users/RespMon12C/subjects > cd /autofs/space/ventzl_036/users/RespMon12C/subjects/RMCON051/mystudy > /usr/local/freesurfer/stable4/bin/bbregister --s RMCON051 --mov > ../bold/009/f.nii --reg ../bold/register.dat --init-spm --bold > > $Id: bbregister,v 1.14.2.13 2009/12/16 20:20:09 greve Exp $ > Linux vantz 2.6.18-194.8.1.el5 #1 SMP Thu Jul 1 19:04:48 EDT 2010 x86_64 > x86_64 x86_64 GNU/Linux > FREESURFER_HOME /usr/local/freesurfer/stable4 > mri_convert ../bold/009/f.nii ../bold/tmp.bbregister.26962/template.nii > mri_convert ../bold/009/f.nii ../bold/tmp.bbregister.26962/template.nii > $Id: mri_convert.c,v 1.146.2.5 2009/04/08 18:40:23 nicks Exp $ > reading from ../bold/009/f.nii... > TR=2000.00, TE=0.00, TI=0.00, flip angle=0.00 > i_ras = (-0.997195, -0.0748521, -0.000274916) > j_ras = (0.0748328, -0.997009, 0.0193167) > k_ras = (-0.00171999, 0.0192419, 0.999813) > writing to ../bold/tmp.bbregister.26962/template.nii... > spmregister --s RMCON051 --mov ../bold/tmp.bbregister.26962/template.nii > --reg ../bold/tmp.bbregister.26962/reg.init.dat --tmp > ../bold/tmp.bbregister.26962/spmregister > Log file is ../bold/tmp.bbregister.26962/spmregister.log > Thu Oct 7 10:07:14 EDT 2010 > --s RMCON051 --mov ../bold/tmp.bbregister.26962/template.nii --reg > ../bold/tmp.bbregister.26962/reg.init.dat --tmp > ../bold/tmp.bbregister.26962/spmregister > $Id: spmregister,v 1.21.2.5 2009/04/15 18:10:23 greve Exp $ > matlab matlab > fmt img > UseSPMGetSpace 1 > -------------------------------------- > /autofs/space/ventzl_036/users/RespMon12C/subjects/RMCON051/mystudy > mri_convert > /space/ventzl/36/users/RespMon12C/subjects/RMCON051/mri/brainmask.mgz > ../bold/tmp.bbregister.26962/spmregister/refvol.spmregister.img -ic 0 0 0 > mri_convert > /space/ventzl/36/users/RespMon12C/subjects/RMCON051/mri/brainmask.mgz > ../bold/tmp.bbregister.26962/spmregister/refvol.spmregister.img -ic 0 0 0 > $Id: mri_convert.c,v 1.146.2.5 2009/04/08 18:40:23 nicks Exp $ > reading from > /space/ventzl/36/users/RespMon12C/subjects/RMCON051/mri/brainmask.mgz... > TR=2530.00, TE=1.64, TI=1200.00, flip angle=7.00 > i_ras = (-1, -1.49012e-08, -2.12167e-08) > j_ras = (-9.8953e-08, -7.69251e-09, -1) > k_ras = (3.72529e-08, 1, 4.14548e-09) > writing to > ../bold/tmp.bbregister.26962/spmregister/refvol.spmregister.img... Analyze > Output Matrix > -1.000 -0.000 0.000 129.000; > -0.000 -0.000 1.000 -129.000; > -0.000 -1.000 0.000 129.000; > 0.000 0.000 0.000 1.000; > -------------------- > INFO: set hdr.hist.orient to -1 > -------------------------------------- > /autofs/space/ventzl_036/users/RespMon12C/subjects/RMCON051/mystudy > mri_convert ../bold/tmp.bbregister.26962/template.nii > ../bold/tmp.bbregister.26962/spmregister/movvol.spmregister.img -ic 0 0 0 > --frame 0 > mri_convert ../bold/tmp.bbregister.26962/template.nii > ../bold/tmp.bbregister.26962/spmregister/movvol.spmregister.img -ic 0 0 0 > --frame 0 > $Id: mri_convert.c,v 1.146.2.5 2009/04/08 18:40:23 nicks Exp $ > reading from ../bold/tmp.bbregister.26962/template.nii... > TR=2000.00, TE=0.00, TI=0.00, flip angle=0.00 > i_ras = (-0.997195, -0.0748521, -0.000274916) > j_ras = (0.0748328, -0.997009, 0.0193167) > k_ras = (-0.00171999, 0.0192419, 0.999813) > keeping frame 0 > writing to > ../bold/tmp.bbregister.26962/spmregister/movvol.spmregister.img... Analyze > Output Matrix > -3.116 0.234 -0.006 95.227; > -0.234 -3.116 0.071 109.325; > -0.001 0.060 3.699 -64.852; > 0.000 0.000 0.000 1.000; > -------------------- > INFO: set hdr.hist.orient to -1 > Matlab file is > ../bold/tmp.bbregister.26962/spmregister/spmregister.27005.m > > monly = 0; > targvol = > '../bold/tmp.bbregister.26962/spmregister/refvol.spmregister.img'; srcvol = > '../bold/tmp.bbregister.26962/spmregister/movvol.spmregister.img'; errfile = > '../bold/tmp.bbregister.26962/spmregister/spmregister.27005.err'; > > if(exist('spm_coreg') ~= 2) > fprintf('ERROR: cannot find spm_coreg.m. Make sure that the SPM\n'); > fprintf(' package is in your matlab path (check ~/matlab/startup)\n'); > fp = fopen(errfile,'w'); > fprintf(fp,'ERROR: cannot find spm_coreg.m. Make sure that the SPM\n'); > fprintf(fp,' package is in your matlab path (check > ~/matlab/startup)\n'); > fclose(fp); > return; quit; > end > > which spm_coreg > > global defaults > spm_defaults % load spm2's default fields > > fprintf('INFO: Assuming RAS coordinate system\n'); > defaults.analyze.flip = 0; > > %=========================================================================== > % coregistration defaults > %=========================================================================== > > defaults.coreg.estimate.cost_fun = 'nmi'; > defaults.coreg.estimate.sep = [4 2]; > defaults.coreg.estimate.tol = [0.02 0.02 0.02 0.001 0.001 0.001 0.01 > 0.01 0.01 0.001 0.001 0.001]; > defaults.coreg.estimate.fwhm = [7 7]; > defaults.coreg.estimate.params = [0 0 0 0 0 0]; > defaults.coreg.estimate.graphics = 0; % dont crate ps file > > > %=========================================================================== > % coregister files > %=========================================================================== > > disp(sprintf('using %s as the target image',targvol)); > disp(sprintf('using %s as the source image',srcvol)); > > [pth1,nam1,ext1] = fileparts(deblank(targvol)); > [pth2,nam2,ext2] = fileparts(deblank(srcvol)); > > %tmp = spm_get('Files',pth1,[nam1 ext1]); > tmp = sprintf('%s/%s%s',pth1,nam1,ext1); > VG = spm_vol(tmp); % target image > if(isempty(VG)) > fprintf('ERROR: loading target %s\n',targvol); > fp = fopen(errfile,'a'); > fprintf(fp,'ERROR: loading target %s\n',targvol); > fclose(fp); > return; quit; > end > % tmp = spm_get('Files',pth2,[nam2 ext2]) > tmp = sprintf('%s/%s%s',pth2,nam2,ext2); > VF = spm_vol(tmp); % source image > if(isempty(VF)) > fprintf('ERROR: loading source %s\n',srcvol); > fp = fopen(errfile,'a'); > fprintf(fp,'ERROR: loading source %s\n',srcvol); > fclose(fp); > return; quit; > end > > fprintf('\n\nINFO: ignore warnings about scalefactor\n\n'); > > disp('determining coregistration parameters...') > > tic; > try > x = spm_coreg(VG.fname,VF.fname,defaults.coreg.estimate); > catch > fprintf('ERROR: spm_coreg\n'); > fp = fopen(errfile,'a'); > fprintf(fp,'ERROR: spm_coreg\n'); > fprintf(fp,'%s\n',which('spm_coreg')); > fclose(fp); > return; quit; > end > if(isempty(x)) > fprintf('ERROR: spm_coreg\n'); > if(~monly) > fp = fopen(errfile,'a'); > fprintf(fp,'ERROR: spm_coreg\n'); > fclose(fp); > return; quit; > end > end > fprintf('Finished after %g sec\n',toc); > > fprintf('Parameters '); > fprintf('%g ',x); > fprintf('\n'); > > %---------write out the .mat file---see spm_coreg_ui.m line 283 > > M = inv(spm_matrix(x)); > > if(1) > fprintf('Using spm_get_space\n'); > MM = zeros(4,4,1); > MM = spm_get_space(deblank(VF.fname)); > spm_get_space(deblank(VF.fname), M*MM); > fprintf('\n\nINFO: ignore warnings about scalefactor\n\n'); > else > fprintf('Using MRIread/write instead of spm_get_space\n'); > ff = MRIread(deblank(VF.fname)); > ff.vox2ras1 = M*ff.vox2ras1; > ff.vox2ras0 = vox2ras_1to0(ff.vox2ras1); > ff.vox2ras = ff.vox2ras0; > MRIwrite(ff,deblank(VF.fname)); > end > > return; > if(~monly) quit; end > > Warning: Unable to open display iconic, MATLAB is starting without a display. > You will not be able to display graphics on the screen. > Warning: No window system found. Java option 'MWT' ignored > > < M A T L A B > > Copyright 1984-2007 The MathWorks, Inc. > Version 7.4.0.287 (R2007a) > January 29, 2007 > > > To get started, type one of these: helpwin, helpdesk, or demo. > For product information, visit www.mathworks.com. > > Warning: Executing startup failed in matlabrc. > This indicates a potentially serious problem in your MATLAB setup, which > should be resolved as soon as possible. Error detected was: > MATLAB:UndefinedFunction > Undefined function or variable 'mne_setup_toolbox'. > >> In matlabrc at 259 >> >>>>>>>>>>>>>>> ERROR: cannot find spm_coreg.m. Make sure that the >>>>>>>>>>>>>>> > SPM > package is in your matlab path (check ~/matlab/startup) > >>>>> 'spm_coreg' not found. >>>>> >>>>>>> ??? Undefined function or variable 'spm_defaults'. >>>>>>> > > >>>>> INFO: Assuming RAS coordinate system >>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> using >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > ../bold/tmp.bbregister.26962/spmregister/refvol.spmregister.img > as the target > image > >>> using ../bold/tmp.bbregister.26962/spmregister/movvol.spmregister.img >>> > as the source image > >>>>>>>>>>>>>>> ??? Undefined function or method 'spm_vol' for input >>>>>>>>>>>>>>> > arguments of type 'char'. > > >>> ??? Undefined function or variable 'VG'. >>> > > >>>>>>> ??? Undefined function or method 'spm_vol' for input arguments of >>>>>>> > type 'char'. > > >>> ??? Undefined function or variable 'VF'. >>> > > > > INFO: ignore warnings about scalefactor > > >>>>> determining coregistration parameters... >>>>> >>>>>>> ERROR: spm_coreg >>>>>>> >>> ??? Undefined function or variable 'x'. >>> > > >>> Finished after 0.008886 sec >>> >>>>> Parameters >> ??? Undefined function or variable 'x'. >>>>> > > >>>>>>>>> ??? Undefined function or variable 'x'. >>>>>>>>> > > >>>>> Using spm_get_space >>>>> > ??? Undefined variable "VF" or class "VF.fname". > > >>>>>>> ERROR: matlab exited with errors >>>>>>> > ERROR: cannot find spm_coreg.m. Make sure that the SPM > package is in your matlab path (check ~/matlab/startup) > ERROR: spm_coreg > > > >> Two suggestions: >> 1. Can you temporarily change the spm path to spm5 to see if that fixes >> > the problem? > >> 2. Can you send me your command line, directory you ran it from, >> > SUBJECTS_DIR, and terminal output? > >> doug >> Chindhuri Selvadurai wrote: >> >>> The path to spm2 was not originally in my startup.m file, but even when >>> > I added it, it didn't work. > >>> I am using 7.8, but I tried to change my cshrc file back to 7.1 >>> > however, > >>> once I ran the script, it was actually running 7.4 >>> Thank you, >>> Chindhuri >>> >>>> Chindhuri, >>>> Is the path to spm2 added in your startup.m file and are you using >>>> >>> matlab 7.1 (required by spm2)? >>> >>>> doug >>>> Chindhuri Selvadurai wrote: >>>> >>>>> Hello, >>>>> I am getting the same error that was discussed in the attached >>>>> > thread, > >>> however, the addition of the path line did not work for me. >>> >>>>> I am also not sure if we should be using spm5 since all in the past >>>>> > we > >>> have been using spm2. It presents this error when running under my >>> > name, > >>>>> but not for other users. >>>>> Any help would be appreciated! >>>>> Thanks, >>>>> Chindhuri >>>>> ________________________________________________ >>>>> Re: [Freesurfer] spmregister error >>>>> Douglas N Greve >>>>> Fri, 30 Jul 2010 09:58:18 -0700 >>>>> Yes, that should work. >>>>> doug >>>>> Adam Nitenson wrote: >>>>> >>>>>> Hi Sandra, >>>>>> I just had this same problem about a week ago. The solution >>>>>> > which > >>>>>> worked for me was adding the following line of text into the >>>>>> > startup.m > >>> file in your matlab folder: >>> >>>>>> path(path,'/usr/pubsw/common/spm/spm5'); >>>>>> I'm not sure it matter exactly where you put it. I put mine in the >>>>>> >>> last >>> >>>>>> row in the FreeSurfer FAST section, under the line beginning with >>>>>> >>> "clear". >>> >>>>>> Hope that helps! >>>>>> -Adam >>>>>> >>>>>>> Hello, >>>>>>> When running spmregister-sess (standard environment was sourced) I >>>>>>> >>> encountered this error: >>> >>>>>>> ERROR: matlab exited with errors >>>>>>> ERROR: cannot find spm_coreg.m. Make sure that the SPM >>>>>>> package is in your matlab path (check ~/matlab/startup) >>>>>>> ERROR: spm_coreg >>>>>>> ERROR: spmregister failed >>>>>>> __________________________________________________________ >>>>>>> Our information: >>>>>>> FREESURFER_HOME: /usr/local/freesurfer/stable4 >>>>>>> Build stamp: freesurfer-Linux-centos4_x86_64-stable-v4.5.0-20100311 >>>>>>> >>> RedHat release: CentOS release 5.3 (Final) >>> >>>>>>> Kernel info: Linux 2.6.18-128.7.1.el5 x86_64 >>>>>>> NMR Center info (/space/freesurfer exists): >>>>>>> machine: purkinje >>>>>>> SUBJECTS_DIR: /cluster/ablood/1/DMRF_ASL/DMRF_ASL_recons >>>>>>> PWD: /cluster/ablood/1/DMRF_ASL >>>>>>> ssh purkinje >>>>>>> setenv SUBJECTS_DIR /cluster/ablood/1/DMRF_ASL/DMRF_ASL_recons cd >>>>>>> >>> /cluster/ablood/1/DMRF_ASL >>> >>>>>>> __________________________________________________________________ >>>>>>> > We > >>> appreciate any help you can give us!! >>> >>>>>>> Thanks, >>>>>>> Sandra >>>>>>> Mood and Motor Control Laboratory >>>>>>> Athinoula Martinos Center for Biomedical Imaging >>>>>>> Massachusetts General Hospital >>>>>>> 120 6th St. >>>>>>> Charlestown, MA 02129 >>>>>>> Tel: 617-643-6245 >>>>>>> Fax: 617-726-1351 >>>>>>> Email: swoodm...@partners.org >>>>>>> _______________________________________________ >>>>>>> Freesurfer mailing list >>>>>>> Freesurfer@nmr.mgh.harvard.edu >>>>>>> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer >>>>>>> >>>>>> Adam Nitenson, B.S. >>>>>> Brain Genomics Lab >>>>>> Massachusetts General Hospital >>>>>> _______________________________________________ >>>>>> Freesurfer mailing list >>>>>> Freesurfer@nmr.mgh.harvard.edu >>>>>> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer >>>>>> >>>> -- >>>> Douglas N. Greve, Ph.D. >>>> MGH-NMR Center >>>> gr...@nmr.mgh.harvard.edu >>>> Phone Number: 617-724-2358 >>>> Fax: 617-726-7422 >>>> Bugs: surfer.nmr.mgh.harvard.edu/fswiki/BugReporting >>>> FileDrop: www.nmr.mgh.harvard.edu/facility/filedrop/index.html >>>> >>> Best, >>> Chindhuri Selvadurai >>> Psychiatric Neuroimaging, Manoach Lab >>> Martinos Center for Biomedical Imaging >>> Massachusetts General Hospital >>> Phone: (617)726-0307 >>> >> -- >> Douglas N. Greve, Ph.D. >> MGH-NMR Center >> gr...@nmr.mgh.harvard.edu >> Phone Number: 617-724-2358 >> Fax: 617-726-7422 >> Bugs: surfer.nmr.mgh.harvard.edu/fswiki/BugReporting >> FileDrop: www.nmr.mgh.harvard.edu/facility/filedrop/index.html >> > > > Best, > > Chindhuri Selvadurai > > Psychiatric Neuroimaging, Manoach Lab > Martinos Center for Biomedical Imaging > Massachusetts General Hospital > Phone: (617)726-0307 > > > > > > > Best, > > Chindhuri Selvadurai > > Psychiatric Neuroimaging, Manoach Lab > Martinos Center for Biomedical Imaging > Massachusetts General Hospital > Phone: (617)726-0307 > > > > _______________________________________________ > Freesurfer mailing list > Freesurfer@nmr.mgh.harvard.edu > https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer > > > -- Andrew Ward Brigham and Women's Hospital (BBNG) Massachusetts General Hospital (GRU) Athinoula A. Martinos Center for Biomedical Imaging 149 13th St., Room 2689C Charlestown, MA 02129 Phone: 617-726-6211 Fax: 617-726-5760 _______________________________________________ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail.