[Insight-users] Convert 3D image data from Matlab .mat file

Mengchen Zhu mengchen.zhu at hotmail.com
Mon Nov 26 23:54:04 EST 2007


Hi,

Thanks a lot. I have temporarily adopted the DICOM I/O in Matlab and Image Series File I/O in ITK for the task. It is not very efficient, but is easier to track. In the real application, I will switch to the meta image as suggested by Karthik.

Regards,
Mengchen

Date: Sun, 25 Nov 2007 20:32:43 -0500
From: karthik.krishnan at kitware.com
To: mengchen.zhu at hotmail.com
Subject: Re: [Insight-users] Convert 3D image data from Matlab .mat file
CC: mathieu.malaterre at gmail.com; insight-users at itk.org

On 11/25/07, Mengchen Zhu <mengchen.zhu at hotmail.com> wrote:


Hi,

Thanks Mathieu. The problem is, the 3D data are not "images" in the first place. The ultrasound data are reconstructed from RF signal directly; the CT, I don't know - 
 
Of course, you need to find a way to interpret the data. Images are really just data stored on a regular grid.
 


So the question should be, can I use the matrix in Matlab to construct image in ITK? I have the physical dimension of voxels by the way, so the data indeed can be treated as images, without header that is. 

 

Write out the 3D image in matlab in raw format. For instance a CT image may be writtten as
 
fid=fopen('image.raw','w+');
cnt=fwrite(fid,mymatrix,'short');
fclose(fid);
 
Create a metaimage header in ITK for the raw data : image.mhd . Look in ITK's testing tree, you should find plenty of examples.  Here's an example. 
 
NDims = 3
DimSize = 100 100 100
ElementSize = 4.000000e+000 4.000000e+000 4.000000e+000
ElementSpacing = 4.000000e+000 4.000000e+000 4.000000e+000
ElementType = MET_SHORT
ElementByteOrderMSB = False

ElementDataFile = image.raw

 
You should be able to load image.mhd in ITK.


If no apparent way exists, I will probably use fprintf() to export the mat as text file and construct my image in ITK using the data in the text.

Thanks,
MC

> Date: Sun, 25 Nov 2007 18:30:26 +0100

> From: mathieu.malaterre at gmail.com
> To: 
mengchen.zhu at hotmail.com
> Subject: Re: [Insight-users] Convert 3D image data from Matlab .mat file
> CC: 
insight-users at itk.org
> 
> On Nov 25, 2007 9:19 AM, Mengchen Zhu <mengchen.zhu at hotmail.com
> wrote:
> >
> > Hi folks,
> >
> > I have some 3D CT and Ultrasound volume data saved as .mat files, with voxel
> > data type int16; what is the best way to export them into ITK for

> > processing? I guess I could export them as DICOM, but not sure.
> 
> Matlab has built-in support for DICOM (read/write). For writing a
> DICOM file, just go to:
> 
> 
http://www.mathworks.com/access/helpdesk/help/toolbox/images/index.html?/access/helpdesk/help/toolbox/images/dicomwrite.html
> 
> The question that remains, is where do these images come from ?
> Without knowing the modalities or the proper DICOM object you will not

> be able to create the correct meta data info for the header. This
> would be better to investigate where is the source for those .mat
> files.
> 
> HTH
> 
> -- 
> Mathieu




Express yourself with free Messenger emoticons. Get them today!
_______________________________________________

Insight-users mailing list
Insight-users at itk.org

http://www.itk.org/mailman/listinfo/insight-users


_________________________________________________________________
Have fun while connecting on Messenger! Click here to learn more.
http://entertainment.sympatico.msn.ca/WindowsLiveMessenger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20071126/bf59688d/attachment.html


More information about the Insight-users mailing list