diff --git a/docs/assets/screenshots/generate_volume.png b/docs/assets/screenshots/generate_volume.png new file mode 100644 index 0000000000000000000000000000000000000000..02ee3b73643630316aec6f00c8d6e00866a06ec7 Binary files /dev/null and b/docs/assets/screenshots/generate_volume.png differ diff --git a/docs/index.md b/docs/index.md index 5a3ca251190a1d906061f4bd23871d19e599185e..ea6111ebbe6f4a893f5aaaf65c99f42418f43386 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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 ) -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 diff --git a/docs/processing.md b/docs/processing.md index 558f857e94aa01cbc128a3d3245b668ca82c1998..cd68efaba653a77ae1f938ca088e17e8b0f81ae7 100644 --- a/docs/processing.md +++ b/docs/processing.md @@ -16,6 +16,11 @@ Here, we provide functionalities designed specifically for 3D image analysis and - minimum - tophat +::: qim3d.processing.Pipeline + options: + members: + - append + ::: qim3d.processing.operations options: members: @@ -23,7 +28,3 @@ Here, we provide functionalities designed specifically for 3D image analysis and - watershed - edge_fade - fade_mask -::: qim3d.processing - options: - members: - - Pipeline \ No newline at end of file diff --git a/docs/utils.md b/docs/utils.md index f86074f1b190446ad487521be309c3aa17515761..6425ef1ad29341cdeda23ac62c413ea604e47e1d 100644 --- a/docs/utils.md +++ b/docs/utils.md @@ -5,6 +5,7 @@ A set of tools to ease managment of the system, with the common needs for large ::: qim3d.utils.img options: members: + - generate_volume - overlay_rgb_images ::: qim3d.utils.system diff --git a/mkdocs.yml b/mkdocs.yml index df02fdf5b76c459bb6035d146a84d808f00a8c5f..02e9b73b47a1dfdff8e6d6ed7831683ae8ec7a30 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -62,6 +62,7 @@ markdown_extensions: - admonition - attr_list - md_in_html + - tables - pymdownx.inlinehilite - pymdownx.snippets - pymdownx.details @@ -84,5 +85,5 @@ plugins: show_root_full_path: true show_object_full_path: true show_symbol_type_heading: true - show_symbol_type_toc: true + show_symbol_type_toc: false separate_signature: true \ No newline at end of file diff --git a/qim3d/io/loading.py b/qim3d/io/loading.py index 42eef66c7e73dcda4619c83690a74c09c30eb528..e45eb1216013b0a0b55d19778795e86833a2b3c7 100644 --- a/qim3d/io/loading.py +++ b/qim3d/io/loading.py @@ -749,6 +749,16 @@ def load( """ 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: path (str or os.PathLike): The path to the file or directory. virtual_stack (bool, optional): Specifies whether to use virtual @@ -833,14 +843,17 @@ class ImgExamples: shell_225x128x128 (numpy.ndarray): A 3D volume of a shell. 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: ```python import qim3d - data = qim3d.examples.blobs_256x256 + vol = qim3d.examples.shell_225x128x128 + qim3d.viz.slices(vol, n_slices=15) ``` +  + """ diff --git a/qim3d/utils/img.py b/qim3d/utils/img.py index 13f181faef80baa52dae596969d3d8a8c90e4651..6b91af384311662885897dcd6c5938fd18c67a84 100644 --- a/qim3d/utils/img.py +++ b/qim3d/utils/img.py @@ -82,9 +82,18 @@ def generate_volume( ValueError: If `dtype` is not a valid numpy number type. Example: + ```python import qim3d - vol = qim3d.utils.generate_volume() - qim3d.viz.slices(vol, vmin=0, vmax=255) + vol = qim3d.utils.generate_volume(noise_scale=0.05, threshold=0.4) + qim3d.viz.slices(vol, vmin=0, vmax=255, n_slices=15) + ``` +  + + ```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: diff --git a/qim3d/viz/img.py b/qim3d/viz/img.py index 24980b5c6ab872652ce8ad04d89a84e3c9449314..f2293565675af6b6fc7cf76b4577d6fbedd2fa22 100644 --- a/qim3d/viz/img.py +++ b/qim3d/viz/img.py @@ -266,8 +266,8 @@ def slices( ```python import qim3d - img = qim3d.examples.shell_225x128x128 - qim3d.viz.slices(img, n_slices=15) + vol = qim3d.examples.shell_225x128x128 + qim3d.viz.slices(vol, n_slices=15) ```  """ diff --git a/qim3d/viz/k3d.py b/qim3d/viz/k3d.py index 9271c56717b6f1ca95f674d16001c07ac3569dab..e612568b95e5a70b40ec99ccc2b914ff6ae71288 100644 --- a/qim3d/viz/k3d.py +++ b/qim3d/viz/k3d.py @@ -25,6 +25,7 @@ def vol( cmap=None, samples="auto", max_voxels=412**3, + data_type="scaled_float16", **kwargs, ): """ @@ -72,6 +73,7 @@ def vol( ``` """ + 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 if samples == "auto": @@ -88,10 +90,10 @@ def vol( if aspectmode.lower() not in ["data", "cube"]: raise ValueError("aspectmode should be either 'data' or 'cube'") - # check if image should be downsampled for visualization original_shape = img.shape img = downscale_img(img, max_voxels=max_voxels) + new_shape = img.shape if original_shape != new_shape: @@ -99,6 +101,17 @@ def vol( 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 color_range = [np.min(img), np.max(img)] if vmin: @@ -106,8 +119,9 @@ def vol( if vmax: color_range[1] = vmax + # Create the volume plot plt_volume = k3d.volume( - scale_to_float16(img), + img, bounds=( [0, img.shape[2], 0, img.shape[1], 0, img.shape[0]] if aspectmode.lower() == "data" @@ -119,7 +133,6 @@ def vol( ) plot = k3d.plot(grid_visible=grid_visible, **kwargs) plot += plt_volume - if save: # Save html to disk with open(str(save), "w", encoding="utf-8") as fp: