Skip to content

Commit 136dce6

Browse files
authored
Update documentation for Release 4 (#202)
* Documentation and readme update
1 parent 0f2313e commit 136dce6

40 files changed

+399
-10
lines changed

Documentation/Documentation.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# UnityVolumeRendering documentation
2+
3+
## General documentation
4+
5+
- [Importing datasets](General/Importing/ImportingDatasets.md)
6+
- [Using the imported datasets](General/VolumeRendering/GameObjectManipulation.md)
7+
- [Changing the appearance](General/VolumeRendering/VolumeRenderingSettings.md)
8+
- [Transfer Functions](General/TransferFunctions/TransferFunctions.md)
9+
- [Cross section tools](General/CrossSectionTools/CrossSectionTools.md)
10+
- [Slice renderer](General/SliceRenderer/SliceRenderer.md)
11+
- [Editor import settings](General/Settings/Settings.md)
12+
13+
## Scripting documentation
14+
15+
- [Importing datasets from code](Scripting/Importing.md)
16+
- [Raycasting the geometry on CPU](Scripting/VolumeRaycasting.md)
17+
18+
## Other
19+
20+
- [SimpleITK integration (for JPEG2000-compressed DICOM and more)](SimpleITK/SimpleITK.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Cross section tools
2+
3+
**Table of contents:**
4+
<!-- TOC -->
5+
6+
- [Cross section tools](#cross-section-tools)
7+
- [Cross section plane](#cross-section-plane)
8+
- [Box cutout](#box-cutout)
9+
- [Sphere cutout](#sphere-cutout)
10+
11+
<!-- /TOC -->
12+
13+
You can spawn cross section tools from the Volume Rendering menu option.
14+
15+
<img src="menu-cross-section.png" width="400px">
16+
17+
There are three types of cross section tools:
18+
19+
## Cross section plane
20+
21+
The cross section plane is a simple plane that can be moved around and rotate, to clip the volume at an arbitrary position and angle.
22+
23+
<img src="plane-tool.png" width="400px">
24+
25+
If you need axis aligned clipping planes, I would recommend to implement your own clipping plane tool that implements the `CrossSectionObject` interface, and add it to the `CrossSectionManager`.
26+
27+
## Box cutout
28+
29+
The box cutout tool spawns a box that you can move around and roate to do a box cutout on a dataset.
30+
31+
<img src="box-cutout.png" width="400px">
32+
33+
The tool has two modes:
34+
- Exclusive: Cuts out everything that overlaps the box.
35+
- Inclusive: Cuts out everything that is outside the box.
36+
37+
You can change these modes by selecting the "CutoutBox" GameObject in the hierarchy and changing the settings in the inspector:
38+
39+
<img src="box-cutout-inspector.png" width="400px">
40+
41+
## Sphere cutout
42+
43+
The sphere cutout tool spawns a sphere that you can move around and roate to do a sphere cutout on a dataset.
44+
45+
<img src="sphere-tool.png" width="400px">
46+
47+
The tool works the same as the box cutout, and also has two modes: inclusive and exclusive.
Loading
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Importing datasets in the editor
2+
3+
**Table of contents:**
4+
<!-- TOC -->
5+
6+
- [Importing datasets in the editor](#importing-datasets-in-the-editor)
7+
- [Importing datasets through the "Volume Rendering" menu bar option](#importing-datasets-through-the-volume-rendering-menu-bar-option)
8+
- [Raw datasets](#raw-datasets)
9+
- [ini files](#ini-files)
10+
- [DICOM datasets](#dicom-datasets)
11+
- [NRRD datasets](#nrrd-datasets)
12+
- [NIfTI datasets](#nifti-datasets)
13+
- [VASP/PARCHG datasets](#vaspparchg-datasets)
14+
- [Image sequence datasets](#image-sequence-datasets)
15+
- [Importing datasets by drag and drop into the assets folder](#importing-datasets-by-drag-and-drop-into-the-assets-folder)
16+
- [Importing datasets by right clicking in the Assets folder](#importing-datasets-by-right-clicking-in-the-assets-folder)
17+
- [Coordinate system and real size](#coordinate-system-and-real-size)
18+
19+
<!-- /TOC -->
20+
21+
For documentation on how to import datasets from code, see [Importing datasets form code](../../Scripting/Importing.md).
22+
23+
There are several ways to import datasets into the editor:
24+
1. [Through "Volume Rendering" -> "Load dataset" in the menu bar.](#importing-datasets-through-the-volume-rendering-menu-bar-option)
25+
2. [By drag-and-drop dataset into the "Assets" directory](#importing-datasets-by-drag-and-drop-into-the-assets-folder) (only RAW/NRRD/NIFTI, Unity 2020.2+)
26+
3. [Right click in "Assets" directory and choose "Volume Rendering" -> "Import dataset"](#importing-datasets-by-right-clicking-in-the-assets-folder)
27+
28+
## Importing datasets through the "Volume Rendering" menu bar option
29+
30+
Click "Volume Rendering" in the menu bar and then "Load dataset" and select which dataset you want to import
31+
32+
<img src="menu-bar-import.png" width="500px">
33+
34+
### Raw datasets
35+
36+
For raw datasets you simply select a single file to import.
37+
38+
An import settings menu will then pop up Here you can set the import setting for the raw dataset. For the included sample files you don't need to change anything.
39+
40+
The available settings are:
41+
- X dimension: Number of voxels/pixels in the x dimension (this may be the row count)
42+
- Y dimension: Number of voxels/pixels in the y dimension (this may be the column count)
43+
- Z dimension: Number of voxels/pixels in the z dimension (this may be the slice count)
44+
- Bytes to skip: If the dataset contains a header, this should be the size of that header - else it should be 0.
45+
- Data format: The format of the voxel data. This will usually be specified somewhere, either in a header or in some documentation for the dataset. You can replace "char" with "int" here (and "uchar" with "uint").
46+
- Endianness: Usually "little endian"
47+
48+
#### .ini files
49+
50+
If the folder contains a ".ini" with the same name (dataset.raw => dataset.raw.ini) then this will be used to populate the import settings with some default values. so you don't have to do it every time you import the same dataset.
51+
52+
For an example .ini file, see [VisMale.raw.init](../../../DataFiles/VisMale.raw.ini).
53+
54+
<img src="raw-import-settings.png" width="400px">
55+
56+
### DICOM datasets
57+
58+
To import a DICOM dataset, click "Load DICOM" and select the folder where the DICOM dataset is loaded.
59+
60+
If the folder contains multiple series, these will be loaded as separate objects.
61+
62+
**Note:** If you are or Windows or Linux it is recommended to [enable the SimpleITK importer](../../SimpleITK/SimpleITK.md), which is a requirement for JPEG2000 compressed DICOM and NRRD.
63+
64+
### NRRD datasets
65+
66+
To import an NRRD dataset, click "Load NRRD dataset" and select the .nrrd file to import.
67+
68+
**Note:** To import NRRD datasets you need to [enable the SimpleITK importer](../../SimpleITK/SimpleITK.md).
69+
70+
### NIfTI datasets
71+
72+
To import a NIfTI dataset, click "Load NIFTI dataset" and select the .nii/.nii.gz file to import.
73+
74+
**Note:** If you are or Windows or Linux it is recommended to [enable the SimpleITK importer](../../SimpleITK/SimpleITK.md), which should work better overall.
75+
76+
### VASP/PARCHG datasets
77+
78+
To import a VASP dataset, click "Load PARCGH dataset" and select the file to import.
79+
80+
### Image sequence datasets
81+
82+
Some datasets will be stored as a series of image files (similar to DICOM, but in .jpg/.png/.tiff format), where each image represents a slice. These are referred to as "image sequence" datasets.
83+
84+
To import an image sequence, click "Load image sequence" and select the folder containing the slices.
85+
86+
## Importing datasets by drag and drop into the assets folder
87+
88+
To import a RAW/NRRD/NIFTI/PARCHG dataset (not DICOM or other image sequences), you can simply drag and drop the dataset file into the "Assets" directory.
89+
90+
<img src="drag-drop-import.png" width="500px">
91+
92+
This will create a new Asset file for the dataset.
93+
94+
For RAW datasets you can change the import settings by clicking on the asset, changing the import settings in the inspector and clicking "Apply".
95+
96+
<img src="raw-asset-settings.png" width="500px">
97+
98+
To use these datasets, you can either:
99+
- Drag and drop the dataset asset into the scene view or scene hierarchy view in the editor (Unity 2021.2 or newer)
100+
- Spawn from code: Referencing the `VolumeDataset` asset somewhere in code, or through the Resources folder, and spawn it using the [VolumeObjectFactory](../../Scripting/Importing.md).
101+
102+
## Importing datasets by right clicking in the Assets folder
103+
104+
You can also import datasets by right clicking in "Assets" directory and choosing "Volume Rendering" -> "Import dataset"
105+
106+
All datasets (also DICOM) can be imported this way.
107+
108+
<img src="import-context-menu.png" width="500px">
109+
110+
Using the imported dataset assets works the same as for [datasets imported by drag and drop](#importing-datasets-by-drag-and-drop-into-the-assets-folder)
111+
112+
# Coordinate system and real size
113+
114+
Coordinate systems are handled for DICOM and NRRD, and we convert to Unity's coordinate system using metre units.
115+
116+
By default import datasets will have their size normalised. If you wish to keep the original size (so multiple datasets will fit well together), you can select the outer GameObject (the ones that has a `VolumeRenderedObject` component), and set its scale to (1,1,1).
Loading
Loading
Loading
Loading
Loading
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Settings window
2+
3+
This window exposes some dataset and import-related settings, for using the plugin in the Editor.
4+
5+
## How to open the settings window
6+
7+
You can open the settings window from the "Volume Rendering" menu bar option:
8+
9+
<img src="menubar-settings.png" width="200px">
10+
11+
## Available settings
12+
13+
<img src="settings-window.png" width="400px">
14+
15+
### Show downscale prompt
16+
17+
When this setting is enabled, you will see a promt asking you if you wish to downscale the dataset every time you import a dataset in the editor.
18+
19+
Imported datasets are automatically downscaled if they are too large to fit into a 3D texture. However, in some cases you may wish to downscale it even if this is not a problem (to save memory, etc.).
20+
21+
### Enable SimpleITK
22+
23+
If you're on Windows/Linux/Mac, you can optionally enable the SimpleITK-based importer.
24+
25+
This has a couple of advantages:
26+
- Better DICOM support (faster import, and fewer issues)
27+
- JPEG2000 compressed DICOM support
28+
- NRRD support
29+
- Better NIFTI support
30+
- Support for image sequence datasets in TIFF format
31+
32+
It is recommeneded to enable this if you don't only use RAW datasets.
33+
34+
This is a native plugin, so to support other platforms you would need to build it yourself.
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Slice renderer
2+
3+
<img src="slice-renderer.png" width="400px">
4+
5+
The slice renderer can be used to create a axis aligned (or free transform) slice view of a dataset.
6+
7+
## How to open the slice renderer window
8+
9+
You can open the slice renderer window from the "Volume Rendering" menu bar option:
10+
11+
<img src="menubar-slice-renderer.png" width="200px">
12+
13+
## Creating slicing planes
14+
15+
To create a new slice renderer, click one of the "Create plane" buttons.
16+
17+
<img src="options.png" width="400px">
18+
19+
The buttons to the left can be used to navigate between different slices.
20+
21+
## Rotating the slice view
22+
23+
At the top of the window there are some more buttons.
24+
25+
<img src="top-options.png" width="400px">
26+
27+
The two rightmost buttons can be used to rotate the slice view 90 degrees.
28+
29+
## Moving and measuring the slices
30+
31+
The three buttons to the top left will change the current interaction mode:
32+
- **Move slice**: Left click + drag mouse up/down => Slice moves forwards/backwards
33+
- **Inspect values**: Left click somewhere in the view, and the value will be printed in the bottom left corner.
34+
- **Measure distances**: Left click and drag mouse to measure a linear distance. The value will be printed at the bottom left corner.
35+
36+
<img src="interaction-modes.gif" width="400px">
Loading
Loading
6.13 KB
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Transfer functions
2+
3+
You can use transfer functions to apply different colours and opacities to different parts of the dataset, resulting in more interesting visualisations.
4+
5+
Ttransfer functions will map density (and optionally gradient magnitude) to a selected colour/opacity, enabling you to highlight parts of the dataset (skin, bones, etc.).
6+
7+
You can open the transfer function editors from the "Volume Rendering" menu bar option in the editor:
8+
9+
<img src="menubar-tf1d.png" width="400px">
10+
11+
## 1. <a name='Dimensionaltransferfunctions'></a>1-Dimensional transfer functions
12+
13+
This is the simplest type of transfer function to work with. It maps density values to a selected colour and opacity (transparency).
14+
15+
<img src="tf1d.png" width="400px">
16+
17+
The axes:
18+
- X-axis: Represents density values.
19+
- Y-axis: Represents alpha values (opacity).
20+
21+
How to use:
22+
- Move the grey alpha knots to create a curve for opacity by density.
23+
- Right-click to add new alpha knots.
24+
- The bottom gradient-coloured panel maps colour to density. Here you can select which colour a part of the dataset should have, based on the density values of the voxels.
25+
- Right-click to add new knots and click on an existing colour knot to modify its colour.
26+
27+
## 2. <a name='Dimensionaltransferfunctions-1'></a>2-Dimensional transfer functions
28+
29+
**Note: The 2D TF editor is still work-in-progress.** I plan to improve it further. Suggestions and feedback is very welcome! ([create an issue](https://github.com/mlavik1/UnityVolumeRendering/issues/new) or [start a discussion thread](https://github.com/mlavik1/UnityVolumeRendering/discussions)).
30+
31+
<img src="tf2d.png" width="400px">
32+
33+
The axes:
34+
- X-axis: Represents density
35+
- Y-axis: Represents gradient magnitude.
36+
37+
How to use:
38+
- Click "add rectangle" to add a new rectangle-shape.
39+
- Click on the rectangle and drag to move it.
40+
- Drag the edges of the rectangle to change its shape.
41+
- Click on the colour picker to change the colour of the selected rectangle shape.
42+
- Change the "min alpha" and "max alpha" sliders to change the minimum and maximum opacity of the selected shape.
43+
- The "max alpha" defines the opacity value at the centre of the shape.
44+
- The "min alpha" defines the opacity value at the edges of the shape.
Loading
21.8 KB
Loading
71.7 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Manipulating spawned datasets
2+
3+
Datasets will be spawned as GameObjects, with a `VolumeRenderedObject` component attached to them.
4+
5+
You can move, rotate and scale these objects like any other GameObject in the Unity Editor.
6+
7+
<img src="movement.gif" width="400px">
8+
9+
# Saving spawned datasets
10+
11+
Spawned datasets can be saved as a part of the scene (simply save the scene).
12+
13+
However, if the datasets are large (or many) this will cause the scene asset to become very large, and saving/loading will be slow (or crash!).
14+
To prevent this, you may consider importing your datasets as an Asset (see [import documentation](ImportingDatasets.md)) and referencing the already imported dataset through some script and spawning it through the [VolumeObjectFactory](../../Scripting/Importing.md).
15+
16+
# Changing the appearance settings
17+
18+
To change the appearance settings and other volume rendering related settings, see [the appearance settings documentation](VolumeRenderingSettings.md).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Volume rendering appearance settings
2+
3+
**Table of contents:**
4+
<!-- TOC -->
5+
6+
- [Cross section tools](#cross-section-tools)
7+
- [Cross section plane](#cross-section-plane)
8+
- [Box cutout](#box-cutout)
9+
- [Sphere cutout](#sphere-cutout)
10+
11+
<!-- /TOC -->
12+
13+
To modify the appearance settings of a volume rendered dataset, simply select the object in the scene / scene hierarchy - and you will find the appearance settings under "Volume Rendered Object" in the inspector.
14+
15+
<img src="inspector.png" width="400px">
16+
17+
## Render mode
18+
19+
<img src="rendermode.png" width="300px">
20+
21+
There are 3 render modes:
22+
- Direct Volume Rendering (raymarching, using transfer functions)
23+
- Maximum Intensity Projection (shows the maximum density)
24+
- Isosurface Rendering (raymarching, stops when it hits a surface)
25+
26+
## Lighting
27+
28+
You can enable lighting to get more realistic visualisation.
29+
30+
<img src="lighting.png" width="300px">
31+
32+
This comes at a cost, and performance may suffer (both memory and rendering speed).
33+
34+
To apply lighting to the volume rendering, we calculate the gradient at each voxel and use this to calculate a normal, which we use to apply phong lighting.
35+
36+
## Cubic interpolation
37+
38+
<img src="cubic-interpolation.png" width="300px">
39+
40+
To reduce so-called "staircase artifacts", you can enable cubic interpolation.
41+
42+
<img src="cubic-sampling-results.png" width="400px">
43+
44+
This can be quite expensive in terms of performance - especially when lighting is enabled!
45+
46+
# Early ray termination
47+
48+
To improve performance, the raymarching shader may optionally exit early when enough samples have been accumulated.
49+
This is a very simple optimisation that improves performance by avoiding enumeration of invisible voxels.
50+
51+
You usually want to leave this setting enabled, since it improves performance considerably - usually without any noticable visual changes.
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)