KVSlab / morphMan

A collection of tools for manipulation of morphological features in patient-specific geometries
https://morphman.readthedocs.io/en/latest/
Other
29 stars 12 forks source link

Manipulate Bifurcation: vtkMassProperties error and ValueError #72

Closed SMSadat98 closed 2 years ago

SMSadat98 commented 2 years ago

Hello @hkjeldsberg

While manipulating bifurcation on different geometries, I get different kinds of error. I have grossly identified 5 cases:

  1. Everything works fine, no error with geometries with 1 inlet, 2 or more outlets
  2. vtkMassProperties error while initially importing geometry, but no further error and angle changed successfully
  3. vtkMassProperties error while initially importing geometry, ValueError afterwards.
  4. only ValueError.
  5. only valueError while moving a certain pair of outlets in geometries with 3 outlets. (Angle between outlet 1 and 2 changes but 1 & 3; or 2 & 3 does not change)

These could indeed be geometry specific problems, but the valueError seems to be consistent in multiple geometries. I have used the "provide inlet" method in all of the geometries. I can provide the geometry files if necessary.

Best Reagrds, Sadat

vtkMassProperties Error:

C:\Users\user\anaconda3\envs\morphman_dev\python.exe C:/Users/user/Desktop/morphman_dev/main.py 2022-09-15 18:57:10.989 ( 0.774s) [ ] vtkDelaunay2D.cxx:840 ERR| vtkDelaunay2D (000001ED0A9A36D0): ERROR: Edge [55 0] is non-manifold!!! 2022-09-15 18:57:11.024 ( 0.809s) [ ] vtkExecutive.cxx:753 ERR| vtkCompositeDataPipeline (000001ED05DEC000): Algorithm vtkDelaunay2D(000001ED0A9A36D0) returned failure for request: vtkInformation (000001ED0B1A5570) Debug: Off Modified Time: 13551 Reference Count: 1 Registered Events: (none) Request: REQUEST_DATA FORWARD_DIRECTION: 0 ALGORITHM_AFTER_FORWARD: 1 FROM_OUTPUT_PORT: 0

2022-09-15 18:57:11.041 ( 0.826s) [ ] vtkMassProperties.cxx:89 ERR| vtkMassProperties (000001ED05DEC200): No data to measure...!

ValueError:

Computing centerlines...Cleaning surface. Triangulating surface. Computing centerlines. Computing centerlines...-- Computing voronoi diagram. -- Clipping centerlines. -- Clipping Voronoi diagram -- Rotating centerlines and voronoi diagram. Traceback (most recent call last): File "C:\Users\user\Desktop\morphman_dev\main.py", line 24, in manipulate_bifurcation(**default_values) File "C:\Users\user\anaconda3\envs\morphman_dev\lib\site-packages\morphman\morphman\manipulate_bifurcation.py", line 157, in manipulate_bifurcation rotated_cl = rotate_cl(patch_cl, end_points[1], m, R) File "C:\Users\user\anaconda3\envs\morphman_dev\lib\site-packages\morphman\morphman\manipulate_bifurcation.py", line 353, in rotate_cl tolerance = get_centerline_tolerance(patch_cl) File "C:\Users\user\anaconda3\envs\morphman_dev\lib\site-packages\morphman\morphman\common\centerline_operations.py", line 257, in get_centerline_tolerance tolerance = np.mean(length[1:n] - length[:n - 1]) / 2.0 ValueError: operands could not be broadcast together with shapes (40,) (41,)

Process finished with exit code 1

hkjeldsberg commented 2 years ago

Hello @SMSadat98 ,

Thanks for reporting this issue! I would be happy to investigate this further. Could you perhaps share the geometries you have been using with me?

Best, Henrik

SMSadat98 commented 2 years ago

Hello @hkjeldsberg ,

I have renamed the geometries according to their error and sent them via email. Thank you for looking into it!

Note: On one of the geometries, I had performed some additional smoothing operations in 3matic prior to running bifurcation manipulation and increased the poly ball size. That seemed to work for the particular geometry. But the other geometries still did not work.

Best Regards, Sadat

hkjeldsberg commented 2 years ago

Hello @SMSadat98 ,

Thanks for sharing the models with me. I was wondering if you could share the command line arguments you used to reproduce the error, or script if you have it available?

Otherwise I will be testing your models now using the example values from the documentation, e.g. +/- 20 degrees.

Best, Henrik

SMSadat98 commented 2 years ago

Hello @hkjeldsberg ,

For both models, the angle was 0.16 radian, and the poly ball size was 250.

using 20 degree (0.35 radian) reproduces the same error.

Best regards, Sadat

hkjeldsberg commented 2 years ago

Hi @SMSadat98 ,

Thanks! I think I detected what caused the different errors:

For the vtkMassProperties Error it appears that the error is geometry related, specifically the triangulation close to the boundaries. As you suggested, performing a light smoothing of the input seemed to fix this (at least for the provided models). I've included this in PR #73, which I will merge as soon as the tests pass.

Similarly, the ValueError was related to an assumption about the centerline sampling. I've fixed this in PR #73 as well, so this should not be an issue anymore.

I've shared a script with you, which should perform the manipulations you mentioned above. Note that for the ValueError model I set the cylinder_factor parameter to 2 (default was 7), which was also causing some errors. For the vtkMassProperties model the algorithm appeared to (automatically) capture the wrong boundary as inlet, so I set select_inlet = True for this model.

Attached you will find the resulting models (in red).

bifurcation_examples

SMSadat98 commented 2 years ago

Hello @hkjeldsberg ,

Thank you very much for addressing the issue immediately! I downloaded the developmental version again, and everything works perfectly without any error.

I have a feature request, which I will be addressing in a separate issue.

Thank you again.

Best Regards, Sadat

hkjeldsberg commented 2 years ago

Hi @SMSadat98 ,

I'm happy things worked out in the latest patch! I'll be closing this issue for now, and will address your latest feature request/issue soon.

Best, Henrik