profile

Machine Learning for Medical Imaging

MRI data in Machine Learning

Published 10 months agoΒ β€’Β 3 min read

Hi Reader,,

Welcome to the PYCAD newsletter, where every week you receive doses of machine learning and computer vision techniques and tools to help you learn how to build AI solutions to empower the most vulnerable members of our society, patients.

​

​

MRI scan : not your typical image

When working with MRI data in ML, you might see: H x W x D x 4.

What do these values represent? And are they different from H x W x C that we find in typical images?

First, you should know that this type of data is referred to as volumetric data.

This is a term that we typically use when we refer to 3 dimensional data.

Now, let’s get back to the values in H x W x D x 4.

H and W refer to the same thing as in typical images, which are height and width.

D here actually represents the number of slices in an MRI scan.

In a lot of medical imaging applications, we take a scan of a whole region in 3D. The way this is done is by taking 2D scans but at multiple levels.

So if D is the number of slices, what does the 4 represent?

Well actually, the number 4 refers to the number of modalities in the input data. Sometimes also referred to as channels, but I think modalities is a better term here.

In MRI scans you can find 4-modalities based scans, which would typically refer to:

  • T1-weighted scans.
  • T1-weighted scans with contrast enhancement (T1c).
  • T2-weighted scans.
  • T2 Fluid-Attenuated Inversion Recovery (FLAIR) scans.

With this in mind, how do we refer to one unit of data in an MRI scan?

We refer to it as a voxel which means volume pixel.

But what does 1 voxel represent in a H x W x D x 4 MRI scan?

Each voxel represents a tiny cube of tissue, and the value of the voxel corresponds to the radio signal intensity measured from that small volume of tissue.

This means that each voxel actually contains four values, one from each type of scan (T1, T1c, T2, FLAIR).

So if you’re reading some ML paper about some neural network that is used for medical imaging, you now know what the inputs of the neural network represent.

Why do you need to know this?

If you're working with MRI scans for any type of application whether that be machine learning or just simple visualization, you need to know how your data is constructed. This gives you the ability to manipulate your data and apply any type of transformation to it to address the problem that you're trying to solve.

Visualizing NIFTI files in Python

Lately I was working on a medical imaging project where I needed to visualized my NIFTI files directly in Python.
​
I tested several options, here's one of them that worked effortlessly!
​
I used a python package called k3d.
​
With a few lines of code you can visualize a 3D model of your NIFTI file directly inside your Jupyter notebook!
​
Now, I personally don't work a lot with jupyter notebooks and I prefer pure python scripts.
​
But the fact that I was able to visualize my NIFIT file quickly was a big positive for me!
​
Below you can see a sample code of a simple function that uses k3d to visualize any NIFTI file.
​
More on k3d package can be found here.

Why do you need to know this?

A lot of times when you're working with medical imaging data in NIFTI format, you'll need to do some sort of visualization to see if your data is correctly formatted or to see if a transformation you applied is doing what you want it to do. This kind of experimentation can be done directly in a Jupyter Notebook. So to be able to visualize data directly in the notebook will help you quickly solve any issues and build a solution to your problem.


​

​

What'd you think of today's edition?

​

​

That's it for this week's edition, I hope you enjoyed it!

​

Machine Learning for Medical Imaging

by Nour Islam Mokhtari from pycad.co

πŸ‘‰ Learn how to build AI systems for medical imaging domain by leveraging tools and techniques that I share with you! | πŸ’‘ The newsletter is read by people from: Nvidia, Baker Hughes, Harvard, NYU, Columbia University, University of Toronto and more!

Read more from Machine Learning for Medical Imaging

Hi Reader,, Welcome to the PYCAD newsletter, where every week you receive doses of machine learning and computer vision techniques and tools to help you learn how to build AI solutions to empower the most vulnerable members of our society, patients. TotalSegmentator : Whole Body Segmentation at your Fingertips This free tool available online can do full body segmentation, it's called TotalSegmentator. I have already mentioned this tool in a previous edition of the newsletter, but in this...

9 days agoΒ β€’Β 3 min read

Hello Reader, Welcome to another edition of PYCAD newsletter where we cover interesting topics in Machine Learning and Computer Vision applied to Medical Imaging. The goal of this newsletter is to help you stay up-to-date and learn important concepts in this amazing field! I've got some cool insights for you below ↓ A Medical Imaging Expert Told Me This Recently I saw a post on LinkedIn where a medical imaging expert showcased his work of segmenting the lungs and its bronchial trees. You can...

16 days agoΒ β€’Β 2 min read

Hello Reader, Welcome to another edition of PYCAD newsletter where we cover interesting topics in Machine Learning and Computer Vision applied to Medical Imaging. The goal of this newsletter is to help you stay up-to-date and learn important concepts in this amazing field! I've got some cool insights for you below ↓ How we helped accelerate inference time for a client's AI product Below is a screenshot of a benchmark we did for a client of ours. The goal was to accelerate inference time. This...

22 days agoΒ β€’Β 3 min read
Share this post