# How do I clear all the nodes so that it looks like it just started to run?

**URL:** <https://discourse.slicer.org/t/how-do-i-clear-all-the-nodes-so-that-it-looks-like-it-just-started-to-run/22228>\
**Category:** Support\
**Created:** [March 1, 2022, 6:57am UTC](https://discourse.slicer.org/t/how-do-i-clear-all-the-nodes-so-that-it-looks-like-it-just-started-to-run/22228 "2022-03-01T06:57:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yllgl](https://avatars.discourse-cdn.com/v4/letter/y/8e7dd6/32.png) [@yllgl](https://discourse.slicer.org/u/yllgl)\
**Post date:** [March 1, 2022, 6:57am UTC](https://discourse.slicer.org/t/how-do-i-clear-all-the-nodes-so-that-it-looks-like-it-just-started-to-run/22228/1 "2022-03-01T06:57:38Z")

</div>

I just want to use python to help me do some jobs on some patients’ data. Each patient data is independent, and to prevent interference between data while the code is running, I want to be able to clear all currently saved state nodes after processing a patient data.

---

<div class="post-metadata">

**Author:** ![yllgl](https://avatars.discourse-cdn.com/v4/letter/y/8e7dd6/32.png) [@yllgl](https://discourse.slicer.org/u/yllgl)\
**Post date:** [March 1, 2022, 9:34am UTC](https://discourse.slicer.org/t/how-do-i-clear-all-the-nodes-so-that-it-looks-like-it-just-started-to-run/22228/2 "2022-03-01T09:34:53Z")

</div>

I have solved this.

```python
if slicer.mrmlScene:
    tmpdict = slicer.util.getNodes(useLists=True)
    for name,tmplist in tmpdict.items():
        for node in tmplist:
            slicer.mrmlScene.RemoveNode(node)

```

---

<div class="post-metadata">

**Author:** ![ebrahim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ebrahim/32/13403_2.png) [@ebrahim](https://discourse.slicer.org/u/ebrahim)\
**Post date:** [March 1, 2022, 10:58am UTC](https://discourse.slicer.org/t/how-do-i-clear-all-the-nodes-so-that-it-looks-like-it-just-started-to-run/22228/3 "2022-03-01T10:58:05Z")

</div>

I think your code would delete all the singleton nodes like the view nodes, etc.

This should achieve the same thing without deleting those:

```nohighlight
slicer.mrmlScene.Clear()

```
