dicomProcessing.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. header('Content-Type:text/xml');
  3. error_log('test');
  4. ?>
  5. <?php
  6. define("DIR_DICOM_FS", getcwd() . "/");
  7. $pixelSpacingX = 0;
  8. $pixelSpacingY = 0;
  9. $physicalDeltaX = 0;
  10. $physicalDeltaY = 0;
  11. $filename = $_GET["filename"];
  12. $fname = DIR_DICOM_FS . 'upload/' . $filename;
  13. $fname = str_replace("'", "_",$fname);
  14. exec('dcmconv.exe -i "' . $fname . '" -o "upload/"');
  15. $dicom = file_get_contents('upload/' . $filename . '.txt');
  16. $result = array();
  17. $physicalDeltaX = null;
  18. preg_match_all("/.*FD\s+(.*)\s+#.*PhysicalDeltaX.*/", $dicom, $result, PREG_PATTERN_ORDER);
  19. if(isset($result[1])){
  20. $physicalDeltaX = $result[1][0];
  21. }
  22. $result = array();
  23. $physicalDeltaY = null;
  24. preg_match_all("/.*FD\s+(.*)\s+#.*PhysicalDeltaY.*/", $dicom, $result, PREG_PATTERN_ORDER);
  25. if(isset($result[1]) && isset($result[1][0])){
  26. $physicalDeltaY = $result[1][0];
  27. }
  28. $result = array();
  29. $pixelSpacingX = null;
  30. $pixelSpacingY = null;
  31. preg_match_all("/.*DS\s+\[(.*)\\\(.*)\]\s+#.*PixelSpacing.*/", $dicom, $result, PREG_PATTERN_ORDER);
  32. if(isset($result[1]) && isset($result[1][0])){
  33. $pixelSpacingX = $result[1][0];
  34. }
  35. if(isset($result[2]) && isset($result[2][0])){
  36. $pixelSpacingY = $result[2][0];
  37. }
  38. // on retourne les Tags
  39. print($filename . '.png');
  40. print('_TAG_');
  41. print ($physicalDeltaX);
  42. print('_TAG_');
  43. print ($physicalDeltaY);
  44. print('_TAG_');
  45. print ($pixelSpacingX);
  46. print('_TAG_');
  47. print ($pixelSpacingY);
  48. print('_TAG_');
  49. ?>