[Insight-users] Read raw file into Matlab

Daniel DaHoIv2 at gmail.com
Thu Jan 27 09:01:16 EST 2011


> Hello
>
> I have a raw file and a mhd file. My mhd file:
>
> ObjectType = Image
> NDims = 3
> BinaryData = True
> BinaryDataByteOrderMSB = False
> CompressedData = False
> TransformMatrix = 1 0 0 0 1 0 0 0 1
> Offset = 0 0 0
> CenterOfRotation = 0 0 0
> AnatomicalOrientation = RAI
> ElementSpacing = 0.329119 0.329119 0.329119
> DimSize = 152 352 314
> ElementType = MET_USHORT
> ElementDataFile = rec_seg.raw
>
> I try to read this data into Matlab with this commands:
>        FID2 = fopen( 'rec_seg.raw','r'');
>        obj.data = reshape( fread(FID2,'ushort'), obj.size );
>        fclose(FID2);
>
>
> I don't get any error message, but obj.data matrix contains only zeros.
> I have tried to specify different "MACHINEFORMAT" in fopen with the same result.
>
>
> Any suggestions of what can be wrong?
>
> I am thankful for all help and suggestions.
>
> Regards
> Daniel
>


More information about the Insight-users mailing list