Opening .nii files with MATLAB (or, converting .nii to .hdr + .img files)

8,363 views
Skip to first unread message

Guy

unread,
Apr 20, 2009, 10:05:30 AM4/20/09
to itksnap-users
I need my images loaded into MATLAB for analysis. My programmer is
having trouble loading the .nii segmentation file and has asked me to
save my files as .hdr and .img, which he says MATLAB can read

My questions are:

1. Is there an easy way to convert a file saved as .nii to .hdr
and .img files?

or

2. Is there a way for MATLAB to read the .nii files?

Thanks,
Guy

Mark Pearson

unread,
Apr 21, 2009, 6:39:57 PM4/21/09
to itksna...@googlegroups.com
Guy wrote:
> I need my images loaded into MATLAB for analysis. My programmer is
> having trouble loading the .nii segmentation file and has asked me to
> save my files as .hdr and .img, which he says MATLAB can read
>
> My questions are:
>
> 1. Is there an easy way to convert a file saved as .nii to .hdr
> and .img files?
>

You could try using medcon http://xmedcon.sourceforge.net/ which
supports conversion between many formats including nifti and analyze.

--
Mark Pearson BSc (Computing)
Technical Support, Dept Nuclear Medicine
Concord Hospital, Hospital Road, Concord, NSW 2139, Australia
Phone:+61-2-97676339 or +61-297677450; FAX:+61-2-97677451

Vince Hradil

unread,
Apr 23, 2009, 6:36:36 AM4/23/09
to itksnap-users

Tom Schoenemann

unread,
Apr 23, 2009, 11:40:43 AM4/23/09
to itksna...@googlegroups.com
Even easier:

1) Open the file in ITKSNAP: File>open>greyscale
2) Save the file in Analyze format (paired .hdr and .img files).  File>save>greyscale; in the dialog window that opens, enter the name you want to save the file as in the Filename box, but instead of using .nii at the end use .hdr  (e.g., instead of image.nii, make it image.hdr).  This will automatically change the Image File Format to 'Analyze' (which is what you want).

One issue: it seems to reorient the file (at least it did with me).  I think this is because Analyze doesn't deal with orientation in a consistent way (I've even had the same file open left-right reversed on different computers, even though they were both running the same image processing program!).

-Tom

_________________________________________________
P. Thomas Schoenemann

Assistant Professor of Anthropology
Department of Sociology & Anthropology
MSC 7501
James Madison University
Harrisonburg, VA  22807

Open Research Scan Archive at Penn Co-Director
Consulting Curator and Research Associate
Museum of Archaeology and Anthropology
University of Pennsylvania
Philadelphia, PA 19104-6398




Guy

unread,
Apr 23, 2009, 1:54:34 PM4/23/09
to itksnap-users
Thanks to for all replies.

Guy
> E-mail: schoe...@jmu.edu
>
> Open Research Scan Archive at Penn Co-Director
> Consulting Curator and Research Associate
> Museum of Archaeology and Anthropology
> University of Pennsylvania
> Philadelphia, PA 19104-6398
> Phone: (215) 573-7671
> E-mail: ptsch...@sas.upenn.edu
>
> Homepage:http://www.sas.upenn.edu/~ptschoen/
Reply all
Reply to author
Forward
0 new messages