|
Many thanks to you too DBP :).
On Friday, 6 July 2012 00:33:55 UTC+8, Siti_Mustaqim wrote:
> I have overlooked the responses in the cited ITK discussion, there is a matlab file to convert mat to mhd;
>
> http://old.nabble.com/How-to-read-.Mat-File-using-ITK-%2B-C%2B%2B-td30402760.html
>
> by:
>
> -----------------
> Jean-Pierre Roux
> CNRS UMR 5220, INSERM U1440
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> Then after editing the mha_read_volume; I can get the image back in mat from created mhd and raw files; In the mha_read_volume function; it implements this command;
>
> datasize=prod(info.Dimensions)*info.BitDepth/8;
>
> where my mhd file generated BitDepth=0 causing the datasize to be 0; and fail to create the matrix. Many thanks to both of them Dr. Roux and Dr. Dirk-Jan.
>
>
>
> On Thursday, 5 July 2012 23:30:28 UTC+8, Siti_Mustaqim wrote:
> > Thank you for your reply,
> > Actually I follow the instruction in this link;
> >
> > http://www.itk.org/pipermail/insight-users/2007-November/024337.html
> >
> >
> > mhd image and raw file is for medical images. I want to use them for ITK appication which is new to me.
> >
> > Thanks again.
> >
> >
> >
> > On Thursday, 5 July 2012 21:30:07 UTC+8, dpb wrote:
> > > On 7/4/2012 7:56 PM, Siti_Mustaqim wrote:
> > > > Hi,
> > > > I have problem in creating raw file for image matlab file. I have CT
> > > > image which has been sampled to 168x168x72 double and I would like
> > > > touse elastix/ITK for registration. I convert them to raw file as follows:
> > > >
> > > > fid=fopen('CTdata.raw','w+');
> > > > fwrite(fid,CTdata,'double');
> > > >
> > > > Then CTdata.raw is created in my existing path. I take a 'mhd' file
> > > > somewhere, delete the contents and put the information related to my
> > > > data and save as CTdata.mhd.
> > > >
> > > > Then I tried to use "mha_read_volume" by Dirk-Jan; it couldnt be
> > > > read.I also tried elastix toolbox yet failed.
> > > >
> > > > Is my way correct? Can someone please advise?
> > >
> > > I've no clue about "mha_read_volume" but it appears you're confusing
> > > that somehow the extension on a file has any bearing on it's content.
> > >
> > > If you wrote the file w/ fwrite() and then just (in effect) renamed it
> > > by the machinations to a file w/ another extension, it's still the same
> > > stream file fwrite() wrote.
> > >
> > > So, read it back w/ fread()
> > >
> > > fid=fopen('CTdata.mhd','r');
> > > x=fread(fid);
> > > fid=fclose(fid);
> > > x=reshape(x,168,168,72);
> > >
> > > If you're trying to create a file in some other specific format you'll
> > > have to write out whatever that format is specifically either from
> > > knowing it and writing the pieces-parts w/ a combination of fwrite()
> > > calls of the appropriate form/info or find some utility that does so. I
> > > have no knowledge of what a 'mhd' file might be...
> > >
> > > --
|