[FieldTrip] out of memory when executing ft_volumesegmentation

Rozendaal, Y.J.W. y.j.w.rozendaal at student.tue.nl
Mon May 21 13:28:08 CEST 2012


I'm trying to create a head model using an MRI to use it for dipole fitting of MEG data. However, currently my Matlab (R2007b on Windows Vista) gives an 'out of memory' error when executing the ft_volumesegment statement. I already tried several things to improve memory handling by Matlab (not keeping trials, not keeping intermediate and the 'pack' statement). 
The first part of the output seems fine:

the input is volume data with dimensions [240 240 170]
Converting the coordinate system from ctf to spm
performing the segmentation on the specified volume
creating scalpmask
smoothing anatomy with a 5-voxel FWHM kernel
thresholding anatomy at a relative threshold of 0.100
??? Error  using ==> spm_bwlabel
Out of memory. Type HELP MEMORY for your options.

Error in ==> ft_volumesegment>threshold at 535
[tmp, N] = spm_bwlabel(output, 6);

Error in ==> ft_volumesegment at 490
	if dothresh, anatomy = threshold(anatomy, cfg.threshold(k), 'anatomy'); end

This problem also occured when using the mri of the provided tutorial data.
How could I fix this and what causes this large memory consumption? Could using another version of Matlab help or is there an error in my code?

Thanks in advance,

%% load MRI file
mri = ft_read_mri(filename_mri);

%% realign MRI to head coordinates
cfg = [];
cfg.method = 'interactive';
mri_realigned = ft_volumerealign(cfg,mri);

%% segment MRI
cfg = [];
cfg.units = 'mm';
cfg.output = {'scalp,'skull','brain'};
cfg.keeptrials = 'no';
cfg.keepintermediate = 'no';


mri_segmented = ft_volumesegment(cfg,mri_realigned);

More information about the fieldtrip mailing list