# Python sitk ExtractImageFilter -- basic usage help??

**URL:** https://discourse.itk.org/t/python-sitk-extractimagefilter-basic-usage-help/949
**Category:** Beginner Questions
**Tags:** simpleitk
**Created:** [May 25, 2018, 8:23am UTC](https://discourse.itk.org/t/python-sitk-extractimagefilter-basic-usage-help/949 "2018-05-25T08:23:10Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [May 25, 2018, 2:36pm UTC](https://discourse.itk.org/t/python-sitk-extractimagefilter-basic-usage-help/949/4 "2018-05-25T14:36:00Z")

</div>

> [@rcatwood](#):
>
> Then I had no idea you could directly use Python slicing on an sitk image.
> 
> But, is it necessary to use a different method if it’s 3d-\>3d as for 4d-\>3d ? , and what results if the python slicing has a unique value eg newim=rawimg[0:20,0:30,0:40,5] , in numpy you might have to squeeze() the array to make it 3-d (which is also a bit fraught) …

The Python slicing is great! I always use it instead of those listed filters, it is flexible and has a consistent way to specify. If `rawimg` was a np.ndarray, then the operation `rawimg[0:20,0:30,0:40,5]` produces an array with shape (20,30,40) of dimension 3, reducing the dimension. In general the simpleitk operator is designed to behave like the numpy or standard slice based indexing.

The support for 4D images is some what limited in SimpleITK, but is should be expanded. The [**get\_item**](https://github.com/SimpleITK/SimpleITK/blob/16adc0838f6a2b5e6574809ba5fab3fb4459475e/Wrapping/Python/Python.i#L324-L434) currently does not fully support 4D images. Could you please create a simpleitk issue to add full 4D support to this method on [SimpleITK GitHub](https://github.com/SimpleITK/SimpleITK/blob/16adc0838f6a2b5e6574809ba5fab3fb4459475e/Wrapping/Python/Python.i#L324-L434).

> [@rcatwood](#):
>
> Probing a little it seems that Image doesn’t actually have anything called “ImageRegion”? There’s “LargestPossibleRegion”,“BufferedRegion”, and “RequestedRegion” , each of which has ‘index’, as well as “Origin” , and indeed a simple test appears (in 2-d) to show that the filters Extract, RegionofIntest, and Crop return the same values for the equivalent inputs (crop has a different meaning for its input parameters) so I was misled by this doxygen entry to think that ROI would behave differently from Extract in this case.

We really should be doing better with our SimpleITK Doxygen. As of right now the description for the filters are just taken from ITK, with all the features exposed from the C++ interface. We should really mark this as coming for C++ ITK, and provide brief info about the SimpleITK simplification done, or implementation choices made. The other simplification done in SimpleITK is that “ITK streaming” is not supported, so the all these regions don’t really apply to simpleITK. There is in the ITK Software Guide about the pipeline and streaming if you are currious.

---

_[View the full topic](https://discourse.itk.org/t/python-sitk-extractimagefilter-basic-usage-help/949)._
