# Automation MONAILabel functionality

**URL:** <https://discourse.slicer.org/t/automation-monailabel-functionality/25335>\
**Category:** Support\
**Tags:** python\
**Created:** [September 19, 2022, 10:55am UTC](https://discourse.slicer.org/t/automation-monailabel-functionality/25335 "2022-09-19T10:55:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukasvanderstricht](https://avatars.discourse-cdn.com/v4/letter/l/7ba0ec/32.png) [@lukasvanderstricht](https://discourse.slicer.org/u/lukasvanderstricht)\
**Post date:** [September 19, 2022, 10:55am UTC](https://discourse.slicer.org/t/automation-monailabel-functionality/25335/1 "2022-09-19T10:55:58Z")

</div>

Hi everyone

I am using MONAILabel to train models to automatically segment certain body parts on MRI/CT images.  
The training went well and I have a decent model. I am interested in volumetric properties of the segmentation I have made with _Automatic segmentation_.  
With the help of some existing blog posts and such, I have already succeeded in writing a `Python` script to generate a table with the `SegmentStatistics` module and save it locally as a `.csv` file. I would however want to automate this process even further and include in my script the step where I press _Run_ for the automatic segmentation in MONAILabel. I am looking for how I can translate this step to `Python` code, similar to [this](https://discourse.slicer.org/t/using-segmentstatistics-module-in-python-script/2140).

I found the [source code](https://github.com/Project-MONAI/MONAILabel/blob/main/plugins/slicer/MONAILabel/MONAILabel.py) for this module, and I suspect that the function I’m looking for is `onClickSegmentation` on [line 1446](https://github.com/Project-MONAI/MONAILabel/blob/df9de94ff8b668d896e5aed902338811a0aca281/plugins/slicer/MONAILabel/MONAILabel.py#L1446). The only problem is that I don’t know how to invoke this function in a `Python` script.

Thanks in advance!

Lukas
