current development SimpleITK

I have a script that loads a tiff image using tifffile into numpy and converted to sitk, and apply a transform stack on the image. It works with an older version of SimpleITK but not the latest.

The latest version of SimpleITK installed with:
pip install --upgrade --pre SimpleITK --find-links

It processes the files up until the 18th transform and then gives this weird error that I don’t get when running the same script with the last release version (simpleitk-1.2.2):

I understand what it’s saying to the extent that there is a mismatch in the images sizes, but I don’t know how to debug it or maybe flush some kind of cache or wait until the image has been fullly read?

the moving image (17, 18)
Debug: ResampleImageFilter (0x7fbe26e9f1a0): Executing ITK filter:
ResampleImageFilter (0x7fbe2710e390)
  RTTI typeinfo:   itk::ResampleImageFilter<itk::Image<unsigned char, 2u>, itk::Image<unsigned char, 2u>, double, double>
  Reference Count: 1
  Modified Time: 18042
  Debug: Off
  Object Name: 
    Primary: (0x7fbe2710b910) *
    ReferenceImage: (0x0)
    Transform: (0x7fbe2710ea40) *
  Indexed Inputs: 
    0: Primary (0x7fbe2710b910)
    1: ReferenceImage (0x0)
  Required Input Names: Primary, Transform
  NumberOfRequiredInputs: 1
    Primary: (0x7fbe2710e530)
  Indexed Outputs: 
    0: Primary (0x7fbe2710e530)
  NumberOfRequiredOutputs: 1
  Number Of Work Units: 4
  ReleaseDataFlag: Off
  ReleaseDataBeforeUpdateFlag: Off
  AbortGenerateData: Off
  Progress: 0
    RTTI typeinfo:   itk::PoolMultiThreader
    Reference Count: 1
    Modified Time: 18011
    Debug: Off
    Object Name: 
    Number of Work Units: 4
    Number of Threads: 4
    Global Maximum Number Of Threads: 128
    Global Default Number Of Threads: 4
    Global Default Threader Type: PoolMultiThreader
    SingleMethod: 0
    SingleData: 0x0
  DynamicMultiThreading: On
  CoordinateTolerance: 1e-06
  DirectionTolerance: 1e-06
  DefaultPixelValue: 243
  Size: [1024, 1024]
  OutputStartIndex: [0, 0]
  OutputSpacing: [4.04, 4.04]
  OutputOrigin: [0, 0]
  OutputDirection: 1 0
0 1

  Transform: 0x7fbe26d4b300
  Interpolator: 0x7fbe2710e850
  Extrapolator: 0x0
  UseReferenceImage: Off

Traceback (most recent call last):
  File "", line 217, in <module>
  File "", line 178, in main
    mean = utils.get_mean_edges(t_sitk)
  File "/Users/sansomk/code/python/Tools/hist/", line 205, in resample_1_rgb
    new_image = filter_.Execute(t_sitk)
  File "/Users/sansomk/anaconda3/envs/reg/lib/python3.7/site-packages/SimpleITK/", line 59346, in Execute
    return _SimpleITK.ResampleImageFilter_Execute(self, *args)
RuntimeError: Exception thrown in SimpleITK ResampleImageFilter_Execute: /Users/runner/runners/2.164.7/work/1/sitk/Code/Common/src/sitkPimpleImageBase.hxx:75:
sitk::ERROR: The image has a LargestPossibleRegion of ImageRegion (0x7fbe2710ba50)
  Dimension: 2
  Index: [0, 0]
  Size: [1024, 1024]
 while the buffered region is ImageRegion (0x7fbe2710baa0)
  Dimension: 2
  Index: [0, 0]
  Size: [1024, 971]

SimpleITK does not support streamming or unbuffered regions!
1 Like


In general the release version should be preferred unless a feature under development is required.

To help debug your problem, when you use the object oriented interface, you can set “DebugOn”, which will print additional information about the ITK filter. You can also print information about the input images before execution too.

Please post a minimal self contained example to reproduce your issue. Currently, I can’t even tell what filter is producing this error, much less the parameters used to configure.

I was trying to use the image pickling and transform pickling at the end of the script.
I updated my text with more info. I apologize for not adding more to begin with.
It appears to be in the resample image filter.

I will need to pair it down to simple example, but the main difference I see so far is that the release version uses itk::MultiThreader versus the latest uses itk::PoolMultiThreader

here is a somewhat minimum example:

import SimpleITK as sitk
import numpy as np

def resample_1_rgb_test(in_transform, t_sitk, mean = 0):
  filter_ = sitk.ResampleImageFilter()
  new_image = filter_.Execute(t_sitk)
  return new_image

def get_mean_edges(itk_image):
  # get the edge values to determine the mean pixel intensity
  l_side = sitk.GetArrayViewFromImage(itk_image)[0,:].flatten()
  r_side = sitk.GetArrayViewFromImage(itk_image)[-1,:].flatten()
  top_side =  sitk.GetArrayViewFromImage(itk_image)[0][1:-2].flatten()
  bot_side = sitk.GetArrayViewFromImage(itk_image)[-1][1:-2].flatten()
  mean = int(np.concatenate((l_side, r_side, top_side, bot_side)).mean())
  return mean

affine_center = (20, 20, 20)
affine_translation = (5,6) 
size_x = 1024
size_y = 1024
grid_r = sitk.GridSource(outputPixelType=sitk.sitkUInt8,
    size=(size_x, size_y),
    sigma=(0.1, 0.1),
    gridSpacing=(3.0, 3.0),
    gridOffset=(0.0, 0.0),
grid_g = sitk.GridSource(outputPixelType=sitk.sitkUInt8,
    size=(size_x, size_y),
    sigma=(0.5, 0.5),
    gridSpacing=(5.0, 5.0),
    gridOffset=(0.0, 0.0),
grid_b = sitk.GridSource(outputPixelType=sitk.sitkUInt8,
    size=(size_x, size_y),
    sigma=(1.0, 1.0),
    gridSpacing=(13.0, 13.0),
    gridOffset=(0.0, 0.0),

compose_new = sitk.ComposeImageFilter()

grid_rgb = compose_new.Execute(grid_r, grid_g, grid_b)
mean_edges = get_mean_edges(grid_rgb)
# Matrix is represented as a vector-like data in row major order.
composite_transform = sitk.Transform(2, sitk.sitkEuler)
for i in range(20):
  euler2d_transform = sitk.Euler2DTransform()
  trans_image = resample_1_rgb_test(composite_transform,
                                      mean = mean_edges )

If I change the line grid_rgb = compose_new.Execute(grid_r, grid_g, grid_b) to
grid_rgb = compose_new.Execute(grid_r) no exception is thrown.

1 Like


Thank you for providing the example. Although the utils modes was not provided and the example couple have been a little smaller :wink:

This was an interesting bug related the new ITKv5 support for streaming in the ResampleImageFilter, and the way SimpleITK runs filters per component some times.

Here is the PR which address the issue:


Ahh missed that one… fixed it up, but you’ve already got the change merged!

Thank you so much for the help, that was faster than any VTK bug fix I ever saw.


Please test the “latest” binaries on Github for the fix. Thanks.


it works! thank you.

1 Like