matRad_writeMhd

Purpose ^

References

Synopsis ^

function matRad_writeMhd(cube,resolution,filename)

Description ^

 References
   -

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 Copyright 2020 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/LICENSES.txt. 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.

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Cross-reference information ^

This function calls: This function is called by:

Source code ^

0001 function matRad_writeMhd(cube,resolution,filename)
0002 
0003 
0004 % References
0005 %   -
0006 %
0007 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0008 %
0009 % Copyright 2020 the matRad development team.
0010 %
0011 % This file is part of the matRad project. It is subject to the license
0012 % terms in the LICENSE file found in the top-level directory of this
0013 % distribution and at https://github.com/e0404/matRad/LICENSES.txt. No part
0014 % of the matRad project, including this file, may be copied, modified,
0015 % propagated, or distributed except according to the terms contained in the
0016 % LICENSE file.
0017 %
0018 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0019 
0020 %% write header file
0021 fileHandle = fopen(filename,'w');
0022 
0023 fprintf(fileHandle,'ObjectType = Image\n');
0024 fprintf(fileHandle,'NDims = 3\n');
0025 fprintf(fileHandle,'BinaryData = True\n');
0026 fprintf(fileHandle,'BinaryDataByteOrderMSB = False\n');
0027 fprintf(fileHandle,'CompressedData = False\n');
0028 fprintf(fileHandle,'TransformMatrix = 1 0 0 0 1 0 0 0 1\n');
0029 fprintf(fileHandle,'Offset = 0 0 0\n');
0030 fprintf(fileHandle,'CenterOfRotation = 0 0 0\n');
0031 fprintf(fileHandle,'AnatomicalOrientation = RAI\n');
0032 fprintf(fileHandle,'ElementSpacing = %f %f %f\n',resolution);
0033 fprintf(fileHandle,'DimSize = %d %d %d\n',size(cube,2),size(cube,1),size(cube,3));
0034 fprintf(fileHandle,'ElementType = MET_DOUBLE\n');
0035 filenameRaw = [filename(1:end-4) '.raw'];
0036 fprintf(fileHandle,'ElementDataFile = %s\n',filenameRaw);
0037 
0038 fclose(fileHandle);
0039 
0040 %% write data file
0041 dataFileHandle = fopen(filenameRaw,'w');
0042 
0043 cube = flip(cube,2);
0044 cube = permute(cube,[2 1 3]);
0045 
0046 fwrite(dataFileHandle,cube(:),'double');
0047 fclose(dataFileHandle);

| Generated by m2html © 2005