Skip to content

Commit 15431a9

Browse files
authored
Merge pull request #64 from AdaptiveParticles/docs_v1
update docstrings
2 parents 18a6631 + 8c6b91b commit 15431a9

File tree

21 files changed

+232
-306
lines changed

21 files changed

+232
-306
lines changed

docs/source/pyapr.io.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ io
1212
pyapr.io.get_particle_names
1313
pyapr.io.get_particle_type
1414
pyapr.io.APRFile
15-
pyapr.io.read_multichannel
16-
pyapr.io.write_multichannel
1715

1816
.. automodule:: pyapr.io
1917
:members:

pyapr/converter/converter_methods.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from _pyaprwrapper.data_containers import APR, APRParameters
22
from ..utils import InteractiveIO, type_to_particles
3-
from _pyaprwrapper.converter import FloatConverter, ShortConverter
3+
from _pyaprwrapper.converter import FloatConverter, ShortConverter, ByteConverter
44
import numpy as np
55
from typing import Union, Optional
66

@@ -9,7 +9,7 @@
99

1010

1111
def get_apr(image: np.ndarray,
12-
converter: Optional[Union[FloatConverter, ShortConverter]] = None,
12+
converter: Optional[Union[ByteConverter, ShortConverter, FloatConverter]] = None,
1313
params: Optional[APRParameters] = None,
1414
verbose: bool = False):
1515
"""
@@ -19,10 +19,10 @@ def get_apr(image: np.ndarray,
1919
----------
2020
image: numpy.ndarray
2121
Input pixel image as an array of 1-3 dimensions.
22-
converter: FloatConverter or ShortConverter (optional)
22+
converter: ByteConverter, ShortConverter or FloatConverter, optional
2323
Converter object used to compute the APR. By default, FloatConverter is used to avoid rounding errors in
2424
internal steps.
25-
params: APRParameters (optional)
25+
params: APRParameters, optional
2626
If provided, sets parameters of the converter. If not, the parameters of the converter object is used, with
2727
'auto_parameters' set to True.
2828
verbose: bool
@@ -32,7 +32,7 @@ def get_apr(image: np.ndarray,
3232
-------
3333
apr: APR
3434
Generated APR object containing the adaptively sampled structure.
35-
parts: ByteParticles, ShortParticles, FloatParticles
35+
parts: ByteParticles, ShortParticles or FloatParticles
3636
Sampled particle values (average downsampled from pixel values). The data type matches that of the input image
3737
(uint8, uint16 or float).
3838
"""
@@ -72,7 +72,7 @@ def get_apr(image: np.ndarray,
7272

7373

7474
def get_apr_interactive(image: np.ndarray,
75-
converter: Optional[Union[FloatConverter, ShortConverter]] = None,
75+
converter: Optional[Union[ByteConverter, ShortConverter, FloatConverter]] = None,
7676
params: Optional[APRParameters] = None,
7777
verbose: bool = False,
7878
slider_decimals: int = 1):
@@ -84,10 +84,10 @@ def get_apr_interactive(image: np.ndarray,
8484
----------
8585
image: numpy.ndarray
8686
Input (pixel) image as an array of 1-3 dimensions.
87-
converter: FloatConverter or ShortConverter (optional)
87+
converter: ByteConverter, ShortConverter or FloatConverter, optional
8888
Converter object used to compute the APR. By default, FloatConverter is used to avoid rounding errors in
8989
internal steps.
90-
params: APRParameters (optional)
90+
params: APRParameters, optional
9191
If provided, sets parameters of the converter. Otherwise default parameters are used.
9292
verbose: bool
9393
Set the verbose mode of the converter (default: False).
@@ -98,7 +98,7 @@ def get_apr_interactive(image: np.ndarray,
9898
-------
9999
apr: APR
100100
Generated APR object containing the adaptively sampled structure.
101-
parts: ByteParticles, ShortParticles, FloatParticles
101+
parts: ByteParticles, ShortParticles or FloatParticles
102102
Sampled particle values (average downsampled from pixel values). The data type matches that of the input image
103103
(uint8, uint16 or float).
104104
"""
@@ -144,7 +144,7 @@ def get_apr_interactive(image: np.ndarray,
144144

145145

146146
def find_parameters_interactive(image: np.ndarray,
147-
converter: Optional[Union[FloatConverter, ShortConverter]] = None,
147+
converter: Optional[Union[ByteConverter, ShortConverter, FloatConverter]] = None,
148148
params: Optional[APRParameters] = None,
149149
verbose: bool = False,
150150
slider_decimals: int = 1):
@@ -155,10 +155,10 @@ def find_parameters_interactive(image: np.ndarray,
155155
----------
156156
image: numpy.ndarray
157157
Input (pixel) image as an array of 1-3 dimensions.
158-
converter: FloatConverter or ShortConverter (optional)
158+
converter: ByteConverter, ShortConverter or FloatConverter, optional
159159
Converter object used to compute the APR. By default, FloatConverter is used to avoid rounding errors in
160160
internal steps.
161-
params: APRParameters (optional)
161+
params: APRParameters, optional
162162
If provided, sets parameters of the converter. Otherwise default parameters are used.
163163
verbose: bool
164164
Set the verbose mode of the converter (default: False).
@@ -168,7 +168,7 @@ def find_parameters_interactive(image: np.ndarray,
168168
Returns
169169
-------
170170
params: APRParameters
171-
The parameters with the selected values.
171+
The parameters with the selected threshold values.
172172
"""
173173

174174
if not image.flags['C_CONTIGUOUS']:

pyapr/filter/convolution.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,21 @@ def correlate(apr: APR,
5656
----------
5757
apr: APR
5858
Input APR object
59-
parts: ShortParticles, FloatParticles
59+
parts: ByteParticles, ShortParticles, FloatParticles or LongParticles
6060
Input particle values
6161
stencil: np.ndarray
6262
Stencil or kernel to correlate with the image. Should be 3-dimensional and of type float32, otherwise
63-
it is expanded, e.g. shape (3, 3) -> (1, 3, 3), and cast.
63+
it is converted and expanded, e.g. shape (3, 3) -> (1, 3, 3).
6464
output: FloatParticles, optional
65-
(optional) Particle object to which the resulting values are written. If not provided, a new object
65+
Particle object to which the resulting values are written. If not provided, a new object
6666
is generated (default: None)
6767
restrict_stencil: bool
6868
If True, the stencil is adapted to coarser resolution levels such that the correlation is consistent with
6969
applying ``stencil`` to the reconstructed pixel image. (default: True)
7070
rescale_stencil: bool
7171
If True, the stencil is adapted to coarser resolution levels by rescaling the weights according to
72-
the distance between particles. Useful for, e.g., finite difference calculations. If both `rescale_stencil`
73-
and `restrict_stencil` are True, rescaling is used. (default: False)
72+
the distance between particles. Useful for, e.g., finite difference calculations. If both ``rescale_stencil``
73+
and ``restrict_stencil`` are True, rescaling is used. (default: False)
7474
normalize_stencil: bool
7575
If True, the stencil is normalized to sum to 1 (if ``restrict_stencil`` is True, the stencil is normalized
7676
at each resolution level. (default: True)
@@ -79,9 +79,9 @@ def correlate(apr: APR,
7979
method: str
8080
Method used to apply the operation:
8181
82-
- 'pencil': construct isotropic neighborhoods of shape (stencil.shape[0], stencil.shape[1], apr.shape[2])
83-
- 'slice': construct isotropic neighborhoods of shape (stencil.shape[0], apr.shape[1], apr.shape[2])
84-
- 'cuda': compute the correlation using the GPU. Requires the package to be built with CUDA support,
82+
- ``'pencil'``: construct isotropic neighborhoods of shape (stencil.shape[0], stencil.shape[1], apr.shape[2])
83+
- ``'slice'``: construct isotropic neighborhoods of shape (stencil.shape[0], apr.shape[1], apr.shape[2])
84+
- ``'cuda'``: compute the correlation using the GPU. Requires the package to be built with CUDA support,
8585
and ``stencil`` to have shape (3, 3, 3) or (5, 5, 5).
8686
8787
The methods may differ in performance, depending on the input data, but produce the same result. (default: 'pencil')
@@ -128,21 +128,21 @@ def convolve(apr: APR,
128128
----------
129129
apr: APR
130130
Input APR object
131-
parts: ShortParticles, FloatParticles
131+
parts: ByteParticles, ShortParticles, FloatParticles or LongParticles
132132
Input particle values
133133
stencil: np.ndarray
134134
Stencil or kernel to convolve with the image. Should be 3-dimensional and of type float32, otherwise
135-
it is expanded, e.g. shape (3, 3) -> (1, 3, 3), and cast.
135+
it is converted and expanded, e.g. shape (3, 3) -> (1, 3, 3).
136136
output: FloatParticles, optional
137-
(optional) Particle object to which the resulting values are written. If not provided, a new object
137+
Particle object to which the resulting values are written. If not provided, a new object
138138
is generated (default: None)
139139
restrict_stencil: bool
140140
If True, the stencil is adapted to coarser resolution levels such that the convolution is consistent with
141141
applying ``stencil`` to the reconstructed pixel image. (default: True)
142142
rescale_stencil: bool
143143
If True, the stencil is adapted to coarser resolution levels by rescaling the weights according to
144-
the distance between particles. Useful for, e.g., finite difference calculations. If both `rescale_stencil`
145-
and `restrict_stencil` are True, rescaling is used. (default: False)
144+
the distance between particles. Useful for, e.g., finite difference calculations. If both ``rescale_stencil``
145+
and ``restrict_stencil`` are True, rescaling is used. (default: False)
146146
normalize_stencil: bool
147147
If True, the stencil is normalized to sum to 1 (if ``restrict_stencil`` is True, the stencil is normalized
148148
at each resolution level. (default: True)
@@ -151,9 +151,9 @@ def convolve(apr: APR,
151151
method: str
152152
Method used to apply the operation:
153153
154-
- 'pencil': construct isotropic neighborhoods of shape (stencil.shape[0], stencil.shape[1], apr.shape[2])
155-
- 'slice': construct isotropic neighborhoods of shape (stencil.shape[0], apr.shape[1], apr.shape[2])
156-
- 'cuda': compute the convolution using the GPU. Requires the package to be built with CUDA support,
154+
- ``'pencil'``: construct isotropic neighborhoods of shape (stencil.shape[0], stencil.shape[1], apr.shape[2])
155+
- ``'slice'``: construct isotropic neighborhoods of shape (stencil.shape[0], apr.shape[1], apr.shape[2])
156+
- ``'cuda'``: compute the convolution using the GPU. Requires the package to be built with CUDA support,
157157
and ``stencil`` to have shape (3, 3, 3) or (5, 5, 5).
158158
159159
The methods may differ in performance, depending on the input data, but produce the same result. (default: 'pencil')

pyapr/filter/gradient.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ def gradient(apr: APR,
2121
----------
2222
apr: APR
2323
Input APR data structure.
24-
parts: ParticleData
24+
parts: ByteParticles, ShortParticles, FloatParticles or LongParticles
2525
Input particle values.
2626
dim: int
2727
Dimension (axis) along which the gradient is computed (0 -> y, 1 -> x, 2 -> z). (default: 0)
2828
delta: float
2929
Voxel size in the dimension of interest, used to scale the gradients. (default: 1.0)
3030
output: FloatParticles, optional
31-
(optional) Particle object to which the resulting values are written. If not provided, a new object
31+
Particle object to which the resulting values are written. If not provided, a new object
3232
is generated. (default: None)
3333
3434
Returns
@@ -57,14 +57,14 @@ def sobel(apr: APR,
5757
----------
5858
apr: APR
5959
Input APR data structure.
60-
parts: ParticleData
60+
parts: ByteParticles, ShortParticles, FloatParticles or LongParticles
6161
Input particle values.
6262
dim: int
6363
Dimension (axis) along which the gradient is computed (0 -> y, 1 -> x, 2 -> z). (default: 0)
6464
delta: float
6565
Voxel size in the dimension of interest, used to scale the gradients. (default: 1.0)
6666
output: FloatParticles, optional
67-
(optional) Particle object to which the resulting values are written. If not provided, a new object
67+
Particle object to which the resulting values are written. If not provided, a new object
6868
is generated. (default: None)
6969
7070
Returns
@@ -92,12 +92,12 @@ def gradient_magnitude(apr: APR,
9292
----------
9393
apr: APR
9494
Input APR data structure.
95-
parts: ParticleData
95+
parts: ByteParticles, ShortParticles, FloatParticles or LongParticles
9696
Input particle values.
9797
deltas: tuple or list of length 3
9898
Voxel size in dimensions (y, x, z) used to scale the gradients. (default: (1.0, 1.0, 1.0))
9999
output: FloatParticles, optional
100-
(optional) Particle object to which the resulting values are written. If not provided, a new object
100+
Particle object to which the resulting values are written. If not provided, a new object
101101
is generated. (default: None)
102102
103103
Returns
@@ -125,12 +125,12 @@ def sobel_magnitude(apr: APR,
125125
----------
126126
apr: APR
127127
Input APR data structure.
128-
parts: ParticleData
128+
parts: ByteParticles, ShortParticles, FloatParticles or LongParticles
129129
Input particle values.
130130
deltas: tuple or list of length 3
131131
Voxel size in dimensions (y, x, z) used to scale the gradients. (default: (1.0, 1.0, 1.0))
132132
output: FloatParticles, optional
133-
(optional) Particle object to which the resulting values are written. If not provided, a new object
133+
Particle object to which the resulting values are written. If not provided, a new object
134134
is generated. (default: None)
135135
136136
Returns

pyapr/filter/rank_filters.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ def median_filter(apr: APR,
2929
----------
3030
apr: APR
3131
APR data structure.
32-
parts: ShortParticles or FloatParticles
32+
parts: ByteParticles, ShortParticles, FloatParticles or LongParticles
3333
Input particle values.
3434
size: (int, int, int)
3535
Size of the neighborhood in (z, x, y) dimensions.
36-
Allowed sizes are (x, x, x) and (1, x, x) for x in [3, 5, 7, 9, 11].
36+
Allowed sizes are (x, x, x) and (1, x, x) for x in [3, 5, 7, 9, 11]. Default: (5, 5, 5)
3737
3838
Returns
3939
-------
40-
output: ShortParticles or FloatParticles
41-
Median filtered particle values of the same type as the input.
40+
output: ByteParticles, ShortParticles, FloatParticles or LongParticles
41+
Median filtered particle values of the same type as the input particles.
4242
"""
4343
_check_input(apr, parts, __allowed_input_types__)
4444
_check_size(size, __allowed_sizes_median__)
@@ -61,16 +61,16 @@ def min_filter(apr: APR,
6161
----------
6262
apr: APR
6363
APR data structure.
64-
parts: ShortParticles or FloatParticles
64+
parts: ByteParticles, ShortParticles, FloatParticles or LongParticles
6565
Input particle values.
6666
size: (int, int, int)
6767
Size of the neighborhood in (z, x, y) dimensions.
68-
Allowed values are (x, x, x) and (1, x, x) for x in [3, 5].
68+
Allowed values are (x, x, x) and (1, x, x) for x in [3, 5, 7, 9, 11]. Default: (5, 5, 5)
6969
7070
Returns
7171
-------
72-
output: ShortParticles or FloatParticles
73-
Minimum filtered particle values of the same type as the input.
72+
output: ByteParticles, ShortParticles, FloatParticles or LongParticles
73+
Minimum filtered particle values of the same type as the input particles.
7474
"""
7575
_check_input(apr, parts, __allowed_input_types__)
7676
_check_size(size, __allowed_sizes_min__)
@@ -93,16 +93,16 @@ def max_filter(apr: APR,
9393
----------
9494
apr: APR
9595
APR data structure.
96-
parts: ShortParticles or FloatParticles
96+
parts: ByteParticles, ShortParticles, FloatParticles or LongParticles
9797
Input particle values
9898
size: (int, int, int)
9999
Size of the neighborhood in (z, x, y) dimensions.
100-
Allowed values are (x, x, x) and (1, x, x) for x in [3, 5].
100+
Allowed values are (x, x, x) and (1, x, x) for x in [3, 5, 7, 9, 11]. Default: (5, 5, 5)
101101
102102
Returns
103103
-------
104-
output: ShortParticles or FloatParticles
105-
Maximum filtered particle values of the same type as the input.
104+
output: ByteParticles, ShortParticles, FloatParticles or LongParticles
105+
Maximum filtered particle values of the same type as the input particles.
106106
"""
107107
_check_input(apr, parts, __allowed_input_types__)
108108
_check_size(size, __allowed_sizes_max__)

pyapr/filter/std.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,20 @@ def std(apr: APR,
1919
----------
2020
apr: APR
2121
Input APR data structure.
22-
parts: ParticleData
22+
parts: ByteParticles, ShortParticles, FloatParticles or LongParticles
2323
Input particle values.
2424
size: int, tuple, list
2525
Size of the box in which standard deviations are computed. If a single integer is provided,
2626
considers a box of size ``min(size, apr.shape[dim])`` in each dimension. To use different sizes,
2727
give a list or tuple of length 3, specifying the size in dimensions (y, x, z)
2828
output: FloatParticles, optional
29-
(optional) Particle object to which the resulting values are written. If not provided, a new object
29+
Particle object to which the resulting values are written. If not provided, a new object
3030
is generated. (default: None)
31+
32+
Returns
33+
-------
34+
output: FloatParticles
35+
The local standard deviation values
3136
"""
3237
_check_input(apr, parts, __allowed_input_types__)
3338
if isinstance(size, int):

pyapr/io/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from _pyaprwrapper.io import APRFile
22
from .io_api import read, write, read_apr, write_apr, read_particles, write_particles, get_particle_type, \
3-
get_particle_names, write_multichannel, read_multichannel
3+
get_particle_names
44

55
__all__ = [
66
'read',
@@ -11,7 +11,5 @@
1111
'write_particles',
1212
'get_particle_names',
1313
'get_particle_type',
14-
'APRFile',
15-
'read_multichannel',
16-
'write_multichannel'
14+
'APRFile'
1715
]

0 commit comments

Comments
 (0)