# Creating a module for electron bolus

**URL:** <https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766>\
**Category:** Development\
**Tags:** extensions-manager, python\
**Created:** [August 8, 2024, 8:49am UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766 "2024-08-08T08:49:27Z")\
**Posts on this page:** 19\
**Page:** 2

<div class="post-metadata">

**Author:** ![sima](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sima/32/67638_2.png) [@sima](https://discourse.slicer.org/u/sima)\
**Post date:** [September 14, 2024, 3:18am UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/21 "2024-09-14T03:18:36Z")

</div>

Oh sorry !

The GitHub repository must be empty and first, a suitable framework should be built in it  
I apologize for misunderstanding 🙏

---

<div class="post-metadata">

**Author:** ![sima](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sima/32/67638_2.png) [@sima](https://discourse.slicer.org/u/sima)\
**Post date:** [September 15, 2024, 10:16am UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/22 "2024-09-15T10:16:56Z")

</div>

I have created a repository on GitHub and invited you. I would be glad if you accepted the invitation

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [September 16, 2024, 8:38am UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/23 "2024-09-16T08:38:01Z")

</div>

Thank you! Can you please rename it to SlicerElectronBolus? You’d need to do that anyway during the acceptance process for extension.

Please see this for the list of requirements (I only found this list in actual PRs so this is of another extension). Some of which are basic settings of the GitHub repo, you can do some of these now

> <https://github.com/Slicer/ExtensionsIndex/pull/2084>
>
> \<!--
> Thank you for contributing to 3D Slicer!
> \- To add a new extension with th…is pull request: Please keep content of "New extension" section and put an 'x' in the brackets for each todo item to indicate that you have accomplished that prerequisite.
> \- To update an existing extension with this pull request: Please delete all text in this template and just describe which extension is updated and optionally tell us in a sentence what has been changed. To make extension updates easier in the future you may consider replacing specific git hash in your json file by a branch name (for example: \`main\` for Slicer Preview Releases; \`(majorVersion).(minorVersion)\` such as \`5.6\` for Slicer Stable Releases).
> \--\>
> 
> \# New extension
> 
> 
> 
> \- \[x\] Extension has a reasonable name (not too general, not too narrow, suggests what the extension is for)
> \- \[x\] Repository name is Slicer+ExtensionName
> \- \[x\] Repository is associated with \`3d-slicer-extension\` GitHub topic so that it is listed \[here\](https://github.com/topics/3d-slicer-extension). To edit topics, click the settings icon in the right side of "About" section header and enter \`3d-slicer-extension\` in "Topics" and click "Save changes". To learn more about topics, read https://help.github.com/en/articles/about-topics
> \- \[x\] Extension description summarizes in 1-2 sentences what the extension is usable (should be understandable for non-experts)
> \- \[x\] Any known related patents must be mentioned in the extension description.
> \- \[x\] LICENSE.txt is present in the repository root. MIT (https://choosealicense.com/licenses/mit/) or Apache (https://choosealicense.com/licenses/apache-2.0/) license is recommended. If source code license is more restrictive for users than MIT, BSD, Apache, or 3D Slicer license then the name of the used license must be mentioned in the extension description.
> \- \[x\] Extension URL and revision (scmurl, scmrevision) is correct, consider using a branch name (main, release, ...) instead of a specific git hash to avoid re-submitting pull request whenever the extension is updated
> \- \[x\] Extension icon URL is correct (do not use the icon's webpage but the raw data download URL that you get from the download button - it should look something like this: https://raw.githubusercontent.com/user/repo/main/SomeIcon.png)
> \- \[x\] Screenshot URLs (screenshoturls) are correct, contains at least one
> \- \[x\] Homepage URL points to valid webpage containing the following:
> - \[x\] Extension name
> - \[x\] Short description: 1-2 sentences, which summarizes what the extension is usable for
> - \[x\] At least one nice, informative image, that illustrates what the extension can do. It may be a screenshot.
> - \[x\] Description of contained modules: at one sentence for each module
> - \[x\] Tutorial: step-by-step description of at least the most typical use case, include a few screenshots, provide download links to sample input data set
> - \[x\] Publication: link to publication and/or to PubMed reference (if available)
> - \[x\] License: We suggest you use a permissive license that includes patent and contribution clauses. This will help protect developers and ensure the code remains freely available. We suggest you use the \[Slicer License\](https://github.com/Slicer/Slicer/blob/main/License.txt) or the \[Apache 2.0\](https://www.apache.org/licenses/LICENSE-2.0). Always mention in your README file the license you have chosen. If you choose a different license, explain why to the extension maintainers. Depending on the license we may not be able to host your work. Read \[here\](https://opensource.guide/legal/#which-open-source-license-is-appropriate-for-my-project) to learn more about licenses.
> - \[x\] Content of submitted json file is consistent with the top-level CMakeLists.txt file in the repository (dependencies, etc. are the same)
> \- Hide unused features in the repository to reduce noise/irrelevant information:
> - \[x\] Click \`Settings\` and in repository settings uncheck \`Wiki\`, \`Projects\`, and \`Discussions\` (if they are currently not used)
> - \[x\] Click the settings icon next to \`About\` in the top-right corner of the repository main page and uncheck \`Releases\` and \`Packages\` (if they are currently not used)

I’ll generate the extension skeleton hopefully soon.

---

<div class="post-metadata">

**Author:** ![sima](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sima/32/67638_2.png) [@sima](https://discourse.slicer.org/u/sima)\
**Post date:** [September 16, 2024, 3:36pm UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/24 "2024-09-16T15:36:24Z")

</div>

Yes, definitely.  
Thank you for your guidance.  
I will thoroughly study this link to learn more.  
I am a beginner in Git and GitHub and have just started learning in this field. If I make any mistakes, I would appreciate it if you could guide me.  
Thank you in advance for your help.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [September 17, 2024, 8:45am UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/25 "2024-09-17T08:45:16Z")

</div>

Thank you very much for the quick rename. For the record the repository is

> **[GitHub - simaaz/SlicerElectronBolus](https://github.com/simaaz/SlicerElectronBolus)**
>
> Contribute to simaaz/SlicerElectronBolus development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [September 17, 2024, 9:20am UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/26 "2024-09-17T09:20:15Z")

</div>

I generated the extension and the module skeleton. I think the user interface you suggested can be simplified, see

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/9/b96322597583530835a39af9a744864f7e11db0d.png)

So we’d only have a selector for the RT plan, the isodose surface, and the skin segment.  
It will be important to describe in the documentation how this module expects the isodose surface to be generated (i.e. what dose level needs to be entered, and to keep only one value).

I’ll make this GUI soon and then I’ll give you instructions on how to fill the class with your code.

---

<div class="post-metadata">

**Author:** ![sima](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sima/32/67638_2.png) [@sima](https://discourse.slicer.org/u/sima)\
**Post date:** [September 18, 2024, 7:47am UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/27 "2024-09-18T07:47:41Z")

</div>

> [@cpinter](#):
>
> I generated the extension and the module skeleton

Thanks a lot. I was so excited to see it !

> [@cpinter](#):
>
> So we’d only have a selector for the RT plan, the isodose surface, and the skin segment

I didn’t quite understand the point you mentioned about “Plan contains reference” and I may have misunderstood some of the concepts. When I add a patient’s Dicom data in 3d Slicer, I see that RTPlan, RTStructure, RTDose, and CT (reference volume) are each separate branches of the patient data. However, I don’t understand how the RTPlan contains a reference. This issue also applies to the PTV model. I used to import the PTV as a model from RTStructure.  
I also have another question regarding segment and model. Previously, you suggested using a segment instead of the model. What changes need to be made in the code for this? Also, regarding the output, the current code I have outputs the bolus as a labelmap volume. What changes are required to have the segment instead?

> [@cpinter](#):
>
> describe in the documentation how this module expects the isodose surface to be generated

Thank you for the reminder. Yes, this is an important point when working with the module

> [@cpinter](#):
>
> then I’ll give you instructions on how to fill the class with your code.

I’m very grateful and delighted to have your valuable assistance by my side.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [September 24, 2024, 9:41am UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/28 "2024-09-24T09:41:58Z")

</div>

> [@sima](#):
>
> I don’t understand how the RTPlan contains a reference. This issue also applies to the PTV model.

An RTPlan node, which is defined in SlicerRT, contains several properties and references. One of these references is the CT, and another one is the target segment. See the related module:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/7/e72f08d072ac7854f7e05df51b4ad4d7ab5dee0e.png)

> [@sima](#):
>
> Previously, you suggested using a segment instead of the model. What changes need to be made in the code for this? Also, regarding the output, the current code I have outputs the bolus as a labelmap volume. What changes are required to have the segment instead?

This takes us to step 4 in the list [here](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/17). I’ll give you guidance to do these changes, but let’s go step by step, I still need to create the module GUI.

---

<div class="post-metadata">

**Author:** ![sima](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sima/32/67638_2.png) [@sima](https://discourse.slicer.org/u/sima)\
**Post date:** [September 25, 2024, 8:17am UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/29 "2024-09-25T08:17:26Z")

</div>

Thank you for your clear and insightful explanations.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [September 25, 2024, 11:54am UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/30 "2024-09-25T11:54:16Z")

</div>

I made the UI. As we discussed, it is quite simple:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/7/d/7d9d4539641a804b67b6640134965a9735d7ca86.png)

The next steps are:

- Go through the `ElectronBolus.py` file and change the obvious things:
  - Module category, contributors, acknowledgement, etc.
  - Differences due to the sample module and yours
    - There is no `invertedOutputSelector`
    - Argument list of the `process` function should be the list of inputs we need (see below)

- Set the segmentation node from the RT plan to the skin segment selector widget (I think this can be done in `_checkCanApply`)
- Modify `_checkCanApply` function to check all the inputs necessary:
  - RT plan plus the objects we need from its references:
    - CT
    - Target segment (segmentation node and segment)

  - Isodose model
  - Skin segment

---

<div class="post-metadata">

**Author:** ![sima](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sima/32/67638_2.png) [@sima](https://discourse.slicer.org/u/sima)\
**Post date:** [October 13, 2024, 6:35pm UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/31 "2024-10-13T18:35:27Z")

</div>

hi Csaba  
I apologize for the considerable delay.

Unfortunately, I couldn’t do all the steps you mention  
I can just change categories, contributors, help and acknowledgment text. (very very obvious and easy things 😔)

> [@cpinter](#):
>
> - 
> - 
> - Argument list of the `process` function should be the list of inputs we need (see below)
> 
> - Set the segmentation node from the RT plan to the skin segment selector widget (I think this can be done in `_checkCanApply`)
> - Modify `_checkCanApply` function to check all the inputs necessary:
> - RT plan plus the objects we need from its references:
> - CT
> - Target segment (segmentation node and segment)
> 
> - Isodose model
> - Skin segment

about these parts, I am confused! and I dont know how should apply changes

Could you please guide me more and in greater detail

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [October 14, 2024, 3:17pm UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/32 "2024-10-14T15:17:26Z")

</div>

Please ask concrete questions and I will try to answer.

---

<div class="post-metadata">

**Author:** ![sima](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sima/32/67638_2.png) [@sima](https://discourse.slicer.org/u/sima)\
**Post date:** [October 15, 2024, 10:50am UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/33 "2024-10-15T10:50:08Z")

</div>

> [@cpinter](#):
>
> checkCanApply

You mentioned that you had created the UI according to the image, but I couldn’t figure out exactly where the definitions and inputs were made. (for example I couldn’t find the **RT plan** or **isodose surface** in the widget function 🙄)

You asked me to modify the process and checkCanApply functions based on the inputs used in the code, but I don’t know how to define my inputs in these functions, especially since we agreed that only the RT plan would be described as a widget and that the CT and PTV would be extracted from the RT plan.

I haven’t worked with GUI codes and the functions used in them before, and my knowledge is very limited ☹ . If there is an informational source that I could learn from, I’d appreciate it if you could introduce it to me.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [October 15, 2024, 11:25am UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/34 "2024-10-15T11:25:38Z")

</div>

> [@sima](#):
>
> If there is an informational source that I could learn from, I’d appreciate it if you could introduce it to me.

Here’s the programming tutorial

> **[GitHub - Slicer/SlicerProgrammingTutorial: Introduction to Python scripting and module...](https://github.com/Slicer/SlicerProgrammingTutorial)**
>
> Introduction to Python scripting and module development for 3D Slicer

Once you finish and understand that, and you still need to see how things are done, there are a lot of Python modules in Slicer and its extensions. Look at any of them for examples.

---

<div class="post-metadata">

**Author:** ![sima](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sima/32/67638_2.png) [@sima](https://discourse.slicer.org/u/sima)\
**Post date:** [November 1, 2024, 7:30pm UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/35 "2024-11-01T19:30:54Z")

</div>

According to your recommendation, I reviewed the file you sent. However, since it was in slide format, the explanations were brief, and it wasn’t a very comprehensive document. So, I attempted to gather more information from GitHub, the internet, and AI. I did my best to implement the points you requested, however, I am uncertain about the success of my attempts. This was my first serious experience working with GitHub so I’d appreciate your feedback on my work and any corrections you suggest, as well as guidance on the next steps. I understand that the tasks you outlined were relatively straightforward, but as a beginner, they took me longer than expected. I apologize for any delay.

---

<div class="post-metadata">

**Author:** ![sima](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sima/32/67638_2.png) [@sima](https://discourse.slicer.org/u/sima)\
**Post date:** [November 14, 2024, 7:46am UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/36 "2024-11-14T07:46:51Z")

</div>

Hello professor Pinter

I just wanted to follow up on my previous message to ensure it was seen. I am still looking forward to any feedback or guidance you could provide to me.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [November 14, 2024, 12:02pm UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/37 "2024-11-14T12:02:36Z")

</div>

I gave all the pointers that I could. The alternative is for us to do this for you, but I am extremely busy these days with funded projects and grant submissions. If you have some funding towards this development, please let me know, otherwise I suggest doing again the Slicer programming tutorial and understand the basics well. On this level it is really not that hard.

---

<div class="post-metadata">

**Author:** ![sima](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sima/32/67638_2.png) [@sima](https://discourse.slicer.org/u/sima)\
**Post date:** [November 15, 2024, 6:32am UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/38 "2024-11-15T06:32:33Z")

</div>

Unfortunately, I don’t have any founding

That project was a part of my master’s thesis and I just wanted to continue my work by making it into a module for software that I have good memories with and I think, with the programming knowledge I had, I had good courage in taking this on. Now I have graduated and I’m on my own. Also, according to the Doller rate in my country, I can’t afford to pay.

I’m surprised to hear about funding from you after 37messages between us. I’ve always been honest in my messages and said that I’m a beginner in programming. My simple questions also showed that I’m not a Python programmer or a Slicer programmer. I can understand that I was slow in completing the tasks you asked of me, and this may have affected your opinion but I was completely sincere in my messages and requests for help.

> [@cpinter](#):
>
> A possible approach:

I was very happy that you gave me a roadmap

> [@cpinter](#):
>
> This takes us to step 4 in the list [here](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/17). I’ll give you guidance to do these changes, but let’s go step by step, I still need to create the module GUI.

and I could learn many things with your guidance. (like that and many other things)

Anyway, I’ll make my effort to continue and solve the fourth step in the roadmap, but not now because I feel discouraged and need time to recover.

Thank you for the time you’ve spent helping me.

Best regard

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [November 15, 2024, 8:46am UTC](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766/39 "2024-11-15T08:46:53Z")

</div>

Please understand that you cannot expect university professors and company directors to actually implement Slicer modules for you. Maybe you will realize this at a later stage of your carreer. I spent a lot of time trying to help you (much more than usual), and it’s unfortunate that it is not enough. Your module is just a little bit more complicated than the example in the tutorial…

[Previous page](https://discourse.slicer.org/t/creating-a-module-for-electron-bolus/37766.md?page=1)
