Merge pull request #13 from OmooLab/feature/dev

Feature/dev
This commit is contained in:
Ma Nan
2024-05-14 14:41:01 +08:00
committed by GitHub
19 changed files with 102 additions and 34 deletions

View File

@@ -139,6 +139,8 @@ def rgb2gray(image):
return sitk.Cast(I, sitk.sitkFloat32)
def x2gray(image):
return sitk.VectorIndexSelectionCast(image, 0, sitk.sitkUInt16)
class ImportVolumeDataDialog(bpy.types.Operator):
bl_idname = "bioxelnodes.import_volume_data_dialog"
@@ -225,6 +227,10 @@ class ImportVolumeDataDialog(bpy.types.Operator):
bioxel_size, image_shape, orig_spacing)
if self.read_as == "labels":
if "vector" in image.GetPixelIDTypeAsString():
print("Convet to Grayscale...")
image = x2gray(image)
else:
image = sitk.Cast(image, sitk.sitkUInt16)
default_value = 0
elif self.read_as == "scalar":

BIN
docs/assets/as-labels.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
docs/assets/as-scalar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

Before

Width:  |  Height:  |  Size: 220 KiB

After

Width:  |  Height:  |  Size: 220 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 126 KiB

After

Width:  |  Height:  |  Size: 126 KiB

View File

Before

Width:  |  Height:  |  Size: 126 KiB

After

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

BIN
docs/assets/resample.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 108 KiB

BIN
docs/assets/to-mesh.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -1,5 +1,45 @@
# Import Volume Data
# Features & Options
# Convert to Mesh
## Import Volume Data as Biovels
# Export Volume Data
File > Import > Volume Data as Biovels
### Resample
![alt text](assets/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 Bixoels.
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/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
![alt text](assets/as-labels.png)
Many AI segmentation task datasets, provide segmentation data, which are often an integer value representing a layer of segmentation labels. You can set the Label Index to determine exactly which labels to load.
#### as Vector (Not implemented)
#### as Color (Not implemented)
### Others
![alt text](assets/import-others.png)
## Convert Bioxels to Mesh
In 3D view, select bioxels and right-click, Bioxels > Bioxels To Mesh
![alt text](assets/to-mesh.png)
## Export Biovels as VDB
File > Export > Biovels as VDB

View File

@@ -2,59 +2,62 @@
Currently only support Blender 4.0 or above, make sure you have the correct version of Blender.
### Add-on Installation
## Add-on Installation
Download the latest version https://github.com/OmooLab/BioxelNodes/releases/latest
In Blender, `Edit - Preferences - Add-ons - Install`, select the `BioxelNodes_{version}.zip` you just downloaded.
In Blender, Edit > Preferences > Add-ons > Install, select the `BioxelNodes_{version}.zip` you just downloaded.
### Dependency Installation
The add-on requires a third-party python dependency called SimpleITK, click the 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 the Installation, **restart blender once**.
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/dependency.png)
This step may have failed due to network factors, just click "Set PyPI Mirror" to change the mirror.
### Basic Usage
## Prepare Your Data
First you need to have your volumetric data ready. If not, you can access open research data from [Dryad](https://datadryad.org) (Dryad publishes data exclusively under a [Creative Commons Public Domain License](https://creativecommons.org/public-domain/cc0/))
First you need to have your volumetric data ready. If not, you can access open research data from list below:
Note: Make sure one folder contains only one sequence, multiple sequences need to be manually split into different folders first.
| Source | Object |
| ------------------------------------------------------------------------------------ | ------------------ |
| [Dryad](https://datadryad.org) | Open Research Data |
| [OpenOrganelle](https://openorganelle.janelia.org/datasets) | Cells |
| [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 |
| [Allen Cell Explorer](https://www.allencell.org/3d-cell-viewer.html) | Cells |
| [Visible Human Project](https://www.nlm.nih.gov/research/visible/visible_human.html) | Medical Images |
In Blender, `File - Import - Volume Data as Bioxels`, select **one** of the .dcm files and click on "Volume Data as Bioxels" (you can also drag one of the .dcm files directly into the 3D viewport to trigger the import, but this is limited to .dcm format files)
## Import Volume Data
File > Import > Volume Data as Bioxels, select **one** of the .dcm files and click on "Volume Data as Bioxels" (you can also drag one of the .dcm files directly into the 3D viewport to trigger the import)
![importing](assets/importing.png)
It may take a while to read data. After finishing reading, it will pop up a dialog box
![import dialog](assets/import_dialog.png)
![import dialog](assets/import-dialog.png)
Ignore the options, just click OK!
After importing, the necessary nodes are automatically added, the reconstruction and shader are created, and then turned on the cycles rendering to directly see the result.
After importing, the necessary nodes are automatically added, the reconstruction and shader are created. Click select Bioxels Object, and open the Geometry Nodes panel, change the "Threshold" in segment node.
![segment node](assets/segment-node.png)
and then turned on the cycles rendering to directly see the result.
![result](assets/result.png)
Click select Bioxels Object, and open the Geometry Nodes panel to see the following node graph:
![segment node](assets/segment_node.png)
You can change the "Threshold" to modify the reconstruction model, or change the "Color", "Density" to modify the shader effect. All the parameters are straightforward, you can understand them by changing the values.
The node, that named "Segment", is a preset node that combines the steps of 3D reconstruction process and shading process. In general, you need to add one of the segmentation node to reconstruction first, and followed by one of the shader node to set the shader. As you can see in the following figure:
## Share Your File
![general graph](assets/general_graph.png)
The VDB cache and the Bioxel nodes are not reachable to computers if you don't save them. If you need to give your blender file to someone else, you will need to perform the following steps:
Currently there are 3 types of nodes
1. Save your blender file
2. Click Scene > Bioxels > Save All Bioxels in the Properties panel.
3. Click Scene > Custom Nodes > Save All Custom Nodes under the Properties panel.
- Segmentation nodes, responsible for splitting the volume into a reconstructed model (we call them "Segment").
- Shader nodes, responsible for giving shader to the Segment.
- Slicer nodes, responsible for partially cutting the Segment.
![before sharin](assets/before-sharing.png)
For example:
![general graph example](assets/general_graph_example.png)
You can add a "Bake" node between segmentation node and shader node, if the reconstruction process consumes too much computing time. But be sure, you are selecting the volume object, not the container object.
![bake node](assets/bake_node.png)
After that, both the VDB cache and the Bioxel nodes are stored in relative locations. When you share a file with someone, pack the entire directory so that the resources are not lost. The other person will be able to load correctly, regardless of whether they have BioxelNodes installed.

View File

@@ -1,6 +1,6 @@
# Future Features
- Support more volumetric data formats (.nii, .map, .txm...)
- Support more volumetric data formats (.map, .txm...)
- Generate sections
- More segmentation methods, e.g. AI segmentation.
- Even better shader for volumetric rendering

View File

@@ -0,0 +1,19 @@
# Geometry Nodes
The node, that named "Segment", is a preset node that combines the steps of 3D reconstruction process and shading process. In general, you need to add one of the segmentation node to reconstruction first, and followed by one of the shader node to set the shader. As you can see in the following figure:
![general graph](assets/general-graph.png)
Currently there are 3 types of nodes
- Segmentation nodes, responsible for splitting the volume into a reconstructed model (we call them "Segment").
- Shader nodes, responsible for giving shader to the Segment.
- Slicer nodes, responsible for partially cutting the Segment.
For example:
![general graph example](assets/general-graph-example.png)
You can add a "Bake" node between segmentation node and shader node, if the reconstruction process consumes too much computing time. But be sure, you are selecting the volume object, not the container object.
![bake node](assets/bake-node.png)

View File

@@ -10,7 +10,7 @@ nav:
- BioxelNodes:
- index.md
- Getting Started: getting-started.md
- Features: features.md
- Features & Options: features.md
- Geometry Nodes: nodes.md
- Future Features: misc.md