예제 #1
0
파일: write_tags.php 프로젝트: igez/gaiaehr
#!/usr/bin/php
<?php 
#
# Write DICOM tags to dean.dcm. $new_tags is an array of tags to be written
#
require_once '../class_dicom.php';
$d = new dicom_tag();
$d->file = 'dean.dcm';
$new_tags = array('0010,0010' => 'VAUGHAN^DEAN', '0008,0080' => 'DEANLAND, AR');
$result = $d->write_tags($new_tags);
if ($result) {
    print "{$result}\n";
} else {
    system("./get_tags.php " . $d->file);
}
예제 #2
0
<?php

#
# You can call this from a URL and it'll print out the header for dean.dcm
#
require_once '../class_dicom.php';
$file = 'testing.jpg.dcm';
if (!file_exists($file)) {
    print "{$file}: does not exist\n";
    exit;
}
$d = new dicom_tag();
$d->file = $file;
$d->load_tags();
print "<pre>";
print_r($d->tags);
$name = $d->get_tag('0010', '0010');
print "Name: {$name}\n";
예제 #3
0
<head>
<title>Upload Form</title>
</head>
<body>

<h3>导入成功</h3>

<ul>
<?php 
//require_once(BASEPATH.'../class_dicom/class_dicom.php');
$file = $upload_data['orig_name'];
//echo $file."</br>";
chdir($upload_data['file_path']);
//echo getcwd()."</br>";
if (is_dcm($file)) {
    $d = new dicom_tag();
    $d->file = $file;
    $d->load_tags();
    $info['name'] = $d->get_tag('0010', '0010');
    $info['id'] = $d->get_tag('0010', '0020');
    $info['birth'] = $d->get_tag('0010', '0030');
    $info['sex'] = $d->get_tag('0010', '0040');
    $info['age'] = $d->get_tag('0010', '1010');
    $info['height'] = $d->get_tag('0010', '1020');
    $info['weight'] = $d->get_tag('0010', '1030');
    $info['ethnic'] = $d->get_tag('0010', '2160');
    $info['diagnoses'] = $d->get_tag('0008', '1080');
    $info['modality'] = $d->get_tag('0008', '0060');
    $info['appt_date'] = $d->get_tag('0008', '0020');
    $info['sop_id'] = $d->get_tag('0002', '0003');
    $info['number'] = $d->get_tag('0020', '0013');
예제 #4
0
파일: storedicom.php 프로젝트: ra-ckhar/www
function process_file($file) {

  if(!is_dcm($file)) {
    print("Not a DICOM file: $file\n");
    unlink($file);
    return(0);
  }

  $d = new dicom_tag;
  $d->file = $file;
  $d->load_tags();

  $name = $d->get_tag('0010', '0010');
  $id = $d->get_tag('0010', '0020');
  $modality = $d->get_tag('0008', '0060');
  $appt_date = $d->get_tag('0008', '0020');
  $sop_id = $d->get_tag('0002', '0003');
  $sex = $d->get_tag('0010', '0040');
  $age = $d->get_tag('0010', '1010');
  $weight = $d->get_tag('0010', '1030');
  $birth = $d->get_tag('0010', '0030');
  $birth = substr($birth,0,4).'-'.substr($birth,4,2).'-'.substr($birth,6,2);
  $appdate = substr($appt_date,0,4).'-'.substr($appt_date,4,2).'-'.substr($appt_date,6,2);
  $series_id = $d->get_tag('0020', '0052');
  $device = $d->get_tag('0008', '0070');
  $descp = $d->get_tag('0008', '1080');
  $operator = $d->get_tag('0018', '1030');
  $model_id = $d->get_tag('0008', '1090');
  $diagnoses = $d->get_tag('0010', '0030');
  $thick = $d->get_tag('0018', '0050');
  $spacing = $d->get_tag('0028', '0030');
  $device = $device.$model_id;
  


  $pa_id = insert_pa($name,$id,$sex,$age,$weight,$birth);
  $se_id = insert_se($pa_id,$series_id,$appdate,$modality,$device,$descp,$operator,$thick,$spacing);
  $year = date('Y', strtotime($appt_date));
  $month = date('m', strtotime($appt_date));
  $day = date('d', strtotime($appt_date));

  $storage = STORAGE . "/".str_pad($pa_id, 5, "0", STR_PAD_LEFT)."_".$name;
  if(!file_exists($storage)) {
    mkdir($storage);
  }
  $storage = $storage . "/".str_pad($se_id, 8, "0", STR_PAD_LEFT)."_".$modality."_".$appdate;
  if(!file_exists($storage)) {
    mkdir($storage);
  }

/*  $name = str_replace('^', '_', $name);
  $arr_replace = array('^', "'", '"', '`', '/', '\\', '?', ':', ';');
  foreach($arr_replace as $replace) {
    $name = str_replace($replace, '', $name);
    $id = str_replace($replace, '', $id);
  }

  $storage = $storage . "/$name" . "_$id";
  if(!file_exists($storage)) {
    mkdir($storage);
  }*/

  $new_file = $modality . "_" . $sop_id . ".dcm";

  if(file_exists("$storage/$new_file")) {
    $new_file = $modality . "_" . $sop_id . "_" . rand(1, 1000) . ".dcm";
  }

//  print "$storage/$new_file\n";

  if(!rename($file, "$storage/$new_file")) {
    print "Failed $file -> $storage/$new_file";
    exit;
  }
  print ".";

//  print "$name - $storage\n";
  //exit;
}
예제 #5
0
 function send_dcm($host, $port, $my_ae = 'DEANO', $remote_ae = 'DEANO', $send_batch = 0)
 {
     if (!$this->transfer_syntax) {
         $tags = new dicom_tag();
         $tags->file = $this->file;
         $tags->load_tags();
         $this->transfer_syntax = $tags->get_tag('0002', '0010');
     }
     $ts_flag = '';
     switch ($this->transfer_syntax) {
         case 'JPEGBaseline':
             $ts_flag = '-xy';
             break;
         case 'JPEGExtended:Process2+4':
             $ts_flag = '-xx';
             break;
         case 'JPEGLossless:Non-hierarchical-1stOrderPrediction':
             $ts_flag = '-xs';
             break;
     }
     $to_send = $this->file;
     if ($send_batch) {
         $to_send = dirname($this->file);
         $send_command = TOOLKIT_DIR . "/storescu -ta 10 -td 10 -to 10 {$ts_flag} -aet \"{$my_ae}\" -aec {$remote_ae} {$host} {$port} +sd \"{$to_send}\"";
     } else {
         $send_command = TOOLKIT_DIR . "/storescu -ta 10 -td 10 -to 10 {$ts_flag} -aet \"{$my_ae}\" -aec {$remote_ae} {$host} {$port} \"{$to_send}\"";
     }
     $out = Execute($send_command);
     if ($out) {
         return $out;
     }
     return 0;
 }
예제 #6
0
파일: uncompress.php 프로젝트: igez/gaiaehr
#!/usr/bin/php
<?php 
#
# Uncompress a DICOM file
#
require_once '../class_dicom.php';
$file = isset($argv[1]) ? $argv[1] : '';
if (!$file) {
    print "USAGE: ./uncompress.php <FILE>\n";
    exit;
}
if (!file_exists($file)) {
    print "{$file}: does not exist\n";
    exit;
}
$d = new dicom_tag();
$d->file = $file;
$d->load_tags();
$ts = $d->get_tag('0002', '0010');
$fsize = filesize($d->file);
print "Original: {$ts} ({$fsize})\n";
$c = new dicom_convert();
$c->file = $file;
$c->uncompress('uncompressed.dcm');
$d->file = 'uncompressed.dcm';
$d->load_tags();
$ts = $d->get_tag('0002', '0010');
$fsize = filesize($d->file);
print "Uncompressed: {$ts} ({$fsize})\n";
예제 #7
0
파일: datasheet.php 프로젝트: ra-ckhar/www
 function process_file($file)
 {
     if (!is_dcm($file)) {
         print "Not a DICOM file: {$file}\n";
         unlink($file);
         return 0;
     }
     $d = new dicom_tag();
     $d->file = $file;
     $d->load_tags();
     $name = $d->get_tag('0010', '0010');
     $id = $d->get_tag('0010', '0020');
     $modality = $d->get_tag('0008', '0060');
     $appt_date = $d->get_tag('0008', '0020');
     $sop_id = $d->get_tag('0002', '0003');
     $year = date('Y', strtotime($appt_date));
     $month = date('m', strtotime($appt_date));
     $day = date('d', strtotime($appt_date));
     $storage = STORAGE . "/{$year}";
     if (!file_exists($storage)) {
         mkdir($storage);
     }
     $storage = $storage . "/{$month}";
     if (!file_exists($storage)) {
         mkdir($storage);
     }
     $storage = $storage . "/{$day}";
     if (!file_exists($storage)) {
         mkdir($storage);
     }
     $name = str_replace('^', '_', $name);
     $arr_replace = array('^', "'", '"', '`', '/', '\\', '?', ':', ';');
     foreach ($arr_replace as $replace) {
         $name = str_replace($replace, '', $name);
         $id = str_replace($replace, '', $id);
     }
     $storage = $storage . "/{$name}" . "_{$id}";
     if (!file_exists($storage)) {
         mkdir($storage);
     }
     $new_file = $modality . "_" . $sop_id . ".dcm";
     if (file_exists("{$storage}/{$new_file}")) {
         $new_file = $modality . "_" . $sop_id . "_" . rand(1, 1000) . ".dcm";
     }
     //  print "$storage/$new_file\n";
     if (!rename($file, "{$storage}/{$new_file}")) {
         print "Failed {$file} -> {$storage}/{$new_file}";
         exit;
     }
     print ".";
     //  print "$name - $storage\n";
     //exit;
 }