[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get Patient Info out of DICO-Files



Emmler, Oliver writes:
> 
> i want to get the header-info out of DICOM-Files. Unfortunately i am not
> very familiar with Object-Programming.
> 
> Does anyone has a solution for this and can post the source. I think i will
> be able to adapt the code.

Here is a very, very simple program that shows the
general idea. You will need my TVImage program to
run it.

   http://www.dfanning.com/programs/tvimage.pro

Cheers,

David

****************************************************************
PRO Dicom_Example

   ; Open a Dicom file for reading.

filename = Filepath('mr_knee.dcm', SubDirectory=['examples', 'data'])
object = Obj_New('IDLffDicom')
ok  = object->Read(filename)
IF NOT ok THEN BEGIN
   Print, 'File: "' + filename + '" cannot be read. Returning...'
   RETURN
ENDIF

   ; Print the patient name.

name = object->GetValue('0010'x, '0010'x)
Print, ""
IF Ptr_Valid(name[0]) THEN Print, '   Patient Name: ', *name[0]

   ; Print the patient age.

age = object->GetValue('0010'x, '1010'x)
IF Ptr_Valid(age[0]) THEN Print, '   Patient Age: ', *age[0]

   ; Print the patient history.

history = object->GetValue('0010'x, '21B0'x)
IF Ptr_Valid(history[0]) THEN Print, '   Patient History: ', *history[0]
Print, ""

   ; Display the image.

image = object->GetValue('7Fe0'x, '0010'x)
IF Ptr_Valid(image[0]) THEN TVImage, BytScl(*image[0]), Margin=0.1, $
   /Keep_Aspect, /Erase

   ; Destroy the object.

Obj_Destroy, object

   ; Free the pointers.
   
Ptr_Free, name
Ptr_Free, age
Ptr_Free, history
Ptr_Free, image

END
****************************************************************

-- 
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155