# How to start with monailabel for new models

**URL:** <https://discourse.slicer.org/t/how-to-start-with-monailabel-for-new-models/21063>\
**Category:** Support\
**Tags:** monailabel\
**Created:** [December 14, 2021, 10:55pm UTC](https://discourse.slicer.org/t/how-to-start-with-monailabel-for-new-models/21063 "2021-12-14T22:55:54Z")\
**Posts on this page:** 13\
**Page:** 7

<div class="post-metadata">

**Author:** ![xiang\_yao](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/xiang_yao/32/68673_2.png) [@xiang\_yao](https://discourse.slicer.org/u/xiang_yao)\
**Post date:** [December 14, 2023, 7:55am UTC](https://discourse.slicer.org/t/how-to-start-with-monailabel-for-new-models/21063/124 "2023-12-14T07:55:04Z")

</div>

Could you please provide more specific information on the differences between Deepedit and Segmentation models？I am not very clear about the differences between these two in practical application.Thanks

---

<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:** [December 15, 2023, 12:41pm UTC](https://discourse.slicer.org/t/how-to-start-with-monailabel-for-new-models/21063/125 "2023-12-15T12:41:00Z")

</div>

ChatGPT´s response to your question is:

MonaiLabel, an open-source tool focused on medical imaging AI, provides various functionalities including annotation and AI-assisted segmentation. Two key models in MonaiLabel are DeepEdit and Segmentation, and understanding their differences is crucial for their effective application.

1. **DeepEdit Models** :

2. **Segmentation Models** :

In practical application, the choice between DeepEdit and Segmentation models depends on the specific requirements of your task. If your work requires detailed, user-guided annotation in complex or highly variable images, DeepEdit is the better choice. On the other hand, if you are dealing with a large volume of images with consistent patterns, a Segmentation model would be more efficient and effective.

Remember that the success of both models heavily depends on the quality and representativeness of the training data. For specialized medical imaging tasks, it’s crucial to have a well-curated dataset that reflects the diversity and complexity of the cases you intend to handle.

[Link to ChatGPT response](https://chat.openai.com/share/d5b1b3fd-141a-47bc-9e42-7f17dbf516f6)

---

<div class="post-metadata">

**Author:** ![sfat](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sfat/32/66469_2.png) [@sfat](https://discourse.slicer.org/u/sfat)\
**Post date:** [December 19, 2023, 4:53am UTC](https://discourse.slicer.org/t/how-to-start-with-monailabel-for-new-models/21063/126 "2023-12-19T04:53:34Z")

</div>

Hi I’m running to a strange problem with my monai label on ubuntu. After successfully pip installing it, whatever command i pass to monailabel in command line I get the same response |

Using PYTHONPATH=/home/xxx::/home/xxx/yy/packages\_zzzl:/home/xxx/yyy/packages\_zzz

I’ve tried installing from git repo but still getting the same response. Can someone help with this please ?

---

<div class="post-metadata">

**Author:** ![sfat](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sfat/32/66469_2.png) [@sfat](https://discourse.slicer.org/u/sfat)\
**Post date:** [December 19, 2023, 7:59am UTC](https://discourse.slicer.org/t/how-to-start-with-monailabel-for-new-models/21063/127 "2023-12-19T07:59:48Z")

</div>

I figured it … needed to set python alias pointing it to python3

---

<div class="post-metadata">

**Author:** ![diazandr3s](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/diazandr3s/32/9973_2.png) [@diazandr3s](https://discourse.slicer.org/u/diazandr3s)\
**Post date:** [December 20, 2023, 9:16pm UTC](https://discourse.slicer.org/t/how-to-start-with-monailabel-for-new-models/21063/128 "2023-12-20T21:16:40Z")

</div>

This is amazing! Thanks for sharing this, @rbumm

---

<div class="post-metadata">

**Author:** ![xiang\_yao](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/xiang_yao/32/68673_2.png) [@xiang\_yao](https://discourse.slicer.org/u/xiang_yao)\
**Post date:** [January 15, 2024, 8:34am UTC](https://discourse.slicer.org/t/how-to-start-with-monailabel-for-new-models/21063/129 "2024-01-15T08:34:13Z")

</div>

Thank you for your professional explanation.This will be of great help to me.

Now I am using MONIAILabel to train a segmentation model for the 1-5 segments of the lumbar spine, which removes the bone cortex.  
However, after using Segmentation, the training results were not satisfactory. Later, I switched to Deepedit for training from scratch. When the training accuracy was 80%, I noticed that my dataset’s train loss was around 0.0010, and the accuracy no longer improved, And I don’t know how to use smartEdit and Scribbles for interactive annotation and editing.  
The comparison between manually annotated images for training and images automatically segmented by models trained through Deepedit is as follows.  
It can be seen that the automatically segmented images have a lot of jagged edges and are not very accurate. I would like to ask if the segmentation model can achieve the level of my own manual segmentation, how to improve segmentation quality, and how to solve jagged edges. 🧐

 ![Manual annotation](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/5/45ff41c5976816becf0cbf1eeaa78e1c3c3806ef.png)  
 ![MONAILabel Deepedit Segmention](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/d/2d44bac4eac86d0b7d2718d713f581ac7455d35e.jpeg)

---

<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:** [January 15, 2024, 12:42pm UTC](https://discourse.slicer.org/t/how-to-start-with-monailabel-for-new-models/21063/130 "2024-01-15T12:42:34Z")

</div>

How many training datasets did you use to achieve this result?

---

<div class="post-metadata">

**Author:** ![xiang\_yao](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/xiang_yao/32/68673_2.png) [@xiang\_yao](https://discourse.slicer.org/u/xiang_yao)\
**Post date:** [January 16, 2024, 1:40am UTC](https://discourse.slicer.org/t/how-to-start-with-monailabel-for-new-models/21063/131 "2024-01-16T01:40:22Z")

</div>

There are only four, but I have increased some by copying and rotating the angle, but I am not sure if it is effective. May I ask if it is necessary to have at least 20 different training datasets like the sample datasets.

---

<div class="post-metadata">

**Author:** ![muratmaga](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/muratmaga/32/83011_2.png) [@muratmaga](https://discourse.slicer.org/u/muratmaga)\
**Post date:** [January 16, 2024, 4:59am UTC](https://discourse.slicer.org/t/how-to-start-with-monailabel-for-new-models/21063/132 "2024-01-16T04:59:02Z")

</div>

With that such low number of samples, that’s probably what you can expect. Also, I believe MonaiLabel does automatic augmentation (random rotations, and other transformations of the training data), so you don’t have to manually do it.

Is there a reason you are not using TotalSegmentator to do this?

---

<div class="post-metadata">

**Author:** ![xiang\_yao](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/xiang_yao/32/68673_2.png) [@xiang\_yao](https://discourse.slicer.org/u/xiang_yao)\
**Post date:** [January 16, 2024, 8:50am UTC](https://discourse.slicer.org/t/how-to-start-with-monailabel-for-new-models/21063/133 "2024-01-16T08:50:30Z")

</div>

Thank you very much for your answer.

I will increase the amount of data in my training datasets in the future.

The TotalSegmentator can automatically and high-quality divide many organs, but I need to segment the lumbar spine L1-5 in a cylindrical shape like the one in the picture, without including the cortical bone. My understanding of the Total Segmenter is that it cannot achieve the desired effect. Perhaps I should try the segmentation effect.

---

<div class="post-metadata">

**Author:** ![mangotee](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@mangotee](https://discourse.slicer.org/u/mangotee)\
**Post date:** [January 16, 2024, 5:41pm UTC](https://discourse.slicer.org/t/how-to-start-with-monailabel-for-new-models/21063/134 "2024-01-16T17:41:03Z")

</div>

Please note that when using the deepedit model, your entire volume will be resampled to the target `spatial_size` (e.g. 128x128x128 by default). You would need to change that in the configuration in [this line](https://github.com/Project-MONAI/MONAILabel/blob/main/sample-apps/radiology/lib/configs/deepedit.py#L77).

By the way, even though ChatGPT’s answer is helpful, it omits an important disctinction between the deepedit and segmentation model 🙂 In the deepedit model, the `target_spacing` parameter is ignored, the entire volume is resampled to a voxel grid of `spatial_size`, which can lead to weird anisotropy issues if the volume is much larger in one of the spatial directions.

To account for that, e.g. as in your case of torso CT scans, I would probably try sth like 128x128x192, to account for the larger FOV in axial direction. Of course, you will need much more VRAM on your GPU to train the model.

Alternatively, to avoid staircase artifacts, you can use the segmentation model, and specify both `spatial_size` and a target resolution, e.g. 1x1x1mm. Hope that helps 🙂

(Side note: I agree with @muratmaga - 4 volumes is probably not sufficient to train this problem)

---

<div class="post-metadata">

**Author:** ![xiang\_yao](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/xiang_yao/32/68673_2.png) [@xiang\_yao](https://discourse.slicer.org/u/xiang_yao)\
**Post date:** [January 17, 2024, 2:09am UTC](https://discourse.slicer.org/t/how-to-start-with-monailabel-for-new-models/21063/135 "2024-01-17T02:09:32Z")

</div>

Thank you for making me realize what you said.  
This has given me a deeper understanding of the difference between Deepedit and Segmentation.  
It also taught me the meaning and purpose of the parameters target\_spacing and spatial\_size, even though they were originally set to 1.0 \* 1.0 \* 1.0 and 128 \* 128 \* 128.  
Next, I will try to increase the number of volumes and try Segmentation and Deepedit separately, and modify some of their parameters, such as changing spatial\_size to 128x128x192 or 256_256_384. Then study the effects achieved by both of them, hoping to improve the jagged image.  
Another small issue is that I found that there seems to be no parameter spatial\_size in the Segmentation model, but a parameter called roi\_size. This should be the difference between the two you mentioned, right?

---

<div class="post-metadata">

**Author:** ![evaherbst](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/evaherbst/32/65595_2.png) [@evaherbst](https://discourse.slicer.org/u/evaherbst)\
**Post date:** [January 17, 2024, 9:35am UTC](https://discourse.slicer.org/t/how-to-start-with-monailabel-for-new-models/21063/136 "2024-01-17T09:35:03Z")

</div>

Thank you for mentioning this distinction between the settings for deepedit and the segmentation model. I have a question - if I work with scans that are roughly the same volume (but slightly different), is that a problem? I assume the “spatial size” parameter in the segmentation model sets it for the whole model (rather than a scan per scan basis).

I am planning on using MonaiLabel for a future project to train segmentation of CT images, and the cropping of the images might vary slightly.

Is it necessary to crop all training volumes to the same size?

Best,  
Eva

[Previous page](https://discourse.slicer.org/t/how-to-start-with-monailabel-for-new-models/21063.md?page=6)
