/** * Decode the datas, depending on the transfer syntax * * @param CDicomStreamReader $stream_reader The stream writer * * @param string $transfer_syntax The UID of the transfer syntax * * @return void */ function decode(CDicomStreamReader $stream_reader, $transfer_syntax) { if (!$transfer_syntax) { return; } $this->attributes = array(); $this->datasets = array(); $stream_length = $stream_reader->getStreamLength(); while ($stream_reader->getPos() < $stream_length) { $dataset = new CDicomDataSet(); $dataset->decode($stream_reader, $transfer_syntax); $group = $dataset->getGroupNumber(); $element = $dataset->getElementNumber(); if (!array_key_exists($group, $this->datasets)) { $this->datasets[$group] = array(); } if (!array_key_exists($group, $this->attributes)) { $this->attributes[$group] = array(); } $this->datasets[$group][$element] = $dataset; $this->attributes[$group][$element] = $dataset->getValue(); } }
/** * Decode the PDU * * @param CDicomStreamReader $stream_reader The stream reader * * @return null */ function decodePDU(CDicomStreamReader $stream_reader) { $this->pdvs = array(); $stream_reader->setStreamLength($this->getTotalLength()); while ($stream_reader->getPos() < $stream_reader->getStreamLength()) { $pdv_length = $stream_reader->readUInt32(); // + 4; //$stream_reader->seek(-4); $pdv_content = $stream_reader->read($pdv_length); $pdv_handle = fopen('php://temp', 'w+'); fwrite($pdv_handle, $pdv_content, $pdv_length); $pdv_stream = new CDicomStreamReader($pdv_handle); $pdv_stream->rewind(); $pdv = new CDicomPDV(array("presentation_contexts" => $this->presentation_contexts, "length" => $pdv_length)); $pdv->decode($pdv_stream); $this->pdvs[] = $pdv; } }