Introduction

Introduction – using File_DICOM

What is DICOM?

File_DICOM allows reading and modifying of DICOM files. DICOM stands for Digital Imaging and COmmunications in Medicine, and is a standard for creating, storing and transfering digital images (X-rays, tomography) and related information used in medicine. This package in particular does not support the exchange/transfer of DICOM data, nor any network related functionality. More information on the DICOM standard can be found at the NEMA site.

Please be aware that any use of the information produced by this package for diagnosing purposes is strongly discouraged by the author. See here for more information.

Using it

File_DICOM can be used to accomplish two things, to retrieve data from a file (including image data), and to set new values for that data (allowing to write the modified file).

Let's see how we could show some relevant data from a DICOM file and export its image data at the same time.

Showing data

<?php
require_once('File/DICOM.php');

$dicom = new File_DICOM();
$res $dicom->parse("test.dcm");

// check for errors
if (PEAR::isError($res)) {
    die(
"Error: ".$res->getMessage()."\n");
}

// show a few attributes of the DICOM file using group and element index
echo 'StudyDate : '.$dicom->getValue(0x00080x0020)."\n";
echo 
'Image Date : '.$dicom->getValue(0x00080x0023)."\n";
echo 
'Image Type : '.$dicom->getValue(0x00080x0008)."\n";
echo 
'Study Time : '.$dicom->getValue(0x00080x0030)."\n";
echo 
'Institution Name : '.$dicom->getValue(0x00080x0080)."\n";
echo 
'Manufacturer : '.$dicom->getValue(0x00080x0070)."\n";
echo 
'Manufacturer Model Name : '.$dicom->getValue(0x00080x1090)."\n";
// or using element name
echo 'Patient Name : '.$dicom->getValue('PatientName')."\n";
echo 
'Patient Age : '.$dicom->getValue('PatientAge')."\n";

// dump a PGM image from the file data
$res $dicom->dumpImage('test.pgm');
if (
PEAR::isError($res)) {
    die(
"Error: ".$res->getMessage()."\n");
}
?>
File_DICOM (Previous) Constructor. (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.