SPM mask

173 views
Skip to first unread message

georc...@googlemail.com

unread,
Jun 2, 2008, 12:53:17 PM6/2/08
to Princeton MVPA Toolbox for Matlab
Hi and thank you for your efforts; I am trying to implement the
analysis using SPM.

Two questions:

1) when I do

subj = load_analyze_mask(subj,'VT_category-
selective','mask_cat_select_vt.img');

I get the following error:

??? Error using ==> spm_vol>subfunc
mask_cat_select_vt.img: Unknown file format.

Error in ==> spm_vol>subfunc1 at 83
v = subfunc(P(i,:));

Error in ==> spm_vol>subfunc2 at 71
V = subfunc1(P);

Error in ==> spm_vol at 57
V = subfunc2(P);

Error in ==> load_analyze_mask at 48
vol = spm_vol(filename);

ANy thoughts?

2)ALSO, how can I have a whole brain mask and/or an ROI mask (produced
by either a GLM or an ROI such as PickAtlas)?

Thanks

George

Greg Detre

unread,
Jun 2, 2008, 4:06:37 PM6/2/08
to mvpa-t...@googlegroups.com
dear george,

with regard to question 1, is it possible that there was an error in the
download of the sample data? all of the hard work in load_analyze_mask
is being done by the standard SPM functions, so if they're having a
problem, it's probably just corrupt data

as for masking, i'm not an SPM user so i don't know what PickAtlas does,
but perhaps i can still help you. MVPA toolbox masks are simply 3D
boolean matrices. see:

https://compmem.princeton.edu/mvpa_docs/Manual#head-739949f183c823a2c9cbba5238e2131d753f1b73

so if you want to import a mask, create an image in SPM with 1s for the
voxels you want, and 0s for the voxels you want to exclude. then, just
load it in with load_analyze_mask. presumably, there are SPM tools to
create wholebrain masks and ROIs in this format? if not, then maybe you
can just load in an image into matlab and do the thresholding yourself

let us know if this answers your question or not.

g


--


---
Greg Detre
cell: 617 642 3902
email: gr...@gregdetre.co.uk
web: http://www.princeton.edu/~gdetre/

George Christopoulos

unread,
Jun 3, 2008, 4:00:41 PM6/3/08
to mvpa-t...@googlegroups.com
Hi,

thanks for your reply. I managed to overcome the first problem - I will come back to the mask issue later maybe.

But now when I do

subj = feature_select(subj,'epi_z','conds','runs_xval');

I receive this error:

??? Out of memory. Type HELP MEMORY for your options.

Error in ==> feature_select at 87
args.new_map_patname = sprintf('%s_%s',data_patin,stripped_name);

This happens in both AFNI and SPM dataset. Moreover it doesnot look to be a problem from my Matlab or pc (I increased virtual memory and also tested it to a better pc).

Any thoughts?

Thanks

George


2008/6/2 Greg Detre <gde...@princeton.edu>:

Greg Detre

unread,
Jun 3, 2008, 4:13:04 PM6/3/08
to mvpa-t...@googlegroups.com
hey george,

in order to narrow down the problem, can you answer 2 sets of questions
for me:

- is this the sample SPM dataset that we provide? and are you following
the exact instructions in the tutorial?

- can you describe your computing setup a little? mac/windows/linux,
RAM, matlab version etc.

thanks,
greg


George Christopoulos wrote:
> Hi,
>
> thanks for your reply. I managed to overcome the first problem - I
> will come back to the mask issue later maybe.
>
> But now when I do
>
> subj = feature_select(subj,'epi_z','conds','runs_xval');
>
> I receive this error:
>
> ??? Out of memory. Type HELP MEMORY for your options.
>
> Error in ==> feature_select at 87
> args.new_map_patname = sprintf('%s_%s',data_patin,stripped_name);
>
> This happens in both AFNI and SPM dataset. Moreover it doesnot look to
> be a problem from my Matlab or pc (I increased virtual memory and also
> tested it to a better pc).
>
> Any thoughts?
>
> Thanks
>
> George
>
>

> 2008/6/2 Greg Detre <gde...@princeton.edu <mailto:gde...@princeton.edu>>:


>
>
> dear george,
>
> with regard to question 1, is it possible that there was an error
> in the
> download of the sample data? all of the hard work in load_analyze_mask
> is being done by the standard SPM functions, so if they're having a
> problem, it's probably just corrupt data
>
> as for masking, i'm not an SPM user so i don't know what PickAtlas
> does,
> but perhaps i can still help you. MVPA toolbox masks are simply 3D
> boolean matrices. see:
>
> https://compmem.princeton.edu/mvpa_docs/Manual#head-739949f183c823a2c9cbba5238e2131d753f1b73
>
> so if you want to import a mask, create an image in SPM with 1s
> for the
> voxels you want, and 0s for the voxels you want to exclude. then, just
> load it in with load_analyze_mask. presumably, there are SPM tools to
> create wholebrain masks and ROIs in this format? if not, then
> maybe you
> can just load in an image into matlab and do the thresholding yourself
>
> let us know if this answers your question or not.
>
> g
>
>

> email: gr...@gregdetre.co.uk <mailto:gr...@gregdetre.co.uk>
> web: http://www.princeton.edu/~gdetre/
> <http://www.princeton.edu/%7Egdetre/>

George Christopoulos

unread,
Jun 3, 2008, 4:21:06 PM6/3/08
to mvpa-t...@googlegroups.com
hi

1) yes is the SPM you provide - I get the same error with the *AFNI* dataset; and I (hope to) follow the exact instructions. This is my matlab file:

clear all
subj = init_subj('haxby8','tutorial_subj');

cd 'C:\Documents and Settings\George\My Documents\Downloads\mvpa\mvpa.1.0\mvpa\data\unit_set';
subj = load_analyze_mask(subj,'VT_category-selective','mask_cat_select_vt.img');

for i=1:10 
     index=num2str(i);
     raw_filenames{i} = ['haxby8_r' index '_.img'];
end


subj = load_analyze_pattern(subj,'epi','VT_category-selective',raw_filenames);

subj = init_object(subj,'regressors','conds');

load('tutorial_regs');

subj = set_mat(subj,'regressors','conds',regs);

condnames = {'face','house','cat','bottle','scissors','shoe','chair','scramble'};

subj = set_objfield(subj,'regressors','conds','condnames',condnames);

subj = init_object(subj,'selector','runs');

load('tutorial_runs');

subj = set_mat(subj,'selector','runs',runs);
%

 subj = zscore_runs(subj,'epi','runs','use_mvpa_ver',true);
%
 subj = create_xvalid_indices(subj,'runs');
%
subj = feature_select(subj,'epi_z','conds','runs_xval');
%
 class_args.train_funct_name = 'train_bp_netlab';
%
 class_args.test_funct_name = 'test_bp_netlab';

class_args.nHidden = 10;

[subj results] = cross_validation(subj,'epi_z','conds','runs_xval','epi_z_thresh0.05',class_args);

But I also tried it by entering the commands line-by-line.

2)My settings is Windows Intel Pentium, RAM = 1.GB. Matlab r2006a

Thanks

George

2008/6/3 Greg Detre <gde...@princeton.edu>:

Greg Detre

unread,
Jun 3, 2008, 4:36:24 PM6/3/08
to mvpa-t...@googlegroups.com
hey george,

thanks for sending all of that. i haven't got a windows computer with
1GB RAM handy to test on, but i'm pretty sure i've tested at least the
afni tutorial on computers with 1GB RAM with no problems in the past. if
you run:

>> summarize(subj)

you should find that the epi_z pattern has only a few hundred voxels.
this should easily fit in 1GB RAM.

did you say you had tried it on a different computer with the same result?

perhaps you could try a different ANOVA function:

>> statmap_arg.use_mvpa_ver = true;
>> subj =
feature_select(subj,'epi_z','conds','runs_xval','statmap_arg',statmap_arg);

my inclination right now is to think that this is some problem with your
particular computer or particular version of matlab, but i've been wrong
before (though only once)

g

> 2)My settings is Windows Intel Pentium, RAM = 1.GB <http://1.GB>.
> Matlab r2006a
>
> Thanks
>
> George
>
> 2008/6/3 Greg Detre <gde...@princeton.edu <mailto:gde...@princeton.edu>>:

> <mailto:gde...@princeton.edu> <mailto:gde...@princeton.edu

> <mailto:georc...@googlemail.com

> <mailto:gr...@gregdetre.co.uk <mailto:gr...@gregdetre.co.uk>>

George Christopoulos

unread,
Jun 3, 2008, 4:44:37 PM6/3/08
to mvpa-t...@googlegroups.com
Hi Greg

true, 1 GB for 577x1210 voxels should have been fine. I have already used the other anova function (i guess is the one for people not having the statistics toolbox?), but the same error message was given. I will give it a try to a third computer and if this fails I guess I will need to give up :(.

Thanks anyway,

George

2008/6/3 Greg Detre <gde...@princeton.edu>:

Greg Detre

unread,
Jun 3, 2008, 4:57:36 PM6/3/08
to mvpa-t...@googlegroups.com
no, don't give up! i've seen these 'out of memory' errors before, and
always been able to deal with them in the past, so i'm confident we can
solve your problem too.

my hunch is that it's a problem with the particular version of matlab
you're using and/or windows. if you're able to upgrade the version of
matlab, that would be diagnostic.

let's try the following:

- close all the other open applications before starting matlab
- exit and re-open matlab
- type 'dbstop if error' to turn on debugging
- now try running the tutorial

when it gives you an error, run 'whos' to tell us about the memory
usage. let's see what that says

g


George Christopoulos wrote:
> Hi Greg
>
> true, 1 GB for 577x1210 voxels should have been fine. I have already
> used the other anova function (i guess is the one for people not
> having the statistics toolbox?), but the same error message was given.
> I will give it a try to a third computer and if this fails I guess I
> will need to give up :(.
>
> Thanks anyway,
>
> George
>

> 2008/6/3 Greg Detre <gde...@princeton.edu <mailto:gde...@princeton.edu>>:

> <mailto:gde...@princeton.edu> <mailto:gde...@princeton.edu

> > <mailto:gde...@princeton.edu <mailto:gde...@princeton.edu>>>>:

Greg Detre

unread,
Jun 3, 2008, 4:59:58 PM6/3/08
to mvpa-t...@googlegroups.com
better still, reboot first. it could be a rogue process running on that
computer that's eating up all the RAM. and make sure there's at least a
few GB space free on the hard disk

g

George Christopoulos

unread,
Jun 3, 2008, 5:10:50 PM6/3/08
to mvpa-t...@googlegroups.com
Hi,

I rebooted - the reply to whos is:

Name                Size                    Bytes  Class

  args                1x1                       678  struct array
  data_patin          1x5                        10  char array
  defaults            1x1                       678  struct array
  regsname            1x5                        10  char array
  selsgroup           1x9                        18  char array
  stripped_name       1x5                        10  char array
  subj                1x1                  32401252  struct array
  varargin            0x0                         0  cell array

Grand total is 2410130 elements using 32402656 bytes

Do you think there is an error with the data?

George

George Christopoulos

unread,
Jun 3, 2008, 5:16:14 PM6/3/08
to mvpa-t...@googlegroups.com
...and these for the afni data:


Name                Size                    Bytes  Class

  args                1x1                       678  struct array
  data_patin          1x5                        10  char array
  defaults            1x1                       678  struct array
  regsname            1x5                        10  char array
  selsgroup           1x9                        18  char array
  stripped_name       1x5                        10  char array
  subj                1x1                  13184367  struct array

  varargin            0x0                         0  cell array

Grand total is 1710645 elements using 13185771 bytes

Greg Detre

unread,
Jun 3, 2008, 6:01:39 PM6/3/08
to mvpa-t...@googlegroups.com
i just downloaded the afni tarball and ran tutorial_easy myself (on a
2GB mac), and it worked fine, so i don't think it's an error with the
data. someone at this end is going to try the SPM data on a 1GB windows
machine to see if it works for them.

can you run this command:

x = zeros([577 1210 2]);

just to see if that gives you an out of memory error.

is this the latest version of the toolbox (v 1.0)?

g

George Christopoulos

unread,
Jun 4, 2008, 7:18:06 AM6/4/08
to mvpa-t...@googlegroups.com
Problem solved: it was the Matlab version. I tried another one and everything run smoothly.

Thanks

George

2008/6/3 Greg Detre <gde...@princeton.edu>:
Reply all
Reply to author
Forward
0 new messages