How to replace markups with np.array in application MarkupsToModel

I want to convert a set of point clouds (np.array) to closed surfaces, How to use np.array directly in MarkupsToModel instead of converting np.array to Markups?

You need to convert the numpy array to a MRML model node to use it in Slicer modules. Bulk data (point coordinates) does not have to be copied, so the conversion should take negligible time.

1 Like

Thanks!!!@lassosan
I see :innocent:

但是, 我想要这个👇面积, 可是转化为model后得到的表面积似乎有点大, 转化为curve后得到的面积似乎又太小了…

However, I want :point_down: this area, but the surface area obtained after converting to model seems to be too large, and the area obtained after converting to curve seems to be too small…what’s wrong?
image

image

What is your end goal?
What the point cloud represents (points on a curve, points on surface, points in a 3D region,…)?
Do you need to interact with the points or just create a model?

I want to get the area of ​​contours formed by a set of point clouds (np.array) that lie in a plane.
:point_down:
image

Do you want to fit a plane to these points? You can do that directly using a markup plane, as shown here. Note that points are imported into a model node instead of a markup point list node.

No…I want the surface Area of ​​contours formed by a set of point clouds (np.array) …

If you want to compute soap bubble surface from ordered points along a closed curve then you can do that by importing the points into a markup closed curve node and enabling the “area” measurement. If you want to see the generated surface then I would recommend to use the Baffle Planner module in SlicerHeart extension and then get the surface area of the generated model from the Models module.

I tried to compute the [quote=“lassoan, post:8, topic:25000”]
surface from ordered points along a closed curve then you can do that by importing the points into a markup closed curve node
[/quote], but found that its efficiency is too low, especially when using slicer.util.updateMarkupsControlPointsFromArray, is there a better and faster method to get a curve from np.array?

I’ve fixed the performance issue in the latest Slicer Preview Release (that you download 2022-09-03 or later). Now slicer.util.updateMarkupsControlPointsFromArray should complete immediately.

Can I only replace the util.py file in the my current version (5.1.0-2022-05-08) Slicer with util.py without updating the Slicer?

As I remember I’ve made some more improvements since Slicer-5.0.3 in C++ code, so updating util.py is probably not sufficient. Another complication may be that util.py of Slicer-5.1 may not be compatible with Slicer-5.0. I would recommend to download the Slicer Preview Release tomorrow and use that.

1 Like