Whats a DICOM file and How do you access data in it?

Okay, so a DICOM file is a file that follows a standard for medical imaging and related data and stands for “Digital Imaging and Communications in Medicine” - (DICOM). 

 

Doctors usually utilize DICOM for storing medical image files, commonly used for medical radiation imaging. It's the standard format that CT scans, X-rays and MRIs come in.

 

You can go to the link below and view an example here:

https://www.dicomlibrary.com/meddream/?study=1.2.826.0.1.3680043.8.1055.1.20111103112244831.40200514.30965937 

 

 

Image Below:

 

So when we download and unzip this file, it’s title is image-00000.dcm.

 

Now in your linux or mac os command line, make sure you have pydicom installed.

pip3 install pydicom

Then create a python script, you can do this with the command line.

vim dicom-info.py

Then save the file with :w and hold shift then press zz to exit.

 

Paste the following code into the python file opened with a file editor.

import pydicom

ds = pydicom.dcmread("./image-00000.dcm")
print(ds)

Note the pathway to the file here assumes that the downloaded DICOM file is in the same directory as they python script.

 

Run the python script.

python3 dicom-info.py > dicom-info.txt

Dicom-info.txt will look like this:

 

Dataset.file_meta -------------------------------

(0002, 0000) File Meta Information Group Length  UL: 212

(0002, 0002) Media Storage SOP Class UID         UI: Secondary Capture Image Storage

(0002, 0003) Media Storage SOP Instance UID      UI: 1.2.826.0.1.3680043.8.1055.1.20111103112244831.30826609.78057758

(0002, 0010) Transfer Syntax UID                 UI: Implicit VR Little Endian

(0002, 0012) Implementation Class UID            UI: 1.2.826.0.1.3680043.8.1055.1

(0002, 0013) Implementation Version Name         SH: 'dicomlibrary-100'

(0002, 0016) Source Application Entity Title     AE: 'DICOMLIBRARY'

-------------------------------------------------

(0008, 0000) Group Length                        UL: 182

(0008, 0008) Image Type                          CS: ['ORIGINAL', 'SECONDARY', 'OTHER', 'ARC', 'DICOM', 'VALIDATION']

(0008, 0016) SOP Class UID                       UI: Secondary Capture Image Storage

(0008, 0018) SOP Instance UID                    UI: 1.2.826.0.1.3680043.8.1055.1.20111103112244831.30826609.78057758

(0008, 0060) Modality                            CS: 'OT'

(0008, 0064) Conversion Type                     CS: 'WSD'

(0010, 0000) Group Length                        UL: 28

(0010, 0010) Patient's Name                      PN: 'Anonymized'

(0010, 0020) Patient ID                          LO: '0'

(0020, 0000) Group Length                        UL: 164

(0020, 000d) Study Instance UID                  UI: 1.2.826.0.1.3680043.8.1055.1.20111103112244831.40200514.30965937

(0020, 000e) Series Instance UID                 UI: 1.2.826.0.1.3680043.8.1055.1.20111103112244831.29109107.29203688

(0020, 0012) Acquisition Number                  IS: "1"

(0020, 0013) Instance Number                     IS: "1"

(0028, 0000) Group Length                        UL: 90

(0028, 0002) Samples per Pixel                   US: 1

(0028, 0004) Photometric Interpretation          CS: 'MONOCHROME2'

(0028, 0010) Rows                                US: 512

(0028, 0011) Columns                             US: 512

(0028, 0100) Bits Allocated                      US: 8

(0028, 0101) Bits Stored                         US: 8

(0028, 0102) High Bit                            US: 7

(0028, 0103) Pixel Representation                US: 0

(7fe0, 0000) Group Length                        UL: 262152

 

(7fe0, 0010) Pixel Data                          OW: Array of 262144 elements

 

To view the dicom files image content I recommend downloading https://horosproject.org/ which is a free open source software to view dicom files.

 

Thanks for reading.

 

 

- Dom

Oct. 19, 2020, 8:15 p.m.

1 LIKES