Demo - Intereacting With MIDRC CT Scan Images

Please note: This notebook uses open access data

In this demo we will review how to import MIDRC imaging data, how to convert CT scan images from dicom (dcm) formats to png and jpeg formats, and how to view these CT scan images. This demo will also show how to extract file and patient metadata from the header of dicom (dcm) files.

Import Data And Packages

Import the packages pydicom, pillow, and dicom_csv, as well as pandas, os and numpy. If any of these packages are not already installed to your workspace you can run one of the following:

Import data objects of CT scan images using the gen3 SDK


All 10 data objects are now stored under the folder 'COVID-19-NY-SBU'

View Image

Read the dcm image using the relative file path.

Get the pixel arrays for the image.

Scale the image's pixel array and convert to a uint8 integer.

Use the Image package to convert the image array and show the image.

Convert Images

Convert images form dcm format to jpeg and png formats and place converted image format to the original image folder.

Convert dicom image to png and save.

Convert dicom image to jpg and save.

Display a few dicom images.

Extract Metadata

The following function will extract the file and patient metadata from the header of each dicom (.dcm) file within a given folder and place the collected metadata into a pandas dataframe.

Included in this metadata are import pieces of file and patient data, such as the body part examined, the patient's sex, the patient's age, etc.