Systems¶
Optical System¶
Bases: Module
Combines a sequence of optical elements into a single Module.
Takes a sequence of functions or Modules (any Callable) and calls
them in sequence, assuming each element of the sequence only accepts a
Field as input and returns a Field as output, with the exception of
the first element of the sequence, which can take any arguments necessary
(e.g. to allow an element from chromatix.elements.sources to initialize
a Field) and the last element of the sequence, which may return an
Array. This is intended to mirror the style of deep learning libraries
that describe a neural network as a sequence of layers, allowing for an
optical system to be described conveniently as a list of elements.
Attributes:
| Name | Type | Description |
|---|---|---|
elements |
Sequence[Callable]
|
A sequence of optical elements describing the system. |
Source code in src/chromatix/systems/optical_system.py
elements = elements
instance-attribute
¶
__call__(*args, **kwargs)
¶
Returns the result of calling all elements in sequence.
Source code in src/chromatix/systems/optical_system.py
Microscope¶
Bases: Module
Microscope with a planewise spatially invariant point spread function.
This Microscope is an equinox Module that accepts a function or
Module that computes the point spread function (PSF) of the microscope.
Microscope then uses this PSF to simulate imaging via a convolution of
the provided sample with the specified PSF. This is useful for simulating
images in the fully incoherent case where coherent propagation through
samples is not an appropriate model, e.g. fluorescence imaging. Microscope
also takes a Sensor which can
perform resampling of the PSF simulation to the desired sensor pixel pitch
or simulate noise. Parameters of the provided PSF can be differentiated
through, e.g. the phase mask of the Optical4FSystemPSF.
Attributes:
| Name | Type | Description |
|---|---|---|
system_psf |
Callable[[Microscope], Field | Array]
|
A function or |
sensor |
Sensor
|
The sensor used for imaging the sample. Must be an instance
of |
f |
ScalarLike
|
Focal length of the system's objective. |
n |
ScalarLike
|
Refractive index of the system's objective. |
NA |
ScalarLike
|
The numerical aperture of the system's objective. |
spectrum |
Spectrum
|
The
|
padding_ratio |
ScalarLike
|
The proportion of the original PSF shape that will be added to simulate the PSF. That means the final PSF simulation shape will be shape * (1.0 + padding) in each dimension. This will then automatically be cropped to the original desired shape after simulation. Defaults to 0, in which case no cropping occurs. |
taper_width |
ScalarLike
|
The width in pixels of the sigmoid that will be used to smoothly bring the edges of the PSF to 0. This helps to prevent edge artifacts in the image if the PSF has edge artifacts. Defaults to 0, in which case no tapering is applied. |
convolution_axes |
tuple[int, ...]
|
The axes over which to perform convolution between the
PSF and the sample. The PSF and the sample must have the same number
of dimensions. Defaults to |
fast_fft_shape |
bool
|
If |
Source code in src/chromatix/systems/microscopes.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
NA = NA
class-attribute
instance-attribute
¶
convolution_axes = convolution_axes
class-attribute
instance-attribute
¶
f = f
class-attribute
instance-attribute
¶
fast_fft_shape = fast_fft_shape
class-attribute
instance-attribute
¶
n = n
class-attribute
instance-attribute
¶
padding_ratio = padding_ratio
class-attribute
instance-attribute
¶
sensor = sensor
instance-attribute
¶
spectrum = Spectrum.build(spectrum)
instance-attribute
¶
system_psf = system_psf
instance-attribute
¶
taper_width = taper_width
class-attribute
instance-attribute
¶
__call__(sample, *args, key=None, **kwargs)
¶
Computes PSF and convolves PSF with data to simulate imaging.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
ArrayLike
|
The sample to be imaged of shape |
required |
*args
|
Any
|
Any positional arguments needed for the PSF model. |
()
|
**kwargs
|
Any
|
Any keyword arguments needed for the PSF model. |
{}
|
Source code in src/chromatix/systems/microscopes.py
__init__(system_psf, sensor, f, n, NA, spectrum, padding_ratio=0, taper_width=0, convolution_axes=(-2, -1), fast_fft_shape=True)
¶
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system_psf
|
Callable[[Microscope, ...], Field | Array]
|
A function or |
required |
sensor
|
Sensor
|
The sensor used for imaging the sample. Must be an
instance of |
required |
f
|
ScalarLike
|
Focal length of the system's objective. |
required |
n
|
ScalarLike
|
Refractive index of the system's objective. |
required |
NA
|
ScalarLike
|
The numerical aperture of the system's objective. |
required |
spectrum
|
Spectrum | ScalarLike | Float[Array, 'wv'] | tuple[Float[Array, 'wv'], Float[Array, 'wv']]
|
The
|
required |
padding_ratio
|
ScalarLike
|
The proportion of the original PSF shape that will be added to simulate the PSF. That means the final shape will be shape * (1.0 + padding) in each dimension. This will then automatically be cropped to the original desired shape after simulation. Defaults to 0, in which case no cropping occurs. |
0
|
taper_width
|
ScalarLike
|
The width in pixels of the sigmoid that will be used to smoothly bring the edges of the PSF to 0. This helps to prevent edge artifacts in the image if the PSF has edge artifacts. Defaults to 0, in which case no tapering is applied. |
0
|
convolution_axes
|
tuple[int, ...]
|
The axes over which to perform convolution between
the PSF and the sample. The PSF and the sample must have the
same number of dimensions. Defaults to |
(-2, -1)
|
fast_fft_shape
|
bool
|
If |
True
|
Source code in src/chromatix/systems/microscopes.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | |
image(sample, psf, key=None)
¶
Computes image or batch of images using the specified psf and
sample. Assumes that both the sample and psf have already
been sampled to the pixels of the sensor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
ArrayLike
|
The sample volume to image with of shape |
required |
psf
|
ArrayLike
|
The PSF intensity volume to image with of shape |
required |
Source code in src/chromatix/systems/microscopes.py
psf(*args, **kwargs)
¶
Optical4FSystemPSF¶
Bases: Module
Simulates the point spread function (PSF) of a 4f system with a phase mask.
Attributes:
| Name | Type | Description |
|---|---|---|
shape |
tuple[int, int]
|
A tuple of form |
spacing |
ScalarLike
|
The desired output spacing of the PSF once it is simulated, e.g. the camera sensor pixel pitch. |
f_tube |
ScalarLike
|
The focal length of the tube lens of the system in units of
distance. The focal length of the objective lens will be accessed
through the |
phase |
ArrayLike
|
The phase mask for the 4f simulation. Must be a 2D array of
phase values in units of radians with shape |