diff --git a/qim3d/features/_common_features_methods.py b/qim3d/features/_common_features_methods.py index aff73350fd4f038c0d564dc4bbf94c32dbd5f1be..b90f0018c34a297e5ed4f124dbde8c586a558c67 100644 --- a/qim3d/features/_common_features_methods.py +++ b/qim3d/features/_common_features_methods.py @@ -12,11 +12,11 @@ def volume(obj: np.ndarray|trimesh.Trimesh, Compute the volume of a 3D volume or mesh. Args: - obj: Either a np.ndarray volume or a mesh object of type trimesh.Trimesh. - **mesh_kwargs: Additional arguments for mesh creation if the input is a volume. + obj (np.ndarray or trimesh.Trimesh): Either a np.ndarray volume or a mesh object of type trimesh.Trimesh. + **mesh_kwargs (Any): Additional arguments for mesh creation if the input is a volume. Returns: - volume: The volume of the object. + volume (float): The volume of the object. Example: Compute volume from a mesh: @@ -58,11 +58,11 @@ def area(obj: np.ndarray|trimesh.Trimesh, Compute the surface area of a 3D volume or mesh. Args: - obj: Either a np.ndarray volume or a mesh object of type trimesh.Trimesh. - **mesh_kwargs: Additional arguments for mesh creation if the input is a volume. + obj (np.ndarray or trimesh.Trimesh): Either a np.ndarray volume or a mesh object of type trimesh.Trimesh. + **mesh_kwargs (Any): Additional arguments for mesh creation if the input is a volume. Returns: - area: The surface area of the object. + area (float): The surface area of the object. Example: Compute area from a mesh: @@ -107,11 +107,11 @@ def sphericity(obj: np.ndarray|trimesh.Trimesh, actual surface area. Args: - obj: Either a np.ndarray volume or a mesh object of type trimesh.Trimesh. - **mesh_kwargs: Additional arguments for mesh creation if the input is a volume. + obj (np.ndarray or trimesh.Trimesh): Either a np.ndarray volume or a mesh object of type trimesh.Trimesh. + **mesh_kwargs (Any): Additional arguments for mesh creation if the input is a volume. Returns: - sphericity: A float value representing the sphericity of the object. + sphericity (float): A float value representing the sphericity of the object. Example: Compute sphericity from a mesh: diff --git a/qim3d/filters/_common_filter_methods.py b/qim3d/filters/_common_filter_methods.py index ddd663fa0cb68e30ba92d9563fc95d7f3b9fdbfb..20099cee767e23d7280e2712d97353f8a48fdd32 100644 --- a/qim3d/filters/_common_filter_methods.py +++ b/qim3d/filters/_common_filter_methods.py @@ -221,14 +221,14 @@ def gaussian(vol: np.ndarray, Applies a Gaussian filter to the input volume using scipy.ndimage.gaussian_filter or dask_image.ndfilters.gaussian_filter. Args: - vol: The input image or volume. - dask: Whether to use Dask for the Gaussian filter. - chunks: Defines how to divide the array into blocks when using Dask. Can be an integer, tuple, size in bytes, or "auto" for automatic sizing. - *args: Additional positional arguments for the Gaussian filter. - **kwargs: Additional keyword arguments for the Gaussian filter. + vol (np.ndarray): The input image or volume. + dask (bool, optional): Whether to use Dask for the Gaussian filter. + chunks (int or tuple or "'auto'", optional): Defines how to divide the array into blocks when using Dask. Can be an integer, tuple, size in bytes, or "auto" for automatic sizing. + *args (Any): Additional positional arguments for the Gaussian filter. + **kwargs (Any): Additional keyword arguments for the Gaussian filter. Returns: - The filtered image or volume. + filtered_vol (np.ndarray): The filtered image or volume. """ if dask: @@ -250,13 +250,13 @@ def median(vol: np.ndarray, Applies a median filter to the input volume using scipy.ndimage.median_filter or dask_image.ndfilters.median_filter. Args: - vol: The input image or volume. - dask: Whether to use Dask for the median filter. - chunks: Defines how to divide the array into blocks when using Dask. Can be an integer, tuple, size in bytes, or "auto" for automatic sizing. - **kwargs: Additional keyword arguments for the median filter. + vol (np.ndarray): The input image or volume. + dask (bool, optional): Whether to use Dask for the median filter. + chunks (int or tuple or "'auto'", optional): Defines how to divide the array into blocks when using Dask. Can be an integer, tuple, size in bytes, or "auto" for automatic sizing. + **kwargs (Any): Additional keyword arguments for the median filter. Returns: - The filtered image or volume. + filtered_vol (np.ndarray): The filtered image or volume. """ if dask: if not isinstance(vol, da.Array): @@ -277,13 +277,13 @@ def maximum(vol: np.ndarray, Applies a maximum filter to the input volume using scipy.ndimage.maximum_filter or dask_image.ndfilters.maximum_filter. Args: - vol: The input image or volume. - dask: Whether to use Dask for the maximum filter. - chunks: Defines how to divide the array into blocks when using Dask. Can be an integer, tuple, size in bytes, or "auto" for automatic sizing. - **kwargs: Additional keyword arguments for the maximum filter. + vol (np.ndarray): The input image or volume. + dask (bool, optional): Whether to use Dask for the maximum filter. + chunks (int or tuple or "'auto'", optional): Defines how to divide the array into blocks when using Dask. Can be an integer, tuple, size in bytes, or "auto" for automatic sizing. + **kwargs (Any): Additional keyword arguments for the maximum filter. Returns: - The filtered image or volume. + filtered_vol (np.ndarray): The filtered image or volume. """ if dask: if not isinstance(vol, da.Array): @@ -304,13 +304,13 @@ def minimum(vol: np.ndarray, Applies a minimum filter to the input volume using scipy.ndimage.minimum_filter or dask_image.ndfilters.minimum_filter. Args: - vol: The input image or volume. - dask: Whether to use Dask for the minimum filter. - chunks: Defines how to divide the array into blocks when using Dask. Can be an integer, tuple, size in bytes, or "auto" for automatic sizing. - **kwargs: Additional keyword arguments for the minimum filter. + vol (np.ndarray): The input image or volume. + dask (bool, optional): Whether to use Dask for the minimum filter. + chunks (int or tuple or "'auto'", optional): Defines how to divide the array into blocks when using Dask. Can be an integer, tuple, size in bytes, or "auto" for automatic sizing. + **kwargs (Any): Additional keyword arguments for the minimum filter. Returns: - The filtered image or volume. + filtered_vol (np.ndarray): The filtered image or volume. """ if dask: if not isinstance(vol, da.Array): @@ -330,15 +330,14 @@ def tophat(vol: np.ndarray, Remove background from the volume. Args: - vol: The volume to remove background from. - radius: The radius of the structuring element (default: 3). - background: Color of the background, 'dark' or 'bright' (default: 'dark'). If 'bright', volume will be inverted. - dask: Whether to use Dask for the tophat filter (not supported, will default to SciPy). - chunks: Defines how to divide the array into blocks when using Dask. Can be an integer, tuple, size in bytes, or "auto" for automatic sizing. - **kwargs: Additional keyword arguments. + vol (np.ndarray): The volume to remove background from. + dask (bool, optional): Whether to use Dask for the tophat filter (not supported, will default to SciPy). + **kwargs (Any): Additional keyword arguments. + `radius` (float): The radius of the structuring element (default: 3). + `background` (str): Color of the background, 'dark' or 'bright' (default: 'dark'). If 'bright', volume will be inverted. Returns: - vol: The volume with background removed. + filtered_vol (np.ndarray): The volume with background removed. """ radius = kwargs["radius"] if "radius" in kwargs else 3 diff --git a/qim3d/io/_loading.py b/qim3d/io/_loading.py index aac7fc5c25c9d082fe97499085377d591bc5939c..b99dde512af678937b2af354dfb9ea4dace515d7 100644 --- a/qim3d/io/_loading.py +++ b/qim3d/io/_loading.py @@ -799,7 +799,7 @@ def load( force_load (bool, optional): If the file size exceeds available memory, a MemoryError is raised. If force_load is True, the error is changed to warning and the loader tries to load it anyway. Default is False. dim_order (tuple, optional): The order of the dimensions in the volume for .vol files. Default is (2,1,0) which corresponds to (z,y,x) - **kwargs: Additional keyword arguments supported by `DataLoader`: + **kwargs (Any): Additional keyword arguments supported by `DataLoader`: - `virtual_stack` (bool) - `dataset_name` (str) - `return_metadata` (bool) @@ -870,10 +870,10 @@ def load_mesh(filename: str) -> trimesh.Trimesh: Load a mesh from an .obj file using trimesh. Args: - filename: The path to the .obj file. + filename (str or os.PathLike): The path to the .obj file. Returns: - mesh: A trimesh object containing the mesh data (vertices and faces). + mesh (trimesh.Trimesh): A trimesh object containing the mesh data (vertices and faces). Example: ```python diff --git a/qim3d/io/_ome_zarr.py b/qim3d/io/_ome_zarr.py index 36976316b8811380d68cbe1b7f5f43e5c001c4f9..2df48c987c016a64b80b3088f3510fbd00bd4e36 100644 --- a/qim3d/io/_ome_zarr.py +++ b/qim3d/io/_ome_zarr.py @@ -222,7 +222,7 @@ def export_ome_zarr( ``` Returns: - None: This function writes the OME-Zarr data to the specified directory and does not return any value. + None (None): This function writes the OME-Zarr data to the specified directory and does not return any value. """ # Check if directory exists @@ -319,8 +319,7 @@ def import_ome_zarr( If False, returns a lazy Dask array. Defaults to True. Returns: - np.ndarray or dask.array.Array: The requested image data, either as a NumPy array if `load=True`, - or a Dask array if `load=False`. + vol (np.ndarray or dask.array.Array): The requested image data, either as a NumPy array if `load=True`, or a Dask array if `load=False`. Raises: ValueError: If the requested `scale` does not exist in the data. diff --git a/qim3d/io/_saving.py b/qim3d/io/_saving.py index eb6c39e521afdf25502ba7077edaac65d66230f0..cc926f9ca45ce8149ee3aa4b2d84d7cb2a2a75f1 100644 --- a/qim3d/io/_saving.py +++ b/qim3d/io/_saving.py @@ -424,14 +424,14 @@ def save( (only relevant for TIFF stacks). Default is None sliced_dim (int, optional): Specifies the dimension that is sliced in case a TIFF stack is saved as several files (only relevant for TIFF stacks). Default is 0, i.e., the first dimension. - **kwargs: Additional keyword arguments to be passed to the DataSaver constructor + **kwargs (Any): Additional keyword arguments to be passed to the DataSaver constructor Raises: ValueError: If the provided path is an existing directory and self.basename is not provided <strong>OR</strong> - If the file format is not supported <strong>OR</strong> - If the provided path does not exist and self.basename is not provided <strong>OR</strong> - If a file extension is not provided <strong>OR</strong> - if a file with the specified path already exists and replace=False. + If the file format is not supported <strong>OR</strong> + If the provided path does not exist and self.basename is not provided <strong>OR</strong> + If a file extension is not provided <strong>OR</strong> + if a file with the specified path already exists and replace=False. Example: ```python @@ -472,8 +472,8 @@ def save_mesh( Save a trimesh object to an .obj file. Args: - filename: The name of the file to save the mesh. - mesh: A trimesh.Trimesh object representing the mesh. + filename (str): The name of the file to save the mesh. + mesh (trimesh.Trimesh): A trimesh.Trimesh object representing the mesh. Example: ```python diff --git a/qim3d/mesh/_common_mesh_methods.py b/qim3d/mesh/_common_mesh_methods.py index d6f184dca6021a4d7f50da79d6381d4a1a38b4fd..0c71872b9a46bfcfc5d099dd6d4655f27f4446cf 100644 --- a/qim3d/mesh/_common_mesh_methods.py +++ b/qim3d/mesh/_common_mesh_methods.py @@ -20,8 +20,7 @@ def from_volume( volume (np.ndarray): The 3D numpy array representing the volume. level (float, optional): The threshold value for Marching Cubes. If None, Otsu's method is used. step_size (int, optional): The step size for the Marching Cubes algorithm. - allow_degenerate (bool, optional): Whether to allow degenerate (i.e. zero-area) triangles in the end-result. - If False, degenerate triangles are removed, at the cost of making the algorithm slower. Default False. + allow_degenerate (bool, optional): Whether to allow degenerate (i.e. zero-area) triangles in the end-result. If False, degenerate triangles are removed, at the cost of making the algorithm slower. Default False. padding (tuple of int, optional): Padding to add around the volume. **kwargs: Additional keyword arguments to pass to `skimage.measure.marching_cubes`. diff --git a/qim3d/operations/_common_operations_methods.py b/qim3d/operations/_common_operations_methods.py index 57caaedf8b5239a92d87fe1925738e887f06c04c..ca31871e4b0baed1b382424a41484338c8c158b0 100644 --- a/qim3d/operations/_common_operations_methods.py +++ b/qim3d/operations/_common_operations_methods.py @@ -19,7 +19,7 @@ def remove_background( median_filter_size (int, optional): The size of the median filter. Defaults to 2. min_object_radius (int, optional): The radius of the structuring element for the tophat filter. Defaults to 3. background (str, optional): The background type. Can be 'dark' or 'bright'. Defaults to 'dark'. - **median_kwargs: Additional keyword arguments for the Median filter. + **median_kwargs (Any): Additional keyword arguments for the Median filter. Returns: np.ndarray: The volume with background removed. @@ -73,7 +73,7 @@ def fade_mask( geometry (str, optional): The geometric shape of the fading. Can be 'spherical' or 'cylindrical'. Defaults to 'spherical'. invert (bool, optional): Flag for inverting the fading. Defaults to False. axis (int, optional): The axis along which to apply the fading. Defaults to 0. - **kwargs: Additional keyword arguments for the edge fading. + **kwargs (Any): Additional keyword arguments for the edge fading. Returns: vol_faded (np.ndarray): The volume with edge fading applied. diff --git a/qim3d/processing/_layers.py b/qim3d/processing/_layers.py index 65fdbbd61cfe1c1b8bb02d2ea793bf8ec73c5ce8..0924b80adab6bc8fe7005a618d527034ffe3b75a 100644 --- a/qim3d/processing/_layers.py +++ b/qim3d/processing/_layers.py @@ -25,7 +25,7 @@ def segment_layers(data: np.ndarray, wrap: If True, starting and ending point of the border between layers are at the same level Returns: - segmentations: list of numpy arrays, even if n_layers == 1, each array is only 0s and 1s, 1s segmenting this specific layer + segmentations (list[np.ndarray]): list of numpy arrays, even if n_layers == 1, each array is only 0s and 1s, 1s segmenting this specific layer Raises: TypeError: If Data is not np.array, if n_layers is not integer. diff --git a/qim3d/processing/_local_thickness.py b/qim3d/processing/_local_thickness.py index 0a83cca87f82006dabd4b2195337b7ad60b95a1a..6eba2b289e6cdc35bbf130068192f48fa03952b0 100644 --- a/qim3d/processing/_local_thickness.py +++ b/qim3d/processing/_local_thickness.py @@ -31,7 +31,7 @@ def local_thickness( mask (np.ndarray, optional): binary mask of the same size of the image defining parts of the image to be included in the computation of the local thickness. Default is None. visualize (bool, optional): Whether to visualize the local thickness. Default is False. - **viz_kwargs: Additional keyword arguments passed to `qim3d.viz.local_thickness`. Only used if `visualize=True`. + **viz_kwargs (Any): Additional keyword arguments passed to `qim3d.viz.local_thickness`. Only used if `visualize=True`. Returns: local_thickness (np.ndarray): 2D or 3D NumPy array representing the local thickness of the input image/volume. diff --git a/qim3d/processing/_structure_tensor.py b/qim3d/processing/_structure_tensor.py index f6dc98cd253f05bd89c4a8a8c5cdf9a8fd228c2d..c772f5d3d2949f11d9c6145c608b345f844efaf2 100644 --- a/qim3d/processing/_structure_tensor.py +++ b/qim3d/processing/_structure_tensor.py @@ -31,7 +31,7 @@ def structure_tensor( base_noise (bool, optional): A flag indicating whether to add a small noise to the volume. Default is True. full (bool, optional): A flag indicating that all three eigenvalues should be returned. Default is False. visualize (bool, optional): Whether to visualize the structure tensor. Default is False. - **viz_kwargs: Additional keyword arguments for passed to `qim3d.viz.vectors`. Only used if `visualize=True`. + **viz_kwargs (Any): Additional keyword arguments for passed to `qim3d.viz.vectors`. Only used if `visualize=True`. Raises: ValueError: If the input volume is not 3D. diff --git a/qim3d/viz/_cc.py b/qim3d/viz/_cc.py index 875980be2b6e5d0ca284e9aabb6e32a6411d94ee..f477539a61ce4593ac53a5d5187fe04eaf6309c7 100644 --- a/qim3d/viz/_cc.py +++ b/qim3d/viz/_cc.py @@ -29,7 +29,7 @@ def plot_cc( color_map (str, optional): Specifies the color map for the image. Defaults to "viridis". value_min (float, optional): Together with vmax define the data range the colormap covers. By default colormap covers the full range. Defaults to None. value_max (float, optional): Together with vmin define the data range the colormap covers. By default colormap covers the full range. Defaults to None - **kwargs: Additional keyword arguments to pass to `qim3d.viz.slices_grid`. + **kwargs (Any): Additional keyword arguments to pass to `qim3d.viz.slices_grid`. Returns: figs (list[plt.Figure]): List of figures, if `display_figure=False`. diff --git a/qim3d/viz/_data_exploration.py b/qim3d/viz/_data_exploration.py index a578edd5c4e46ba13210a117fe1f2acbdd3d740a..9861691aeff12abf67b4ffb2c7548061379bebf9 100644 --- a/qim3d/viz/_data_exploration.py +++ b/qim3d/viz/_data_exploration.py @@ -48,7 +48,7 @@ def slices_grid( If `slice_positions` is given as a list, `num_slices` will be ignored and the slices from `slice_positions` will be plotted. Args: - vol np.ndarray: The 3D volume to be sliced. + volume (np.ndarray): The 3D volume to be sliced. slice_axis (int, optional): Specifies the axis, or dimension, along which to slice. Defaults to 0. slice_positions (str, int, list, optional): One or several slicing levels. If None, linearly spaced slices will be displayed. Defaults to None. num_slices (int, optional): Defines how many slices the user wants to be displayed. Defaults to 15. @@ -607,7 +607,7 @@ def chunks(zarr_path: str, **kwargs)-> widgets.interactive: Args: zarr_path (str): Path to the Zarr dataset. - **kwargs: Additional keyword arguments to pass to the visualization method. + **kwargs (Any): Additional keyword arguments to pass to the visualization method. Example: ```python @@ -874,9 +874,9 @@ def histogram( Args: volume (np.ndarray): A 3D NumPy array representing the volume to be visualized. - bins (Union[int, str], optional): Number of histogram bins or a binning strategy (e.g., "auto"). Default is "auto". + bins (int or str, optional): Number of histogram bins or a binning strategy (e.g., "auto"). Default is "auto". axis (int, optional): Axis along which to take a slice. Default is 0. - slice_idx (Union[int, str], optional): Specifies the slice to visualize. If an integer, it represents the slice index along the selected axis. + slice_idx (int or str, optional): Specifies the slice to visualize. If an integer, it represents the slice index along the selected axis. If "middle", the function uses the middle slice. If None, the entire volume is visualized. Default is None. kde (bool, optional): Whether to overlay a kernel density estimate. Default is True. log_scale (bool, optional): Whether to use a logarithmic scale on the y-axis. Default is False. @@ -888,10 +888,10 @@ def histogram( element (str, optional): Type of histogram to draw ('bars', 'step', or 'poly'). Default is "step". return_fig (bool, optional): If True, returns the figure object instead of showing it directly. Default is False. show (bool, optional): If True, displays the plot. If False, suppresses display. Default is True. - **sns_kwargs: Additional keyword arguments for `seaborn.histplot`. + **sns_kwargs (Any): Additional keyword arguments for `seaborn.histplot`. Returns: - Optional[matplotlib.figure.Figure]: If `return_fig` is True, returns the generated figure object. Otherwise, returns None. + fig (Optional[matplotlib.figure.Figure]): If `return_fig` is True, returns the generated figure object. Otherwise, returns None. Raises: ValueError: If `axis` is not a valid axis index (0, 1, or 2). diff --git a/qim3d/viz/_detection.py b/qim3d/viz/_detection.py index d10fc32cd7c5dd296166f575b74bb994806c1ec9..b3b14605fb8ef1a92dbb739c3c49165b54e90ad4 100644 --- a/qim3d/viz/_detection.py +++ b/qim3d/viz/_detection.py @@ -20,7 +20,7 @@ def circles(blobs: tuple[float,float,float,float], vol: np.ndarray, alpha: float vol (array-like): The 3D volume on which to plot the blobs. alpha (float, optional): The transparency of the blobs. Defaults to 0.5. color (str, optional): The color of the blobs. Defaults to "#ff9900". - **kwargs: Arbitrary keyword arguments for the `slices` function. + **kwargs (Any): Arbitrary keyword arguments for the `slices` function. Returns: slicer_obj (ipywidgets.interactive): An interactive widget for visualizing the blobs. diff --git a/qim3d/viz/_k3d.py b/qim3d/viz/_k3d.py index f86ff9b847c09b32a2bc2e43a6ba54889ce6fcf2..495eb1d590cf3149dea8be3b80d1155321df9582 100644 --- a/qim3d/viz/_k3d.py +++ b/qim3d/viz/_k3d.py @@ -50,7 +50,7 @@ def volumetric( Lower values will render faster but with lower quality. max_voxels (int, optional): Defaults to 512^3. data_type (str, optional): Default to 'scaled_float16'. - **kwargs: Additional keyword arguments to be passed to the `k3d.plot` function. + **kwargs (Any): Additional keyword arguments to be passed to the `k3d.plot` function. Returns: plot (k3d.plot): If `show=False`, returns the K3D plot object. @@ -196,7 +196,7 @@ def mesh( save (bool or str, optional): If True, saves the visualization as an HTML file. If a string is provided, it's interpreted as the file path where the HTML file will be saved. Defaults to False. - **kwargs: Additional keyword arguments to be passed to the `k3d.plot` function. + **kwargs (Any): Additional keyword arguments to be passed to the `k3d.plot` function. Returns: plot (k3d.plot): If `show=False`, returns the K3D plot object.