module Dicomm:sig..end
Dicomm is a non-blocking streaming decoder to
decode DICOM data elements.
Consult the data model, features and limitations and examples of use.
Release 0.0.0-13-gaff23ca — Daniel Bünzli <daniel.buenzl i@erratique.ch>
typesyntax =[ `BE_explicit | `File | `LE_explicit | `LE_implicit ]
Dicomm.decoder.typevr =[ `AE
| `AS
| `AT
| `CS
| `DA
| `DS
| `DT
| `FD
| `FL
| `IS
| `LO
| `LT
| `OB
| `OF
| `OW
| `PN
| `SH
| `SL
| `SQ
| `SS
| `ST
| `TM
| `UI
| `UL
| `UN
| `US
| `UT ]
val pp_vr : Format.formatter -> vr -> unitpp_vr ppf vr prints an unspecified representation of vr on ppf.type tag
module Tag:sig..end
module Uid:sig..end
typetime =[ `Daytime of float | `Stamp of float * float option ]
`Stamp (u, tz) is used for `DA and `DT value representations.
u should be interpreted as an absolute time in POSIX seconds
since 1970-01-01 00:00:00 UTC. tz is a timezone offset in seconds.
If tz is None, time is in local time.`Daytime s is used for `TM, it's a time point in a day in seconds
since 00:00:00.val pp_time : Format.formatter -> time -> unitpp_time ppf t prints an unspecified representation of t on ppf.type('a, 'b)bigarray =('a, 'b, Bigarray.c_layout) Bigarray.Array1.t
typevalue =[ `Float32 of (float, Bigarray.float32_elt) bigarray
| `Float64 of (float, Bigarray.float64_elt) bigarray
| `Int16 of (int, Bigarray.int16_signed_elt) bigarray
| `Int32 of (int32, Bigarray.int32_elt) bigarray
| `String of [ `Many of string list | `One of string ]
| `Tag of [ `Many of Tag.t list | `One of Tag.t ]
| `Time of [ `Many of time list | `One of time ]
| `UInt16 of (int, Bigarray.int16_unsigned_elt) bigarray
| `UInt32 of (int32, Bigarray.int32_elt) bigarray
| `UInt8 of (int, Bigarray.int8_unsigned_elt) bigarray ]
`String for `AE, `AS, `CS, `DA, `DT, `LO, `LT,
`PN, `SH, `ST, `TM, `UI, `UT.`UInt8 for `OB, `UN`Int16 for `SS`UInt16 for `US, `OW`Int32 for `IS, `SL.`UInt32 for `UL.`Float32 for `FL, `OF`Float64 for `DS, `FD`Tag for `AT`Time is TODOval pp_value : ?limit:int -> Format.formatter -> [< value ] -> unitpp_value limit ppf v prints an unspecified textual representation
of v on ppf. limit is the maximal number of printed element
arrays.typeelement =Tag.t * vr * value
val pp_element : Format.formatter -> element -> unitpp_element names ppf v prints and unspecified textual representation
of v on ppf. If names is true (defaults to falsetypelexeme =[ `E of element | `I | `Se of Tag.t | `Ss of Tag.t ]
`Ss and `Se are respectively for
starting and ending sequences of data elements items (SQ value
representation).
A well-formed sequence of lexemes belongs to the language of
the dicom grammar:
dicom = `E e / `Es t *(`I dicom) `Ee t / dicom
A decoder returns only well-formed sequences
of lexemes or `Errors are returned.
val pp_lexeme : Format.formatter -> [< lexeme ] -> unitpp_lexeme names ppf l prints an unspecified textual representation of
l on ppf.typeerror =[ `Eoi of
[ `File_dicom_prefix
| `File_preamble
| `Reserved of Tag.t
| `Tag
| `Tag_or_eoi
| `Value of Tag.t
| `Value_length of Tag.t
| `Vr of Tag.t ]
| `File_syntax_unspecified
| `File_syntax_vr_not_uid of vr
| `Parse_file_dicom_prefix
| `Parse_float of Tag.t * string
| `Parse_int of Tag.t * string
| `Parse_time of Tag.t * string
| `Unknown_vr of Tag.t * string
| `Value_length_mismatch of Tag.t * int * int
| `Value_length_overflow of Tag.t
| `Value_length_undefined of Tag.t ]
val pp_error : Format.formatter -> [< error ] -> unitpp_error e prints an unspecified representation of e on ppf.typesrc =[ `Channel of Pervasives.in_channel | `Manual | `String of string ]
`Manual source the client must
provide input with Dicomm.Manual.src.type decoder
val decoder : ?vr:(Tag.t -> vr) ->
syntax:syntax -> [< src ] -> decoderdecoder private_tag file src is a DICOM decoder that inputs DICOM data
elements from src according to syntax.
If syntax is `File, the decoder first parses a DICOM file
preamble and the DICM prefix reporting an error if it fails to do
so. Decodes then return the DICOM file meta information and the
decoder automatically switch to the right syntax for decoding the
data object.
If decoding is done using the implicit syntax vr is called on
tags that return None on Tag.vr to determine the value representation
to use (defaults to fun _ -> `UN).
val decode : decoder ->
[ `Await | `End | `Error of error | `Lexeme of lexeme ]decode d is:
`Await if d has a `Manual source and awaits more imput.
The client must use Dicomm.Manual.src to provide it.`Lexeme l if a lexeme l was decoded.`End if the end of input was reached.`Error e if a decoding error occured. If the client is interested
in a best-effort decoding it can still continue to decode after an error
see Error recovery.val decoded_range : decoder -> int * intdecoded_range d is the range of bytes spanning the last `Lexeme or
`Error decoded by d.val decoder_src : decoder -> srcdecoder_src d is d's input source.val decoder_syntax : decoder -> syntaxdecoder_syntax d is d's decoded syntax.val pp_decode : Format.formatter ->
[< `Await | `End | `Error of error | `Lexeme of lexeme ] ->
unitpp_decode ppf v prints an unspecified representation of v on
ppf.module Manual:sig..end
After a decoding error, if best-effort decoding is performed. The following happens before continuing:
`Eoi _, `End is eventually returned.`File_syntax_unspecified, continues with `LE_implicit.`File_syntax_vr_not_uid, ignores the VR and parses as an UID.`Parse_int, `Parse_float, `Parse_time skips the data element.`Unknown_vr, continues assuming a UN value representation.`Value_length_overflow, skips the data element.`Value_length_undefined, skips the data element whose value
is assumed to be of 0xFFFFFFFF bytes (this may not be very useful).`Value_length_mismatch, skips the data element.
On decoding:
`AS is unparsed and returned as
a string.`IS are parsed with Int32.of_string and
`FS with float_of_string.Dicomm.Tag module.Dicomm.Tag.vr). In that case we unconditionally map
`OB_or_OW to `OW, `US_or_SS to `US, `US_or_OW to `US
`US_or_SS_or_OW to `US. Depending on contextual information
you may want to reinterpret that data differently,
see PS 3.5 Annex A.1.Sys.max_string_length, In each of these cases the error
`Size_overflow is returned and the data element is skipped.
Note that none of this should happen on 64 bits platforms.
This limitation could be lifted in future versions of the library.
On decoding for DICOM bitmap data, the pixel representation
tag (0028,0103) is captured and if tag (7FE0, 0010) has
a 16 bits representation the value is mapped to `UInt16 or `Int16
accordingly.