@@ -20,6 +20,7 @@ def get_isosurface_scene(
2020 isolvl : float | None = None ,
2121 step_size : int = 4 ,
2222 origin : ArrayLike | None = None ,
23+ isolvl_as_percentile : bool = True ,
2324 ** kwargs : Any ,
2425) -> Scene :
2526 """Get the isosurface from a VolumetricData object.
@@ -30,6 +31,7 @@ def get_isosurface_scene(
3031 isolvl (float, optional): The cutoff to compute the isosurface
3132 step_size (int, optional): step_size parameter for marching_cubes_lewiner. Defaults to 3.
3233 origin (ArrayLike, optional): The origin of the isosurface. Defaults to None.
34+ isolvl_as_percentile (bool, optional): If True, interpret `isolvl` as a percentile in the range 0 to 100; if False, treat it as an absolute value.
3335 **kwargs: Passed to the Surface object.
3436
3537 Returns:
@@ -42,10 +44,10 @@ def get_isosurface_scene(
4244 if isolvl is None :
4345 # get the value such that 20% of the weight is enclosed
4446 isolvl = np .percentile (data , 20 )
45- else :
47+ elif isolvl_as_percentile :
4648 isolvl = np .percentile (
47- data , min (isolvl , 1 ) * 100
48- ) # min is used for avoiding floating-point precision
49+ data , np . clip (isolvl , 0.01 , 99.9 )
50+ ) # np.clip is used for avoiding floating-point precision
4951
5052 padded_data = np .pad (data , (0 , 1 ), "wrap" )
5153 try :
0 commit comments