[Gdcm-hackers] gdcm-git:Grassroots DICOM branch master updated. 248e80a110154cf28b6aa5e318c96346fb9
Cross-platform DICOM implementation
Brought to you by:
malat
|
From: Mathieu M. <ma...@us...> - 2011-01-26 09:25:23
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Grassroots DICOM".
The branch, master has been updated
via 248e80a110154cf28b6aa5e318c96346fb9e7a7e (commit)
from b57560c45959debd4c4d63643abd5f2354677d29 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://gdcm.git.sourceforge.net/git/gitweb.cgi?p=gdcm/gdcm;a=commit;h=248e80a110154cf28b6aa5e318c96346fb9e7a7e
commit 248e80a110154cf28b6aa5e318c96346fb9e7a7e
Author: Mathieu Malaterre <mat...@gm...>
Date: Wed Jan 26 10:24:52 2011 +0100
Adding examples from Aleš Pave
diff --git a/Examples/PHP/hello_world.php b/Examples/PHP/hello_world.php
new file mode 100644
index 0000000..c0f4097
--- /dev/null
+++ b/Examples/PHP/hello_world.php
@@ -0,0 +1,87 @@
+<?php
+/*=========================================================================
+
+ Program: GDCM (Grassroots DICOM). A DICOM library
+ Module: $URL$
+
+ Copyright (c) 2006-2010 Mathieu Malaterre
+ All rights reserved.
+ See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notice for more information.
+
+=========================================================================*/
+
+/*
+ * \author Aleš Pavel
+ */
+require_once( 'gdcm.php' );
+
+$reader = new Reader();
+$reader->SetFilename( "test.dcm" );
+$ret=$reader->Read();
+if( !$ret )
+{
+ return 1;
+}
+
+$file = $reader->GetFile();
+// The output of gdcm::Reader is a gdcm::File
+
+// the dataset is the the set of element we are interested in:
+$ds = $file->GetDataSet();
+print_r($ds);
+$g = c_Global::getInstance();
+
+$dicts = $g->GetDicts();
+$pubdict = $dicts->GetPublicDict();
+
+// In this example we will show why using name to lookup attribute can be
+// dangerous.
+$tPatientName= new Tag(0x0,0x0);
+$de1 = $pubdict->GetDictEntryByName("Patient Name", $tPatientName);
+
+printf("Found %s",$tPatientName);
+
+// Indeed the attribute could not be found. Since DICOM 2003, Patient Name
+// has become Patient's Name.
+
+$tPatientsName = new Tag();
+$de2 = $pubdict->GetDictEntryByName("Patient's Name", $tPatientsName);
+
+printf("Found: %s",$tPatientsName);
+
+// Let's try to read an arbitrary DICOM Attribute:
+$tDoseGridScaling=new Tag();
+$de3 = $pubdict->GetDictEntryByName("Dose Grid Scaling", $tDoseGridScaling);
+
+printf("Found: %s",$tDoseGridScaling);
+
+if( $ds->FindDataElement( $tDoseGridScaling ) )
+{
+ $sf= new StringFilter();
+ $sf->SetFile($file);
+ printf("Attribute Value as String: %s",$sf->ToString( $tDoseGridScaling ));
+
+ // Let's check the name again:
+ $pss = $sf->ToStringPair( $tDoseGridScaling );
+ printf("Attribute Name Checked: %s", $pss->first);
+ printf("Attribute Value (string): %s", $pss->second);
+
+ $dgs = $ds->GetDataElement( $tDoseGridScaling );
+
+ // Let's assume for a moment we knew the tag number:
+ $at=new Tag(0x3004,0x000e);
+ assert( $at.GetTag() == $tDoseGridScaling );
+ $at->SetFromDataSet( $ds );
+ // For the sake of long term maintenance, we will not write
+ // that this particular attribute is stored as a double. What if
+ // a user made a mistake. It is much safer to rely on GDCM internal
+ // mechanism to deduce the VR::DS type (represented as a ieee double)
+ $v = $at->GetValue();
+ printf("DoseGridScaling=%s",$v);
+}
+
+?>
diff --git a/Examples/PHP/modify_file.php b/Examples/PHP/modify_file.php
new file mode 100644
index 0000000..caa1944
--- /dev/null
+++ b/Examples/PHP/modify_file.php
@@ -0,0 +1,53 @@
+<?php
+/*=========================================================================
+
+ Program: GDCM (Grassroots DICOM). A DICOM library
+ Module: $URL$
+
+ Copyright (c) 2006-2010 Mathieu Malaterre
+ All rights reserved.
+ See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notice for more information.
+
+=========================================================================*/
+
+/*
+ * \author Aleš Pavel
+ */
+require_once( 'gdcm.php' );
+
+$reader = new Reader();
+$reader->SetFilename( "test.dcm" );
+$ret=$reader->Read();
+if( !$ret )
+{
+ return 1;
+}
+
+$file = $reader->GetFile();
+$ano = new Anonymizer();
+$ano->SetFile($file);
+$ano->RemovePrivateTags();
+$ano->RemoveGroupLength();
+$t = new Tag(0x10,0x10);
+$ano->Replace( $t, "GDCM^PHP^Test^Hello^World" );
+
+$g = new UIDGenerator();
+$ano->Replace( new Tag(0x0008,0x0018), $g->Generate() );
+$ano->Replace( new Tag(0x0020,0x000d), $g->Generate() );
+$ano->Replace( new Tag(0x0020,0x000e), $g->Generate() );
+$ano->Replace( new Tag(0x0020,0x0052), $g->Generate() );
+
+$writer = new Writer();
+$writer->SetFileName( "test2.dcm" );
+$writer->SetFile( $ano->GetFile() );
+$ret = $writer->Write();
+if( !$ret )
+{
+ return 1;
+}
+
+?>
-----------------------------------------------------------------------
Summary of changes:
Examples/PHP/hello_world.php | 87 ++++++++++++++++++++
.../PHP/{rewrite_header.php => modify_file.php} | 35 ++++++--
2 files changed, 112 insertions(+), 10 deletions(-)
create mode 100644 Examples/PHP/hello_world.php
copy Examples/PHP/{rewrite_header.php => modify_file.php} (54%)
hooks/post-receive
--
Grassroots DICOM
|