Skip to content

Commit

Permalink
Merge pull request #38 from OmooLab/fix-import
Browse files Browse the repository at this point in the history
fix: color ramp not fit
  • Loading branch information
icrdr authored Aug 7, 2024
2 parents 2429eef + 38fb888 commit 21e0b85
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 deletions.
4 changes: 2 additions & 2 deletions bioxelnodes/assets/Nodes/BioxelNodes_4.2.blend
Git LFS file not shown
28 changes: 18 additions & 10 deletions bioxelnodes/bioxel/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from . import scipy
from . import skimage as ski
from . import scipy as ndi

# 3rd-party
import transforms3d
Expand Down Expand Up @@ -97,36 +98,43 @@ def fill(self, value: float, mask: np.ndarray):
_mask = np.expand_dims(_mask, axis=-1)
self.data = _mask * value + (1-_mask) * self.data

def resize(self, shape:tuple, progress_callback=None):
def resize(self, shape: tuple, progress_callback=None):
if len(shape) != 3:
raise Exception("Shape must be 3 dim")

data = self.data
order = 0 if self.dtype == bool else 1

# TXYZC > TXYZ
if self.kind in ['label', 'scalar']:
data = np.amax(data, -1)

if self.kind in ['scalar']:
dtype = data.dtype
data = data.astype(np.float32)
# if self.kind in ['scalar']:
# dtype = data.dtype
# data = data.astype(np.float32)

data_frames = ()
for f in range(self.frame_count):
if progress_callback:
progress_callback(f, self.frame_count)

frame = ski.resize(data[f, :, :, :],
shape,
preserve_range=True,
anti_aliasing=data.dtype.kind != "b")
# frame = ski.resize(data[f, :, :, :],
# shape,
# preserve_range=True,
# anti_aliasing=data.dtype.kind != "b")

factors = np.divide(self.shape, shape)
zoom_factors = [1 / f for f in factors]
frame = ndi.zoom(data[f, :, :, :],
zoom_factors,
order=order)

data_frames += (frame,)

data = np.stack(data_frames)

if self.kind in ['scalar']:
data = data.astype(dtype)
# if self.kind in ['scalar']:
# data = data.astype(dtype)

# TXYZ > TXYZC
if self.kind in ['label', 'scalar']:
Expand Down
2 changes: 1 addition & 1 deletion bioxelnodes/blender_manifest.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
schema_version = "1.0.0"

id = "bioxelnodes"
version = "0.3.2"
version = "0.3.3"
name = "Bioxel Nodes"
tagline = "For scientific volumetric data visualization in Blender"
maintainer = "Ma Nan <icrdr2010@outlook.com>"
Expand Down
6 changes: 4 additions & 2 deletions bioxelnodes/operators/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,12 @@ class ParseVolumetricData(bpy.types.Operator):
filepath: bpy.props.StringProperty(subtype="FILE_PATH") # type: ignore

skip_read_as: bpy.props.BoolProperty(name="Skip Read As",
default=False) # type: ignore
default=False,
options={"SKIP_SAVE"}) # type: ignore

skip_series_select: bpy.props.BoolProperty(name="Skip Sries Select",
default=True) # type: ignore
default=True,
options={"SKIP_SAVE"}) # type: ignore

read_as: bpy.props.EnumProperty(name="Read as",
default="scalar",
Expand Down
3 changes: 1 addition & 2 deletions bioxelnodes/operators/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ def execute(self, context):
return {'FINISHED'}
base_obj = label_objs[0]
label_objs = label_objs[1:]
container_obj = base_obj.parent

base_layer = obj_to_layer(base_obj)
modified_layer = base_layer.copy()
Expand All @@ -241,7 +240,7 @@ def execute(self, context):
for label_obj in label_objs:
label_layer = obj_to_layer(label_obj)
label_layer.resize(base_layer.shape)
modified_layer.data = np.maximum(base_layer.data, label_layer.data)
modified_layer.data = np.maximum(modified_layer.data, label_layer.data)
label_names.append(label_layer.name)

modified_layer.name = f"{'-'.join(label_names)}-Combined"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bioxelnodes"
version = "0.3.2"
version = "0.3.3"
description = ""
authors = ["Ma Nan <icrdr2010@outlook.com>"]
license = "MIT"
Expand Down

0 comments on commit 21e0b85

Please sign in to comment.