An Introduction to Python-based MRI Data Analysis: mini-project III/VIII
EJZ (Polytechnique Montreal, Sainte-Justine Hosptical Research Center (UdeM) )
This project is about diffusion magnetic resonance imaging (dMRI) data processing and analysis. It mainly consists of three parts: brain dMR data preprocessing, dMRI reconstruction, data visualization and left and right hemispherical preprocessed MR images classification.
With reproducibility being a primary concern, this project was completed by using open-source softwares/tools (Python, FSL, DIPYPE...) and dataset (dHCP and PRIME). With this project, you can have a general idea of dMRI processing and analysis. It can be used as a simple warmup project for new students in neuroscience (dMRI brain imaging).
Low blood sugar is a common problem in both children and adults. Existing research showed that it may lead to serious both transient and permanent structural abnormalities on brains. Magnetic resonance imaging (MRI), specially diffusion MRI, has a higher in vivo sensitivity to lesions in soft tissues compared to other imaging modalities, and has potential to identify and quantify brain structure changes. Some of these changes are not appraient enough,even for experienced experts. Machine learning is a useful method to discover potential features.
Currently, there are some open-source softwares to reconstruct and analyze diffusion MRI data. However, only using these tools, one, like me as a new student in this field, may get confused about operations and principle behind them. This seriously stops people to reach their long-term goals in their diffusion MRI project.
Thus, I began this project to preprocess dMRI data, reconstruct diffusion MR images and do some analysis by using machine learning. The goals are as following:
- Data Preprocesssing Get preprocessed diffusion MR images from raw MRI data;
- Image Reconstruction Reconstruct diffusion tensor images from the preprocessed data;
- Machine Learning Classsification By using machine learning, randomly choose left or right hemispheres on each slice of MRI images preprocessed above and find method to give results that which part it is belonging to (right or left?).
The "Diffusion MRI reconstruction project" will rely on the following tools:
- Python3: coding language used to complete this project (Python2 also needed for some special packages).
- Github and git: to organize this project and make version control
- Jupyter Notebook: to file code, visualizations and results
- Markdown, to structure the text in README and Jupyter Notebook
- Visual Studio Code: to be code editor
- Nipype: to use FSL command preprocessing image data
- DIPY: to be used as diffusion tensor imaging (DTI) fitting and denoising
- matplotlib, plotly and ipython widgets: data visualization
- Linux (Ubuntu 20.04)
This project used data from online dataset offered by:
- The Developing Human Connectome Project. It consists of over 800 neonatal scans and over 250 fetal scans and can be used for data analysis after image reconstruction.
- PRIME: used this dataset to reconstruct diffusion Images. This also can be downloaded here directly.
- Since during preprocessing, we used EPI data with two opposite phase-encoding directions to correct distortions, other data can also be used as the source data if it meets this requirement.
- Data used for analysis is generated from image data after preprocessing. The final data can be found in this github project folder.
At the end of this project, we will have: Jupyter notebook will be developed, allowing diffusion MR reconstruction and data analyzation. Weekly Deliverables are as following:
- Week 1: Assignment 2
- Week 2: README file
- Week 3: Data visualization
- Week 4: Project report and project prosentation
- Data Visualization (see gif figure below):
- 3D volume slices image
- Show different slices of images;
- Change observe view point;
- Play animation;
- Interactive widgets use to show preprocessed results
- Select different maps;
- Select slices;
- Select maximum diffusion sthrength;
- Display title
- Interactive widgets use to show reconstruction results;
- Play different maps;
- Select slices;
- Slect maximum diffusion sthrength;
- Display give title.
- Interactive widgets 2 use to show preprocessed results
- play different maps;
- Select slices;
- Select maximum diffusion sthrength;
- Display title.
-
Method
- Load diffusion weighted image data and set data path;
- Denoise data by using MP-PCA method of DIPY;
- Correct distortion by using FSL TOPUP;
- Extract brain and create brain mask by using FST bet;
- Correct head movement artifacts by using FSL EDDY;
- Extract maps from 4D data and show results.
-
Results
- DTI reconstruction
-
Method
- DIPY was used to fit tensor model;
- Different maps were saved;
- Colored diffusion map was coded and saved;
- Show maps
-
Results
- Left and right hemispheres classification
-
Method
- 80 Slices of brain images (40 left hemisphere slice and 40 right hemisphere) were extracted and transfered to brain parts classification;
- Left hemisphere brain image and right hemisphere brain iamge were taged with 0 and 1 specifically;
- Slice number was treated as one of features used for classification;
- Diffusino strength of each slice hemisphere was calculated as the second feature of classification;
- Total effictive voxel of eahc slice hemisphere was calculated as the third feature for classification;
- Dataset was splitted into train dataset (70%) and test dataset (30%);
- Use KNN to classify
-
Classification Reports
Since May 11, this project goes well and three goals of this project have been reached. This is just to let me be familiar with steps and tools of diffusion MRI processing. Next, I will combine different processing methods into this project. Specifically, I would like to look deep into DTI model fitting and try to replace it by a new model created by myself.
- Python
- FSL, Nipype.interfaces, DIPY
- matplotlib, plotly, ipywidgets
- Function definition and calling
- Markdown
- Format this README file
- Insert figures and animation
- LaTex to edit mathematical equations
- Github
- Version control
- Project organization
- BIDS
- Jupter notebook
- Found and learnt to use some small but useful tools
- Medical file format (NII) and data structure (BIDS)
- Statistical method and machine learning
This project started with medical imaging data format, then preprocessed the diffusion weighted images, which includes MP-PCA denoising, FSL TOPUP distortion correction and head movement correction. After this, DTI images were reconstructed from these preprocessed images successfully. Additionally, a dataset for left and right hemispheres classification was generated from these preprocessed images. By using the KNN method, classification accuracy of 92% was reached. In the future, self-made models, instead of DTI model, will be used to reconstruct diffusion images. Machine learning methods will also be used to classify potential changes of brain microstructures.
Acknowledgement
Thanks to Brainhack Summer School 2020 and all instructors. Specifically, I would like to thank my instructors Noor, Greg and Agah for your advice, instruction and encouragement. I would also like to thank all the summer school students, just because of you, I know how wonderful the neuroscience world is and how active the neuroscience group is! This work was completed in Magic Lab, TransMedTech Institute, CHU Saint-Justine Hospital and NeoroPoly Lab at Polytechnique.