I built UNet3D from scratch. Painfully


Hi Reader!

I hope you're doing well in this fine weekend!

In the past weeks I've been working on implementing basic image segmentation models for 2D and 3D from scratch.

While doing so, I found a few things that were delightfully surprising while other things were painfully irritating. I tell you all about it in this edition of the newsletter!

What Building AI Models from Scratch has Thought me

One of the reasons why I did these experimentations was to understand some of the nitty gritty details about some basic semantic segmentation models like UNet and UNet3D.

If you read open source code online about these models implementation then you'll notice how "simple" it is to implement them. But only when you get your feet wet by implementing these models from scratch, you'll start to notice those small details that you didn't think about when you first started the implementation.

Some of the things that I didn't quite pay attention in the beginning were how different SimpleITK and numpy look at the 3D volumes.

In memory, SimpleITK "sees" my 3D scans like CT or MRI in the format of (X, Y, Z), where:

  • X: Represents the column within each slice.
  • Y: Represents the row within each slice.
  • Z: Represents the slice or depth of the volume.

While in memory numpy "sees" these 3D scans in the format (Z, Y, X).

This is very important to pay attention to. Because when you call the SimpleITK function GetArrayFromImage(), it alters the axis from SimpleITK format to numpy format.

There are other technical things that noticed but I'm not going to cover them all today to not dry out the content 😂

This surprised me

One thing that delightfully surprised me was how easy it was to implement the 3D version of UNet once you implement the 2D version. So if you've implemented 2D UNet before you'll be able to code the 3D version rather quickly.

The difficulty in the 3D segmentation pipeline was the data handling side. How to prepare data, preprocess it and how to feed it to the network.

This irritated me

On the other hand, one thing that irritated me was trying to find cheap but reliable online servers to train my models.

My laptop is not that powerful so I always look for online servers.

Although in the past years I've been mostly using servers from big cloud providers, especially GCP, I am now finding them to be more and more expensive and not easily rentable. In fact, in many instances I had to wait for hours and sometimes days before some of the servers that I wanted became available.

And don't even get me started on the quota stupidity that these big cloud providers require for small accounts.

What I wanted

When it comes to renting online virtual machines or online servers, what I wanted is a solution that allowed me to rent a VM with a few clicks while making it affordable to do so.

The 2 solutions that I found so far are vast.ai and runpod.

But between the 2, I must say that runpod is the best. This is because the servers that rented (they call them pods) worked exactly as expected.

While for vast.ai, I noticed a couple of problems when I was running my trainings and it cost me time and money!

Have You Ever Needed to Download Datasets Directly to your Google Drive?

I deal with large datasets every day.

Medical imaging datasets, especially 3D datasets that contain CT or MR scans are usually pretty big.

A lot of these datasets are found online on different websites.

I personally like to download them and save them in some place for future use. This place is usually my google drive.

I used to download those datasets to my local machine then upload them manually to my google drive.

But now, what I do is:

  • Start a google colab.
  • Connect it to my drive.
  • Run wget command to download the dataset from anywhere on the web directly on my google drive.

If you didn’t think of this before (like I didn’t) now you know.

Now go save those precious datasets that are scattered all over the internet!

Business Opportunity in Medical Imaging Field

You guys have told me that you liked this section of the previous edition of the newsletter so I'm keeping it! At least until I run out of ideas for these business opportunities 😂

The opportunity that I have for you this week is about Blender plugins that solve medical imaging problems.

I know it sounds strange, but actually, some people are developing Blender plugins because some clinicians actually use this tool when working on some of their pre-surgical plans.

If you don't know what Blender is, it's a software that is used to design 3D scenes and structures. It's free and very powerful!

You can add a PAID plugin to this software which should solve a particular problem in medical imaging.

One such plugin is BlenderForDental. When you check their website you'll see their Blender plugins for dentistry.

So there is definitely an opportunity here for building more plugins that can be used to solve particular problems in medical imaging.

So instead of dentistry, you can think of orthopedics or other similar domains and then see how to build a plugin to help them with their pre-surgical planning.


Share with friends, get 30 carefully chosen colab notebooks for Medical AI!

Have friends who'd love our newsletter too?

Give them your unique referral link (below) and get access to 30 colab notebooks for medical AI that we handpicked them just for you!

[RH_REFLINK GOES HERE]

PS: You have referred [RH_TOTREF GOES HERE]/1 people so far

⚡️ by SparkLoop

We Can Help You with Your Next Medical Imaging Project

If your company or organization is looking to build a machine learning solution for a medical imaging problem, then feel free to reach out to us at:

contact@pycad.co

We can help you build a full ML solution from training to deployment with affordable rates!

You can check out some of the projects that we worked on here:

https://pycad.co/portfolio and some of our clients case studies here.


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

Machine Learning for Medical Imaging

👉 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, I haven't sent you a newsletter email for some time now. This is because there are major events happening in my personal life. We just had our first kid, so I'm still trying to adapt to the new routine set by this cute little creature! I also changed my office! I used to work from home, but now I am working in a coworking space. I'm hoping that this will help me deliver more value to the newsletter subscribers as well as our clients at PYCAD. Now, back to the newsletter! I've got...

Dental implant - Wikipedia

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 ↓ Applications of Machine Learning for Dentistry At PYCAD, we have worked a lot on the applications of AI to the dentistry domain. Here are 3 incredible ones. 1 - Diagnosis and...

photo

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 ↓ 3 Resources we released in the past 2 weeks for nnUNet In the past 2 weeks we released a ton of information about how to nnUNet to build powerful medical imaging segmentation...