Linux/DICOM: Create DICOM Video

PHOTO EMBED

Sun Aug 28 2022 12:58:32 GMT+0000 (UTC)

Saved by @marcopinero #bash

#Using dcm4che:

#capture:
$ ffmpeg -an -f video4linux2 -s 640x480  -r 30 -i /dev/video0 -vcodec mpeg4 -vtag DIVX my_test.avi

# convert:
$ jpg2dcm -c mpg2dcm.cfg -ts 1.2.840.10008.1.2.4.100 <mpegfile> <dcmfile>

//---------------------------------------------------------------------

#Send to pacs: dcmtk:
$ dcmsend -d -aec AETITLE <ip address> <dicom port> <dcmfile>

//---------------------------------------------------------------------

#Video props:

$ mplayer video.wmv -identify -vo null -ao null -frames 0 2>&1 /dev/null | egrep "(^ID|VIDEO|AUDIO)"

//---------------------------------------------------------------------

# Use/compare mpg2dcm.config: (at DCM4CHE/BIN/JPG2DCM)

//---------------------------------------------------------------------

# jpg2dcm Sample Configuration for encapsulating MPEG2 MP@ML streams into
# DICOM Video Photographic Image objects
# (s. DICOM Part 3, A.32.7 Video Photographic Image IOD)
# Usage: jpg2dcm -c mpg2dcm.cfg -ts 1.2.840.10008.1.2.4.100 <mpegfile> <dcmfile>

# Patient Module Attributes
# Patient's Name
00100010:
# Patient ID
00100020:
# Issuer of Patient ID
#00100021:
# Patient's Birth Date
00100030:
# Patient's Sex
00100040:

# General Study Module Attributes
# Study Instance UID
#0020000D:
# Study Date
00080020:
# Study Time
00080030:
# Referring Physician's Name
00080090:
# Study ID
00200010:
# Accession Number
00080050:
# Study Description
#00081030:

# General Series Module Attributes
# Modality
00080060:XC
# Series Instance UID
#0020,000E:
# Series Number
00200011:1

# General Equipment Module Attributes
# Manufacturer
00080070:

# General Image Module Attributes
# Instance Number
00200013:1

# Cine Module Attributes
# Frame Time [525-line NTSC]
#00181063:33.33
# Frame Time [625-line PAL]
00181063:40.0
# Multiplexed Audio Channels Description Code Sequence
003A0300

# Multi-frame Module Attributes
#Number of Frames (use dummy value, if unknown)
00280008:1500
# Frame Increment Pointer
00280009:00181063

# Image Pixel Module Attributes (MUST be specified for encapsulating MPEG2 streams)
# (s. DICOM Part 5, 8.2.5 MPEG2 MP@ML IMAGE COMPRESSION for details)
# Samples per Pixel
00280002:3
# Photometric Interpretation
00280004:YBR_PARTIAL_420
# Planar Configuration
00280006:0
# Rows
00280010:480
# Columns
00280011:640
# Bits Allocated
00280100:8
# Bits Stored
00280101:8
# High Bit
00280102:7
# Pixel Representation
00280103:0

# Acquisition Context Module Attributes
# Acquisition Context Sequence
00400555

# VL Image Module Attributes
# Image Type
00080008:ORIGINAL\\PRIMARY
# Lossy Image Compression
00282110:01

# SOP Common Module Attributes
# SOP Class UID
00080016:1.2.840.10008.5.1.4.1.1.77.1.4.1
# SOP Instance UID
#00080018

#----------------------------------------------------------------------------
#convert video to frames:

$ ffmpeg -i test.mp4 -r 24 -f image2 test_files/%05d.png

#----------------------------------------------------------------------------
content_copyCOPY