Code covered by the BSD License  

Highlights from
MRI Brain Segmentation

4.0 | 38 ratings Rate this file 280 Downloads (last 30 days) File Size: 2.6 MB File ID: #4879
image thumbnail

MRI Brain Segmentation


Robert Bemis (view profile)


06 May 2004 (Updated )

Neuroimaging Case Study for seminars and webinars.

| Watch this File

File Information

This case study shows how MATLAB can be used for a medical imaging problem. Given an MRI scan, first segment the brain mass from the rest of the head, then determine the brain volume. Also compare portions of gray and white matter present. This example was developed for seminars. It was also used for webinars for medical applications broadcast live on May 6, 2004.

This package includes some MATLAB code and an MRI scan series consisting of 60 DICOM images. Note that this code relies on MATLAB Central submissions from others. Detailed references to those sources are included.


Sliceomatic, Hline And Vline, and Data Marker inspired this file.

Required Products Image Processing Toolbox
MATLAB release MATLAB 7 (R14)
Other requirements * Requires 2 other MATLAB Central submissions. * At least 512MB physical RAM is strongly recommended to run this example.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (62)
09 Apr 2015 Peng Dai

great tools, it's based on old version of Matlab. have to make a little change to run on version2012

04 Mar 2015 Hieu Lam

hi, i am using matlab R2012b and they have the error:
Error using imview (line 8)
Function IMVIEW has been removed. Use IMTOOL instead.

Error in analyze_series8 (line 47)
imview(im,[0 max_level])

How to fix it? thanks

Comment only
14 Feb 2015 Xinzhou

Hello, I am student learning medical image processing by applying matlab. When I use the function "threshold_tool' in this folder. It shows function 'vline' not defined. Is there any way can solve this problem. Thank you so much.

25 Jan 2015 shruti

shruti (view profile)

Sir,I am searching for segmentation of gray matter from T1 weigheted brain MR images.Can u plz send me the code to this address.

Comment only
20 Oct 2014 sp 2013

Sir, pls give me the matlab code for whitematter sementation from mr images my mail id is

Comment only
17 Oct 2014 sp 2013  
17 Oct 2014 sp 2013

Sir,I am searching for segmenting white matter from a T2 weighted brain MRI scan. But I could not get the correct tutorial to follow it. Please suggest me an algorithm that works better and accurately to segment the gray matter alone from the T2 wieghted MRI scan image my mail id

Comment only
17 Oct 2014 sp 2013

Sir i'm a student and my project is mild brain injury detection
Can you please send to me the segmentation code in this addresse :

Comment only
17 Oct 2014 sp 2013

sir, iam a PG student doing project on the mild brain injury detection.Will you please help me to get the database(t2 weighted mri of mild brain injured images) for the same . My mail id is

Comment only
19 Sep 2014 NTUT

NTUT (view profile)

Hello Sir, I am PhD student of National Taipei University of Technology. i doing a project in dementia with MRI brain images using freesurfer and Matlab software. can you please tell me how to run new subject of images in Matlab. thank you! My email id is:

Comment only
16 Apr 2014 majid SHOKRI

sir, iam a PG student doing project on the mri brain tumor segmentation.Will you please help me to get the database(mri tumor brain dicom images) for the same . My mail id is

Comment only
16 Apr 2014 redouan pitrochka

Thnak you Sir for the nice work !
Please i'm a student and my project is brain tumor detection.
Can you please send to me the segmentation code in this addresse :
thnak you in advance !

21 Dec 2013 soniya joy  
09 Dec 2013 Aysha

Aysha (view profile)

sir, iam a PG student doing project on the mri brain tumor segmentation.Will you please help me to get the database(mri tumor brain dicom images) for the same . My mail id is

Comment only
08 Dec 2013 Fatemeh

If you want to download this useful package, click on download submission button,

Comment only
30 Oct 2013 haribabu

how to download this package..
please help me...

Comment only
24 Oct 2013 Hg

Hg (view profile)

07 Aug 2013 devabhaktuni phaneendrababu

Can you please help me how to download this file

Comment only
23 Jul 2013 SIVA

SIVA (view profile)

its very use ful ,,,.

Comment only
20 Apr 2013 naila

naila (view profile)

I couldn't able to download the code. please can any one help me?

Comment only
04 Apr 2012 elise lau

I'm new to matlab, doing segmentation of brain tumor from 2D MRI images for my project. anyone have the coding? can help me?thx very much..

Comment only
21 Mar 2012 yuvaranjini

Really good work sir. It would be nice if you add some description to the code.
It helps me a lot

24 Feb 2012 mariam

mariam (view profile)

dear All, would you please guide me how I can 1/8 of volume image I mean I can reconstruct the volume image but I do not know how to extract for example 90 degree volume slice of it. I appreciate your help

10 Feb 2012 priya dharsini

good work sir. iam a PG student doing project on the same. I dont know how to split white matter from a brain MRI image using matlab.Will you please help me. My mail id is

Comment only
28 Oct 2011 manoj

manoj (view profile)

high to all........actually i am beginner in image segmentation could anybody help me

my email id is


Comment only
21 Aug 2011 porngamol sitlaothaworn

it helps me in senior project :)

02 Nov 2010 Nurhasanah Ivansyah

it's very good tutorial. Very good coding for matlap brain image processing.
but can you help how to segmenting brain white matter, gray matter and cerebrospinal fluid. if you have algoritm or code in matlab, help give me.
i really need....

Comment only
09 Aug 2010 Deepak Kumar Rout  
01 Dec 2009 Robert Bemis

Robert Bemis (view profile)

Note for users who get stuck by the IMVIEW error. That function was replaced by IMTOOL (years ago). In analyze_series8.m just replace all occurrences of "imview" with "imtool" (and save).

See also
>> doc imview

Comment only
23 Nov 2009 Preeti

Preeti (view profile)

i am getting the error in imtool and not able to remove even downloading the patch as advised. please help.

Comment only
26 Jun 2009 sheldon

your work is good. it is helping me a lot. but i am facing a small problem if i give input(dcm files) of larger size like 138 kb other than that you used is 129 kb. please help me out with this. i am using matlab r2008a. i get the error;

voxel_size =

0.9375 0.9375 6.0000

Name Size Bytes Class Attributes

D 256x256x12 1572864 uint16

??? Index exceeds matrix dimensions.

Error in ==> analyze_series8 at 43
im = squeeze(D(:,:,i));

after the dicom files stored are read.

16 Mar 2009 Nandan S  
06 Sep 2008 shokrollah derafsh  
25 Jul 2008 Fazl-e- wahab  
11 Jul 2008 mahima bansal

Make it more explanatory. so that it could be efficient for a beginner.

26 Mar 2008 sajal chirvi  
20 Feb 2008 rohit garg

i wanted a code for segmentation of brain tumor from 2D MRI images.

10 Jan 2008 nandy kidd

getting the following error in R2007

??? Output argument "hout" (and maybe others) not assigned during call to "C:\Program Files\MATLAB\R2007a\toolbox\images\imuitools\imtool.m (imtool)".

Error in ==> imtool at 155
close_all = nargin == 2 && ischar(varargin{1}) && ischar(varargin{2}) && ...

Error in ==> imview at 18
hh = imtool(varargin{:});

Error in ==> analyze_series8 at 53
imview close all


me sirve para el trabajo de grado

07 Sep 2007 mitali lembhe  
29 Jul 2007 Dheeraj Chahal

Excellent code

18 May 2007 basil abu-hijleh

Very good coding for matlap brain image processing

25 Nov 2006 Jau-Jie You

Good tutorial.

03 May 2006 chethana s s

matlab codeing on brain image segmentation

Comment only
15 Apr 2006 Joseph Paul  
23 Mar 2006 l smith

very good!

Comment only
12 Feb 2006 Roman Rodionov

Excellent presentation as an introductory talk for those who start MRI analysis with MATLAB.
Thank you very much!

19 Jan 2006 aftab muhammad


Comment only
23 Nov 2005 Muhammad altaf

help ful for the study of MRI
I am in search for xray enhancement

15 Nov 2005 Mohammad Ahmad  
26 Sep 2005 Jiang Yun

It's helpful for my study in medical imaging. I've not been kowning that MATLAB could also deal with the DICOM files.

28 Aug 2005 Sanaz negahbani

program with Matlab software for leaf classification & image segmentation
thanks alot

Comment only
30 May 2005 PAN QF  
06 Apr 2005 hamid reza imani  
14 Feb 2005 bahare vafadar  
19 Jan 2005 George Theofilogiannakos  
15 Dec 2004 ee fzaf  
17 Sep 2004 S.Ravikumar sampathkumar  
23 Jun 2004 zj zhao


31 May 2004 yd ccec

good ,i like it

11 May 2004 roopa m  
07 May 2004 wenshu lee

it can help the students interested in the image processing.

08 May 2006

R2006a incompatibilities were recently reported. See the ReadMe.txt file for more details.

02 Mar 2009

Fix thumbnail for animated GIF

13 Jan 2010


Contact us