Code covered by the BSD License  

Highlights from
Read Medical Data 3D

4.8

4.8 | 5 ratings Rate this file 158 Downloads (last 30 days) File Size: 54.45 KB File ID: #29344
image thumbnail

Read Medical Data 3D

by Dirk-Jan Kroon

 

10 Nov 2010 (Updated 23 Feb 2011)

GUI to open most Medical file-formats: Dicom, V3D, ISI, NifTI, Analyze and other formats

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information
Description

This function ReadData3D allows the user to open medical 3D files. It
  supports the following formats :
 
    Dicom Files ( .dcm , .dicom )
    V3D Philips Scanner ( .v3d )
    GIPL Guys Image Processing Lab ( .gipl )
    HDR/IMG Analyze ( .hdr )
    ISI Files ( .isi )
    NifTi ( .nii )
    RAW files ( .raw , .* )
    VMP BrainVoyager ( .vmp )
    XIF HDllab/ATL ultrasound ( .xif )
    VTK Visualization Toolkit ( .vtk )
    Insight Meta-Image ( .mha, .mhd )
    Micro CT ( .vff )
    PAR/REC Philips ( .par, .rec)

  usage:
 
  [V,info]=ReadData3D;
 
  or,
 
  [V,info]=ReadData3D(filename);
 
  outputs,
    V : The 3D Volume
    info : Struct with info about the data
         Always the following fields are present
         info.Filename : Name of file
         info.Dimensions : Dimensions of Volume
         info.PixelDimensions : Size of one pixel / voxel
  
  Warning!
   The read functions are not fully implemented as defined in
   the file-format standards. Do not use this function for
   critical applications.
 

Question,
If you know an example file of GE_Version_4, GE_Version_5 or some other often used 3D medical format, please leave a comment (so I can implement that format).

MATLAB release MATLAB 7.11 (2010b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (10)
11 Nov 2010 Sean de

Excellent! I've always wondered what was in those HDR files. We knew the dimensions of the IMG files ahead of time but this is a great tool for ones which we've lost and because the number of slices is not always uniform.

Thanks!

18 Mar 2011 Yannick

Nice submission. I fixed two bugs in the parts which read .mha/mhd files (correct datasize --> work with oversized volume files; interpreting NumberOfDimensions --> work with 4D files). If interested, send me a private message with your email address and I will send you my updated files.

16 May 2011 Yannick

For the record, these are my changes:

***** old\mha_read_volume.m

datasize=prod(info.Dimensions)*info.BitDepth/8;

***** NEW\MHA_READ_VOLUME.M

datasize=prod(info.Dimensions)*info.NumberOfDimensions;

*****

***** old\mha_read_volume.m
fclose(fid);
V = reshape(V,info.Dimensions);

***** NEW\MHA_READ_VOLUME.M
fclose(fid);
V = reshape(V,[info.NumberOfDimensions, info.Dimensions]);

*****

26 May 2011 Siyi Deng

great tool!

15 Jul 2011 Felx

I had trouble reading data that I imported from DICOM (using SPM) and analyzed/modified through SPM. SPM saved the data in .hdr/.img files and I used the 'hdr_read_volume()' function to read it back into matlab. I fond that some datasets were read incorrectly and found that this happened when the value of the 'ImgDataType' in the .hdr file was 512. Both, the coustom read function ('get_info_analyze_hdr()') as well as Matlabs 'analyze75info.m' can't handle that value. After a little research I found that the datatype for 512 is DT_UNINT16 but this datatype is not known either so I tried DT_SIGNED_SHORT and the data is read in correctly.

So my fix was to add to strImgData in
'get_info_analyze_hdr()' the cell

strImgData{512}.ImgDataType = 'DT_SIGNED_SHORT';
strImgData{512}.ColorType = 'grayscale';

alternatively one could modify 'analyze76info.m' and add under

switch ImgDataType
...
case int16(512)
            metadata.ImgDataType = 'DT_SIGNED_SHORT'

04 Oct 2011 Nicolas Toussaint

hi, I just have 2 or 3 corrections to your code if you are interested :

(1) : in par_read_volume.m - line 27 : replace 'short' by 'ushort'

(2) : in mha_read_volume - line 78 :

replace :

vector = info.Dimensions;

by :

if isfield(info, 'ElementNumberOfChannels')
    vector = [str2double(info.ElementNumberOfChannels) info.Dimensions];
else
    vector = info.Dimensions;

cheers :-)

04 Feb 2012 maya

recently i have downloaded this tool.actually i have a setof 2D dicom slices and i converted to a 3D volume(.hdr) using a software,can i use your tool to read the intensity values of the voxels.I tried to use your tool,its giving error in the guifn
rror in ==> gui_mainfcn>local_openfig at 216
    gui_hFigure = openfig(name, singleton, 'auto');

Error in ==> gui_mainfcn at 94
        gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt);

Error in ==> ReadData3D at 68
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

pleases help
 

06 Mar 2012 Shihui

There are some problems in reading my mhd file, which are list below.

Error using fseek
Invalid file identifier. Use fopen to generate a valid file
identifier.

Error in mha_read_volume (line 36)
        fseek(fid,0,'bof');

Error in ReadData3D>loaddata (line 379)
data.volume=feval(fhandle,data.info);

Error in ReadData3D>pushbutton_load_Callback (line 365)
loaddata();

Error in gui_mainfcn (line 96)
        feval(varargin{:});

Error in ReadData3D (line 70)
    gui_mainfcn(gui_State, varargin{:});

Error in
@(hObject,eventdata)ReadData3D('pushbutton_load_Callback',hObject,eventdata,guidata(hObject))

 
Error using waitfor
Error while evaluating uicontrol Callback

30 Mar 2012 Amedeo

Good Tool.
Probably you should modify source code for saving the loaded volume.
Now you save only filename and fileformatid.

look at ReadData3D.m - line 398

12 Apr 2012 slama najla

Hello, can some body send for me an example of 3d medical data to test it with an algorithm of watermarking because i didn't arrive to find it.thanks

Please login to add a comment or rating.
Updates
23 Feb 2011

VTK bug fix by C. Aguilar

Tag Activity for this File
Tag Applied By Date/Time
dicom Dirk-Jan Kroon 10 Nov 2010 11:12:02
dcm Dirk-Jan Kroon 10 Nov 2010 11:12:02
v3d Dirk-Jan Kroon 10 Nov 2010 11:12:02
philips Dirk-Jan Kroon 10 Nov 2010 11:12:02
scanner Dirk-Jan Kroon 10 Nov 2010 11:12:02
gipl Dirk-Jan Kroon 10 Nov 2010 11:12:02
guys image processing Dirk-Jan Kroon 10 Nov 2010 11:12:02
lab Dirk-Jan Kroon 10 Nov 2010 11:12:02
hdr Dirk-Jan Kroon 10 Nov 2010 11:12:02
img Dirk-Jan Kroon 10 Nov 2010 11:12:02
analyze Dirk-Jan Kroon 10 Nov 2010 11:12:02
isi Dirk-Jan Kroon 10 Nov 2010 11:12:02
nifti Dirk-Jan Kroon 10 Nov 2010 11:12:02
nii Dirk-Jan Kroon 10 Nov 2010 11:12:02
raw Dirk-Jan Kroon 10 Nov 2010 11:12:02
vmp Dirk-Jan Kroon 10 Nov 2010 11:12:02
brainvoyager Dirk-Jan Kroon 10 Nov 2010 11:12:02
xif Dirk-Jan Kroon 10 Nov 2010 11:12:02
hdlab Dirk-Jan Kroon 10 Nov 2010 11:12:02
export Dirk-Jan Kroon 10 Nov 2010 11:12:02
ultrasound Dirk-Jan Kroon 10 Nov 2010 11:12:02
medical Dirk-Jan Kroon 10 Nov 2010 11:12:02
atl Dirk-Jan Kroon 10 Nov 2010 11:12:02
read Dirk-Jan Kroon 10 Nov 2010 11:12:02
file Dirk-Jan Kroon 10 Nov 2010 11:12:02
file formats Dirk-Jan Kroon 10 Nov 2010 11:12:02
vtk Dirk-Jan Kroon 10 Nov 2010 11:12:02
insight Dirk-Jan Kroon 10 Nov 2010 11:12:02
mha Dirk-Jan Kroon 10 Nov 2010 11:12:02
mhd Dirk-Jan Kroon 10 Nov 2010 11:12:02
mirco ct Dirk-Jan Kroon 10 Nov 2010 11:12:02
import Dirk-Jan Kroon 10 Nov 2010 11:12:02
3d Dirk-Jan Kroon 10 Nov 2010 11:12:02
export Qian 06 Jun 2011 05:06:35
dicom José Antonio Flores 30 Jan 2012 02:38:21
hai maya 04 Feb 2012 11:50:47
mhd Shihui 06 Mar 2012 16:46:32
potw Lindsay Coutinho 18 May 2012 10:59:59
pick of the week Lindsay Coutinho 18 May 2012 10:59:59

Contact us at files@mathworks.com