Segmentation visible only in 3D

Thank you for your answer. It makes a lot more sense now!

I’m working on a deep neural network to segment two bones in the hand from CT scans. I preprocess my input scans and save them after resampling. Then, I run my model to predict the segmentation and save it. I’m going to have a look at how I save my model predictions to fix this origin problem.

Thank you for the hint.

I would recommend using NRRD format, it is much simpler, it has a human-readable header, so you can immediately see if something is off, it is more flexible (as you can store arbitrary custom fields in it). Nifti has many issues, it only make sense to use it for brain imaging (that’s what it is developed for). I know that many people in the AI community use nifti was a general-purpose file format - I hope we can convince them to change this practice.

Thanks for the input. Unfortunately, the deep learning framework I’m using (MONAI) only supports writing the model outputs as NIfTI files or PNG files for segmentation tasks. So I guess I’ll have to find a way to make it work with this format :sweat:.

What deep learning framework do you use?

If the deep learning framework gives you access to the results as a numpy array then you can go and fix the output image (set the correct image origin, spacing, axis directions, and cast to unsigned short or unsigned char) and save it as nrrd (for example, using pynrrd).

If the deep learning framework does not give you access to the data set, only to files, then ask the developers to fix these issues for you.

Deep learning developers are often not familiar with common conventions in medical image computing and don’t preserve essential metadata and choose suboptimal data types and formats. If your collaborators are not sure what fixes they need to make and how, you can direct them to the Slicer forum so that we can help them.

1 Like

I’m using MONAI and I do have access to the torch tensor. So, I could convert it to a numpy array and then save it as nrrd. Thanks for the tip :+1:t2:

Great. We will work together with MONAI developers at the upcoming Slicer project week to ensure they better integrate with applications.

Did you start from one of their tutorial notebooks? Which one? Maybe just that notebook needs to be fixed up.

I used the spleen tutorial and this script as a basis, and then did some minor tweaks to make it work with my custom dataset. I posted an issue today to see how we could fix this problem on MONAI’s GitHub.

1 Like