amiraCTWriter.m 849 B

1234567891011121314151617
  1. function amiraCTWriter(data,filename,dx,dy,dz,M,N,P,FOV,zFOV)
  2. fid = fopen([filename],'w');
  3. fprintf(fid,'# AmiraMesh 3D BINARY 2.0\n\n');
  4. fprintf(fid,['# CreationDate: ' datestr(now,'ddd mmm') datestr(now,' dd HH:MM:SS yyyy') '\n\n']);
  5. fprintf(fid,'define Lattice %g %g %g\n\n',M,N,P);
  6. fprintf(fid,'Parameters {\n');
  7. fprintf(fid,' Content "%gx%gx%g %s, uniform coordinates",',M,N,P,'float');
  8. fprintf(fid,' BoundingBox %g %g %g %g %g %g,\n',0,FOV-dx,0,FOV-dy,0,zFOV-dz);
  9. fprintf(fid,' CoordType "uniform"\n');
  10. fprintf(fid,'}\n\n');
  11. fprintf(fid,'Lattice { %s Data } @1\n\n','float');
  12. fprintf(fid,'# Data section follows\n');
  13. fprintf(fid,'@1\n');
  14. fclose(fid); % close the text part of the file
  15. fid = fopen([filename],'ab','ieee-b');
  16. fwrite(fid,data(:,:,:),'float');
  17. fclose(fid);