Skip to content

Instantly share code, notes, and snippets.

@nanodocumet
Created January 10, 2013 07:59
Show Gist options
  • Save nanodocumet/4500300 to your computer and use it in GitHub Desktop.
Save nanodocumet/4500300 to your computer and use it in GitHub Desktop.
Workaround to add tags to DICOM file. Uses anonymizer to set the new tag at the right order in the dataset. Certainly a bug.
<?php
// 1) Workaround to create new elements for Nanodicom
try
{
$dicom = Nanodicom::factory($filename, 'anonymizer');
// Set Value (Patient Name here)
$dicom->value(0x0010, 0x0010, 'JKD');
//$dicom->value(0x0010, 0x0010, 'JKD'); Others as well
$tags = array(
array(0xF0ED, 0xF0ED, 'id{random}'), // Non-existing tag. Sorry, needs one at least
);
$replacements = array(
array(0x0010, 0x0010, 'JKD', 'JKD'),
// array(0x0010, 0x0010, 'JKD', 'JKD'), Whatever was used above should be added here. Same value to be saved should be set for both last parameters
);
// Save the file with same name
file_put_contents($filename, $dicom->anonymize($tags, $replacements));
}
catch (Nanodicom_Exception $e)
{
echo 'File failed. '.$e->getMessage()."\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment