# Error in SegmentMesher

**URL:** <https://discourse.slicer.org/t/error-in-segmentmesher/26117>\
**Category:** Support\
**Created:** [November 7, 2022, 7:13pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117 "2022-11-07T19:13:33Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZSoltani](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zsoltani/32/17166_2.png) [@ZSoltani](https://discourse.slicer.org/u/ZSoltani)\
**Post date:** [November 7, 2022, 7:13pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/1 "2022-11-07T19:13:33Z")

</div>

Hello all,

I get the following error when I try to use Cleaver method to mesh a vertebra.

“Command ‘cleaver-cli’ returned non-zero exit status 109.” (attached photo)

 ![Screenshot from 2022-11-07 13-58-33](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/c/bc4fbdc35d16b6784b3c36e54217444a3a4818af.png)

Do you have any idea what does this error mean and how it can be solved?

Also, I am looking for some documents on using Cleaver method through programming Python intractor, which I guess it’s needed for adaptive mesh. I found some ideas in this [post](https://discourse.slicer.org/t/get-cell-indices-in-exported-mesh-corresponding-to-each-segment/15437/7), but it is comprehensive enough. Any suggestion is highly appreciated.

Thank you,  
Zahra

---

<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:** [November 7, 2022, 7:47pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/2 "2022-11-07T19:47:21Z")

</div>

The cleaver mesher CLI [never explicitly returns with error code 109](https://github.com/SCIInstitute/Cleaver2/blob/master/src/cli/mesher/main.cpp), so most likely this is generated at somewhere higher level and will not reveal anything specific about the problem. Maybe the process has ran out of memory. Monitor the memory usage and free memory while the mesher is running to confirm this.

You can also build Cleaver and run it in a debugger to understand what is happening, and if you don’t find a solution then report all your findings at [Cleaver’s issue tracker](https://github.com/SCIInstitute/Cleaver2/issues). While you are waiting for the answer, you can adjust the meshing parameters to avoid this error.

---

<div class="post-metadata">

**Author:** ![ZSoltani](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zsoltani/32/17166_2.png) [@ZSoltani](https://discourse.slicer.org/u/ZSoltani)\
**Post date:** [November 7, 2022, 8:08pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/3 "2022-11-07T20:08:49Z")

</div>

Hi Andras,

Thanks for your reply. I tried to use the module on another disk and actually another operating system (from Linux to Windows), but I still get the same error. The mesher doesn’t run at all for monitoring the process and the error pops up immediately. Plus, the WorkStation has plenty of empty space available.

Attached you can also see the error message in Python interactor, if it helps any.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/6/c/6c306f6bd1e47c3f63e318d6501ff4d23cd8aee7.png)

---

<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:** [November 7, 2022, 8:22pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/4 "2022-11-07T20:22:42Z")

</div>

What are the messages above `Run with --help for more information`?

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [November 7, 2022, 8:26pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/5 "2022-11-07T20:26:32Z")

</div>

Didn’t we have an issue lately where an extra space or empty string was being post-pended to a command line string leading to an error message like this? The error message makes it look like the same issue.

---

<div class="post-metadata">

**Author:** ![ZSoltani](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zsoltani/32/17166_2.png) [@ZSoltani](https://discourse.slicer.org/u/ZSoltani)\
**Post date:** [November 7, 2022, 8:28pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/6 "2022-11-07T20:28:40Z")

</div>

Here is the full message:

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/5/c5d1dcf3f6f9364c0d7c009adc3f3af424707aa6.png)

(I played with meshing parameters a bit!)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [November 7, 2022, 8:30pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/7 "2022-11-07T20:30:21Z")

</div>

Yes, that last `''` in the argument list looks like the issue I mentioned. Maybe you can try editing the python code to remove it before running the command.

---

<div class="post-metadata">

**Author:** ![ZSoltani](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zsoltani/32/17166_2.png) [@ZSoltani](https://discourse.slicer.org/u/ZSoltani)\
**Post date:** [November 7, 2022, 8:32pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/8 "2022-11-07T20:32:59Z")

</div>

Thanks Steve for the reply. Can you explain a bit more on the source of the error, so I can find a clue where should I edit in the code?  
​​  
​​​​​​​​​​​

---

<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:** [November 7, 2022, 8:33pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/9 "2022-11-07T20:33:58Z")

</div>

I’ve pushed a fix:

> <https://github.com/lassoan/SlicerSegmentMesher/commit/444adc113a63533a433b7f15706555bcc33f31f3>
>
> There was an extra empty command-line parameter and the new, more strict parser …of Cleaver2 returned with failure due to the unexpected argument.

You can make the change in the script on your computer right now or update the extension from the extensions manager tomorrow.

---

<div class="post-metadata">

**Author:** ![ZSoltani](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zsoltani/32/17166_2.png) [@ZSoltani](https://discourse.slicer.org/u/ZSoltani)\
**Post date:** [November 7, 2022, 8:34pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/10 "2022-11-07T20:34:45Z")

</div>

Thank you Andras, I’ll do that.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [November 7, 2022, 8:35pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/11 "2022-11-07T20:35:25Z")

</div>

Yes, that’s the fix I would have expected. Will be great if you can try it out and report back @ZSoltani

---

<div class="post-metadata">

**Author:** ![ZSoltani](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zsoltani/32/17166_2.png) [@ZSoltani](https://discourse.slicer.org/u/ZSoltani)\
**Post date:** [November 7, 2022, 8:36pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/12 "2022-11-07T20:36:38Z")

</div>

Sure, I will try it and report back. Thank you @lassoan and @pieper for your great support.

---

<div class="post-metadata">

**Author:** ![ZSoltani](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zsoltani/32/17166_2.png) [@ZSoltani](https://discourse.slicer.org/u/ZSoltani)\
**Post date:** [November 8, 2022, 4:40pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/13 "2022-11-08T16:40:39Z")

</div>

HI,

As a report: With the updated version of the Segment Mesher, it can complete the mesh generation using Cleaver method. Thank you for that.

However, at the end of the process, Python interactor shows a message that .vtk and .info files are written in a subfolder in SegmentMesher folder. But the folder is empty and no file is there (I checked view the hidden option too). Please see the attached image.

Thanks,  
Zahra

 ![Screenshot from 2022-11-08 09-28-21](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/e/e/ee129f943994822070e94fc1c8ac5836d13af16c.png)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [November 8, 2022, 7:00pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/14 "2022-11-08T19:00:00Z")

</div>

Hi Zahra -

I think you are getting close - the files are usually deleted after they are re-loaded in Slicer (with the idea that you can save out your final version form Slicer). But you can have them preserved if you check the box in the application settings:

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/4/f47e6320a9e820e5944ebe3447578a59ebdd23c8.png)

For me the current nightly version of the Segment Mesher extension is working as expected in the 5.0.3 release. Let us know if it works for you or you run into other issues. Here the source segmentation is shown semi-transparent over the meshed result.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/b/cb3ea233edf02c385351527afeb061902de063c8.jpeg)

---

<div class="post-metadata">

**Author:** ![ZSoltani](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zsoltani/32/17166_2.png) [@ZSoltani](https://discourse.slicer.org/u/ZSoltani)\
**Post date:** [November 8, 2022, 7:28pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/15 "2022-11-08T19:28:18Z")

</div>

Thank you @pieper, that default setting makes a real sense.

I was also wondering if there is a way to improve the mesh quality in a few local areas manually? In the attached image, I want to have some control in the two specified areas.

Thanks,  
Zahra

 ![Screenshot from 2022-11-08 13-13-46](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/c/2c34abd9100103a35551f16502289300cb17fe77.png)

---

<div class="post-metadata">

**Author:** ![ZSoltani](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zsoltani/32/17166_2.png) [@ZSoltani](https://discourse.slicer.org/u/ZSoltani)\
**Post date:** [November 8, 2022, 8:23pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/16 "2022-11-08T20:23:04Z")

</div>

With changing the mesh parameters, I could get rid of those areas and have a nice mesh generated as below. But still I am wondering about possibility to control mesh in local areas?

Thank you,  
Zahra

 ![Screenshot from 2022-11-08 14-19-10](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/3/c/3c90c5db31b1d1327e493d55b6b03f7f6afa88a3.png)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [November 8, 2022, 8:31pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/17 "2022-11-08T20:31:18Z")

</div>

Great 🎉 Glad it’s working for you.

---

<div class="post-metadata">

**Author:** ![ZSoltani](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zsoltani/32/17166_2.png) [@ZSoltani](https://discourse.slicer.org/u/ZSoltani)\
**Post date:** [November 8, 2022, 8:36pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/18 "2022-11-08T20:36:26Z")

</div>

Thanks Steve indeed for the great support!

I have another question though. The mesh generated is 4-node linear tetrahedral element (C3D4), by default. How can I change the element type to 10-node quadratic tetrahedral element (C3D10)?

Thanks,  
Zahra

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [November 8, 2022, 8:42pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/19 "2022-11-08T20:42:38Z")

</div>

That’s a great question but I don’t know enough about Cleaver to answer. If nobody here knows you could follow up at the cleaver github.

---

<div class="post-metadata">

**Author:** ![ZSoltani](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zsoltani/32/17166_2.png) [@ZSoltani](https://discourse.slicer.org/u/ZSoltani)\
**Post date:** [November 9, 2022, 3:04pm UTC](https://discourse.slicer.org/t/error-in-segmentmesher/26117/20 "2022-11-09T15:04:35Z")

</div>

Just as an update, I asked people in the Cleaver github and based on their reply, higher order elements aren’t supported in Cleaver at this time. But still, C3D4 can be converted to C3D10 by adding nodes at the midpoints of the edges.

Best,  
Zahra

[Next page](https://discourse.slicer.org/t/error-in-segmentmesher/26117.md?page=2)
