diff --git a/README.md b/README.md index 7a49539..276600e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[中文文档](https://uj6xfhbzp0.feishu.cn/wiki/Qx3VwHuNPimeI8kr6nDcvl1DnHf?from=from_copylink) +[中文文档](https://uj6xfhbzp0.feishu.cn/wiki/LPKEwjooSivxjskWHlCcQznjnNf?from=from_copylink) # Bioxel Nodes @@ -26,18 +26,18 @@ Welcome to our [discord server](https://discord.gg/pYkNyq2TjE), if you have any ## Support Multiple Formats -| Format | EXT | Test | -| ------ | ---------------------------------------- | ------- | -| DICOM | .dcm, .DCM, .DICOM, .ima, .IMA | ✅ pass | -| BMP | .bmp, .BMP | ✅ pass | -| JPEG | .jpg, .JPG, .jpeg, .JPEG | ✅ pass | -| PNG | .png, .PNG | ✅ pass | -| TIFF | .tif, .TIF, .tiff, .TIFF | ✅ pass | -| Nifti | .nia, .nii, .nii.gz, .hdr, .img, .img.gz | ✅ pass | -| Nrrd | .nrrd, .nhdr | ✅ pass | -| HDF5 | .hdf, .h4, .hdf4, .he2, .h5, .hdf5, .he5 | ✅ pass | -| OME | .ome.tiff, .ome.tif | ✅ pass | -| MRC | .mrc, .mrc.gz, .map, .map.gz | ✅ pass | +| Format | EXT | +| ------ | ---------------------------------------- | +| DICOM | .dcm, .DCM, .DICOM, .ima, .IMA | +| BMP | .bmp, .BMP | +| JPEG | .jpg, .JPG, .jpeg, .JPEG | +| PNG | .png, .PNG | +| TIFF | .tif, .TIF, .tiff, .TIFF | +| Nifti | .nia, .nii, .nii.gz, .hdr, .img, .img.gz | +| Nrrd | .nrrd, .nhdr | +| HDF5 | .hdf, .h4, .hdf4, .he2, .h5, .hdf5, .he5 | +| OME | .ome.tiff, .ome.tif | +| MRC | .mrc, .mrc.gz, .map, .map.gz | ## Support 4D volumetric data @@ -59,16 +59,6 @@ Welcome to our [discord server](https://discord.gg/pYkNyq2TjE), if you have any - Only works with Cycles CPU , Cycles GPU (OptiX), EEVEE - Section surface cannot be generated when convert to mesh (will be supported soon) -## Compatible to Newer Version - -**v0.3.x is not compatible to v0.2.x, Updating this addon may break old files. Read the following carefully before upgradation** - -Before upgradation, you need to ask yourself whether this project file will be modified again or not, if it's an archived project file, I would recommend that you run **Bioxel Nodes > Save Staged Data** to make the addon nodes permanent. In this way, there will be no potential problem with the nodes not functioning due to the addon update. - -After the addon update, your old project files may not work either, this may be because you had executed **Save Staged Data**. If so, you need to execute **Bioxel Nodes > Relink Nodes to Addon** to relink them to make sure that the addon's new functionality and the addon nodes are synchronized. - -Also, the older shaders are not based on OSL, so if you find that you can't render volumes, you need to turn on **Open Shading Language (OSL)** in the Render Settings. - ## Roadmap - Better multi-format import experience diff --git a/bioxelnodes/assets/Nodes/BioxelNodes_v0.1.x.blend b/bioxelnodes/assets/Nodes/BioxelNodes_v0.1.x.blend deleted file mode 100644 index 70cc114..0000000 --- a/bioxelnodes/assets/Nodes/BioxelNodes_v0.1.x.blend +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d6832d20cb556ff904cfd7c5574b048ea54011cb531fe6423c4689186de2c8aa -size 1749214 diff --git a/bioxelnodes/assets/Nodes/BioxelNodes_v0.2.x.blend b/bioxelnodes/assets/Nodes/BioxelNodes_v0.2.9.blend similarity index 100% rename from bioxelnodes/assets/Nodes/BioxelNodes_v0.2.x.blend rename to bioxelnodes/assets/Nodes/BioxelNodes_v0.2.9.blend diff --git a/bioxelnodes/assets/Nodes/BioxelNodes_v0.3.x.blend b/bioxelnodes/assets/Nodes/BioxelNodes_v0.3.3.blend similarity index 100% rename from bioxelnodes/assets/Nodes/BioxelNodes_v0.3.x.blend rename to bioxelnodes/assets/Nodes/BioxelNodes_v0.3.3.blend diff --git a/bioxelnodes/assets/Nodes/BioxelNodes_v1.0.0.blend b/bioxelnodes/assets/Nodes/BioxelNodes_v1.0.0.blend new file mode 100644 index 0000000..bd08aa5 --- /dev/null +++ b/bioxelnodes/assets/Nodes/BioxelNodes_v1.0.0.blend @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:13ae301e135b547c9a348e2e7a0f2fbac42947e70c58a3a8b90875a23c5b0a4f +size 8976894 diff --git a/bioxelnodes/assets/Nodes/BioxelNodes_v1.0.x.blend b/bioxelnodes/assets/Nodes/BioxelNodes_v1.0.x.blend deleted file mode 100644 index ef7bc8b..0000000 --- a/bioxelnodes/assets/Nodes/BioxelNodes_v1.0.x.blend +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cda3a7c9f63386b6c7e48e5447a03366b51a3e2b446b53955cc42b7b98e5c504 -size 9005254 diff --git a/bioxelnodes/bioxelutils/common.py b/bioxelnodes/bioxelutils/common.py index e2d2a4e..b7e0011 100644 --- a/bioxelnodes/bioxelutils/common.py +++ b/bioxelnodes/bioxelutils/common.py @@ -2,7 +2,7 @@ from pathlib import Path import bpy -from ..constants import NODE_LIB_FILEPATH, VERSION +from ..constants import NODE_LIB_DIRPATH, VERSIONS from ..utils import get_cache_dir @@ -215,31 +215,46 @@ def get_file_prop(prop): return props.get(prop) +def get_node_version(): + node_version = get_file_prop("node_version") + return literal_eval(node_version) if node_version else None + + def is_incompatible(): - if get_file_prop("addon_version") is None: + node_version = get_node_version() + if node_version is None: for node_group in bpy.data.node_groups: if node_group.name.startswith("BioxelNodes"): return True else: - addon_version = literal_eval(get_file_prop("addon_version")) - if addon_version[0] != VERSION[0]\ - or addon_version[1] != VERSION[1]: + addon_version = VERSIONS[0]["node_version"] + if node_version[0] != addon_version[0]\ + or node_version[1] != addon_version[1]: return True return False + +def get_node_lib_path(node_version): + version_str = "v"+".".join([str(i) for i in list(node_version)]) + lib_filename = f"BioxelNodes_{version_str}.blend" + return Path(NODE_LIB_DIRPATH, + lib_filename).resolve() + + def local_lib_not_updated(): + addon_version = VERSIONS[0]["node_version"] + addon_lib_path = get_node_lib_path(addon_version) + use_local = False for node_group in bpy.data.node_groups: if node_group.name.startswith("BioxelNodes"): - node_group_lib = node_group.library - if node_group_lib: - abs_filepath = bpy.path.abspath(node_group_lib.filepath) - _local_lib_file = Path(abs_filepath).resolve().as_posix() - if _local_lib_file != NODE_LIB_FILEPATH.as_posix(): + lib = node_group.library + if lib: + lib_path = Path(bpy.path.abspath(lib.filepath)).resolve() + if lib_path != addon_lib_path: use_local = True break - - addon_version = literal_eval(get_file_prop("addon_version")) - not_update = addon_version != VERSION - return use_local and not_update \ No newline at end of file + + not_update = get_node_version() != addon_version + return use_local and not_update diff --git a/bioxelnodes/bioxelutils/container.py b/bioxelnodes/bioxelutils/container.py index 3be1f4c..f8cb3d3 100644 --- a/bioxelnodes/bioxelutils/container.py +++ b/bioxelnodes/bioxelutils/container.py @@ -92,7 +92,7 @@ def add_layers(layers: list[Layer], layer_obj = layer_to_obj(layer, container_obj, cache_dir) fetch_node = add_node_to_graph("FetchLayer", node_group, - get_use_link()) + use_link=get_use_link()) fetch_node.label = get_layer_prop_value(layer_obj, "name") fetch_node.inputs[0].default_value = layer_obj diff --git a/bioxelnodes/bioxelutils/layer.py b/bioxelnodes/bioxelutils/layer.py index 14a0df7..0bebe84 100644 --- a/bioxelnodes/bioxelutils/layer.py +++ b/bioxelnodes/bioxelutils/layer.py @@ -172,7 +172,9 @@ def layer_to_obj(layer: Layer, socket_type="NodeSocketGeometry") modifier.node_group = node_group - layer_node = add_node_to_graph("_Layer", node_group, get_use_link()) + layer_node = add_node_to_graph("_Layer", + node_group, + use_link=get_use_link()) layer_node.inputs['name'].default_value = layer.name layer_node.inputs['shape'].default_value = layer.shape diff --git a/bioxelnodes/bioxelutils/node.py b/bioxelnodes/bioxelutils/node.py index 7279116..f642ea6 100644 --- a/bioxelnodes/bioxelutils/node.py +++ b/bioxelnodes/bioxelutils/node.py @@ -1,11 +1,10 @@ from pathlib import Path -import shutil import bpy -from .common import get_file_prop, set_file_prop +from .common import get_file_prop, get_node_lib_path, set_file_prop from ..exceptions import Incompatible, NoFound -from ..constants import NODE_LIB_FILEPATH, VERSION +from ..constants import VERSIONS def get_node_group(node_type: str, use_link=True): @@ -13,26 +12,27 @@ def get_node_group(node_type: str, use_link=True): # node_group = bpy.data.node_groups[node_type] # return node_group - if get_file_prop("addon_version") is None: - set_file_prop("addon_version", VERSION) + # added node is always from latest node version + addon_version = VERSIONS[0]["node_version"] + addon_lib_path = get_node_lib_path(addon_version) - local_lib_file = None - addon_lib_file = NODE_LIB_FILEPATH.as_posix() + if get_file_prop("node_version") is None: + set_file_prop("node_version", addon_version) + local_lib_path = None for node_group in bpy.data.node_groups: if node_group.name.startswith("BioxelNodes"): - node_group_lib = node_group.library - if node_group_lib: - abs_filepath = bpy.path.abspath(node_group_lib.filepath) - _local_lib_file = Path(abs_filepath).resolve().as_posix() - if _local_lib_file != addon_lib_file: - local_lib_file = _local_lib_file + lib = node_group.library + if lib: + lib_path = Path(bpy.path.abspath(lib.filepath)).resolve() + if lib_path != addon_lib_path: + local_lib_path = lib_path break # local lib first - lib_file = local_lib_file or addon_lib_file + lib_path = local_lib_path or addon_lib_path bpy.ops.wm.append('EXEC_DEFAULT', - directory=f"{lib_file}/NodeTree", + directory=f"{lib_path.as_posix()}/NodeTree", filename=node_type, link=use_link, use_recursive=True, @@ -52,8 +52,9 @@ def assign_node_group(node, node_type: str): return node -def add_node_to_graph(node_name: str, node_group, use_link=True): +def add_node_to_graph(node_name: str, node_group, node_label=None, use_link=True): node_type = f"BioxelNodes_{node_name}" + node_label = node_label or node_name # Deselect all nodes first for node in node_group.nodes: @@ -64,5 +65,6 @@ def add_node_to_graph(node_name: str, node_group, use_link=True): node = node_group.nodes.new("GeometryNodeGroup") assign_node_group(node, node_type) + node.label = node_label node.show_options = False return node diff --git a/bioxelnodes/blender_manifest.toml b/bioxelnodes/blender_manifest.toml index a166bb9..20c5057 100644 --- a/bioxelnodes/blender_manifest.toml +++ b/bioxelnodes/blender_manifest.toml @@ -19,10 +19,10 @@ wheels = [ "./wheels/SimpleITK-2.3.1-cp311-cp311-macosx_10_9_x86_64.whl", "./wheels/SimpleITK-2.3.1-cp311-cp311-macosx_11_0_arm64.whl", "./wheels/SimpleITK-2.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", - "./wheels/lxml-5.2.2-cp311-cp311-win_amd64.whl", - "./wheels/lxml-5.2.2-cp311-cp311-macosx_10_9_arm64.whl", - "./wheels/lxml-5.2.2-cp311-cp311-macosx_10_9_x86_64.whl", - "./wheels/lxml-5.2.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", + "./wheels/lxml-5.3.0-cp311-cp311-win_amd64.whl", + "./wheels/lxml-5.3.0-cp311-cp311-macosx_10_9_arm64.whl", + "./wheels/lxml-5.3.0-cp311-cp311-macosx_10_9_x86_64.whl", + "./wheels/lxml-5.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", "./wheels/h5py-3.11.0-cp311-cp311-win_amd64.whl", "./wheels/h5py-3.11.0-cp311-cp311-macosx_11_0_arm64.whl", "./wheels/h5py-3.11.0-cp311-cp311-macosx_10_9_x86_64.whl", @@ -34,4 +34,4 @@ wheels = [ ] [permissions] -files = "Import/export volume data from/to disk" +files = "Import/export volume data from/to disk" \ No newline at end of file diff --git a/bioxelnodes/constants.py b/bioxelnodes/constants.py index e93018e..53692f7 100644 --- a/bioxelnodes/constants.py +++ b/bioxelnodes/constants.py @@ -1,9 +1,11 @@ from pathlib import Path -VERSION = (1, 0, 0) -NODE_LIB_FILENAME = "BioxelNodes_v1.0.x" -NODE_LIB_FILEPATH = Path(Path(__file__).parent, - f"assets/Nodes/{NODE_LIB_FILENAME}.blend").resolve() +VERSIONS = [{"label": "Current", "node_version": (1, 0, 0)}, + {"label": "v0.3.x", "node_version": (0, 3, 3)}, + {"label": "v0.2.x", "node_version": (0, 2, 9)}] + +NODE_LIB_DIRPATH = Path(Path(__file__).parent, + "assets/Nodes").resolve() MENU_ITEMS = [ { @@ -23,9 +25,9 @@ 'description': '' }, { - 'label': 'Cutout by Color', + 'label': 'Cutout by Hue', 'icon': 'COLOR', - 'name': 'CutoutByColor', + 'name': 'CutoutByHue', 'description': '' }, "separator", @@ -50,7 +52,7 @@ ] }, { - 'label': 'Properties', + 'label': 'Property', 'icon': 'PROPERTIES', 'items': [ { @@ -148,7 +150,7 @@ ] }, { - 'label': 'Cutters', + 'label': 'Cut', 'icon': 'MOD_BEVEL', 'items': [ { @@ -173,31 +175,31 @@ ] }, { - 'label': 'Utils', + 'label': 'Extra', 'icon': 'MODIFIER', 'items': [ { - 'label': 'Pick Surface', + 'label': 'Fetch Surface', 'icon': 'OUTLINER_OB_MESH', - 'name': 'PickSurface', + 'name': 'FetchSurface', 'description': '' }, { - 'label': 'Pick Volume', + 'label': 'Fetch Volume', 'icon': 'OUTLINER_OB_VOLUME', - 'name': 'PickVolume', + 'name': 'FetchVolume', 'description': '' }, { - 'label': 'Pick Shape Wire', + 'label': 'Fetch Shape Wire', 'icon': 'FILE_VOLUME', - 'name': 'PickShapeWire', + 'name': 'FetchShapeWire', 'description': '' }, { - 'label': 'Pick Bbox Wire', + 'label': 'Fetch Bbox Wire', 'icon': 'MESH_CUBE', - 'name': 'PickBboxWire', + 'name': 'FetchBboxWire', 'description': '' }, "separator", diff --git a/bioxelnodes/menus.py b/bioxelnodes/menus.py index a120844..2323026 100644 --- a/bioxelnodes/menus.py +++ b/bioxelnodes/menus.py @@ -1,11 +1,11 @@ import bpy -from .constants import MENU_ITEMS, NODE_LIB_FILENAME +from .constants import MENU_ITEMS, VERSIONS from .node_menu import NodeMenu from .bioxelutils.common import (get_container_obj, get_container_layer_objs, get_layer_label, - get_layer_prop_value) + get_layer_prop_value, get_node_version, is_incompatible) from .operators.layer import (FetchLayer, RelocateLayer, RetimeLayer, RenameLayer, RemoveSelectedLayers, SaveSelectedLayersCache, ResampleLayer, SignScalar, CombineLabels, @@ -22,6 +22,39 @@ ReLinkNodeLib, RemoveAllMissingLayers, RenderSettingPreset, SaveAllLayersCache, SaveNodeLib, SliceViewer) +class IncompatibleMenu(bpy.types.Menu): + bl_idname = "BIOXELNODES_MT_INCOMPATIBLE" + bl_label = "Bioxel Nodes" + + def draw(self, context): + tip_text = "please downgrade addon version." + node_version = get_node_version() + if node_version: + version_str = "v"+".".join([str(i) for i in list(node_version)]) + tip_text = f"please downgrade addon version to {version_str}." + + layout = self.layout + layout.label(text="Incompatible node version detected.") + layout.separator() + layout.label( + text="If you still want to edit this file with bioxel nodes, ") + layout.label(text=tip_text) + layout.separator() + layout.label(text="If this file is archived, " + "please relink node library, ") + layout.label(text="check if it still works, " + "then save node library.") + layout.separator() + layout.menu(ReLinkNodeLibMenu.bl_idname) + layout.operator(SaveNodeLib.bl_idname) + + layout.separator() + layout.menu(DangerZoneMenu.bl_idname) + + layout.separator() + layout.menu(RenderSettingMenu.bl_idname) + + class FetchLayerMenu(bpy.types.Menu): bl_idname = "BIOXELNODES_MT_ADD_LAYER" bl_label = "Fetch Layer" @@ -122,18 +155,11 @@ class ReLinkNodeLibMenu(bpy.types.Menu): def draw(self, context): layout = self.layout - versions = [{"label": "v0.3.x", "filename": "BioxelNodes_v0.3.x"}, - {"label": "v0.2.x", "filename": "BioxelNodes_v0.2.x"}, - {"label": "v0.1.x", "filename": "BioxelNodes_v0.1.x"}] - op = layout.operator(ReLinkNodeLib.bl_idname, - text="Current Version") - op.node_lib_filename = NODE_LIB_FILENAME - layout.separator() - for version in versions: + for index, version in enumerate(VERSIONS): op = layout.operator(ReLinkNodeLib.bl_idname, text=version["label"]) - op.node_lib_filename = version["filename"] + op.index = index class RenderSettingMenu(bpy.types.Menu): @@ -185,7 +211,11 @@ def draw(self, context): def TOPBAR(self, context): layout = self.layout - layout.menu(BioxelNodesTopbarMenu.bl_idname) + + if is_incompatible(): + layout.menu(IncompatibleMenu.bl_idname) + else: + layout.menu(BioxelNodesTopbarMenu.bl_idname) class NodeHeadMenu(bpy.types.Menu): @@ -248,6 +278,9 @@ def draw(self, context): def NODE_CONTEXT(self, context): + if is_incompatible(): + return + container_obj = context.object is_geo_nodes = context.area.ui_type == "GeometryNodeTree" is_container = get_container_obj(container_obj) @@ -261,6 +294,9 @@ def NODE_CONTEXT(self, context): def NODE_HEAD(self, context): + if is_incompatible(): + return + container_obj = context.object is_geo_nodes = context.area.ui_type == "GeometryNodeTree" is_container = get_container_obj(container_obj) @@ -274,6 +310,9 @@ def NODE_HEAD(self, context): def NODE_PROP(self, context): + if is_incompatible(): + return + container_obj = context.object is_geo_nodes = context.area.ui_type == "GeometryNodeTree" is_container = get_container_obj(container_obj) @@ -354,8 +393,7 @@ def NODE_PROP(self, context): def VIEW3D_TOPBAR(self, context): layout = self.layout - layout.operator(SliceViewer.bl_idname, - icon=SliceViewer.bl_icon, text="") + layout.operator(SliceViewer.bl_idname) node_menu = NodeMenu( diff --git a/bioxelnodes/operators/container.py b/bioxelnodes/operators/container.py index ba9fc01..df4c347 100644 --- a/bioxelnodes/operators/container.py +++ b/bioxelnodes/operators/container.py @@ -100,7 +100,8 @@ def execute(self, context): output_node = get_nodes_by_type(node_group, 'NodeGroupOutput')[0] fetch_mesh_node = add_node_to_graph(f"Fetch{self.object_type}", node_group, - get_use_link()) + node_label=f"Fetch {self.object_type}", + use_link=get_use_link()) fetch_mesh_node.inputs[0].default_value = container_obj node_group.links.new(fetch_mesh_node.outputs[0], output_node.inputs[0]) @@ -220,7 +221,7 @@ def execute(self, context): # center = [find_center(axis) for axis in [x, y, z]] # cutter_obj.location = center - name = self.cutter_type.capitalize() + name = f"{self.cutter_type.capitalize()}_Cutter" cutter_obj.name = name cutter_obj.data.name = name cutter_obj.visible_camera = False @@ -243,13 +244,14 @@ def execute(self, context): if len(cut_nodes) == 0: cutter_node = add_node_to_graph("ObjectCutter", node_group, - get_use_link()) + node_label=name, + use_link=get_use_link()) cutter_node.inputs[0].default_value = self.cutter_type.capitalize() cutter_node.inputs[1].default_value = cutter_obj cut_node = add_node_to_graph("Cut", node_group, - get_use_link()) + use_link=get_use_link()) output_node = get_nodes_by_type(node_group, 'NodeGroupOutput')[0] @@ -362,7 +364,7 @@ def execute(self, context): slice_node = add_node_to_graph("Slice", node_group, - get_use_link()) + use_link=get_use_link()) slice_node.inputs[1].default_value = slicer_obj @@ -412,7 +414,8 @@ def execute(self, context): parent_node = add_node_to_graph("TransformParent", node_group, - get_use_link()) + node_label="Transform Parent", + use_link=get_use_link()) parent_node.inputs[1].default_value = locator_obj diff --git a/bioxelnodes/operators/io.py b/bioxelnodes/operators/io.py index 7819256..9e90a73 100644 --- a/bioxelnodes/operators/io.py +++ b/bioxelnodes/operators/io.py @@ -828,7 +828,7 @@ def modal(self, context, event): container = Container(name=name, layers=self.layers) - step_size = container.layers[0].bioxel_size[0]*5 + step_size = container.layers[0].bioxel_size[0]*10 container_obj = container_to_obj(container, scene_scale=self.scene_scale, step_size=step_size, @@ -839,8 +839,8 @@ def modal(self, context, event): # Change render setting for better result if is_first_import: bpy.ops.bioxelnodes.render_setting_preset('EXEC_DEFAULT', - preset="preview_c") - # bpy.ops.bioxelnodes.slice_viewer('EXEC_DEFAULT') + preset="balance") + bpy.context.scene.render.engine = 'CYCLES' self.report({"INFO"}, "Successfully Imported") return {'FINISHED'} diff --git a/bioxelnodes/operators/layer.py b/bioxelnodes/operators/layer.py index 16c8c0e..49da89f 100644 --- a/bioxelnodes/operators/layer.py +++ b/bioxelnodes/operators/layer.py @@ -3,14 +3,17 @@ import numpy as np + + from ..exceptions import NoContent from ..bioxel.layer import Layer +from ..bioxelutils.node import add_node_to_graph from ..bioxelutils.common import (get_container_obj, get_layer_kind, get_layer_label, get_layer_name, get_layer_prop_value, get_container_layer_objs, - get_node_type, is_missing_layer, set_layer_prop_value) + get_node_type, is_missing_layer, move_node_to_node, set_layer_prop_value) from ..bioxelutils.layer import layer_to_obj, obj_to_layer -from ..utils import get_cache_dir, copy_to_dir +from ..utils import get_cache_dir, copy_to_dir, get_use_link def get_label_layer_selection(self, context): @@ -105,12 +108,17 @@ def operate(self, orig_layer: Layer, context): return orig_layer def add_layer_node(self, context, layer): + orig_node = context.selected_nodes[0] layer_obj = layer_to_obj(layer, container_obj=context.object, cache_dir=get_cache_dir()) - - bpy.ops.bioxelnodes.fetch_layer('INVOKE_DEFAULT', - layer_obj_name=layer_obj.name) + node_group = context.space_data.edit_tree + fetch_node = add_node_to_graph("FetchLayer", + node_group, + use_link=get_use_link()) + fetch_node.label = get_layer_prop_value(layer_obj, "name") + fetch_node.inputs[0].default_value = layer_obj + move_node_to_node(fetch_node, orig_node, (0, -100)) def execute(self, context): layer_obj = get_selected_layer(context) diff --git a/bioxelnodes/operators/misc.py b/bioxelnodes/operators/misc.py index 52e848b..8b11151 100644 --- a/bioxelnodes/operators/misc.py +++ b/bioxelnodes/operators/misc.py @@ -2,10 +2,10 @@ from pathlib import Path import shutil -from ..bioxelutils.common import get_all_layer_objs, is_missing_layer, set_file_prop +from ..bioxelutils.common import get_all_layer_objs, get_node_lib_path, get_node_version, is_missing_layer, set_file_prop from .layer import RemoveLayers, SaveLayersCache -from ..constants import NODE_LIB_FILEPATH, VERSION +from ..constants import NODE_LIB_DIRPATH, VERSIONS from ..utils import get_cache_dir @@ -15,13 +15,12 @@ class ReLinkNodeLib(bpy.types.Operator): bl_description = "Relink all nodes to addon library source" bl_options = {'UNDO'} - node_lib_filename: bpy.props.StringProperty( - default="" - ) # type: ignore + index: bpy.props.IntProperty() # type: ignore def execute(self, context): - lib_filepath = Path(NODE_LIB_FILEPATH.parent, - f"{self.node_lib_filename}.blend") + node_version = VERSIONS[self.index]['node_version'] + lib_path = get_node_lib_path(node_version) + node_libs = [] for node_group in bpy.data.node_groups: if node_group.name.startswith("BioxelNodes"): @@ -32,10 +31,12 @@ def execute(self, context): node_libs = list(set(node_libs)) for node_lib in node_libs: - node_lib.filepath = str(lib_filepath) + node_lib.filepath = str(lib_path) # FIXME: may cause crash node_lib.reload() + set_file_prop("node_version", node_version) + self.report({"INFO"}, f"Successfully relinked.") return {'FINISHED'} @@ -54,13 +55,22 @@ class SaveNodeLib(bpy.types.Operator): ) # type: ignore def execute(self, context): + node_version = get_node_version() + if node_version is None: + node_version = VERSIONS[0]["node_version"] + else: + if node_version not in [v["node_version"] for v in VERSIONS]: + node_version = VERSIONS[0]["node_version"] + + lib_path = get_node_lib_path(node_version) + lib_dir = bpy.path.abspath(self.lib_dir) - local_lib_path: Path = Path(lib_dir, NODE_LIB_FILEPATH.name).resolve() - addon_lib_path: Path = NODE_LIB_FILEPATH + local_lib_path: Path = Path(lib_dir, lib_path.name).resolve() + node_lib_path: Path = lib_path blend_path = Path(bpy.path.abspath("//")).resolve() - if local_lib_path != addon_lib_path: - shutil.copy(addon_lib_path, local_lib_path) + if local_lib_path != node_lib_path: + shutil.copy(node_lib_path, local_lib_path) libs = [] for node_group in bpy.data.node_groups: @@ -73,8 +83,6 @@ def execute(self, context): lib.filepath = bpy.path.relpath(str(local_lib_path), start=str(blend_path)) - set_file_prop("addon_version", VERSION) - return {'FINISHED'} def invoke(self, context, event): @@ -116,55 +124,64 @@ class RenderSettingPreset(bpy.types.Operator): bl_options = {'UNDO'} PRESETS = { - "preview_e": "Preview (EEVEE)", - "preview_c": "Preview (Cycles)", - "production_e": "Production (EEVEE)", - "production_c": "Production (Cycles)" + "performance": "Performance", + "balance": "Balance", + "quality": "Quality", } preset: bpy.props.EnumProperty(name="Preset", - default="preview_c", + default="balance", items=[(k, v, "") for k, v in PRESETS.items()]) # type: ignore def execute(self, context): - if self.preset == "preview_e": - bpy.context.scene.render.engine = 'BLENDER_EEVEE_NEXT' + if self.preset == "performance": + # EEVEE bpy.context.scene.eevee.use_taa_reprojection = False - bpy.context.scene.eevee.taa_samples = 16 bpy.context.scene.eevee.volumetric_tile_size = '2' - bpy.context.scene.eevee.volumetric_shadow_samples = 128 + bpy.context.scene.eevee.volumetric_shadow_samples = 32 + bpy.context.scene.eevee.volumetric_samples = 64 + bpy.context.scene.eevee.volumetric_ray_depth = 1 + bpy.context.scene.eevee.use_volumetric_shadows = True + + # Cycles + bpy.context.scene.cycles.shading_system = True + bpy.context.scene.cycles.volume_bounces = 0 + bpy.context.scene.cycles.transparent_max_bounces = 4 + bpy.context.scene.cycles.volume_preview_step_rate = 4 + bpy.context.scene.cycles.volume_step_rate = 4 + + elif self.preset == "balance": + # EEVEE + bpy.context.scene.eevee.use_taa_reprojection = False + bpy.context.scene.eevee.volumetric_tile_size = '2' + bpy.context.scene.eevee.volumetric_shadow_samples = 64 bpy.context.scene.eevee.volumetric_samples = 128 - bpy.context.scene.eevee.volumetric_ray_depth = 16 + bpy.context.scene.eevee.volumetric_ray_depth = 8 bpy.context.scene.eevee.use_volumetric_shadows = True - elif self.preset == "production_e": - bpy.context.scene.render.engine = 'BLENDER_EEVEE_NEXT' + # Cycles + bpy.context.scene.cycles.shading_system = True + bpy.context.scene.cycles.volume_bounces = 4 + bpy.context.scene.cycles.transparent_max_bounces = 8 + bpy.context.scene.cycles.volume_preview_step_rate = 1 + bpy.context.scene.cycles.volume_step_rate = 1 + + elif self.preset == "quality": + # EEVEE bpy.context.scene.eevee.use_taa_reprojection = False - bpy.context.scene.eevee.taa_samples = 16 - bpy.context.scene.eevee.volumetric_tile_size = '1' + bpy.context.scene.eevee.volumetric_tile_size = '2' bpy.context.scene.eevee.volumetric_shadow_samples = 128 bpy.context.scene.eevee.volumetric_samples = 256 bpy.context.scene.eevee.volumetric_ray_depth = 16 bpy.context.scene.eevee.use_volumetric_shadows = True - elif self.preset == "preview_c": - bpy.context.scene.render.engine = 'CYCLES' + # Cycles bpy.context.scene.cycles.shading_system = True - bpy.context.scene.cycles.volume_bounces = 12 + bpy.context.scene.cycles.volume_bounces = 8 bpy.context.scene.cycles.transparent_max_bounces = 16 - bpy.context.scene.cycles.volume_preview_step_rate = 1 - bpy.context.scene.cycles.volume_step_rate = 1 - # bpy.context.scene.cycles.use_fast_gi = True - - elif self.preset == "production_c": - bpy.context.scene.render.engine = 'CYCLES' - bpy.context.scene.cycles.shading_system = True - bpy.context.scene.cycles.volume_bounces = 16 - bpy.context.scene.cycles.transparent_max_bounces = 32 bpy.context.scene.cycles.volume_preview_step_rate = 0.5 bpy.context.scene.cycles.volume_step_rate = 0.5 - # bpy.context.scene.cycles.use_fast_gi = False return {'FINISHED'} @@ -177,7 +194,6 @@ class SliceViewer(bpy.types.Operator): def execute(self, context): bpy.context.scene.eevee.use_taa_reprojection = False - bpy.context.scene.eevee.taa_samples = 4 bpy.context.scene.eevee.volumetric_tile_size = '2' bpy.context.scene.eevee.volumetric_shadow_samples = 128 bpy.context.scene.eevee.volumetric_samples = 128 diff --git a/bioxelnodes/operators/node.py b/bioxelnodes/operators/node.py index 8ba94ce..f831e94 100644 --- a/bioxelnodes/operators/node.py +++ b/bioxelnodes/operators/node.py @@ -1,8 +1,6 @@ import bpy -from ..bioxelutils.common import get_file_prop, is_incompatible, local_lib_not_updated -from ..constants import VERSION -from ast import literal_eval +from ..bioxelutils.common import is_incompatible, local_lib_not_updated from ..bioxelutils.node import assign_node_group, get_node_group from ..utils import get_use_link @@ -57,6 +55,6 @@ def execute(self, context): if local_lib_not_updated(): self.report({"WARNING"}, - "Local library version does not match the current addon version, which may cause problems, please save the node library again.") + "Local node library version does not match the current addon version, which may cause problems, please save the node library again.") return {"FINISHED"} diff --git a/docs/advanced.md b/docs/advanced.md new file mode 100644 index 0000000..518035f --- /dev/null +++ b/docs/advanced.md @@ -0,0 +1,3 @@ +# Advanced + +WIP diff --git a/docs/assets/cover.png b/docs/assets/cover.png index a740192..300118a 100644 Binary files a/docs/assets/cover.png and b/docs/assets/cover.png differ diff --git a/docs/assets/features_as-scalar.png b/docs/assets/features_as-scalar.png deleted file mode 100644 index 4644982..0000000 Binary files a/docs/assets/features_as-scalar.png and /dev/null differ diff --git a/docs/assets/features_concept.png b/docs/assets/features_concept.png deleted file mode 100644 index 31e2a4f..0000000 Binary files a/docs/assets/features_concept.png and /dev/null differ diff --git a/docs/assets/features_container.png b/docs/assets/features_container.png deleted file mode 100644 index d25ae7b..0000000 Binary files a/docs/assets/features_container.png and /dev/null differ diff --git a/docs/assets/features_import-others.png b/docs/assets/features_import-others.png deleted file mode 100644 index 4a179f6..0000000 Binary files a/docs/assets/features_import-others.png and /dev/null differ diff --git a/docs/assets/features_resample.png b/docs/assets/features_resample.png deleted file mode 100644 index 35ded07..0000000 Binary files a/docs/assets/features_resample.png and /dev/null differ diff --git a/docs/assets/gallery.png b/docs/assets/gallery.png deleted file mode 100644 index eac61da..0000000 Binary files a/docs/assets/gallery.png and /dev/null differ diff --git a/docs/assets/getting-started_convert_to_mesh.png b/docs/assets/getting-started_convert_to_mesh.png deleted file mode 100644 index db02f09..0000000 Binary files a/docs/assets/getting-started_convert_to_mesh.png and /dev/null differ diff --git a/docs/assets/getting-started_cutting.png b/docs/assets/getting-started_cutting.png deleted file mode 100644 index d5d0911..0000000 Binary files a/docs/assets/getting-started_cutting.png and /dev/null differ diff --git a/docs/assets/getting-started_graph.png b/docs/assets/getting-started_graph.png deleted file mode 100644 index acc90e8..0000000 Binary files a/docs/assets/getting-started_graph.png and /dev/null differ diff --git a/docs/assets/getting-started_importing.png b/docs/assets/getting-started_importing.png deleted file mode 100644 index ffd4978..0000000 Binary files a/docs/assets/getting-started_importing.png and /dev/null differ diff --git a/docs/assets/getting-started_masking.png b/docs/assets/getting-started_masking.png deleted file mode 100644 index 919465c..0000000 Binary files a/docs/assets/getting-started_masking.png and /dev/null differ diff --git a/docs/assets/getting-started_result.png b/docs/assets/getting-started_result.png deleted file mode 100644 index 2628cb5..0000000 Binary files a/docs/assets/getting-started_result.png and /dev/null differ diff --git a/docs/assets/getting-started_save_staged_data.png b/docs/assets/getting-started_save_staged_data.png deleted file mode 100644 index 56a5f48..0000000 Binary files a/docs/assets/getting-started_save_staged_data.png and /dev/null differ diff --git a/docs/assets/getting-started_shading.png b/docs/assets/getting-started_shading.png deleted file mode 100644 index 647bc40..0000000 Binary files a/docs/assets/getting-started_shading.png and /dev/null differ diff --git a/docs/assets/getting-started_share-file.png b/docs/assets/getting-started_share-file.png deleted file mode 100644 index 8d4e67c..0000000 Binary files a/docs/assets/getting-started_share-file.png and /dev/null differ diff --git a/docs/assets/improve_performance/image-1.png b/docs/assets/improve_performance/image-1.png new file mode 100644 index 0000000..08fde44 Binary files /dev/null and b/docs/assets/improve_performance/image-1.png differ diff --git a/docs/assets/improve_performance/image-2.png b/docs/assets/improve_performance/image-2.png new file mode 100644 index 0000000..abc4534 Binary files /dev/null and b/docs/assets/improve_performance/image-2.png differ diff --git a/docs/assets/improve_performance/image.png b/docs/assets/improve_performance/image.png new file mode 100644 index 0000000..1f81956 Binary files /dev/null and b/docs/assets/improve_performance/image.png differ diff --git a/docs/assets/installation_extension.png b/docs/assets/installation/image.png similarity index 100% rename from docs/assets/installation_extension.png rename to docs/assets/installation/image.png diff --git a/docs/assets/installation_dependency.png b/docs/assets/installation_dependency.png deleted file mode 100644 index e88e1c3..0000000 Binary files a/docs/assets/installation_dependency.png and /dev/null differ diff --git a/docs/assets/nodes_bake.png b/docs/assets/nodes_bake.png deleted file mode 100644 index 71b245d..0000000 Binary files a/docs/assets/nodes_bake.png and /dev/null differ diff --git a/docs/assets/nodes_color-presets.png b/docs/assets/nodes_color-presets.png deleted file mode 100644 index d4c2908..0000000 Binary files a/docs/assets/nodes_color-presets.png and /dev/null differ diff --git a/docs/assets/nodes_color-ramp-2.png b/docs/assets/nodes_color-ramp-2.png deleted file mode 100644 index 58eda88..0000000 Binary files a/docs/assets/nodes_color-ramp-2.png and /dev/null differ diff --git a/docs/assets/nodes_color-ramp-3.png b/docs/assets/nodes_color-ramp-3.png deleted file mode 100644 index f3b4a7b..0000000 Binary files a/docs/assets/nodes_color-ramp-3.png and /dev/null differ diff --git a/docs/assets/nodes_color-ramp-4.png b/docs/assets/nodes_color-ramp-4.png deleted file mode 100644 index 8619525..0000000 Binary files a/docs/assets/nodes_color-ramp-4.png and /dev/null differ diff --git a/docs/assets/nodes_color-ramp-5.png b/docs/assets/nodes_color-ramp-5.png deleted file mode 100644 index 22022c8..0000000 Binary files a/docs/assets/nodes_color-ramp-5.png and /dev/null differ diff --git a/docs/assets/nodes_concept.png b/docs/assets/nodes_concept.png deleted file mode 100644 index 6f5c149..0000000 Binary files a/docs/assets/nodes_concept.png and /dev/null differ diff --git a/docs/assets/nodes_cut.png b/docs/assets/nodes_cut.png deleted file mode 100644 index 99ac754..0000000 Binary files a/docs/assets/nodes_cut.png and /dev/null differ diff --git a/docs/assets/nodes_example.png b/docs/assets/nodes_example.png deleted file mode 100644 index eb0a5d9..0000000 Binary files a/docs/assets/nodes_example.png and /dev/null differ diff --git a/docs/assets/nodes_join-component.png b/docs/assets/nodes_join-component.png deleted file mode 100644 index ddfeb4a..0000000 Binary files a/docs/assets/nodes_join-component.png and /dev/null differ diff --git a/docs/assets/nodes_mask-by-label.png b/docs/assets/nodes_mask-by-label.png deleted file mode 100644 index 6afc39b..0000000 Binary files a/docs/assets/nodes_mask-by-label.png and /dev/null differ diff --git a/docs/assets/nodes_mask-by-range.png b/docs/assets/nodes_mask-by-range.png deleted file mode 100644 index 53f43e4..0000000 Binary files a/docs/assets/nodes_mask-by-range.png and /dev/null differ diff --git a/docs/assets/nodes_mask-by-threshold.png b/docs/assets/nodes_mask-by-threshold.png deleted file mode 100644 index 04d247f..0000000 Binary files a/docs/assets/nodes_mask-by-threshold.png and /dev/null differ diff --git a/docs/assets/nodes_plane-cutter.png b/docs/assets/nodes_plane-cutter.png deleted file mode 100644 index 4b1c8da..0000000 Binary files a/docs/assets/nodes_plane-cutter.png and /dev/null differ diff --git a/docs/assets/nodes_plane-object-cutter.png b/docs/assets/nodes_plane-object-cutter.png deleted file mode 100644 index 0840884..0000000 Binary files a/docs/assets/nodes_plane-object-cutter.png and /dev/null differ diff --git a/docs/assets/nodes_separate-component.png b/docs/assets/nodes_separate-component.png deleted file mode 100644 index 9f8da9c..0000000 Binary files a/docs/assets/nodes_separate-component.png and /dev/null differ diff --git a/docs/assets/nodes_slime-shader.png b/docs/assets/nodes_slime-shader.png deleted file mode 100644 index fb055f3..0000000 Binary files a/docs/assets/nodes_slime-shader.png and /dev/null differ diff --git a/docs/assets/nodes_solid-shader.png b/docs/assets/nodes_solid-shader.png deleted file mode 100644 index b8cb875..0000000 Binary files a/docs/assets/nodes_solid-shader.png and /dev/null differ diff --git a/docs/assets/nodes_universal-shader.png b/docs/assets/nodes_universal-shader.png deleted file mode 100644 index 5a5b605..0000000 Binary files a/docs/assets/nodes_universal-shader.png and /dev/null differ diff --git a/docs/assets/nodes_volume-shader.png b/docs/assets/nodes_volume-shader.png deleted file mode 100644 index 1352190..0000000 Binary files a/docs/assets/nodes_volume-shader.png and /dev/null differ diff --git a/docs/assets/step_by_step/image-1.png b/docs/assets/step_by_step/image-1.png new file mode 100644 index 0000000..6da5ea1 Binary files /dev/null and b/docs/assets/step_by_step/image-1.png differ diff --git a/docs/assets/step_by_step/image-2.png b/docs/assets/step_by_step/image-2.png new file mode 100644 index 0000000..58ed84b Binary files /dev/null and b/docs/assets/step_by_step/image-2.png differ diff --git a/docs/assets/step_by_step/image-3.png b/docs/assets/step_by_step/image-3.png new file mode 100644 index 0000000..ec8b203 Binary files /dev/null and b/docs/assets/step_by_step/image-3.png differ diff --git a/docs/assets/step_by_step/image-4.png b/docs/assets/step_by_step/image-4.png new file mode 100644 index 0000000..df8a855 Binary files /dev/null and b/docs/assets/step_by_step/image-4.png differ diff --git a/docs/assets/step_by_step/image-5.png b/docs/assets/step_by_step/image-5.png new file mode 100644 index 0000000..30d4f7a Binary files /dev/null and b/docs/assets/step_by_step/image-5.png differ diff --git a/docs/assets/step_by_step/image-6.png b/docs/assets/step_by_step/image-6.png new file mode 100644 index 0000000..a4dfece Binary files /dev/null and b/docs/assets/step_by_step/image-6.png differ diff --git a/docs/assets/step_by_step/image-7.png b/docs/assets/step_by_step/image-7.png new file mode 100644 index 0000000..d3f3e41 Binary files /dev/null and b/docs/assets/step_by_step/image-7.png differ diff --git a/docs/assets/step_by_step/image-8.png b/docs/assets/step_by_step/image-8.png new file mode 100644 index 0000000..7a99002 Binary files /dev/null and b/docs/assets/step_by_step/image-8.png differ diff --git a/docs/assets/step_by_step/image-9.png b/docs/assets/step_by_step/image-9.png new file mode 100644 index 0000000..3540f03 Binary files /dev/null and b/docs/assets/step_by_step/image-9.png differ diff --git a/docs/assets/step_by_step/image.png b/docs/assets/step_by_step/image.png new file mode 100644 index 0000000..2d1ba8a Binary files /dev/null and b/docs/assets/step_by_step/image.png differ diff --git a/docs/benchmark.md b/docs/benchmark.md deleted file mode 100644 index e69de29..0000000 diff --git a/docs/color.md b/docs/color.md deleted file mode 100644 index a78060c..0000000 --- a/docs/color.md +++ /dev/null @@ -1 +0,0 @@ -This type of node is responsible for setting the color properties of the shader diff --git a/docs/concept.md b/docs/concept.md deleted file mode 100644 index a44f471..0000000 --- a/docs/concept.md +++ /dev/null @@ -1,46 +0,0 @@ -# Concepts & Pipeline - -## Container, Layer, Component - -Bioxel Nodes imports volumetric data and put it into a **Container** as a **Layer**. One container may has more than one layer, and each layer stores the information of different fields under the same location, which is similar to the view layers in map app, except that here it is in 3D space. - -In order to visualize the volumetric data the way we want it to, we need to build renderable objects from layers. We call those objects **Component**. The following diagram shows the relationship of **Container**, **Layer**, and **Component**: - -![alt text](assets/features_concept.png) - -### Container Structure - -In Blender, container structure is like this: - -```bash -Case_0000 # Container -|-- Case_0000_CT # Layer -|-- Case_0000_Label_1 # Layer -`-- Case_0000_Label_2 # Layer -``` - -The container also stores the build process in geometry nodes: - -![alt text](assets/features_container.png) - -### Layer Type -The layer is categorized into these by data type: - -- Scalar -- Label -- Vector (Not implemented yet) -- Color (Not implemented yet) - -## Component Building Pipline - -In order to build a component, the general process is to first use a "Mask Method" node to build the surface of the component based on its layers, and then connect to a "Assign Shader" node to add the physical properties. Finally, if you need to cut the cross-section, then connect to a "Cut" node. The whole process is shown in the following diagram - -![alt text](assets/nodes_concept.png) - -A typical example looks like this: - -![alt text](assets/nodes_example.png) - -The "Mask Method" node tends to be very computationally intensive, and if it consumes too much time, then you can bake it with a "Bake" node after it (but you need to save the Blender file first). - -![alt text](assets/nodes_bake.png) diff --git a/docs/cut.md b/docs/cut.md deleted file mode 100644 index ef6b0ad..0000000 --- a/docs/cut.md +++ /dev/null @@ -1 +0,0 @@ -This type of node is responsible for cutting components to present cross-section \ No newline at end of file diff --git a/docs/import.md b/docs/import.md deleted file mode 100644 index 699fafb..0000000 --- a/docs/import.md +++ /dev/null @@ -1,41 +0,0 @@ - -## First Time Import Volume Data - -File > Import > Volume Data as Bioxel Layer - -### Resample - -![alt text](assets/features_resample.png) - -Sometimes the original data is too big, or the spacing in the original data is not reasonable, you can modify the `Bioxel Size` and `Original Spacing` to adjust the Shape of the layer. - -A bioxel is like a pixel, the larger the `Bioxel Size`, the lower the resolution of the image, Original Spacing will be read from the original data record, but sometimes the image doesn't have original spacing, you may need to input it manually to get the correct shape. - -### Read as - -- as Scalar - - ![alt text](assets/features_as-scalar.png) - - In some cases the environment value is higher than the value of the target object, you can check `Invert Scalar` to adjust the value for better result. - -- as Labels - - Many AI segmentation task datasets, provide segmentation data, which are often an integer value representing a layer of segmentation labels. You can set it to `Labels` to load them. - -- _as Vector (Not implemented yet)_ - -- _as Color (Not implemented yet)_ - -### Others - -![alt text](assets/features_import-others.png) - -`Scene Scale` determines how many units of length in the Blender world correspond to one unit of length in the Bioxel world. Since Blender defaults to meters, and the default size of blender primitives are around 1 blender unit. Therefore `Scene Scale` set to 0.01 is appropriate. - -`Orient to RAS` determines whether the layer should be converted to the RAS coordinate system. Regardless of the format of the medical image data, the coordinate system is mostly the LPS coordinate system. Bioxel, however, are in the RAS coordinate system and therefore need to be transformed in most cases. - -## Adding Volume Data to an existing container - -In 3D view or outliner panel, select the container and right click, Bioxel Nodes > Add Volume Data to Container. -The import settings are the same as for the first time import. \ No newline at end of file diff --git a/docs/improve_performance.md b/docs/improve_performance.md new file mode 100644 index 0000000..380ddf0 --- /dev/null +++ b/docs/improve_performance.md @@ -0,0 +1,39 @@ +# Improve Performance + +Volume reconstruction and volume rendering are very consuming computation, I believe that this add-on's experience is terrible on poorly hardware. here are tips to improve the add-on performance. + +## Use Low-Res Data as Preview + +The addon provides data resample function, the operation is as follows. First, in the container's geometry node, select the layer you need to resample, right-click **Bioxel Nodes > Resample Value**, in the dialog box, change the "Bioxel Size" value to twice or more than the current value, click OK. the addon will create a low-res version of the layer and load it into the container's geometry node. + +![alt text](assets/improve_performance/image.png) + +You can see that the speed of the reconstruction has been reduced from 240 ms to 37 ms, making it possible to compute in almost real-time, and improving the speed of the feedback of the changing the parameters. Once you are satisfied with the adjustment, you can then connect the original layer to the nodes. This tip can greatly improve the operation experience of the node. + +## Raise the Step Rate of a Container + +Step rate is a key setting in volume rendering. The higher the step rate, the faster the rendering will be, but at the same time, the thinner the volume will look. If you want to have a very thin effect, or if you don't need to cut through component, you can always set the step rate high, you can adjust step rate in the render settings globaly. However, I recommend you to adjust the step rate of the container separately, so that it doesn't affect the rendering of the other volume in the Blender file, do as follows. + +In the container's geometry nodes panel menu, click **Bioxel Nodes > Change Container Properties**, in the dialog box, raise the "Step Rate" value (up to 100) and click OK. + +![alt text](assets/improve_performance/image-1.png) + +You can see that the rendering speed is much higher, but at the same time the cuts look blurry and transparent. + +## Balance rendering settings + +I list some of the settings that affect the volume rendering most, so you can find the most balanced settings for your needs. + +- **Light Paths > Max Bounces > Volume** affects the number of bounces a volume has, the higher the value, the more transparent it will look. + +- **Light Paths > Max Bounces > Transparent** affects the number of times transparent surfaces are transmitted, the higher the value, the more transparent it will look. + +- **Volumes > Step Rate Render | Viewport** affects the volume rendering step, the smaller the value, the more detailed the volume will look + +Bioxel Nodes provides some render setting presets for quick setup. In the top menu, click **Bioxel Nodes > Render Setting Presets**, including Performance (left), Balance (center), and Quality (right). Here is a comparison of them. + +![alt text](assets/improve_performance/image-2.png) + +## Rendering with EEVEE + +EEVEE doesn't render volume as well as Cycles, but it does have the advantage of rendering the volumetric data, and is even a better choice if you want to get a clear view of slice. And EEVEE's real-time rendering make it possible to create interactive stuff in Blender. diff --git a/docs/index.md b/docs/index.md index 7a49539..276600e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,4 +1,4 @@ -[中文文档](https://uj6xfhbzp0.feishu.cn/wiki/Qx3VwHuNPimeI8kr6nDcvl1DnHf?from=from_copylink) +[中文文档](https://uj6xfhbzp0.feishu.cn/wiki/LPKEwjooSivxjskWHlCcQznjnNf?from=from_copylink) # Bioxel Nodes @@ -26,18 +26,18 @@ Welcome to our [discord server](https://discord.gg/pYkNyq2TjE), if you have any ## Support Multiple Formats -| Format | EXT | Test | -| ------ | ---------------------------------------- | ------- | -| DICOM | .dcm, .DCM, .DICOM, .ima, .IMA | ✅ pass | -| BMP | .bmp, .BMP | ✅ pass | -| JPEG | .jpg, .JPG, .jpeg, .JPEG | ✅ pass | -| PNG | .png, .PNG | ✅ pass | -| TIFF | .tif, .TIF, .tiff, .TIFF | ✅ pass | -| Nifti | .nia, .nii, .nii.gz, .hdr, .img, .img.gz | ✅ pass | -| Nrrd | .nrrd, .nhdr | ✅ pass | -| HDF5 | .hdf, .h4, .hdf4, .he2, .h5, .hdf5, .he5 | ✅ pass | -| OME | .ome.tiff, .ome.tif | ✅ pass | -| MRC | .mrc, .mrc.gz, .map, .map.gz | ✅ pass | +| Format | EXT | +| ------ | ---------------------------------------- | +| DICOM | .dcm, .DCM, .DICOM, .ima, .IMA | +| BMP | .bmp, .BMP | +| JPEG | .jpg, .JPG, .jpeg, .JPEG | +| PNG | .png, .PNG | +| TIFF | .tif, .TIF, .tiff, .TIFF | +| Nifti | .nia, .nii, .nii.gz, .hdr, .img, .img.gz | +| Nrrd | .nrrd, .nhdr | +| HDF5 | .hdf, .h4, .hdf4, .he2, .h5, .hdf5, .he5 | +| OME | .ome.tiff, .ome.tif | +| MRC | .mrc, .mrc.gz, .map, .map.gz | ## Support 4D volumetric data @@ -59,16 +59,6 @@ Welcome to our [discord server](https://discord.gg/pYkNyq2TjE), if you have any - Only works with Cycles CPU , Cycles GPU (OptiX), EEVEE - Section surface cannot be generated when convert to mesh (will be supported soon) -## Compatible to Newer Version - -**v0.3.x is not compatible to v0.2.x, Updating this addon may break old files. Read the following carefully before upgradation** - -Before upgradation, you need to ask yourself whether this project file will be modified again or not, if it's an archived project file, I would recommend that you run **Bioxel Nodes > Save Staged Data** to make the addon nodes permanent. In this way, there will be no potential problem with the nodes not functioning due to the addon update. - -After the addon update, your old project files may not work either, this may be because you had executed **Save Staged Data**. If so, you need to execute **Bioxel Nodes > Relink Nodes to Addon** to relink them to make sure that the addon's new functionality and the addon nodes are synchronized. - -Also, the older shaders are not based on OSL, so if you find that you can't render volumes, you need to turn on **Open Shading Language (OSL)** in the Render Settings. - ## Roadmap - Better multi-format import experience diff --git a/docs/installation.md b/docs/installation.md index 9d023b2..3b7d645 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -1,27 +1,19 @@ # Installation -> **Currently only support Blender 4.1 or above, make sure you have the correct version of Blender.** +**Currently only support Blender 4.2 or above, make sure you have the correct version of Blender.** -## For Blender 4.2 or higher +## Install in Blender (recommended) -The most recommended way is to open **Edit > Preferences > Extension**, enter "bio" in the search box and click **Install**. since the addon is quite large (20MB) you may need to wait a while! +This is the most recommended way, in the top menu, click **Edit > Preferences**, in "Get Extensions" Section, enter "bio" in the search box, then click Install. due to the add-on size (25MB~50MB) you may need to wait a while. -![extension](assets/installation_extension.png) +![alt text](assets/installation/image.png) -Thats it! +## Blender Official Extensions Website -> If it cannot be enable, reboot blender or install again as administrator +Or you can visit the Blender official extensions website at [https://extensions.blender.org/add-ons/bioxelnodes/](https://extensions.blender.org/add-ons/bioxelnodes/) +Click Get Add-on, open Blender, drag in Blender and follow the instructions to install. -Also, you can do it maually. Download the **Extension** version `BioxelNodes_Extension_{version}.zip` from https://github.com/OmooLab/BioxelNodes/releases/latest -In Blender, **Edit > Preferences > Extensions > Install from Disk**, select the zip file you just downloaded. +## Manual Install -## For Blender 4.1 - -Download the **Addon** version `BioxelNodes_Addon_{version}.zip` from https://github.com/OmooLab/BioxelNodes/releases/latest -In Blender, Edit > Preferences > Add-ons > Install, select the zip file you just downloaded. - -The add-on requires a third-party python dependency called SimpleITK, click `Install SimpleITK` button below to install the dependency. After clicking, blender may get stuck, it is downloading and installing, just wait for a moment. After that, click `Reboot Blender` button. - -![dependency](assets/installation_dependency.png) - -This step may have failed due to network factors, just click "Set PyPI Mirror" to change the mirror. +You can also install _BioxelNodes\_{version}.zip_ manually by downloading from [bere](https://github.com/OmooLab/BioxelNodes/releases/latest). +In the top menu, click **Edit > Preferences**, **Add-ons > Install from Disk** and select the Zip file you just downloaded. diff --git a/docs/intergration.md b/docs/intergration.md deleted file mode 100644 index e69de29..0000000 diff --git a/docs/mask.md b/docs/mask.md deleted file mode 100644 index c723f85..0000000 --- a/docs/mask.md +++ /dev/null @@ -1 +0,0 @@ -This type of node is responsible for culling out the extent of the component that does not need to be rendered, forming the interface between the object and the object, or the surface of the object (i.e., the interface between the object and the air) diff --git a/docs/nodes.md b/docs/nodes.md deleted file mode 100644 index cc54ab0..0000000 --- a/docs/nodes.md +++ /dev/null @@ -1,350 +0,0 @@ -# Nodes - -## Mask Methods - -### ⬆️ Mask by Threshold - -
- -- ![alt text](assets/nodes_mask-by-threshold.png) - -- Generate a mask by keeping only the positions that exceed the threshold (this only works with scalar) - - *** - - Node Parameter: - - - **Layer**, _the input scalar_ - - **Threshold**, _the threshold value_ - - Preview - - **Detail Factor**, _the fineness of the preview, the larger the factor, the coarser preview is_ - - (Label Mask) - - **Layer**, _the input label_ - - **Invert**, _invert mask_ - - **Sample Size**, _the mask sample size_ - - (Replacement) - - **Joined**, _the joined layer_ - -
- -### ↕ Mask by Range - -
- -- ![alt text](assets/nodes_mask-by-range.png) - -- Generate a mask by keeping only the positions that in range (this only works with scalar) - - *** - - Node Parameter: - - - **Layer**, _the input scalar_ - - **Fram Min**, _the lower limit_ - - **Fram Max**, _the upper limit_ - - Preview - - **Detail Factor**, _the fineness of the preview, the larger the factor, the coarser preview is_ - - (Label Mask) - - **Layer**, _the input label_ - - **Invert**, _invert mask_ - - **Sample Size**, _the mask sample size_ - - (Replacement) - - **Joined**, _the joined layer_ - -
- -### 🔤 Mask by Label - -
- -- ![alt text](assets/nodes_mask-by-label.png) - -- Generate a mask by keeping only the positions that in label (this only works with label) - - *** - - Node Parameter: - - - **Layer**, _the input label_ - - Preview - - **Detail Factor**, _the fineness of the preview, the larger the factor, the coarser preview is_ - - (Replacement) - - **Joined**, _the joined layer_ - -
- -## Shaders - -### 🥚 Solid Shader - -
- -- ![alt text](assets/nodes_solid-shader.png) - -- Assign a opaque shader based on a preview mesh with no inclusions visible. Fastest rendering speed. Does not support cross-section and color ramp. - - *** - - Node Parameter: - - - **Component**, _the upstream component_ - - Base - - **Color**, _albedo or emission color_ - - **Subsurface**, _the subsurface scale_ - - **Opacity**, _the opacity of all_ - - Specular - - **Specular**, _the specular of surface_ - - **Roughness**, _the roughness of surface_ - - Emission - - **Emission**, _the emission strength_ - -
- -### 🦠 Slime Shader - -
- -- ![alt text](assets/nodes_slime-shader.png) - -- Assign a semi-transparent shader based on the preview mesh with visible inclusions. Does not support cross-section and color ramp. - - *** - - Node Parameter: - - - **Component**, _the upstream component_ - - Base - - **Color**, _albedo or emission color_ - - **Density**, _the degree of solidity_ - - **Anisotropy**, _the anisotropy of scatting_ - - Specular - - **Specular**, _the specular of surface_ - - **Roughness**, _the roughness of surface_ - - Emission - - **Emission**, _the emission strength_ - -
- -### ☁️ Volume Shader - -
- -- ![alt text](assets/nodes_volume-shader.png) - -- Assign a volume-based shader with support for cross-section and color ramp. - - *** - - Node Parameter: - - - **Component**, _the upstream component_ - - Base - - **Color**, _albedo or emission color_ - - **Density**, _the degree of solidity_ - - **Anisotropy**, _the anisotropy of scatting_ - - Emission - - **Emission**, _the emission strength_ - -
- -### 🔬 Universal Shader - -
- -- ![alt text](assets/nodes_universal-shader.png) - -- Assign a ultimate shader, supporting all features of Bioxel Nodes. Of course, the price is slow rendering, which can be greatly improved by adjusting the Volumes > Step Rate to 100 in the Render Settings Panel. - - *** - - Node Parameter: - - - **Component**, _the upstream component_ - - Base - - **Color**, _albedo or emission color_ - - **Density**, _the degree of solidity_ - - **Anisotropy**, _the anisotropy of scatting_ - - Specular - - **Specular**, _the specular of surface_ - - **Roughness**, _the roughness of surface_ - - Emission - - **Emission**, _the emission strength_ - -
- -## Cutters - -### 🪚 Cut - -
- -- ![alt text](assets/nodes_cut.png) - -- Execute all cutters on one component. - - *** - - Node Parameter: - - - **Component**, _the upstream component_ - - **Cutter 0~4**, _the cutters_ - - **Hide Guide**, _hide the cutter guide_ - -
- - -### 🧀 Plane Object Cutter - -
- -- ![alt text](assets/nodes_plane-object-cutter.png) - -- Also a plane cutter, but origin and direction are based on exist object. - - *** - - Node Parameter: - - - **Plane**, _the plane object_ - - Guide - - **Show**, _show the cutter guide_ - - **Scale**, _scale the cutter guide_ - -
- -## Colors - -### 🎨 Color Presents - -
- -- ![alt text](assets/nodes_color-presets.png) - -- Set color from presets. - - *** - - Node Parameter: - - - **Component**, _the upstream component_ - - **Presets**, _select color presents_ - - **Fram Min**, _ramp factor lower limit_ - - **Fram Max**, _ramp factor upper limit_ - -
- -### 2️⃣ Color Ramp 2 - -
- -- ![alt text](assets/nodes_color-ramp-2.png) - -- Set color ramp base on scalar value. - - *** - - Node Parameter: - - - **Component**, _the upstream component_ - - **Fram Min**, _ramp factor lower limit_ - - **Fram Max**, _ramp factor upper limit_ - - Ramp - - **Pos0 Color**, _position 0% Color_ - - **Pos1 Color**, _position 100% Color_ - - **Gamma**, _non-linear coefficient, the larger the coefficient, the more lower value color_ - - **Contrast**, _the larger the contrast, the harder color ramp will be_ - -
- -### 3️⃣ Color Ramp 3 - -
- -- ![alt text](assets/nodes_color-ramp-3.png) - -- Set color ramp base on scalar value. - - *** - - Node Parameter: - - - **Component**, _the upstream component_ - - **Fram Min**, _ramp factor lower limit_ - - **Fram Max**, _ramp factor upper limit_ - - Ramp - - **Pos0 Color**, _position 0% Color_ - - **Pos1 Color**, _position 50% Color_ - - **Pos2 Color**, _position 100% Color_ - - **Gamma**, _non-linear coefficient, the larger the coefficient, the more lower value color_ - - **Contrast**, _the larger the contrast, the harder color ramp will be_ - -
- -### 4️⃣ Color Ramp 4 - -
- -- ![alt text](assets/nodes_color-ramp-4.png) - -- Set color ramp base on scalar value. - - *** - - Node Parameter: - - - **Component**, _the upstream component_ - - **Fram Min**, _ramp factor lower limit_ - - **Fram Max**, _ramp factor upper limit_ - - Ramp - - **Pos0 Color**, _position 0% Color_ - - **Pos1 Color**, _position 33.3% Color_ - - **Pos2 Color**, _position 66.6% Color_ - - **Pos3 Color**, _position 100% Color_ - - **Gamma**, _non-linear coefficient, the larger the coefficient, the more lower value color_ - - **Contrast**, _the larger the contrast, the harder color ramp will be_ - -
- -### 5️⃣ Color Ramp 5 - -
- -- ![alt text](assets/nodes_color-ramp-5.png) - -- Set color ramp base on scalar value. - - *** - - Node Parameter: - - - **Component**, _the upstream component_ - - **Fram Min**, _ramp factor lower limit_ - - **Fram Max**, _ramp factor upper limit_ - - Ramp - - **Pos0 Color**, _position 0% Color_ - - **Pos1 Color**, _position 25% Color_ - - **Pos2 Color**, _position 50% Color_ - - **Pos3 Color**, _position 75% Color_ - - **Pos4 Color**, _position 100% Color_ - - **Gamma**, _non-linear coefficient, the larger the coefficient, the more lower value color_ - - **Contrast**, _the larger the contrast, the harder color ramp will be_ - -
- -## Utils - -### 📦 Join Component - -
- -- ![alt text](assets/nodes_join-component.png) - -- Components' combination should not be done by "Join Geometry" node because Blender Cycles can't render volumes in the same position, so the node will slightly offset all components randomly to avoid this problem. - - *** - - Node Parameter: - - - **Component 0~4**, _the components_ - -
diff --git a/docs/prepare_data.md b/docs/prepare_data.md deleted file mode 100644 index 6883231..0000000 --- a/docs/prepare_data.md +++ /dev/null @@ -1,45 +0,0 @@ -# Prepare Your Data - -## Support Formats - -First thing first, you need to get your volumetric data ready in disk. Bioxel Nodes is developed based on Simple ITK, so theoretically all formats supported by Simple ITK are supported by the addon. If your data is not in the support list, you may do the data conversion first. - -| Format | EXT | Test | -| ------ | ---------------------------------------- | ------- | -| DICOM | .dcm, .DCM, .DICOM, .ima, .IMA | ✅ pass | -| BMP | .bmp, .BMP | ✅ pass | -| JPEG | .jpg, .JPG, .jpeg, .JPEG | ✅ pass | -| PNG | .png, .PNG | ✅ pass | -| TIFF | .tif, .TIF, .tiff, .TIFF | ✅ pass | -| Nifti | .nia, .nii, .nii.gz, .hdr, .img, .img.gz | ✅ pass | -| Nrrd | .nrrd, .nhdr | ✅ pass | -| Meta | .mha, .mhd | yet | -| HDF5 | .hdf, .h4, .hdf4, .he2, .h5, .hdf5, .he5 | ✅ pass | -| VTK | .vtk | yet | -| BioRad | .PIC, .pic | yet | -| Gipl | .gipl, .gipl.gz | yet | -| LSM | .lsm, .LSM | yet | -| MINC | .mnc, .MNC | yet | -| MRC | .mrc, .rec | yet | -| OME | .ome.tiff, .ome.tif | ✅ pass | -| MRC | .mrc, .mrc.gz, .map, .map.gz | ✅ pass | - -## Download Data from Internet - -If you don't have any volumetric data, you can access open research data from list below. - -> Note that just because they are open and available for download does not mean you can use them for anything! Be sure to look at the description of the available scopes from website. - -| Source | Object | -| ------------------------------------------------------------------------------------ | ------------------ | -| [MorphoSource](https://www.morphosource.org/) | Open Research Data | -| [Dryad](https://datadryad.org) | Open Research Data | -| [Cell Image Library](http://cellimagelibrary.org/home) | Cells | -| [OpenOrganelle](https://openorganelle.janelia.org/datasets) | Cells | -| [Allen Cell Explorer](https://www.allencell.org/3d-cell-viewer.html) | Cells | -| [EMDB](https://www.ebi.ac.uk/emdb/) | Protein, Viruses | -| [Embodi3D](https://www.embodi3d.com/files/category/37-medical-scans/) | Medical Images | -| [Github](https://github.com/sfikas/medical-imaging-datasets) | Medical Images | -| [NIHR](https://nhsx.github.io/open-source-imaging-data-sets/) | Medical Images | -| [Medical Segmentation Decathlon](http://medicaldecathlon.com/) | Medical Images | -| [Visible Human Project](https://www.nlm.nih.gov/research/visible/visible_human.html) | Medical Images | diff --git a/docs/qa.md b/docs/qa.md new file mode 100644 index 0000000..c66f5c9 --- /dev/null +++ b/docs/qa.md @@ -0,0 +1,15 @@ +# Q & A + +## Nothing in the scene when rendering? + +If you're using the Cycles renderer with GPU, make sure your GPU supports "Optix", as Bioxel Nodes relies on OSL (Open shader language) for volumetric rendering, otherwise you'll have to use the CPU for rendering. + +If you're using the EEVEE renderer, this issue is due to EEVEE not loading shaders for some unknown reason, save the file and restart Blender to fix it. + +## After updating the addon, the nodes in the file have turned red? + +This is because the version of the nodes in the file does not match the current version of the addon after updating. + +If you still want to edit the file with Bioxel Nodes, you can only roll back the addon version to the version that corresponds to the nodes. + +If you just want the file to work and you won't rely on Bioxel Nodes any more, then you can just click **Bioxel Nodes > Relink Node Library >** in the top menu and select the corresponding version. Check to see if the nodes are working and rendering properly, and when everything is OK, click **Bioxel Nodes > Save Node Library** and select the save location in the dialog box. diff --git a/docs/render.md b/docs/render.md deleted file mode 100644 index e69de29..0000000 diff --git a/docs/shader.md b/docs/shader.md deleted file mode 100644 index 812e94b..0000000 --- a/docs/shader.md +++ /dev/null @@ -1 +0,0 @@ -This type of node is responsible for setting material physical properties to the component to reflect the differences in rendering effects of different components. \ No newline at end of file diff --git a/docs/step_by_step.md b/docs/step_by_step.md index c6ca945..4bc9f3c 100644 --- a/docs/step_by_step.md +++ b/docs/step_by_step.md @@ -1,54 +1,101 @@ # Step by Step -## 1. Import Volumetric Data +## Download Data -**Bioxel Nodes > Import Volumetric Data (Init) > as Scalar**, select the data file, click on **Import as Scalar**. If the data is a sequence of files in directory, just pick **one** file in that directory, not the whole directory or multiple selection of files. +Here is the open data from [Visible Human Project (VHP)](https://www.nlm.nih.gov/research/visible/visible_human.html) for you to learn how to use this addon. It is a CT scan image of a male head, download and unzip it to any location for later usage. -> you can also drag one of the data file directly into the 3D viewport to trigger the importing +[VHP_M_CT_Head.zip](https://drive.google.com/file/d/1kcnEwwDj-5X4U8330G_FNfWFS8f-892R/view?usp=sharing) -![importing](assets/getting-started_importing.png) +VHP original radiology data was shared in the proprietary format that predated DICOM, complicating its use. Now all data has been harmonized to standard DICOM and released in [NCI Imaging Data Commons (IDC)](https://portal.imaging.datacommons.cancer.gov/), you also can download data from IDC by yourself. -It may take a while to read data. After finishing reading, it will pop up a dialog box. Ignore all the options, just click OK (we will talk about them later). +## Import Data -After the importing, the add-on will automatically add the necessary nodes to build the preview. +In the top menu, click **Bioxel Nodes > Import Volumetric Data (Init) > as Scalar**, locate to the unzipped folder, select any DICOM file (don't select more than one, and don't select the folder either), and click **Import as Scalar**. -![masking](assets/getting-started_masking.png) +![alt text](assets/step_by_step/image.png) -If there is nothing in the bbox wireframe, select the wireframe in 3D viewport, open the geometry nodes panel, set **Threshold** in the node lower to modify the preview. +You can also choose to import data by dragging one DICOM file into the 3D viewport (some DICOM files don't have extension suffix and can't be dragged in). -## 2. Shading the Structure +The process of reading the data may take a while, the bottom right corner of the Blender interface will show you the progress of the reading, and a dialog box will pop up when the reading is successful. Ignore all the options for now and just click OK, I will explain the purpose of these options later. -The only node "Scalar" is responsible for mask out the unwanted area and generate the structure surface. You need to assign a shader to truly see the structure, connect a **Slime Shader** node (**Add > Bioxel Nodes > Shaders > Slime Shader**) after it. Turned on the cycles rendering to see the result. +The import process involves data conversion, so there is more waiting time, and the progress of the import is displayed in the lower right corner of the interface. After importing, the addon will create a new object, with a new geometry nodes that will serve as a "workbench" for manipulating the data, the new object is called the **Container**. The newly imported data is stored in the Container as a **Layer**, which is loaded into the Container's Geometry node via the "Fetch Layer" node (the red one), and be converted into a **Component** that can be rendered. -![shading](assets/getting-started_shading.png) +![alt text](assets/step_by_step/image-1.png) -You may change the **Color**, **Density** to modify the shader effect. All the parameters are straightforward, you can understand them by changing their values. +Next, let's preview the data in Blender. -## 3. Cut to Cross-section +In the container's geometry nodes panel menu, click **Bioxel Nodes > Add a Slicer**. The addon will insert a node named "Slice" between the "Fetch Layer" and the "Output" and create a new plane object named "Slicer". Click the "Slice Viewer" button in the upper right corner of the 3D viewport to enter the preview mode, then move and rotate the "Slicer" object. You will see a slice image of the data, which should be familiar to anyone who has used any DICOM viewing software. -We often need to cut the structure to see the inside of the volumetric data. With Bioxel Nodes, it can be done by one click: select the structure in 3D viewport, right click, **Bioxel Nodes > Add a Plane Cutter** -. The add-on will add a cut node and a cutter object node to the node graph, which are responsible for the cutting process. +![alt text](assets/step_by_step/image-2.png) -![cutting](assets/getting-started_cutting.png) +(If the volume disappears when you click the "Slice Viewer" button, save the file and restart Blender, it should be fixed, or you can turn on the Cycles rendering to see the slicer plane as well. The issue is caused by EEVEE's failure of reloading the shaders.) -> Change the shader from **Slime** to **Universal** to render the cross-section. But it will increase rendering time +The "Slicer" node is used to display the slices of the data, with an external object as the location of the slice plane. This step is not necessary for visualization, but it provides a quick way to preview the data in Blender for user perception. Next, let's turn the volumetric data into a renderable object. -## 4. Save Staged Data (Optional) +## Cutout the skull -The VDB cache and the custom nodes are not reachable to other computers if you don't save them. Those staged data should be saved, If you want to give your blender file to someone else, or you want to archive your blender file. +Bone tends to have much higher CT values than soft tissue, so you can split bone and soft tissue by setting a threshold. In the Geometry Nodes panel menu of the container, click **Add > Bioxel Nodes > Component > Cutout by Threshold** to add a "Cutout" node and connect it between the "Fetch Layer" node and the "Output", and then set the "Threshold" parameter of the "Cutout by Threshold" node to 0.3 and turn on the "With Surface" option. Switch to viewport shading to "Render Preview". The node graph and the render result are shown below. -Save your blender file, then just click **Bioxel Nodes > Save Staged Data** +![alt text](assets/step_by_step/image-3.png) -![save staged data](assets/getting-started_save_staged_data.png) +If you want the render result to be consistent with the above image, you also need to change the default light object type from "Point" to "Area" to increase the brightness, and change the Look in Color Management to "High Contrast". -Just click **OK**, after that, both the VDB cache and the custom nodes are restored in relative locations. When you share this file with someone, pack the entire directory so that the resources will be not lost. The other person will be able to open it correctly, regardless of whether they have Bioxel Nodes installed or not. +You can understand the role of the "Threshold" parameter in shaping the output by changing it. If you feel very laggy while draging the parameter, you can temporarily turn off the "With Surface" option in the "Cutout" node. When you are satisfied, turn it on again. In addition, the volume rendering is very computationally intensive, which is also a major cause of the lag, so you can adjust the parameters in "Slice Viewer" mode first, and then do the Cycles rendering when you are satisfied. -## 5. Convert to Editable Mesh (Optional) +You may consider using GPU for faster rendering, but please note that Bioxel Nodes only supports Optix GPUs due to its dependency on OSL (Open shader language), and the first time you turn on GPU rendering, you may need to wait for Blender to load the appropriate dependencies (the screen will get stuck), so please be patient. -If you want digital sculpting, 3D printing, exporting to game engine, you should convert to editable mesh first. +Although the output component looks like a mesh object, it retains its internal information through its volume, so when you cut through the component, you should see an inhomogeneous cross-section made up of volume, rather than just an empty shell like any mesh object. Let's cut the skull to see its complex internal structure. -Select the wireframe in 3D viewport, right click **Bioxel Nodes > Pick Mesh**. +## Cut and Color -![to mesh](assets/getting-started_convert_to_mesh.png) +In the container's geometry nodes panel menu, click **Bioxel Nodes > Add a Cutter > Plane Cutter**, the addon will insert a "Cut" node and a "Object Cutter" node. Also, it will create a new plane object named "Plane Cutter" to the scene, at this point you should be able to see that the skull has been cut through as expected. -It will create a new object with geometry nodes to refer the mesh. You can apply the geometry node to break the connection. +Just like the "Slicer" object, move and rotate the "Plane Cutter" and the position and direction of the cut will change accordingly. Please adjust the Cutter object to a vertical orientation so that it cuts the skull vertically, as shown below. + +![alt text](assets/step_by_step/image-4.png) + +The CT value of the skull is inhomogeneous, which reflects the difference in substance density of the bone. We can enhance the display of this difference by coloring. In the Geometry Nodes panel menu of the container, click **Add > Bioxel Nodes > Propetry > Set Color by Ramp 5** to add the "Set Color" node and connect it after any node. Set the node's parameters "From Min" to 0.3 and "From Max" to 0.5, as shown below. + +![alt text](assets/step_by_step/image-5.png) + +When rendering is turned on, you can clearly see that the calvaria and teeth are colored red, meaning that the bone in these areas is denser. You can try to adjust the parameters of the "Set Color" node to recognize their roles. If you feel laggy when draging the parameters, you can temporarily turn off "With Surface" and switch to "Slice Viewer" mode. + +## Transformation + +You may find that the position of the skull is a bit off the origin, this is due to the fact that the addon keeps the position information from the original data record during the import process. If you need to change the position, do not move the container (object) directly as you would in 3D viewport; the addon provides dedicated "Transform" node to handle transformations. + +In the Geometry Nodes panel menu of the container, click **Bioxel Nodes > Add a Locator**, the addon will insert the "Transform Parent" node and create a new empty object named "Locator". If you move, rotate, or scale the "Locator", the skull will Transform as well. If you also want the origin of the rotational transformation to be set at the geometric center of the skull, just add a "ReCenter" node (Add > Bioxel Nodes > Transform > ReCenter) in front of the "Transform Parent" node, as shown below. + +![alt text](assets/step_by_step/image-6.png) + +Being used to moving objects directly in the 3D viewport, you may find it strange to have an extra step to transform component like this. This is in consideration of the fact that there may be multiple components involved in one container with different transform needs, as well as future development plans for resampling mechanism, which I'll explain in more detail later. + +## Surface Mesh + +A mesh, made up of vertexs and faces, is the "greatest common" in the 3D world. Therefore, in order to be compatible with other 3D workflow, the addon provides the "To Surface" node (Add > Bioxel Nodes > Component > ToSurface), which converts the component into a mesh. Note that the surface mesh is not editable in the container's geometry node, and can only be connected to "Transform" and "Shader" nodes. + +As shown below, you can connect "Slime Shader" node (Add > Bioxel Nodes > Surface > Slime Shader) after the "To Surface" node to give the surface a shader, or connect "Transform" nodes. + +![alt text](assets/step_by_step/image-7.png) + +If you want to edit the mesh, click **Bioxel Nodes > Extract from Container > Extract Surface** in the Geometry Nodes panel menu of the container. The addon will create a new object with Geometry Nodes, in which a "Fetch Surface" node to read the surface mesh. You can apply this geometry node to edit the mesh as usual. Or you can leave the geometry node in place and keep it connected to the original container in real time. + +![alt text](assets/step_by_step/image-8.png) + +(To show it better, I made an X-axis offset to the newly created mesh, otherwise the container and the mesh are perfectly overlapping.) + +## Save Temporary Files + +The layers cache is stored in a temporary folder, while the addon's custom nodes are linked to the node library file in addon directory. Both of them are exist locally by default, and if you only deliver the Blender file to other devices, the file will not work properly because the resources are missing. + +Therefore, you need to save all temporary files before you deliver the Blender file. The procedure is simple: + +1. Save the Blender file. +2. in the top menu, click **Bioxel Nodes > Save Node Library**, and set the relative path. +3. in the top menu, click **Bioxel Nodes > Save All Layers Cache** and set the relative path. + +Zip the Blender file together with the local node library file and the layer cache files (there may be more than one). + +![alt text](assets/step_by_step/image-9.png) + +🤗 If you can follow the documentation up to this point, you're already started! diff --git a/docs/support_format.md b/docs/support_format.md new file mode 100644 index 0000000..958bf65 --- /dev/null +++ b/docs/support_format.md @@ -0,0 +1,39 @@ +# Support Format + +Can't wait to play with the addon using your own data? Here's a list of the formats currently supported. + +| Format | EXT | +| ------ | ---------------------------------------- | +| DICOM | .dcm, .DCM, .DICOM, .ima, .IMA | +| BMP | .bmp, .BMP | +| JPEG | .jpg, .JPG, .jpeg, .JPEG | +| PNG | .png, .PNG | +| TIFF | .tif, .TIF, .tiff, .TIFF | +| Nifti | .nia, .nii, .nii.gz, .hdr, .img, .img.gz | +| Nrrd | .nrrd, .nhdr | +| HDF5 | .hdf, .h4, .hdf4, .he2, .h5, .hdf5, .he5 | +| OME | .ome.tiff, .ome.tif | +| MRC | .mrc, .mrc.gz, .map, .map.gz | + +Despite my best efforts, I still can't achieve perfect support for all volumetric data formats, and I will continue to work on this. + +## Open Databases + +If you don't have volumetric data, then you can download from some open databases. + +**Note that just because they are open and available for download does not mean you can use them for anything! Be sure to look at the description of the available scopes from website.** + +| Source | Object | +| ------------------------------------------------------------------------------------ | ------------------ | +| [MorphoSource](https://www.morphosource.org/) | Open Research Data | +| [Dryad](https://datadryad.org) | Open Research Data | +| [Cell Image Library](http://cellimagelibrary.org/home) | Cells | +| [OpenOrganelle](https://openorganelle.janelia.org/datasets) | Cells | +| [Allen Cell Explorer](https://www.allencell.org/3d-cell-viewer.html) | Cells | +| [EMDB](https://www.ebi.ac.uk/emdb/) | Protein, Viruses | +| [IDC](https://portal.imaging.datacommons.cancer.gov/explore/) | Medical Images | +| [Embodi3D](https://www.embodi3d.com/files/category/37-medical-scans/) | Medical Images | +| [Github](https://github.com/sfikas/medical-imaging-datasets) | Medical Images | +| [NIHR](https://nhsx.github.io/open-source-imaging-data-sets/) | Medical Images | +| [Medical Segmentation Decathlon](http://medicaldecathlon.com/) | Medical Images | +| [Visible Human Project](https://www.nlm.nih.gov/research/visible/visible_human.html) | Medical Images | diff --git a/docs/terms.md b/docs/terms.md deleted file mode 100644 index 3064394..0000000 --- a/docs/terms.md +++ /dev/null @@ -1,7 +0,0 @@ -# Terms - -### Bioxels - -Bioxels is based on the RAS coordinate system, Right Aanterior Superior, which was chosen over LPS because it is more compatible with most 3D CG software coordinate systems, and is in line with the 3D artist's understanding of space. - -All distances within Bioxels are in Units, and are specified in Meter pre unit. However, when Bioxels is imported into 3D CG software, its size in the software is not scaled by reading the Meter pre unit directly. The reason for this is that many 3D operations in software require that the primtives not be too large or too small. diff --git a/mkdocs.yml b/mkdocs.yml index 7781f0d..c9e57ba 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -10,21 +10,11 @@ nav: - index.md - Getting Started: - Installation: installation.md - - Prepare Your Data: prepare_data.md - Step by Step: step_by_step.md - - Concepts & Pipeline: concept.md - - Visualizing any Bio-structure: - - Import & Preprocess: import.md - - Mask Methods: mask.md - - Assgin a Shader: shader.md - - Cut the Component: cut.md - - Set Colors: color.md - - Integration into Other Pipeline: intergration.md - - Render Tips: render.md - - Reference: - - Terms: terms.md - - Nodes: nodes.md - - Benchmark: benchmark.md + - Support Format: support_format.md + - Improve Performance: improve_performance.md + - Advanced: advanced.md + - Q & A: qa.md theme: name: material