# Resampling in the direction where labelmap spans only one slice

**URL:** https://discourse.slicer.org/t/resampling-in-the-direction-where-labelmap-spans-only-one-slice/30789
**Category:** Radiomics
**Tags:** resample
**Created:** [July 25, 2023, 7:06pm UTC](https://discourse.slicer.org/t/resampling-in-the-direction-where-labelmap-spans-only-one-slice/30789 "2023-07-25T19:06:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![msahin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/msahin/32/66973_2.png) [@msahin](https://discourse.slicer.org/u/msahin)
#### Post date: [July 25, 2023, 7:06pm UTC](https://discourse.slicer.org/t/resampling-in-the-direction-where-labelmap-spans-only-one-slice/30789/1 "2023-07-25T19:06:43Z")

</div>

Hi everyone,

I am working on extracting radiomics features from MR images. In my dataset, some ROIs span only a single slice. On imageoperations.py I read a comment saying “Do not resample in those directions where labelmap spans only one slice.” I was wondering about the reason for this. Is there a way within PyRadiomics to allow me to resample such cases to make them isotropic?

Thanks,  
Meryem

---

<div class="post-metadata">

### Author: ![msahin](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/msahin/32/66973_2.png) [@msahin](https://discourse.slicer.org/u/msahin)
#### Post date: [July 26, 2023, 10:47am UTC](https://discourse.slicer.org/t/resampling-in-the-direction-where-labelmap-spans-only-one-slice/30789/2 "2023-07-26T10:47:37Z")

</div>

I have found a way to resample such cases. I have changed a line in imageoperations.py from:

```auto
 # Do not resample in those directions where labelmap spans only one slice.
  maskSize = numpy.array(maskNode.GetSize())
  resampledPixelSpacing = numpy.where(bb[Nd_mask:] != 1, resampledPixelSpacing, maskSpacing)

```

to:

```auto
 # Do not resample in those directions where labelmap spans only one slice.
  maskSize = numpy.array(maskNode.GetSize())
  resampledPixelSpacing = numpy.where(bb[Nd_mask:] != 0, resampledPixelSpacing, maskSpacing)

```

This seemed to help with my problem.
