# Jupyter notebook

**URL:** https://discourse.slicer.org/t/jupyter-notebook/24150
**Category:** Development
**Created:** [July 1, 2022, 7:26pm UTC](https://discourse.slicer.org/t/jupyter-notebook/24150 "2022-07-01T19:26:09Z")
**Posts on this page:** 8
**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: [July 1, 2022, 7:26pm UTC](https://discourse.slicer.org/t/jupyter-notebook/24150/1 "2022-07-01T19:26:09Z")

</div>

I am using Jupyter notebook to manage 3D slicer.  
I am trying to control 3D slicer using python commands to automate the use of one Module.  
I want to edit the buttons of the module so that I can insert the data from Jupyter. For example, when it says insert Input volume, instead of using the 3D slicer GUI, use python commands.  
Can anyone help me with this, thank you!!

---

<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: [July 3, 2022, 3:18am UTC](https://discourse.slicer.org/t/jupyter-notebook/24150/2 "2022-07-03T03:18:26Z")

</div>

I would recommend to start with the [Scripting and module development tutorial](https://www.slicer.org/wiki/Documentation/Nightly/Training#PerkLab.27s_Slicer_bootcamp_training_materials) and then check out the [Python FAQ](https://slicer.readthedocs.io/en/latest/developer_guide/python_faq.html) for information on how to use CLI and Loadable modules from Python scripting. You can also find many examples in the [script repository](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html) and in the [modules section of the developer manual](https://slicer.readthedocs.io/en/latest/developer_guide/modules/index.html) and in Python-scripted module tests. Since all these documentations are indexed by search engines, you can also google any question that you have. If you don’t find answers to any specific question (e.g., how to access a certain feature of certain module from a Python script) then you can ask it here.

---

<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: [July 13, 2022, 7:18am UTC](https://discourse.slicer.org/t/jupyter-notebook/24150/3 "2022-07-13T07:18:03Z")

</div>

Thank you for your answer Andras, I am going to check all the provided information

---

<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: [July 14, 2022, 7:18am UTC](https://discourse.slicer.org/t/jupyter-notebook/24150/4 "2022-07-14T07:18:36Z")

</div>

Hi. I couldnt find the solution to my problem.  
I am going to explain it better. I am using the a module and I want to automate the process.  
For example, in this box I need to choose “Create new volume”. Do you know if there is any python code I can write instead of having to click it with the mouse.

 ![Captura de pantalla 2022-07-14 a las 9.18.15](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/7/a793808885e1c2f753cdedff134b7c41356bddfa.png)

---

<div class="post-metadata">

### Author: ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)
#### Post date: [July 15, 2022, 5:47pm UTC](https://discourse.slicer.org/t/jupyter-notebook/24150/5 "2022-07-15T17:47:02Z")

</div>

If the YourExtension you want to automate has a YourExtensionLogic(ScriptedLoadableModuleLogic) class then you would need to find the settable parameters in that class.

Example: This code sets some necessary things in the LungCTAnalyzer extension logic from a Python script.

```auto
import LungCTAnalyzer

from LungCTAnalyzer import LungCTAnalyzerTest
from LungCTAnalyzer import LungCTAnalyzerLogic

logic = LungCTAnalyzerLogic()

# loadedVolumeNode and loadedMaskNode were created before
logic.inputVolume = loadedVolumeNode
logic.inputSegmentation = loadedMaskNode

logic.rightLungMaskSegmentID = loadedMaskNode.GetSegmentation().GetSegmentIdBySegmentName("right lung")
logic.leftLungMaskSegmentID = loadedMaskNode.GetSegmentation().GetSegmentIdBySegmentName("left lung")
logic.setDefaultThresholds(-1050,-990,-650,-400,0,3000)
            
logic.detailedSubsegments = True
logic.shrinkMasks = False
logic.countBullae = False

```

When ready, you would

```auto
logic.process()

```

to do the actual work.

---

<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: [July 18, 2022, 11:07am UTC](https://discourse.slicer.org/t/jupyter-notebook/24150/6 "2022-07-18T11:07:57Z")

</div>

Thank you for your answer.

I am trying to use SlicerIGT (SegmentationUnet module) but there is no SlicerIGTLogic class, do you know any other way to achieve this?

---

<div class="post-metadata">

### Author: ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)
#### Post date: [July 18, 2022, 8:16pm UTC](https://discourse.slicer.org/t/jupyter-notebook/24150/7 "2022-07-18T20:16:27Z")

</div>

Gee this module is complicated. Could maybe @Sunderlandkyl or @lassoan provide a starting point for Isabella?

---

<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: [July 18, 2022, 9:17pm UTC](https://discourse.slicer.org/t/jupyter-notebook/24150/8 "2022-07-18T21:17:27Z")

</div>

> [@Isabella\_Romero](#):
>
> I am trying to use SlicerIGT (SegmentationUnet module) but there is no SlicerIGTLogic class, do you know any other way to achieve this?

SlicerIGT is an extension. There is no logic for an extension but only modules have logic classes. SegmentationUNet module has a logic class - see [here](https://github.com/SlicerIGT/aigt/blob/5c452a9dac1749768dc484af7f986b43ae91b47e/SlicerExtension/LiveUltrasoundAi/SegmentationUNet/SegmentationUNet.py#L349).
