Skip to content

Instantly share code, notes, and snippets.

@nanodocumet
Created January 20, 2015 20:58
Show Gist options
  • Save nanodocumet/54875a3d1af1afbff3e2 to your computer and use it in GitHub Desktop.
Save nanodocumet/54875a3d1af1afbff3e2 to your computer and use it in GitHub Desktop.
Snippet to read DirectoryRecordSequenceItems from a DICOMDIR file using Nanodicom
<?php
require 'nanodicom.php';
// File to read
$filename = 'DICOMDIR';
$dicom = Nanodicom::factory($filename);
// Parse whole file
$dicom->parse();
// Get the sequence
$DirectoryRecordSequence = $dicom->value(0x0004, 0x1220);
// Get the sequence items
$DirectoryRecordSequenceItems = $dicom->read_sequence_items($DirectoryRecordSequence);
// You can iterate through now
foreach ($DirectoryRecordSequenceItems as $item)
{
// Returned value when it does not exist is FALSE.
$ReferencedFileID = ($dicom->dataset_value($item, 0x0004, 0x1500) === FALSE) ? 'N/A' : $dicom->dataset_value($item, 0x0004, 0x1500);
echo $ReferencedFileID."\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment