IO

Input/output functions for reading and writing matRad-compatible data formats.

matRad_readMHD(filename)

matRad NRRD reader

call

[cube, metadata] = matRad_readMHD(filename)

Input:

filename – full path to mhd or mha file

Output:
  • cube – the read cube

  • metadata – metadata from header information

References

[1] https://itk.org/Wiki/MetaIO/Documentation


Copyright 2015-2026 the matRad development team.

This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSE.md. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.


matRad_exportDij(filename, dij, stf, metadata)

matRad physical dose writer

call

matRad_exportDij(filename,dij,stf,…

additionalFields,additionalKeyValuePairs)

Input:
  • filename – full output path, including the file extension

  • dij – matRad dij struct

  • stf – matRad stf struct

  • metadata – struct of metadata


Copyright 2015-2026 the matRad development team.

This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSE.md. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.


matRad_readNifTI(filename)

matRad NifTI reader

call

[cube, metadata] = matRad_readNifTI(filename)

Input:

filename – full path to .nii(.gz) file

Output:
  • cube – the read cube

  • metadata – metadata from header information

References

[1] http://teem.sourceforge.net/nrrd/format.html5


Copyright 2024-2026 the matRad development team.

This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSE.md. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.


matRad_importPatient(ctFile, maskFiles, hlutFilename)

matRad patient import from binary files (CT and masks)

call

[ct,cst] = matRad_importPatient(cubeFile,maskFiles) [ct,cst] = matRad_importPatient(cubeFile,maskFiles, hlutFilename)

Input:
  • ctFile – path to CT file. If HLUT is not set, values are interpreted as HU and interpolated to ED.

  • maskFiles – cell array with filenames to the masks if maskFiels contains a folder, all contained and recognized data files are treated as masks

  • hlutFilname – (optional) HLUT, (n,2) array. if set to ‘default’, we will use a default HLUT

Output:
  • ct ct struct for use with matlab

  • cst cst struct for use with matlab


Copyright 2015-2026 the matRad development team.

This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSE.md. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.


matRad_supportedBinaryFormats()

matRad function to obtain supported binary formats

call

[read,write] = matRad_supportedBinaryFormats()

input:

Output:
  • read cell array with file filter in first column, name in second – column, and handle to read function in third column

  • write cell array with file filter in first column, name in second – column, and handle to write function in third column

References

[1] http://teem.sourceforge.net/nrrd/format.html5


Copyright 2015-2026 the matRad development team.

This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSE.md. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.


matRad_writeNifTI(filepath, cube, metadata)

matRad NifTI reader

call

[cube, metadata] = matRad_writeNifTI(filename)

Input:

filename – full path to .nii(.gz) file

Output:

file will be written to disk


Copyright 2024-2026 the matRad development team.

This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSE.md. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.


matRad_readCube(filename)

matRad Cube read wrapper determines the extension and assigns the appropriate reader to it

call

matRad_readCube(filename)

Input:

filename – full path of the file


Copyright 2015-2026 the matRad development team.

This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSE.md. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.


matRad_writeNRRD(filename, cube, metadata)

matRad NRRD writer

call

matRad_writeNRRD(filename,cube,datatype,…

additionalFields,additionalKeyValuePairs)

Input:
  • filename – full output path, including the nrrd extension

  • cube – cube that is to be written

  • metadata – struct of metadata. Writer will wrap the existing metadata to nrrd standard-specific fields [1].

References

[1] http://teem.sourceforge.net/nrrd/format.html5


Copyright 2015-2026 the matRad development team.

This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSE.md. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.


matRad_writeMHD(filepath, cube, metadata)

matRad function to write mha files

call

matRad_writeMHA(filepath,cube,metadata)

Input:
  • filepath – full filename (with extension)

  • cube – 3D array to be written into file

  • metadata – struct of metadata. Writer will wrap the existing metadata to MHA standard-specific fields Necessary fieldnames are: - resolution: [x y z] - datatype: numeric MATLAB-Datatype

Output:

file will be written to disk

References

https://itk.org/Wiki/MetaIO/Documentation


Copyright 2015-2026 the matRad development team.

This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSE.md. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.


matRad_writeCube(filepath, cube, datatype, metadata)

matRad wrapper for Cube export

call

[saved_metadata] = matRad_writeCube(filepath,cube,meta)

Input:
  • filepath – full output path. needs the right extension to choose the appropriate writer

  • cube – cube that is to be written

  • datatype – MATLAB numeric datatype

  • metadata – meta-information in struct. Necessary fieldnames are: - resolution: [x y z] Optional: - axisPermutation (matRad default [2 1 3]) - coordinateSystem (matRad default ‘LPS’) - imageOrigin (as used in DICOM) - dataUnit (i.e. Gy..) - dataName (i.e. dose, ED, …) - compress (true/false) (default chosen by writer)


Copyright 2015-2026 the matRad development team.

This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSE.md. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.


matRad_readHLUT(filename)

matRad function to read HLUT from filename

call

hlut = matRad_readHLUT(filename)

Input:

filename – hlut filename

Output:

hlut – lookup table

References

Copyright 2018-2026 the matRad development team.

This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSE.md. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.


matRad_writeVTK(filepath, cube, metadata)

matRad function to write vtk cubes

call

matRad_writeVTK(filepath,cube,metadata)

Input:
  • filepath – full filename (with extension)

  • cube – 3D array to be written into file

  • metadata – struct of metadata. Writer will wrap the existing metadata to VTK standard-specific fields Necessary fieldnames are: - resolution: [x y z] - datatype: numeric MATLAB-Datatype

Output:

file will be written to disk

References

Copyright 2015-2026 the matRad development team.

This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSE.md. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.


matRad_writeMHA(filepath, cube, metadata)

matRad function to write mha files

call

matRad_writeMHA(filepath,cube,metadata)

Input:
  • filepath – full filename (with extension)

  • cube – 3D array to be written into file

  • metadata – struct of metadata. Writer will wrap the existing metadata to MHA standard-specific fields Necessary fieldnames are: - resolution: [x y z] - datatype: numeric MATLAB-Datatype

Output:

file will be written to disk

References

https://itk.org/Wiki/MetaIO/Documentation


Copyright 2015-2026 the matRad development team.

This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSE.md. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.


matRad_readBinData(binFile, cubeDim)

Instance of MatRad_Config class

matRad_readNRRD(filename)

matRad NRRD reader

call

[cube, metadata] = matRad_readNRRD(filename)

Input:

filename – full path to nrrd file

Output:
  • cube – the read cube

  • metadata – metadata from header information

References

[1] http://teem.sourceforge.net/nrrd/format.html5


Copyright 2015-2026 the matRad development team.

This file is part of the matRad project. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution and at https://github.com/e0404/matRad/LICENSE.md. No part of the matRad project, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.