The unofficial File_DICOM.php v 0.3

This is an updated version of the latest DICOM_php package available at the File_DICOM::Pear website. Last year I contacted David who is in charge of this package at pear.php.net, we had some emails exchanged but I haven’t seen any new release there; thus, I make this new unofficial version public so people can take advantage of the changes I made.

To download the package (zip version) and the sample test page click here: File_DICOM

The main changes include:

  1. Add support for sequences. Now you will have access to the elements inside sequences
  2. Tested on Windows and Linux
  3. Converts the image data to gd objects
  4. Supports multi-frame images. When converting the data to images returns an array of gd objects
  5. Support for different Transfer Syntaxes. Added support for “Explicit VR Big Endian”, by default it was “Explicit VR Little Endian”
  6. Added a function to display the DICOM structure in html. Useful to take a look of the DICOM fields
  7. Added support to read 2’s complement gray values (PixelRepresentation[0x0028,0x0103])
  8. Added a trim function to properly obtain the values when they have been padded with extra zeros
  9. Added a pad function to properly add extra zeros when the length of value is not even
  10. moved the Dictionary data to a single file, for the purposes of maintenance and readibility
  11. Also moved the VR array from the Element class to a global variable so less memory is allocated when elements are created
  12. New! (version 0.3.1) Added support for color images

Please feel free to comment on this version.

Update:
– (April 05 2008) Bug: Images with 3 samples per pixel were not displayed correctly. I will fix that and update the files.
– (April 07 2008) Version 0.3.1 was created
– (April 07 2008) Version 0.3.1 added support for color images. (Fixes above Bug(.
– (April 07 2008) Issue: Memory consumption is considerable when creating the image objects. Needs improvement.

Thanks,

Nano.



Thank you for reading this post. You can now Read Comments (15) or Leave A Trackback.

15 Responses to “The unofficial File_DICOM.php v 0.3

  • 1
    John
    April 12th, 2008 09:25

    Hi m8

    Thanks for Your Help about Dicom & Others its very appreciated
    but i have a question about DICOM
    How can i Show DICOM Image on Browser
    i mean when i used this class DICOM it only Show me info about This Dicom Image
    but how can i show it really as picture

    Thanks m8 !

    [Response from Nano.] To display the image on the browser you can either have a DICOM viewer (java applet, ActiveX or Flash) or you convert the image to a known image for browsers (jpeg, gif, png). Both have their pros and cons. In the case of this package, it does the conversion to jpeg (the test page) but only if ($rows * $cols >= 500000)

  • 2
    Pascal
    June 24th, 2008 01:22

    Hi,
    I really want to thank you for your versions of File_DICOM.php. I’m integrating it into my app.
    But maybe you could help me with “the other side”. The simple scenario is that I want to receive DICOM-Images and want to provide a Worklist out of my app (written nearly completely in PHP). Maybe you have an idea how to implement that?!
    I could use the OFFIS-package, but talking HTTP with C++ to PHP is, well, suicide.

  • 3
    Juan Felipe Alvarez Saldarriaga
    July 3rd, 2008 16:18

    Hey! great work, but I have an issue (I already fix it but I don’t know :P), my issue that you have the Value Representations array ($VR_array) as a global var into File_DICOM class, I’m using PHP5 and Zend Framework, so when I try to parse a DCM file I got this error: Warning: array_key_exists(): The second argument should be either an array or an object in /home/jfalvarez/public_html/dicom_cli/library/File/DICOM/Element.php on line 269, well, seems like when you do global $VR_array; in the File_DICOM_Element::_readLength method the result is that this $VR_array is null, so, I set the $VR_array structure as a static attribute of File_DICOM class, so I call it in File_DICOM_Element using a static method that I wrote in File_DICOM to get it there :D, now works fine, I don’t know if is an issue or maybe is PHP5.

    Cya!
    Nano: It will be nice to see your modification. Thank you
    Update [Jul-25-08]: We are currently working to move this project to Google code

  • 4
    Kashif
    July 10th, 2008 01:05

    how to open dcm image in php?
    i am kashif i made a software on matlab which is DICOM viewer in maiuplate the dcm image but i jus want to know how open dcm image in matlab ?

    Nano: In Matlab I know there is a library for manipulating DICOM (and it is quite good). For PHP you can use this library, and what you are actually saying about how to open a dcm image is maybe how to read and parse a dcm image (which is provided in this package). But if you are talking about a user interface that will allow you to open dcm images as in matlab, then this package will not be enough. Try this PHP-GTK

  • 5
    Alok Jain
    March 26th, 2009 00:31

    Hello Nano,
    I am making an open source for PCAS application.i ve difficulty for how to read dicom images and fetch patient information from dicom files then create images (.gif,jpeg). Please help me out this problem.
    In advance thanks Nano

  • 6
    PAKORN
    May 16th, 2009 00:13

    Dear Nano,

    Thank you very much for your PHP scripts.
    I trying to create the image from report and convert
    the report to DICOM and auto matic send to PACS
    in that study. Can you do that.

  • 7
    Adeel Malik
    September 24th, 2009 04:16

    AOA.
    dear i want to convert dicom image into jpg and duwnload ur code from ur side but it not work well.
    tel me how can i get latest updated version of it
    thanks

  • 8
    priyavrat
    September 25th, 2009 03:20

    Hi,
    i downloaded your code,when i tried it does not displayed any image to me only data related to patient……! What that means is that dcm file does not contain any image data

  • 9
    Andras
    September 30th, 2009 10:03

    Hi,

    I have downloaded “DICOM.zip” which have tested on a CentOS 5.3 with Apache2 and PHP5. we got an error:

    “Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 76 bytes) in “—snipped—“/DICOM/Element.php on line 318”

    I`m not yet sure as to what causing this, but I see no documentation as to what your app expect to have (extensions etc.) in order to properly work. — on the side note: we also tried the same dicom(s) on a windows based host with xamp and it works flawlessly there……
    any assumption(s)?

    thanks

    Andras

  • 10
    Abdul Ershad A.K
    October 26th, 2009 00:18

    I hav downloaded the DICOM.ZIP……..

    thanx for ur kind support

  • 11
    Abdul Ershad
    October 30th, 2009 02:53

    Fisrt of all thanx for the Updates,
    I down loaded the Dicom.zip package, now it is working fine for a single image, when am uploading the zip images its got Extarcted to the Upload/zip folder with an extensin of .tmp that also fine,

    Can i convert the tmp image to Jpg and can display it thru the browser? i tried But it is showing som Memroy erro!!!

    how can i solve? where and which portion of the code i need to add for the Jpg convertion at the time of Zip file extraxtion

    thanx in Adavance….

  • 12
    Kiran Vathaluru
    March 1st, 2010 22:00

    Hi All,

    This DICOM library was helping us a lot. And here I’ve a small question can any one of you please suggest me

    I’ve a DICOM File, I want to process that DICOM File and need to edit header information like for empty representations, how can we make this happens, simply to say I want to edit DICOM file and again need to store/save it as a DICOM again.

    Any one of you could suggest me please and actually I want make all this things using PHP only… Or suggest me the approach, so that help us a lots

    Thanks in advance

    Kiran Kumar Reddy V

  • 13
    Mikee
    August 20th, 2010 09:29

    Hi all,

    this piece of code is really great.
    But I found one little error in the dictionary: the element [0x0018][0x7050] is defined with code “LT” but it has to be “CS” (see http://medical.nema.org/dicom/2003/03_06PU.PDF). So just change line 583 in dictionary.php

    With “LT” I got a memory error, because the code tried to read the rest of the dicom-file (including image-data) in this element.

    I hope this information will help someone.

    Mikee

  • 14
    Nidaan
    September 16th, 2010 23:17

    Hello,

    I tried to download DICOM.zip file but it gives me error ( the source file could not be read).

    Thanks.

    [Nano says: That package is no longer supporte, please use nanodicom]

  • 15
    felipe
    October 14th, 2011 15:52

    always get this error
    Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to allocate 71 bytes) in /home/nanodocumet/nanodocumet.com/DICOM.php on line 546



Leave a Reply

Note: Any comments are permitted only because the site owner is letting you post, and any comments will be removed for any reason at the absolute discretion of the site owner.