Created
January 20, 2015 20:58
-
-
Save nanodocumet/54875a3d1af1afbff3e2 to your computer and use it in GitHub Desktop.
Snippet to read DirectoryRecordSequenceItems from a DICOMDIR file using Nanodicom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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