1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- namespace app\common\library;
- // include 'Nanodicom/nanodicom.php';
- // use app\common\library\nanodicom\Nanodicom;
- require dirname(__FILE__).'/nanodicom/Nanodicom.php';
- use Nanodicom;
- use app\common\library\DicomPaserTag;
- use think\Exception;
- class DicomPaser {
- public static function paser($filePath = '') {
- if(empty($filePath)) {
- throw new Exception("The filePath $filePath is empty or null");
- }
- if(!file_exists($filePath)) {
- throw new Exception("The filePath $filePath not exist");
- }
- if(!is_file($filePath)) {
- throw new Exception("The filePath $filePath not file");
- }
- $dicom = Nanodicom::factory($filePath);
- if(! $dicom->is_dicom()) {
- throw new Exception("The filePath $filePath not dcm file");
- }
- $a = $dicom->get(0x0010, 0x0010, 'N/A');
- return self::formatDataSet($dicom);
- }
- public static function formatDataSet($dicom) {
- $DICOM_TAG = DicomPaserTag::DICOM_TAG;
- $dataSet = [];
- foreach ($DICOM_TAG as $Tag) {
- $dataSet[$Tag['field']] = $dicom->get($Tag['group'], $Tag['element'], $Tag['default']);
- }
- return $dataSet;
- }
- }
|