Note that you almost always need the header information, you cannot assume that pixel spacing is isotropic or 1mm/pixel but of course separating the file to a text header and a raw file makes loading easier to implement. In MITK and most other medical image computing research software, you can save file as .mhd, which results in two files, a text header file (mhd) and a raw file. You can also save as .nrrd file format and use nrrdread.m and nrrdwrite.m to read/write the files (it supports up to 4D data sets and raw or compressed data) - available at https://app.assembla.com/spaces/slicerrt/subversion/source/HEAD/trunk/MatlabBridge/src/MatlabCommander/commandserver
If you need convenient user interface for importing DICOM data, visualization in 2D/3D, and running your Matlab algorithms on it, then probably the best option is to use 3D Slicer (www.slicer.org) with the MatlabBridge extension (https://www.slicer.org/wiki/Documentation/Nightly/Extensions/MatlabBridge). If you need any help, post a message on http://discourse.slicer.org.
@Andras Lasso: Thank you Lasso. I need medical images for image segmentation. To evaluate my image segmentation algorithm, I need some medical images with their ground truth. So, if I convert images from .mha format to .jpg or .raw formats, I can evaluate my segmentation algorithm in Matlab
Here is an answer someone else posted in ReserchGate which may answer your question:
Ahmed Elazab · 19.04 · Chinese Academy of Sciences
Hi
You can not directly read the BRATS 2013 or 2014 directly into Matlab as the .mha format is not supported. To tackle this problem, first, I used to convert the .mha to . raw format. Second I read the .raw into Matlab using file manipulation functions (fopen, fread).
To summarize:
1- You can use the MITK visualization software to convert from .mha to .raw
2- Use the following Matlab toolbox to read the .raw
@Andras Lasso : I also tried with 3D Slicer. It show a message ("Cannot write data file:") when I want to save scene with formats .raw, .bmp, .jpg, .png and ...
Save as .nrrd and use nrrdread.m available at https://app.assembla.com/spaces/slicerrt/subversion/source/HEAD/trunk/MatlabBridge/src/MatlabCommander/commandserver.
Forget about .bmp, .jpg and other consumer file formats, they are not intended to be used for medical image computing (no standard way of storing essential metadata, compression artifacts, etc).
@Andras Lasso: I read .nrrd file in matlab using nrrdread.m. But, this function returns only Sagittal slices into "pixelData" Matlab variable . How do we access to Axial slices?