# How to judge a roinode changed or not by python code?

**URL:** <https://discourse.slicer.org/t/how-to-judge-a-roinode-changed-or-not-by-python-code/22393>\
**Category:** Development\
**Tags:** python\
**Created:** [March 9, 2022, 3:12am UTC](https://discourse.slicer.org/t/how-to-judge-a-roinode-changed-or-not-by-python-code/22393 "2022-03-09T03:12:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [March 9, 2022, 3:12am UTC](https://discourse.slicer.org/t/how-to-judge-a-roinode-changed-or-not-by-python-code/22393/1 "2022-03-09T03:12:41Z")

</div>

How to judge a roinode changed or not?

markupsROInode 可以很方便地在slice里调节大小, 我想在程序里判断这个node是否发生改变, 我该怎么做呢?

> markupsROInode can easily adjust the size in slice, I want to judge whether this node has changed or not in the program, what should I do?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 9, 2022, 6:20am UTC](https://discourse.slicer.org/t/how-to-judge-a-roinode-changed-or-not-by-python-code/22393/2 "2022-03-09T06:20:41Z")

</div>

Can you tell a bit more about your use case? Do you want to prevent changes, get notified about changes when they happen, or just want to check at some point that the ROI was changed compared to some previous state?

---

<div class="post-metadata">

**Author:** ![jumbojing](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jumbojing/32/10811_2.png) [@jumbojing](https://discourse.slicer.org/u/jumbojing)\
**Post date:** [March 9, 2022, 7:03am UTC](https://discourse.slicer.org/t/how-to-judge-a-roinode-changed-or-not-by-python-code/22393/3 "2022-03-09T07:03:08Z")

</div>

I “want to check at some point that the ROI was changed compared to some previous state”.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 9, 2022, 7:08am UTC](https://discourse.slicer.org/t/how-to-judge-a-roinode-changed-or-not-by-python-code/22393/4 "2022-03-09T07:08:05Z")

</div>

The simplest is to check the modification time of the MRML node (you can get it by calling `node.GetMTime()`). Any modification of the node will make the timestamp value larger.

If you need to be more specific, for example only check control point position changes: you can then save the old positions in a variable and compare it to the current positions when you want to check if there were modifications.

---

<div class="post-metadata">

**Author:** ![yuvsaha123](https://avatars.discourse-cdn.com/v4/letter/y/b77776/32.png) [@yuvsaha123](https://discourse.slicer.org/u/yuvsaha123)\
**Post date:** [March 15, 2022, 11:58am UTC](https://discourse.slicer.org/t/how-to-judge-a-roinode-changed-or-not-by-python-code/22393/5 "2022-03-15T11:58:59Z")

</div>

> [@lassoan](#):
>
> The simplest is to check the modification time of the MRML node (you can get it by calling `node.GetMTime()` ). Any modification of the node will make the timestamp value larger.
> 
> If you need to be more specific, for example only check control point position changes: you can then save the old positions in a variable and compare it to the current positions when you want to check if there were modifications.

thanks for the awesome information.
