# SegmentationUnet

**URL:** <https://discourse.slicer.org/t/segmentationunet/25497>\
**Category:** Support\
**Tags:** segmentation, python\
**Created:** [September 30, 2022, 8:20am UTC](https://discourse.slicer.org/t/segmentationunet/25497 "2022-09-30T08:20:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Isabella\_Romero](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/isabella_romero/32/15865_2.png) [@Isabella\_Romero](https://discourse.slicer.org/u/Isabella_Romero)\
**Post date:** [September 30, 2022, 8:20am UTC](https://discourse.slicer.org/t/segmentationunet/25497/1 "2022-09-30T08:20:38Z")

</div>

Hi,  
I am trying to automate the SegmentationUNet module with Python (using the logic and widget commands).  
I am trying to code the following buttons so that I can choose an input volume and prediction volume with python.

 ![Captura de pantalla 2022-09-30 a las 10.16.04](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/8/68758f216d2be3a4c799a0576e42aa899a901f15.png)

I want to set the following values for input Volume (image) and Prediction volume (Create new Volume as… and a name).

 ![Captura de pantalla 2022-09-30 a las 10.16.13](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/3/036bb892c92553e57e4322adc84e21abe5f81c4e.png)

I found the following command in logic but it doesn’t work to set the input volume as desired:

setInputImage(self, inputImageNode)  
| Sets input image node  
| :param inputImageNode: vtkMRMLScalarVolumeNode  
| :return: None

---

<div class="post-metadata">

**Author:** ![Connor-Bowley](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/connor-bowley/32/12762_2.png) [@Connor-Bowley](https://discourse.slicer.org/u/Connor-Bowley)\
**Post date:** [October 3, 2022, 12:41pm UTC](https://discourse.slicer.org/t/segmentationunet/25497/2 "2022-10-03T12:41:08Z")

</div>

In general, updating the logic doesn’t update the UI. If you are looking to update the UI, you can access the UI’s “Input Volume” `qMRMLNodeComboBox` using `widget.ui.inputSelector` (where `widget` is the widget object).

In general for Python modules, you can access the UI elements using the `.ui` section of the widget object. By looking at `SegmentationUNet.ui`, you can determine the names of the elements, like [here](https://github.com/SlicerIGT/aigt/blob/66343f6b9c8c8fa6974d6af9297d03a83f3dcb64/SlicerExtension/LiveUltrasoundAi/SegmentationUNet/Resources/UI/SegmentationUNet.ui#L48).

Here is a [reference](https://apidocs.slicer.org/master/classqMRMLNodeComboBox.html) to `qMRMLNodeComboBox` so you can see how to set the node programmatically.

---

<div class="post-metadata">

**Author:** ![Isabella\_Romero](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/isabella_romero/32/15865_2.png) [@Isabella\_Romero](https://discourse.slicer.org/u/Isabella_Romero)\
**Post date:** [October 4, 2022, 7:03am UTC](https://discourse.slicer.org/t/segmentationunet/25497/3 "2022-10-04T07:03:46Z")

</div>

Thank you so much for your answer. I am going to try it now and let you know how it goes.
