# SlicerQR Development

**URL:** <https://discourse.slicer.org/t/slicerqr-development/15954>\
**Category:** Development\
**Tags:** registration, build, segmentation, dicom, python\
**Created:** [February 11, 2021, 3:59pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954 "2021-02-11T15:59:22Z")\
**Posts on this page:** 20\
**Page:** 5

<div class="post-metadata">

**Author:** ![spycolyf](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@spycolyf](https://discourse.slicer.org/u/spycolyf)\
**Post date:** [April 14, 2021, 5:55pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954/120 "2021-04-14T17:55:33Z")

</div>

Yes, I installed TortoiseGit and it is really nice. I’ll tell my team about it for managing GIT for QREADS. Thanks for sharing that @lassoan

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [April 15, 2021, 10:03pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954/121 "2021-04-15T22:03:56Z")

</div>

Split this topic on April 15, 2021, 10:03pm UTC

2 posts were split to a new topic: [Is there a way to load images using the Python Interactor in Slicer?](https://discourse.slicer.org/t/is-there-a-way-to-load-images-using-the-python-interactor-in-slicer/17113)

---

<div class="post-metadata">

**Author:** ![spycolyf](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@spycolyf](https://discourse.slicer.org/u/spycolyf)\
**Post date:** [April 15, 2021, 12:49am UTC](https://discourse.slicer.org/t/slicerqr-development/15954/123 "2021-04-15T00:49:29Z")

</div>

@lassoan @pieper @jcfr,

Is it possible to position the image scroll slider at the bottom of the images rather than the top?

---

<div class="post-metadata">

**Author:** ![spycolyf](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@spycolyf](https://discourse.slicer.org/u/spycolyf)\
**Post date:** [April 15, 2021, 12:55am UTC](https://discourse.slicer.org/t/slicerqr-development/15954/124 "2021-04-15T00:55:16Z")

</div>

I’m proud of myself. Thanks to @lassoan helping me today, with TortoiseGit, I was able create a branch, make minor changes, commit, push, and then create a pull request. Lots more to learn, but it’s a start.

---

<div class="post-metadata">

**Author:** ![spycolyf](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@spycolyf](https://discourse.slicer.org/u/spycolyf)\
**Post date:** [April 15, 2021, 1:28am UTC](https://discourse.slicer.org/t/slicerqr-development/15954/125 "2021-04-15T01:28:34Z")

</div>

@pieper @lassoan @jcfr

Can the mouse button event assignment be done in Python? For example, with the Python script, can I assign zoom to the mouse wheel down and drag, and pan to the left button, and W/L to simultaneous left and right buttons?

Maybe the SetEventTranslationClickAndDrag function?

---

<div class="post-metadata">

**Author:** ![spycolyf](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@spycolyf](https://discourse.slicer.org/u/spycolyf)\
**Post date:** [April 15, 2021, 9:21pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954/128 "2021-04-15T21:21:43Z")

</div>

@jcfr,

I built the latest code and the title information still does not work. I tried the following and nothing printed in Python interactor. Does this mean that the code never gets executed?. Here’s where I placed the print statements in the code…

```
def _update():
  slicer.app.processEvents()
  slicer.app.layoutManager().resetThreeDViews()
  QReadsLogic.setZoom(self._parameterNode.GetParameter("Zoom"))
  # Dictionary of name and values
  values = {QReadsLogic.DICOM_TAGS[tag]: value for tag, value in QReadsLogic.dicomTagValues(node).items()}

  print("*" * 40)
  print(values)
  print("*" * 40)

  # Update window title
  slicer.util.mainWindow().windowTitle = "CMRN: {PatientID} Patient Name: {PatientName} Study: {StudyDescription} Series: {SeriesDescription}".format(**values)
```

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [April 15, 2021, 9:29pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954/129 "2021-04-15T21:29:59Z")

</div>

To help others understand the context:

> <https://github.com/KitwareMedical/SlicerQReads/blob/7fcd4749c80ead46cbbe60829126c7a1814ae6b1/Modules/Scripted/QReads/QReads.py#L210-L232>

This code is called after a node is created, failing to see the information reported in the log file or python interactor probably means there are other errors happen beforehand during the loading of the data.

---

<div class="post-metadata">

**Author:** ![spycolyf](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@spycolyf](https://discourse.slicer.org/u/spycolyf)\
**Post date:** [April 16, 2021, 5:13pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954/130 "2021-04-16T17:13:24Z")

</div>

@jamesobutler @lassoan @pieper @jcfr

How do I show and un-show the ruler at the bottom of the image?

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/0/10dbce06eff44c2beeb86231dd7d55702c6a2976.png)

I can’t find it in the Script Repository.

Thanks

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [April 16, 2021, 5:30pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954/131 "2021-04-16T17:30:16Z")

</div>

This is how I do it:

```auto
#For the 3D view
ThreeDViewNode = slicer.mrmlScene.GetSingletonNode("1", "vtkMRMLViewNode")
ThreeDViewNode.SetRulerType(1)# Change 1 by 0, 2 to get no ruler or thick
ThreeDViewNode.SetRulerColor(0)# Change 0 to 1, 2 to get other colors

#For red slice
redSliceNode = slicer.mrmlScene.GetSingletonNode("Red", "vtkMRMLSliceNode")
redSliceNode.SetRulerType(1)
redSliceNode.SetRulerColor(2)

```

---

<div class="post-metadata">

**Author:** ![spycolyf](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@spycolyf](https://discourse.slicer.org/u/spycolyf)\
**Post date:** [April 16, 2021, 5:40pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954/132 "2021-04-16T17:40:04Z")

</div>

Thanks @mau_igna_06,

Do you also implement an interactive measuring tool? One where the user can draw a line on the image and a measurement is given?

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mau_igna_06/32/9056_2.png) [@mau\_igna\_06](https://discourse.slicer.org/u/mau_igna_06)\
**Post date:** [April 16, 2021, 6:08pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954/133 "2021-04-16T18:08:36Z")

</div>

I think you can implement it yourself using a vtkMRMLMarkupsLineNode, some event listeners and GUI buttons. But the experts may guide you further

---

<div class="post-metadata">

**Author:** ![spycolyf](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@spycolyf](https://discourse.slicer.org/u/spycolyf)\
**Post date:** [April 16, 2021, 6:29pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954/134 "2021-04-16T18:29:31Z")

</div>

> [@mau\_igna\_06](#):
>
> vtkMRMLMarkupsLineNode

Some info is here I believe. In case you want to know.

> [@Help with orientation marker and ruler](https://discourse.slicer.org/t/help-with-orientation-marker-and-ruler/13454/4):
>
> Hello again, I spoke to the people who will be the end users of my Slicer module and they really do want something more precise than the built-in ruler tool I referred to in the first post in this thread. If you have any links to share that could help me figure out the syntax for adding a ruler tool to my module (using qSlicerSimpleMarkupsWidget?) that would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![spycolyf](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@spycolyf](https://discourse.slicer.org/u/spycolyf)\
**Post date:** [May 4, 2021, 4:08pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954/135 "2021-05-04T16:08:52Z")

</div>

@pieper @lassoan @jcfr @jamesobutler

My module works perfectly except if I push the “Set Thickness” button first. Then hardly anything works. If I push other buttons first, everything works perfectly. We beta test next Monday, so HELP!!!

This issue is listed in tracker here: https://github.com/KitwareMedical/SlicerQReads/issues/103

Here’s the deal. After I push the “Set Threshold” button I get this error…

```
Traceback (most recent call last):
  File "/home/jcfr/Projects/SlicerQReads-Release/Slicer-build/lib/SlicerQReads-4.13/qt-scripted-modules/QReads.py", line 389, in updateGUIFromParameterNode
    QReadsLogic.slabThicknessInMmToNumberOfSlices(volumeNode, slabThicknessInMm))
  File "/home/jcfr/Projects/SlicerQReads-Release/Slicer-build/lib/SlicerQReads-4.13/qt-scripted-modules/QReads.py", line 612, in slabThicknessInMmToNumberOfSlices
    assert tichknessInMm > 0
AssertionError

```

Here’s the code segments at 389 and 612

> ```
> def updateGUIFromParameterNode(self, caller=None, event=None):
> QReadsLogic.setSlab( (line 389)
> QReadsLogic.slabModeFromString(slabModeStr),
> QReadsLogic.slabThicknessInMmToNumberOfSlices(volumeNode, slabThicknessInMm))
> 
> ```

```
@staticmethod
  def slabThicknessInMmToNumberOfSlices(volumeNode, tichknessInMm):
     if volumeNode is None:
      return 1
    assert tichknessInMm > 0 (line 612)
    return int(tichknessInMm / max(volumeNode.GetSpacing()))

```

… and no jokes anout

---

<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:** [May 4, 2021, 4:52pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954/136 "2021-05-04T16:52:45Z")

</div>

Can you upload an Windows installation package and send the link so that we can test it?

You can also check it yourself by attaching a Python debugger and check where the 0 slice thickness value comes from.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [May 4, 2021, 4:53pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954/137 "2021-05-04T16:53:34Z")

</div>

To ensure messages posted on the forum benefit the community, we suggest to provide minimally reproducible example.

In that particular case, it turns out I started to look at this and it is a simple logic issue.

---

<div class="post-metadata">

**Author:** ![spycolyf](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@spycolyf](https://discourse.slicer.org/u/spycolyf)\
**Post date:** [May 4, 2021, 5:17pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954/138 "2021-05-04T17:17:32Z")

</div>

@lassoan

Yes, I would have done that if I could get my debugger to work. I’ve successfully attached the Python Debugger fro VS Code, and tried to set break points, but get this error…

```
pydev debugger: warning: trying to add breakpoint to file that does not exist: c:\programdata\na-mic\slicer 4.13.0-2021-04-22\qreads.py (will have no effect)
Traceback (most recent call last):
  File "C:/SlicerQReads-0.1.0-2021-04-27-win-amd64/lib/SlicerQReads-4.13/qt-scripted-modules/QReads.py", line 55, in eventFilter
    slicer.util.mainWindow().writeSettings()
AttributeError: qSlicerAppMainWindow has no attribute named 'writeSettings'

```

Although my SlicerQREADS module folder was set to “C:/SlicerQReads-0.1.0-2021-04-27-win-amd64/lib/SlicerQReads-4.13/qt-scripted-modules/QReads.py”, why is it trying to set break points in “c:\programdata\na-mic\slicer 4.13.0-2021-04-22\qreads.py?”

Thanks

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [May 4, 2021, 5:28pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954/139 "2021-05-04T17:28:07Z")

</div>

> started to look at this and it is a simple logic issue.

This has been fixed in [BUG: Fix toggling of SlabThickness mode by jcfr · Pull Request #105 · KitwareMedical/SlicerQReads · GitHub](https://github.com/KitwareMedical/SlicerQReads/pull/105)

> `qSlicerAppMainWindow has no attribute named 'writeSettings'`

Consider rebuilding the application, the error reported indicate you didn’t rebuilt. Changes have been integrated.

See [BUG: Ensure window geometry and position is restored · KitwareMedical/SlicerQReads@2150063 · GitHub](https://github.com/KitwareMedical/SlicerQReads/commit/215006327069cb90633487a409adb710b8c472fe)

---

<div class="post-metadata">

**Author:** ![spycolyf](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@spycolyf](https://discourse.slicer.org/u/spycolyf)\
**Post date:** [May 4, 2021, 5:29pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954/140 "2021-05-04T17:29:41Z")

</div>

Sorry @jcfr,

I’ll try to speak more in the context of addressing the Slicer community rather than the experts. Got it.

And thanks so much for the fix, I was losing a little sleep over this one. You just added a couple more days to my life I think.

Thanks

---

<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:** [May 4, 2021, 6:13pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954/141 "2021-05-04T18:13:31Z")

</div>

> [@spycolyf](#):
>
> Although my SlicerQREADS module folder was set to “C:/SlicerQReads-0.1.0-2021-04-27-win-amd64/lib/SlicerQReads-4.13/qt-scripted-modules/QReads.py”, why is it trying to set break points in “c:\programdata\na-mic\slicer 4.13.0-2021-04-22\qreads.py?”

This is a recent regression in Visual Studio Code’s Python debugger. On Windows, you need to remove `pathMappings` section from the default debugger configuration - see instruction [here](https://github.com/SlicerRt/SlicerDebuggingTools#one-time-setup-1).

---

<div class="post-metadata">

**Author:** ![spycolyf](https://avatars.discourse-cdn.com/v4/letter/s/f17d59/32.png) [@spycolyf](https://discourse.slicer.org/u/spycolyf)\
**Post date:** [May 4, 2021, 7:53pm UTC](https://discourse.slicer.org/t/slicerqr-development/15954/142 "2021-05-04T19:53:38Z")

</div>

@lassoan

Wow! That fixed it. Thanks

[Previous page](https://discourse.slicer.org/t/slicerqr-development/15954.md?page=4)

[Next page](https://discourse.slicer.org/t/slicerqr-development/15954.md?page=6)
