Mary PW Chin
钱碧慧博士 PhD (Wales), MSc (Surrey) E-mail:
Medical image processing
Slides here are continuously being revised and updated. If you have been here before, your browser might have some old files cached. To ensure that you see the latest version, please follow the instructions given in the following link:
☞ how to clear browser cache.
You would need the pydicom module/package by Darcy Mason. To check whether it is already installed on your system, go to the Python or IPython console and type in:
help("modules") From the long list of installed modules, look for 'dicom' or 'pydicom'.
If you are using PythonAnywhere, you may install pydicom by typing into your Bash console:
pip3.5 install --user pydicom
To be able to run the examples given in the slides, you need the anonymised DICOM datasets:
☞ download brain dataset (21M)
☞ download pelvis dataset (21M)
Download the dataset to your space.
If you are using PythonAnywhere, your space would be in the cloud, because that's where PythonAnywhere resides. So, you would need to first download to your computer, then upload to PythonAnywhere. The upload button can be found by clicking PythonAnywhere > Files. Look for the orange button at the bottom of the page.
If you are using your local computer, your space would be your local computer.
After downloading, go to the Bash console and type in:
tar xzf brain.tar.gz
tar xzf pelvis.tar.gz
to uncompress the compressed files.
3D arrays and array slicing;
Module dicom and its method read_file;
Module os and its method chdir;
Module glob and its method glob;
Module matplotlib, submodule pyplot and methods
subplots_adjust and its wspace and hpsace options;
imshow and its extent option;
Module numpy as its method transpose;
DICOM tags and headers.
For every program you encounter it is always an excellent exercise to change the variable names to names which are most meaningful to you, then make the program run. You will gain deeper understanding of the program. You will see the program in a new light. Everyone is different: variable names most intuitive to me differ from variable names most intuitive to you. My programs are written with variable names most intuitive to me, so you should change them to names most intuitive to you so that the program flow becomes more obvious.
Take the brain dataset, locate the midsagittal slice. That is, the sagittal slice that divides the head into right and left halves. Do a plot consisting 10 subplots arranged in 2 columns and 5 rows. On the first row, show the pair of sagittal slices immediately left and right of the midsagittal slice. Moving out symmetrically from the midsagittal slice, show the next pair of sagittal slices left and right of the midsagittal slice on the second row, and the next pair on the third row, and so on. The bottom row should then have the 5th sagittal slices left and right of the midsagittal slice.
Plot a histogram of pixel values. You may refer to 4th bite of Python. Note that for image processing involving physical meaning of the pixel values (e.g. Hounsfield Unit for CT, relaxation times for MRI, radionuclide uptake for PET), we need to obtain RescaleSlope (m) and RescaleIntercept (c) from the DICOM headers. The pixel values (x) should then be transformed linearly as mx + c.