Skip to content
Snippets Groups Projects
Commit a05e2fe7 authored by fima's avatar fima :beers:
Browse files

Merge branch 'docs_update' into 'main'

Docs update

See merge request !97
parents 25675ca4 71df7f91
No related branches found
No related tags found
1 merge request!97Docs update
docs/assets/screenshots/generate_volume.png

91.7 KiB

...@@ -131,8 +131,21 @@ You can find us at Gitlab: ...@@ -131,8 +131,21 @@ You can find us at Gitlab:
[https://lab.compute.dtu.dk/QIM/tools/qim3d](https://lab.compute.dtu.dk/QIM/tools/qim3d [https://lab.compute.dtu.dk/QIM/tools/qim3d](https://lab.compute.dtu.dk/QIM/tools/qim3d
) )
This project is licensed under the MIT License. This project is licensed under the [MIT License](https://lab.compute.dtu.dk/QIM/tools/qim3d/-/blob/main/LICENSE).
### Contributors
Below is a list of contributors to the project, arranged in chronological order of their first commit to the repository:
| Author | Commits | First commit |
|:--------------------------|----------:|-------------:|
| Felipe Delestro | 170 | 2023-05-12 |
| Stefan Engelmann Jensen | 29 | 2023-06-29 |
| Oskar Kristoffersen | 15 | 2023-07-05 |
| Christian Kento Rasmussen | 19 | 2024-02-01 |
| Alessia Saccardo | 7 | 2024-02-19 |
| David Grundfest | 4 | 2024-04-12 |
| Anna Bøgevang Ekner | 3 | 2024-04-18 |
## Support ## Support
......
...@@ -16,6 +16,11 @@ Here, we provide functionalities designed specifically for 3D image analysis and ...@@ -16,6 +16,11 @@ Here, we provide functionalities designed specifically for 3D image analysis and
- minimum - minimum
- tophat - tophat
::: qim3d.processing.Pipeline
options:
members:
- append
::: qim3d.processing.operations ::: qim3d.processing.operations
options: options:
members: members:
...@@ -23,7 +28,3 @@ Here, we provide functionalities designed specifically for 3D image analysis and ...@@ -23,7 +28,3 @@ Here, we provide functionalities designed specifically for 3D image analysis and
- watershed - watershed
- edge_fade - edge_fade
- fade_mask - fade_mask
::: qim3d.processing
options:
members:
- Pipeline
\ No newline at end of file
...@@ -5,6 +5,7 @@ A set of tools to ease managment of the system, with the common needs for large ...@@ -5,6 +5,7 @@ A set of tools to ease managment of the system, with the common needs for large
::: qim3d.utils.img ::: qim3d.utils.img
options: options:
members: members:
- generate_volume
- overlay_rgb_images - overlay_rgb_images
::: qim3d.utils.system ::: qim3d.utils.system
......
...@@ -62,6 +62,7 @@ markdown_extensions: ...@@ -62,6 +62,7 @@ markdown_extensions:
- admonition - admonition
- attr_list - attr_list
- md_in_html - md_in_html
- tables
- pymdownx.inlinehilite - pymdownx.inlinehilite
- pymdownx.snippets - pymdownx.snippets
- pymdownx.details - pymdownx.details
...@@ -84,5 +85,5 @@ plugins: ...@@ -84,5 +85,5 @@ plugins:
show_root_full_path: true show_root_full_path: true
show_object_full_path: true show_object_full_path: true
show_symbol_type_heading: true show_symbol_type_heading: true
show_symbol_type_toc: true show_symbol_type_toc: false
separate_signature: true separate_signature: true
\ No newline at end of file
...@@ -749,6 +749,16 @@ def load( ...@@ -749,6 +749,16 @@ def load(
""" """
Load data from the specified file or directory. Load data from the specified file or directory.
Supported formats:
- `Tiff` (including file stacks)
- `HDF5`
- `TXRM`/`TXM`/`XRM`
- `NIfTI`
- `PIL` (including file stacks)
- `VOL`/`VGI`
- `DICOM`
Args: Args:
path (str or os.PathLike): The path to the file or directory. path (str or os.PathLike): The path to the file or directory.
virtual_stack (bool, optional): Specifies whether to use virtual virtual_stack (bool, optional): Specifies whether to use virtual
...@@ -833,14 +843,17 @@ class ImgExamples: ...@@ -833,14 +843,17 @@ class ImgExamples:
shell_225x128x128 (numpy.ndarray): A 3D volume of a shell. shell_225x128x128 (numpy.ndarray): A 3D volume of a shell.
Tip: Tip:
Call `qim3d.examples.<name>` to access the image examples easily as this class is instantiated when importing `qim3d` Simply call `qim3d.examples.<name>` to access the image examples.
Example: Example:
```python ```python
import qim3d import qim3d
data = qim3d.examples.blobs_256x256 vol = qim3d.examples.shell_225x128x128
qim3d.viz.slices(vol, n_slices=15)
``` ```
![Grid of slices](assets/screenshots/viz-slices.png)
""" """
......
...@@ -82,9 +82,18 @@ def generate_volume( ...@@ -82,9 +82,18 @@ def generate_volume(
ValueError: If `dtype` is not a valid numpy number type. ValueError: If `dtype` is not a valid numpy number type.
Example: Example:
```python
import qim3d import qim3d
vol = qim3d.utils.generate_volume() vol = qim3d.utils.generate_volume(noise_scale=0.05, threshold=0.4)
qim3d.viz.slices(vol, vmin=0, vmax=255) qim3d.viz.slices(vol, vmin=0, vmax=255, n_slices=15)
```
![generate_volume](assets/screenshots/generate_volume.png)
```python
qim3d.viz.vol(vol)
```
<iframe src="https://platform.qim.dk/k3d/synthetic_volume.html" width="100%" height="500" frameborder="0"></iframe>
""" """
if not isinstance(final_shape, tuple) or len(final_shape) != 3: if not isinstance(final_shape, tuple) or len(final_shape) != 3:
......
...@@ -266,8 +266,8 @@ def slices( ...@@ -266,8 +266,8 @@ def slices(
```python ```python
import qim3d import qim3d
img = qim3d.examples.shell_225x128x128 vol = qim3d.examples.shell_225x128x128
qim3d.viz.slices(img, n_slices=15) qim3d.viz.slices(vol, n_slices=15)
``` ```
![Grid of slices](assets/screenshots/viz-slices.png) ![Grid of slices](assets/screenshots/viz-slices.png)
""" """
......
...@@ -25,6 +25,7 @@ def vol( ...@@ -25,6 +25,7 @@ def vol(
cmap=None, cmap=None,
samples="auto", samples="auto",
max_voxels=412**3, max_voxels=412**3,
data_type="scaled_float16",
**kwargs, **kwargs,
): ):
""" """
...@@ -72,6 +73,7 @@ def vol( ...@@ -72,6 +73,7 @@ def vol(
``` ```
""" """
pixel_count = img.shape[0] * img.shape[1] * img.shape[2] pixel_count = img.shape[0] * img.shape[1] * img.shape[2]
# target is 60fps on m1 macbook pro, using test volume: https://data.qim.dk/pages/foam.html # target is 60fps on m1 macbook pro, using test volume: https://data.qim.dk/pages/foam.html
if samples == "auto": if samples == "auto":
...@@ -88,10 +90,10 @@ def vol( ...@@ -88,10 +90,10 @@ def vol(
if aspectmode.lower() not in ["data", "cube"]: if aspectmode.lower() not in ["data", "cube"]:
raise ValueError("aspectmode should be either 'data' or 'cube'") raise ValueError("aspectmode should be either 'data' or 'cube'")
# check if image should be downsampled for visualization # check if image should be downsampled for visualization
original_shape = img.shape original_shape = img.shape
img = downscale_img(img, max_voxels=max_voxels) img = downscale_img(img, max_voxels=max_voxels)
new_shape = img.shape new_shape = img.shape
if original_shape != new_shape: if original_shape != new_shape:
...@@ -99,6 +101,17 @@ def vol( ...@@ -99,6 +101,17 @@ def vol(
f"Downsampled image for visualization. From {original_shape} to {new_shape}" f"Downsampled image for visualization. From {original_shape} to {new_shape}"
) )
# Scale the image to float16 if needed
if save:
# When saving, we need float64
img = img.astype(np.float64)
else:
if data_type == "scaled_float16":
img = scale_to_float16(img)
else:
img = img.astype(data_type)
# Set color ranges # Set color ranges
color_range = [np.min(img), np.max(img)] color_range = [np.min(img), np.max(img)]
if vmin: if vmin:
...@@ -106,8 +119,9 @@ def vol( ...@@ -106,8 +119,9 @@ def vol(
if vmax: if vmax:
color_range[1] = vmax color_range[1] = vmax
# Create the volume plot
plt_volume = k3d.volume( plt_volume = k3d.volume(
scale_to_float16(img), img,
bounds=( bounds=(
[0, img.shape[2], 0, img.shape[1], 0, img.shape[0]] [0, img.shape[2], 0, img.shape[1], 0, img.shape[0]]
if aspectmode.lower() == "data" if aspectmode.lower() == "data"
...@@ -119,7 +133,6 @@ def vol( ...@@ -119,7 +133,6 @@ def vol(
) )
plot = k3d.plot(grid_visible=grid_visible, **kwargs) plot = k3d.plot(grid_visible=grid_visible, **kwargs)
plot += plt_volume plot += plt_volume
if save: if save:
# Save html to disk # Save html to disk
with open(str(save), "w", encoding="utf-8") as fp: with open(str(save), "w", encoding="utf-8") as fp:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment