MIScnn icon indicating copy to clipboard operation
MIScnn copied to clipboard

Strategies to Resampling?

Open innat opened this issue 3 years ago • 1 comments
trafficstars

Let's say, 3D data with shape (height, width, depth). Now, the depth is 100. After doing some eda, we've found that, out of 100 slices, most of them are black, especially at the beginning and at the end. Let's say, the middle range with (30 - 70) are the most informative slices.

Now, this was only with one 3D data. There might be a whole batch of 3D data with different numbers of depth slices. For example

h, w, 400
h, w, 200
h, w, 300
h, w, 250

Most of cases, the begging and ending slices are mostly black, and some middle slices have the most salient features. My question is, what are the best strategies are taken in this case to adaptively pick relevant slices?.

My current assumption is to calculate the approximate middle range. For example:

depth_list = range(volumes.shape[-1])

strt_idx = (len(depth_list) // 2) - (picl_slice // 2)
end_idx  = (len(depth_list) // 2) + (picl_slice // 2)

picked_slices = depth_list[strt_idx:end_idx:1]
volumes = np.take(volumes, picked_slices, axis=-1)

innat avatar Mar 29 '22 06:03 innat

Heyho @innat,

first of all: I would do a data exploration of depth ranges after applied resampling, to get a update range/histogram of depths with normalized voxel spacing (due to resampling will also dramatically impact shape size).

Then, you have various options:

  • You can resample to a smaller image shape to ensure that even large volumes are fully in scope of your patch shape (or the most of it, at least). You will see this approach most of the times in the latest challenges. However, obviously if you resample/resize it too small, you will loose resolution and, thus, important features/information in your image
  • Another quite simple approach is to perform a center crop. As you already told, most of the valuable information is in the middle/center. Thus, you can just crop out the center with a custom Subfunction for MIScnn based on the https://github.com/MIC-DKFZ/batchgenerators center_crop augmentation. This is often applied in lung analysis of CT scans because we know that the lung is always somewhere in the middle of our thorax CT.
  • "begging and ending slices are mostly black" if they are really lower than a specific threshold, you can use this by applying a bounding box approach with a custom Subfunction for MIScnn. By just identifying the the 4x corners with a value higher than your threshold, you can crop your image and remove the redundant edges from it. Mostly, this approach is used with a previously mask e.g. applying a lung mask on a thorax CT -> shrink volume according to mask of lung lobes -> obtain a smaller volume with minimal size.

There are probably more options, but these three are the most popular one I read in the literature and which came into my mind right now.

But be aware, that this operations will always remove information from your image even if you think that this information should not be important. E.g. COVID-19 severity if we want to stick to the lung thorax CT example. There is a correlation with obese patients and pneumonia severity, but if we apply a lung mask, we purely just analyze the lungs and throw away the remaining CT information which could indicate a high body fat ratio.

Hope that this helps with your issue.

Cheers, Dominik

muellerdo avatar Mar 30 '22 09:03 muellerdo

@muellerdo Hi, could you please transfer this ticket to the discussion tab? I think it suits there more.

innat avatar Aug 04 '23 18:08 innat