# Clarifying General Syntax When SimpleITK Documentation

**URL:** <https://discourse.itk.org/t/clarifying-general-syntax-when-simpleitk-documentation/1357>\
**Category:** Beginner Questions\
**Created:** [October 16, 2018, 1:48pm UTC](https://discourse.itk.org/t/clarifying-general-syntax-when-simpleitk-documentation/1357 "2018-10-16T13:48:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bsmarine](https://discourse.itk.org/letter_avatar_proxy/v4/letter/b/7ea924/32.png) [@bsmarine](https://discourse.itk.org/u/bsmarine)\
**Post date:** [October 16, 2018, 1:48pm UTC](https://discourse.itk.org/t/clarifying-general-syntax-when-simpleitk-documentation/1357/1 "2018-10-16T13:48:42Z")

</div>

Hi All,

With most SimpleITK modules the expected syntax is intuitive. But as a beginner I get occasionally stumped. For example, below I’m trying to load the SetChangeMap parameter for ChangeLabelLabelMapFilter but am not sure how to interpret the correct syntax from the documentation.

How am I supposed to pass the SetChangeMap parameter that defines old and new labels?

More generally, does anyone have suggestions for beginners on how to understand expected syntax as it’s described [here](https://itk.org/SimpleITKDoxygen07/html/index.html).

Thank you!

## filter = sitk.ChangeLabelLabelMapFilter() filter.SetChangeMap((1,0))

TypeError Traceback (most recent call last)  
\<ipython-input-26-f55c87c7566e\> in \<module\>()  
----\> 1 filter.SetChangeMap((1,1))  
~/anaconda3/lib/python3.6/site-packages/SimpleITK/SimpleITK.py in SetChangeMap(self, ChangeMap)  
\_SimpleITK.ChangeLabelLabelMapFilter\_SetChangeMap(self, ChangeMap)  
TypeError: in method ‘ChangeLabelLabelMapFilter\_SetChangeMap’, argument 2 of type ‘std::map\< double,double,std::less\< double \>,std::allocator\< std::pair\< double const,double \> \> \>’

---

<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:** [October 16, 2018, 2:30pm UTC](https://discourse.itk.org/t/clarifying-general-syntax-when-simpleitk-documentation/1357/2 "2018-10-16T14:30:03Z")

</div>

Hello,

The Doxgen link you have is old. Here is the link to the 1.1 release: [https://itk.org/SimpleITKDoxygen110/html/](https://itk.org/SimpleITKDoxygen110/html/)  
There is also the read the docs: [https://simpleitk.readthedocs.io/en/master/](https://simpleitk.readthedocs.io/en/master/)

There is the “ChangeLabelImageFilter” and the “ChangeLabelLabelMapFilter”, the former has the “ImageFilter” while the later has the “LabelMapFilter” suffix. They work on scalar images and label map images respectfully. The label map images have pixel id’s such as `sitk.sitkLabelUInt8` or `sitk.sitkLabelUInt32` and are internally represented as run length encoded images for efficient storage and label operations. Make sure you have the proper image as input to the proper filer.

For this particular issue, the C++ SimpleITK filter is expecting `std::map<double,double>`. The wrapper creates as “DoubleDoubleMap” type:

```auto

In [5]: sitk.ChangeLabelLabelMap?
Signature: sitk.ChangeLabelLabelMap(*args, **kwargs)
Docstring:
ChangeLabelLabelMap(Image image1, DoubleDoubleMap changeMap) -> Image

```

The `DoubleDoubleMap` type is a wrapper for the `std::map` class:

```auto
sitk.DoubleDoubleMap?
Init signature: sitk.DoubleDoubleMap(self, *args)
Docstring: Proxy of C++ std::map<(double,double)> class.
Init docstring:
__init__ (std::map<(double,double)> self, std::less< double > const & arg2) -> DoubleDoubleMap
__init__ (std::map<(double,double)> self) -> DoubleDoubleMap
__init__ (std::map<(double,double)> self, DoubleDoubleMap arg2) -> DoubleDoubleMap
File: /scratch/blowekamp/build/SimpleITK-ibex/SimpleITK-build/Wrapping/Python/SimpleITK.py
Type: type

```

But the wrappers also allows conversion from a Python dictionary to this wrapped type. So you can just pass a dictionary to the function or class. So you can simple do the following:

```auto
In [1]: import SimpleITK as sitk

In [2]: img = sitk.Image([10,10], sitk.sitkLabelUInt16)

In [3]: img[1,2] = 1

In [4]: result = sitk.ChangeLabelLabelMap(img, {1:2,0:1})

In [5]: result[1,2]
Out[5]: 2

In [6]: result[0,0]
Out[6]: 1

```

Perhaps an example of for this class would help?
