# Remove circular dependency between CompareVolumes and LandmarkRegistration

**URL:** <https://discourse.slicer.org/t/remove-circular-dependency-between-comparevolumes-and-landmarkregistration/44221>\
**Category:** Development\
**Created:** [August 27, 2025, 12:15pm UTC](https://discourse.slicer.org/t/remove-circular-dependency-between-comparevolumes-and-landmarkregistration/44221 "2025-08-27T12:15:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![koeglfryderyk](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/koeglfryderyk/32/14638_2.png) [@koeglfryderyk](https://discourse.slicer.org/u/koeglfryderyk)\
**Post date:** [August 27, 2025, 12:15pm UTC](https://discourse.slicer.org/t/remove-circular-dependency-between-comparevolumes-and-landmarkregistration/44221/1 "2025-08-27T12:15:10Z")

</div>

@pieper mentioned [here](https://github.com/pieper/CompareVolumes/pull/16#pullrequestreview-3157455960) that it would be a good idea to remove the circular dependencies.

The simplest approach for me seemed to be just to move common functionality into `qt-scripted-modules/RegistrationLib/Visualization.py`.

Now CompareVolumes simply does `import RegistrationLib`and `LandmarkRegistration.py` and `Visualization.py` don’t import `CompareVolumes` any more.

You can take a look at the changes here:

> **[Comparing pieper:master...koegl:removeCircularDependency · pieper/CompareVolumes](https://github.com/pieper/CompareVolumes/compare/master...koegl:CompareVolumes:removeCircularDependency)**
>
> Slicer module providing high level layout and visualization options - Comparing pieper:master...koegl:removeCircularDependency · pieper/CompareVolumes

> **[Comparing Slicer:master...koegl:removeCircularDependency ·...](https://github.com/Slicer/LandmarkRegistration/compare/master...koegl:LandmarkRegistration:removeCircularDependency)**
>
> An interactive registration tool that manages viewing and manipulating of sets of fiducials - Comparing Slicer:master...koegl:removeCircularDependency · Slicer/LandmarkRegistration

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 27, 2025, 3:43pm UTC](https://discourse.slicer.org/t/remove-circular-dependency-between-comparevolumes-and-landmarkregistration/44221/2 "2025-08-27T15:43:40Z")

</div>

Thanks @koeglfryderyk - I haven’t worked with the code in a while, so maybe what you are proposing is the most expeditious way to remove the circular dependency. My thought though had been that the CompareVolumes code is more of the helper library and that LandmarkRegistration is the specific application so to me, putting the visualization and widgets in CompareVolumes would feel more natural. I don’t know if you had looked into that and prefer this organization?

---

<div class="post-metadata">

**Author:** ![koeglfryderyk](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/koeglfryderyk/32/14638_2.png) [@koeglfryderyk](https://discourse.slicer.org/u/koeglfryderyk)\
**Post date:** [August 28, 2025, 11:12am UTC](https://discourse.slicer.org/t/remove-circular-dependency-between-comparevolumes-and-landmarkregistration/44221/3 "2025-08-28T11:12:41Z")

</div>

My thinking was: `CompareVolumes.py` and `LandmarkRegistration.py` are scripted modules, so any code that they share (or that could be reused) should be moved to a helper library, e.g., to `RegistrationLib/Visualization.py`

This way, any scripted module that wants to use this code can just import RegistrationLib

Does that make sense?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 28, 2025, 3:04pm UTC](https://discourse.slicer.org/t/remove-circular-dependency-between-comparevolumes-and-landmarkregistration/44221/4 "2025-08-28T15:04:26Z")

</div>

If you think it’s a lot of work to change we can leave it in RegistrationLib, but to me the visualization features and the corresponding widgets are proper to CompareVolumes. The other RegistrationLib code is to support the different kinds of transforms that plug into LandmarkRegistration. Since CompareVolumes is the more general module it makes more sense to me that other modules would only want to import the lower level code. But your point is true that since they are both available in the app it doesn’t make any real practical difference.
