Learn R Programming

oro.dicom (version 0.5.3)

str2time: Convert DICOM Time/Date Entry

Description

The DICOM time entry (TM) is converted into two alternative formats: a text version of the original format and a number in seconds. The DICOM date entry (DA) is converted into a simple alternative format.

Usage

str2time(tt, format.out = "%02i:%02i:%08.5f")

str2date(dd, format.in = "%Y%m%d", format.out = "%d %b %Y")

Arguments

tt

TM field from a DICOM header.

dd

DA field from a DICOM header.

format.in, format.out

Appropriate formatting of input or output.

Value

For “TM”, a list structure containing two fields

txt

A text version of the time where colons have been inserted for readability.

time

Time in seconds from midnight.

for DA, a simple character string.

Details

DICOM “TM” format consists of a string of characters of the format hhmmss.frac; where hh contains hours (range “00” - “23”), mm contains minutes (range “00” - “59”), ss contains seconds (range “00” - “59”), and frac contains a fractional part of a second as small as 1 millionth of a second (range 000000 - 999999). A 24 hour clock is assumed. Midnight can be represented by only 0000 since 2400 would violate the hour range. The string may be padded with trailing spaces. Leading and embedded spaces are not allowed. One or more of the components mm, ss, or frac may be unspecified as long as every component to the right of an unspecified component is also unspecified. If frac is unspecified the preceding “.” may not be included. Frac shall be held to six decimal places or less to ensure its format conforms to the ANSI HISPP MSDS Time common data type. Examples:

1.

070907.0705 represents a time of 7 hours, 9 minutes and 7.0705 seconds.

2.

1010 represents a time of 10 hours, and 10 minutes.

3.

021 is an invalid value.

Notes: For reasons of backward compatibility with versions of this standard prior to V3.0, it is recommended that implementations also support a string of characters of the format hh:mm:ss.frac for this VR.

DICOM “DA” format A string of characters of the format yyyymmdd; where yyyy shall contain year, mm shall contain the month, and dd shall contain the day. This conforms to the ANSI HISPP MSDS Date common data type. Example:

1.

19930822 would represent August 22, 1993.

Notes: For reasons of backward compatibility with versions of this standard prior to V3.0, it is recommended that implementations also support a string of characters of the format yyyy.mm.dd for this VR.

References

Digital Imaging and Communications in Medicine (DICOM) http://medical.nema.org http://en.wikipedia.org/wiki/Digital_Imaging_and_Communications_in_Medicine

See Also

readDICOM

Examples

Run this code
# NOT RUN {
str2date("19930822")
str2time("112308")

# }

Run the code above in your browser using DataLab