0

I got this error while trying to do the sample on Registering Multimodal 3-D Medical Images. the sample files are at this URL. Here are what commands I used:

fixedHeader  = helperReadHeaderRIRE('header.ascii'); // at training_001/mr_T1 folder
movingHeader = helperReadHeaderRIRE('header.ascii'); // at training_001/ct folder
fixedVolume  = multibandread('image.bin',...
                            [fixedHeader.Rows, fixedHeader.Columns, fixedHeader.Slices],...
                            'int16=>single', 0, 'bsq', 'ieee-be' );
                            // at training_001/mr_T1 folder
movingVolume = multibandread('image.bin',...
                            [movingHeader.Rows, movingHeader.Columns, movingHeader.Slices],...
                            'int16=>single', 0, 'bsq', 'ieee-be' );
                            // at training_001/ct folder
helperVolumeRegistration(fixedVolume,movingVolume);
centerFixed = size(fixedVolume)/2;
centerMoving = size(movingVolume)/2;
figure, title('Unregistered Axial slice');
imshowpair(movingVolume(:,:,centerMoving(3)), fixedVolume(:,:,centerFixed(3)));

and I get the error. I use MATLAB 2014a version.

Kourosh
  • 29
  • 1
  • For the [generic solution to this problem](http://stackoverflow.com/a/20054048/983722), see [this question](http://stackoverflow.com/q/20054047/983722). – Dennis Jaheruddin May 26 '14 at 15:35

1 Answers1

1

The cause probably is that the 3rd dimension of fixedVolume and/or movingVolume is an odd number so that dividing by 2 produces a non-integer (###.5). Such a fractional number can not be used as an index into an array, as you try to do on the last line. A possible fix is to round the result of the division:

centerFixed = round(size(fixedVolume)/2);
centerMoving = round(size(movingVolume)/2);
A. Donda
  • 8,381
  • 2
  • 20
  • 49