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

Karthik Krishnan karthik.krishnan at kitware.com
Sun Nov 25 20:32:43 EST 2007


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!<http://www.freemessengeremoticons.ca/?icid=EMENCA122>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20071125/cca9b2cd/attachment.html


More information about the Insight-users mailing list