4

I have to train a neural net for semantic segmentation of kidney and his tumor, starting from the dataset available from the kiTS 19 Challenge. In this dataset, I have 100 CT scans for the training set, with a great variety in terms of size and pixel spacing. Studying several approaches on the internet, I found that it is a good practice to decide a unique set of pixel spacing that has to be the same for all the volumes (e.g. new_spacing = [2. , 1.5, 1.5]); by resampling the volumes to this new spacing, of course their dimensions will change according to this formula: new_size = original_size*(original_spacing/new_spacing).

What I did until now was using the scipy.ndimage.zoom in order to resample the volume to the desired new_spacing and new_size computed, then padding or cropping the obtained volume to the desired dimension (the dimensions for the input of the NN, which in my case are (n_slice, 512,512)). The problem is that this approach is really time-consuming, I'd need a faster way to do what I need to, is there any?

Pi.Lilac
  • 135
  • 1
  • 7
Saras
  • 41
  • 1
  • If you are trying to resample all images each time you feed them to the NN, better resample the images before running the NN. – Colim Aug 03 '22 at 12:20
  • @Colim actually, that's what I did before training the NN - I prepared the dataset in advance to speed up the training process. The problem is that the zoom slows me down in the second step of my project, where I need to test my cascade of 2D NN and 3D NN and obtain the segmentation mask for all the volumes that I have (210, considering the training, validation and test sets). This process requires an absurd amount of time (10 h only for training set), and I was able to understend that the problematic steps were in the zooms (30 s per resample). I still need a way to speed up the resampling. – Saras Aug 04 '22 at 15:48

1 Answers1

1

You can use itkResampleImageFilter, it is available in C++ which is the fastest. If you know about C++, you can use the Cpp version. Otherwise, you can use ResampleImageFilter in simpleItk which is available in many different languages. Note that you should do this step as preprocessing and before NN.

  • FYI, calling ResampleImageFilter in other languages shouldn't be any slower than the C++ version, since underneath they all it. – Dave Chen Jan 03 '23 at 18:20
  • You are right and all the other languages are actually a wrapper on C++ version, but the performance is not the same. – Mahdiye Imanpanah Jan 04 '23 at 07:39