Class: Nanodicom_Core

Source Location: /nanodicom/core.php

Class Overview [line 23]


Nanodicom_Core class.

Author(s):

Version:

  • 1.1

Copyright:

  • (c) 2010

Variables

Constants

Methods


Child classes:

Nanodicom
abstract Nanodicom class.

Inherited Variables

Inherited Constants

Inherited Methods



Class Details

Nanodicom_Core class.

Tags:

[ Top ]


Class Variables

static $default_dictionary = array('UN', '1', 'Unknown')

[line 57]

Tags:

  • var - default dictionary
  • access - public

Type: array

Overrides:

[ Top ]

static $encapsulated_transfer_syntaxes = array(
      '1.2.840.10008.1.2.1.99', // DICOM DEFLATED LITTLE ENDIAN TRANSFER SYNTAX (EXPLICIT VR)
   )

[line 67]

Tags:

  • var - list of encapsulated transfer syntax
  • access - public

Type: array

Overrides:

[ Top ]

static $is_cli =  FALSE

[line 74]

Tags:

  • var - command line environment?
  • access - public

Type: boolean

Overrides:

[ Top ]

static $is_windows =  FALSE

[line 79]

Tags:

  • var - Windows environment?
  • access - public

Type: boolean

Overrides:

[ Top ]

static $items_elements = array(self::ITEM, self::ITEM_DELIMITER, self::SEQUENCE_DELIMITER)

[line 52]

The elements for group 0xFFFE should be Encoded as Implicit VR.

DICOM Standard 09. PS 3.6 - Section 7.5: "Nesting of Data Sets"

Tags:

  • var - item elements
  • access - public

Type: array

Overrides:

[ Top ]

static $vr_array = array(
      'AE' => array('Application Entity', 16, 0),'AS'=>array('Age String',4,1),'AT'=>array('Attribute Tag',4,1),'CS'=>array('Code String',16,0),'DA'=>array('Date',8,1),'DS'=>array('Decimal String',16,0),'DT'=>array('Date Time',26,0),'FL'=>array('Floating Point Single',4,1),'FD'=>array('Floating Point Double',8,1),'IS'=>array('Integer String',12,0),'LO'=>array('Long String',64,0),'LT'=>array('Long Text',10240,0),'OB'=>array('Other Byte String',0,0),'OF'=>array('Other Float String',4294967292,0),'OX'=>array('Mixed. Other {Byte|Word} String',0,0),'OW'=>array('Other Word String',0,0),'PN'=>array('Person Name',64,0),'SH'=>array('Short String',16,0),'SL'=>array('Signed Long',4,1),'SQ'=>array('Sequence of Items',0,0),'SS'=>array('Signed Short',2,1),'ST'=>array('Short Text',1024,0),'TM'=>array('Time',16,0),'UI'=>array('Unique Identifier UID',64,0),'UL'=>array('Unsigned Long',4,1),'UN'=>array('Unknown',0,0),'US'=>array('Unsigned Short',2,1),'UT'=>array('Unlimited Text',4294967294,0))

[line 88]

Value Representations (DICOM Standard PS 3.5 Section 6.2) Bytes = 0 => Undefined length.

Fixed = 1 => Exact field length, otherwise max length. each array contains: Name, Bytes, Fixed

Tags:

  • access - public

Type: array

Overrides:

[ Top ]

static $vr_explicit_4bytes = array('OB', 'OW', 'OF', 'SQ', 'UT', 'UN')

[line 62]

Tags:

  • var - list of vr that have the explicit 4 bytes
  • access - public

Type: array

Overrides:

[ Top ]

static $_read_int =  '_read_int_32'

[line 225]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

static $_write_int =  '_write_int_32'

[line 228]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

$profiler = array()

[line 240]

Tags:

  • access - public

Type: mixed

Overrides:

[ Top ]

$_blob =  ''

[line 273]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

$_check_list_function =  '_dummy'

[line 285]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

$_children

[line 276]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

$_counted_elements =  0

[line 282]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

$_current_pointer =  0

[line 258]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

$_dataset = array()

[line 234]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

$_errors = array()

[line 270]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

$_file_length

[line 255]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

$_force_load_dictionary =  FALSE

[line 231]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

$_is_dicom =  FALSE

[line 237]

Tags:

  • access - public

Type: mixed

Overrides:

[ Top ]

$_is_parsed =  FALSE

[line 243]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

$_location

[line 249]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

$_meta_group_last_byte =  -1

[line 252]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

$_meta_information_group_length =  NULL

[line 261]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

$_parent_vr

[line 279]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

$_preamble

[line 246]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

$_transfer_syntax =  self::IMPLICIT_VR_LITTLE_ENDIAN

[line 267]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]

$_vr_reading_list = array()

[line 264]

Tags:

  • access - protected

Type: mixed

Overrides:

[ Top ]


Class Methods

static decode_transfer_syntax

static array decode_transfer_syntax( string $transfer_syntax)

[line 158]

Get the VR mode and endian from a transfer syntax.

Tags:

  • return - returning the vr mode and endian
  • access - public

Parameters:

  • string $transfer_syntax - transfer syntax to check

[ Top ]

static factory

static Dicom_tool factory( mixed $location, [string $name = 'simple'], [string $type = 'file'])

[line 130]

Create a new Nanodicom instance. It is usually called from a class extended from Nanodicom, ie Dumper

$file = Nanodicom::factory($location, 'dumper');

Tags:

  • return - A Tool
  • access - public

Parameters:

  • mixed $location - file blob or location of the file
  • string $name - name of the tool to load
  • string $type - type of data passed

[ Top ]

static _compare

static boolean _compare( string $needle, mixed $haystack)

[line 187]

Compare a needle with a haystack.

$key = Fragment::_cache_key('footer', TRUE);

Tags:

  • return - true if found, false if not found
  • access - protected

Parameters:

  • string $needle - what to search
  • mixed $haystack - where to look it, could be simple or associative array

[ Top ]

static _is_associative

static boolean _is_associative( $array)

[line 214]

Check if the array is associative or not.

Borrowed from Kohan_Arr

Tags:

  • return - true if associative, false if not
  • access - protected

Parameters:

  • array $array - array to check

[ Top ]

__construct

Nanodicom __construct( mixed $location, string $type, $name)

[line 297]

Create a new Nanodicom instance. It is usually called from a class extended from core, ie Dumper

$file = DICOM_Dumper::factory($location);

Tags:

  • access - public

Parameters:

  • mixed $location - file blob or location of the file
  • string $type - type of first parameter
  • $name -

[ Top ]

extend

this extend( string $name)

[line 423]

Public method to extend the tool to include other tools.

It is preferable to load the required tool directly. This mechanism is still under evaluation.

Unknown results when the object is extended and then manipulated and then extended.

Tags:

  • access - public

Parameters:

  • string $name - name of the tool to extend

[ Top ]

flush

void flush( )

[line 507]

Public method to flush the object

Tags:

  • access - public

Parameters:

[ Top ]

is_dicom

boolean is_dicom( )

[line 497]

Public method to quickly check if file is DICOM (DICM check)

Tags:

  • return - true if file has preamble and DICM, false if not
  • access - public

Parameters:

[ Top ]

last_error

string last_error( )

[line 487]

Returns the last error found

Tags:

  • access - public

Parameters:

[ Top ]

parse

this parse( [array $vr_reading_list = array()])

[line 624]

Parses the object

If the list of elements has a tag name, dictionaries will be loaded. For performance is better to pass only arrays of the form: array(group, element) where group and element are in hexadecimal

Tags:

  • access - public

Parameters:

  • array $vr_reading_list - a list of elements tags to read. parsing stops when all found

[ Top ]

profiler_diff

float profiler_diff( string $name)

[line 459]

Public method to show the profiling time for methods. Profiling names MUST be equal to method names.

Tags:

  • return - the number of seconds used
  • access - public

Parameters:

  • string $name - name of the method

[ Top ]

set_vr_reading_list

void set_vr_reading_list( array $vr_reading_list)

[line 714]

Public method to set the vrs to read

Tags:

  • access - public

Parameters:

  • array $vr_reading_list - a list of elements tags to read. Either names or array of (group,element)

[ Top ]

value

mixed|false|void value( [mixed $group = NULL], [mixed $element = NULL], [mixed $new_value = NULL], [boolean $create = FALSE])

[line 537]

Public method to get and set values.

Only values at top level.

Tags:

  • return - found value or false when tag was not found or not enough arguments or void when setting a value successfully
  • access - public

Parameters:

  • mixed $group - either the group or name of the tag
  • mixed $element - either the element or value to set of the tag
  • mixed $new_value - either the value to set or the create
  • boolean $create - flag to allow creation of tag or not

[ Top ]

write

string write( )

[line 660]

Returns a blob of the current dataset

This function will do some corrections:

  1. Make the File Meta Information EXPLICIT VR LITTLE ENDIAN
  2. Convert Known tags to their real Tag values
  3. [probably] Prepend preamble (future versions)
  4. [probably] Prepend File Meta Information if not present (future versions)

Tags:

  • return - binary string of contents
  • access - public

Parameters:

[ Top ]

write_file

this write_file( string $filename)

[line 644]

Writes the file to the specified location

TODO: Throw exceptions in errors

Tags:

  • access - public

Parameters:

  • string $filename - location of the file where the contents will be written

[ Top ]

_check_list

boolean _check_list( integer $group, integer $element)

[line 786]

After every element loaded we check if we need to stop

Tags:

  • return - true if all elements have been found (finish parsing), false otherwise
  • access - protected

Parameters:

  • integer $group - the group
  • integer $element - the element

[ Top ]

_decode_vr

boolean _decode_vr( integer $group, integer $element, $vr, $length)

[line 817]

Decodes the proper vr from the group, element, current vr and length.

The priority order is: 1) From dictionary 2) If current vr is a valid vr and not UN or empty, then set as current vr (Explicit mode) 3) If length is undefined, most likely it is a sequence, 4) Otherwise is it the default VR ('UN')

Tags:

  • return - true if all elements have been found (finish parsing), false otherwise
  • access - protected

Parameters:

  • integer $group - the group
  • integer $element - the element
  • $vr -
  • $length -

[ Top ]

_dummy

void _dummy( [ $arg1 = NULL], [ $arg2 = NULL], [ $arg3 = NULL], [ $arg4 = NULL], [ $arg5 = NULL])

[line 735]

Tags:

  • access - protected

Parameters:

  • $arg1 -
  • $arg2 -
  • $arg3 -
  • $arg4 -
  • $arg5 -

[ Top ]

_forward

void _forward( integer $offset)

[line 1679]

Moves the current_pointer forward

Tags:

  • access - protected

Parameters:

  • integer $offset - number of bytes to move forward

[ Top ]

_parse

this _parse( [boolean $check_dicom_only = FALSE])

[line 850]

Does the parsing work

Tags:

  • return - for chaining
  • access - protected

Parameters:

  • boolean $check_dicom_only - true to check file is dicom, default to false

[ Top ]

_proper_name

string _proper_name( string $name)

[line 773]

Get the proper name of the tag name. Removes spaces and _, and converts it to lowercase.

Tags:

  • return - the proper name
  • access - protected

Parameters:

  • string $name - tag name

[ Top ]

_read

boolean|string _read( [integer $length = NULL])

[line 1763]

Reads specified number of bytes from blob, or checks if there is still data left to be read

Tags:

  • return - boolean when checking if there is still data or a binary string otherwise
  • throws - Nanodicom_Exception
  • access - protected

Parameters:

  • integer $length - number of bytes to read or NULL

[ Top ]

_read_element

void _read_element( )

[line 946]

Read an element

PS 3.10 Page 22 (2009) Except for the 128 byte preamble and the 4 byte prefix, the File Meta Information shall be encoded using the Explicit VR Little Endian Transfer Syntax (UID=1.2.840.10008.1.2.1) as defined in DICOM PS 3.5. Values of each File Meta Element shall be padded when necessary to achieve an even length, as specified in PS 3.5 by their corresponding Value Representation. The Unknown (UN) Value Representation shall not be used in the File Meta Information. For compatibility with future versions of this Standard, any Tag (0002,xxxx) not defined in Table 7.1-1 shall be ignored.

However, this parser CAN read File Meta Information encoded (wrongly) with Implicit VR Little Endian TODO: Thow a warning

This parser handles (incorrectly set) odd lengths as well.

Tags:

  • throws - Nanodicom_Exception
  • access - protected

Parameters:

[ Top ]

_read_file

void _read_file( [integer $starting_byte = 0], [mixed $length = NULL])

[line 1702]

Read file or blob accordingly

Tags:

  • throws - Nanodicom_Exception
  • access - protected

Parameters:

  • integer $starting_byte - starting byte for reading
  • mixed $length - how many bytes to read

[ Top ]

_read_float

mixed _read_float( integer $bytes, integer $length, integer 2)

[line 1603]

Reads a float

Tags:

  • return - a float or an array of floats
  • access - protected

Parameters:

  • integer 2 - the sign
  • integer $bytes - number of bytes to read per float
  • integer $length - total length to read

[ Top ]

_read_int_32

mixed _read_int_32( integer $bytes, integer $endian, integer $length, [integer $sign = self::UNSIGNED])

[line 1519]

Reads integers

Tags:

  • return - a single value or an array
  • access - protected

Parameters:

  • integer $bytes - the bytes needed per integer
  • integer $endian - the endian mode: Little or Big Endian
  • integer $length - the number of bytes to read
  • integer $sign - the sign

[ Top ]

_read_int_64

mixed _read_int_64( integer $bytes, integer $endian, integer $length, [integer $sign = self::UNSIGNED])

[line 1490]

Reads an integer for 64-bit machines

Tags:

  • return - a single value or an array
  • access - protected

Parameters:

  • integer $bytes - the bytes needed per integer
  • integer $endian - the endian mode: Little or Big Endian
  • integer $length - the number of bytes to read
  • integer $sign - the sign

[ Top ]

_read_value

array _read_value( string $vr, string $value_representation, integer $length, mixed $vr_mode, [mixed $endian = NULL])

[line 1110]

Read the value of an Tag element accordingly. No numeric values are interpreted. No reading of PN

Tags:

  • return - a list of $value, $value_representation, $is_binary, $items
  • access - protected

Parameters:

  • string $vr - the read VR
  • string $value_representation - the obtained VR
  • integer $length - the number of bytes to read
  • mixed $vr_mode - either the vr_mode already or the transfer syntax
  • mixed $endian - either NULL (not set so decode from transfer syntax), or the endian

[ Top ]

_read_value_from_blob

void _read_value_from_blob( object the &$elem, integer $group, integer $element)

[line 1081]

Read the value from the blob

Tags:

  • access - protected

Parameters:

  • object the &$elem - element array
  • integer $group - the group
  • integer $element - the element

[ Top ]

_rewind

void _rewind( [integer $position = 0])

[line 1659]

Set the current_pointer to a given value

Tags:

  • access - protected

Parameters:

  • integer $position - the new position, defaults to beginning of file

[ Top ]

_tell

integer _tell( )

[line 1689]

Finds current position of pointer

Tags:

  • return - current position of pointer
  • access - protected

Parameters:

[ Top ]

_update_group_length

void _update_group_length( integer $group)

[line 747]

Updates the group length value if exists

Tags:

  • access - protected

Parameters:

  • integer $group - the group

[ Top ]

_write

string _write( integer $group, integer $element, string $data)

[line 1291]

Creates a binary string from the current dataset

Tags:

  • return - the binary string
  • access - protected

Parameters:

  • integer $group - the group
  • integer $element - the element
  • string $data - the data

[ Top ]

_write_float

string _write_float( integer $value, integer $bytes, integer $length)

[line 1630]

Writes a float

Tags:

  • return - the binary value
  • access - protected

Parameters:

  • integer $value - the new value
  • integer $bytes - the bytes needed per integer
  • integer $length - the number of bytes to read

[ Top ]

_write_int_32

string _write_int_32( integer $value, integer $bytes, integer $endian, integer $length, [integer $sign = self::UNSIGNED])

[line 1572]

Writes an integer for 32-bit machines.

Tags:

  • return - the binary value
  • access - protected

Parameters:

  • integer $value - the new value
  • integer $bytes - the bytes needed per integer
  • integer $endian - the endian mode: Little or Big Endian
  • integer $length - the number of bytes to read
  • integer $sign - the sign

[ Top ]

_write_int_64

string _write_int_64( integer $value, integer $bytes, integer $endian, integer $length, [integer $sign = self::UNSIGNED])

[line 1552]

Writes an integer for 64-bit machines. Uses 32-bit function

Tags:

  • return - the binary value
  • access - protected

Parameters:

  • integer $value - the new value
  • integer $bytes - the bytes needed per integer
  • integer $endian - the endian mode: Little or Big Endian
  • integer $length - the number of bytes to read
  • integer $sign - the sign

[ Top ]

__call

mixed|false __call( string $name, $args)

[line 397]

Magic method to call an undefined method. It will look for methods on children Performance is better when called directly

Tags:

  • return - when the method if found in any children or false in case the method does not exist
  • access - public

Parameters:

  • string $name - tag element name
  • $args -

[ Top ]

__get

mixed __get( string $name)

[line 340]

Magic method, calls [Nanodicom::value] with the same parameters.

$view->foo = 'something';

Tags:

  • access - public

Parameters:

  • string $name - tag element name

[ Top ]

__set

mixed __set( string $name, mixed $value)

[line 354]

Magic method, calls [Nanodicom::value] with the corresponding group and element.

$dicom->name = 'something';

Tags:

  • access - public

Parameters:

  • string $name - tag element name
  • mixed $value - new value

[ Top ]

__toString

string __toString( )

[line 327]

Returns the name of the loaded file or 'blob'

Tags:

  • return - name of loaded file or 'blob'
  • access - public

Parameters:

[ Top ]

__unset

void __unset( string $name)

[line 373]

Magic method to unset a tag element

$dicom->name = 'something';

Tags:

  • access - public

Parameters:

  • string $name - tag element name

[ Top ]


Class Constants

BIG_ENDIAN =  100

[line 29]

[ Top ]

CODENAME =  'Majestic Arequipa'

[line 27]

[ Top ]

EXPLICIT_VR_BIG_ENDIAN =  '1.2.840.10008.1.2.2'

[line 35]

[ Top ]

EXPLICIT_VR_LITTLE_ENDIAN =  '1.2.840.10008.1.2.1'

[line 34]

[ Top ]

GROUP_LENGTH =  0x0000

[line 36]

[ Top ]

IMPLICIT_VR_LITTLE_ENDIAN =  '1.2.840.10008.1.2'

[line 33]

[ Top ]

ITEM =  0xE000

[line 43]

[ Top ]

ITEMS_GROUP =  0xFFFE

[line 42]

[ Top ]

ITEM_DELIMITER =  0xE00D

[line 44]

[ Top ]

LITTLE_ENDIAN =  101

[line 30]

[ Top ]

METADATA_GROUP =  0x0002

[line 37]

[ Top ]

SEQUENCE_DELIMITER =  0xE0DD

[line 45]

[ Top ]

SEQUENCE_VR =  'SQ'

[line 41]

[ Top ]

SIGNED =  101

[line 40]

[ Top ]

UNDEFINED_LENGTH =  -1

[line 38]

[ Top ]

UNSIGNED =  100

[line 39]

[ Top ]

VERSION =  '1.1'

[line 26]

[ Top ]

VR_MODE_EXPLICIT =  101

[line 32]

[ Top ]

VR_MODE_IMPLICIT =  100

[line 31]

[ Top ]


Documentation generated on Thu, 09 Dec 2010 16:19:32 -0800 by phpDocumentor 1.4.3