noise_models
GaussianMixtureNoiseModel
#
Bases: Module
Define a noise model parameterized as a mixture of gaussians.
If config.path
is not provided a new object is initialized from scratch. Otherwise, a model is loaded from config.path
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config | GaussianMixtureNMConfig | A | required |
Attributes:
Name | Type | Description |
---|---|---|
min_signal | float | Minimum signal intensity expected in the image. |
max_signal | float | Maximum signal intensity expected in the image. |
path | Union[str, Path] | Path to the directory where the trained noise model (*.npz) is saved in the |
weight | Parameter | A [3*n_gaussian, n_coeff] sized array containing the values of the weights describing the GMM noise model, with each row corresponding to one parameter of each gaussian, namely [mean, standard deviation and weight]. Specifically, rows are organized as follows: - first n_gaussian rows correspond to the means - next n_gaussian rows correspond to the weights - last n_gaussian rows correspond to the standard deviations If |
n_gaussian | int | Number of gaussians in the mixture. |
n_coeff | int | Number of coefficients to describe the functional relationship between gaussian parameters and the signal. 2 implies a linear relationship, 3 implies a quadratic relationship and so on. |
device | device | GPU device. |
min_sigma | float | All values of |
Source code in src/careamics/models/lvae/noise_models.py
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 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 |
|
forward(x, y)
#
getGaussianParameters(signals)
#
Returns the noise model for given signals.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
signals | Tensor | Underlying signals | required |
Returns:
Name | Type | Description |
---|---|---|
gmmParams | list[Tensor] | A list containing tensors representing |
Source code in src/careamics/models/lvae/noise_models.py
getSignalObservationPairs(signal, observation, lowerClip, upperClip)
#
Returns the Signal-Observation pixel intensities as a two-column array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
signal | numpy array | Clean Signal Data | required |
observation | Noisy observation Data | required | |
lowerClip | Lower percentile bound for clipping. | required | |
upperClip | Upper percentile bound for clipping. | required |
Returns:
Name | Type | Description |
---|---|---|
gmmParams | list of torch floats | Contains a list of |
Source code in src/careamics/models/lvae/noise_models.py
likelihood(observations, signals)
#
Evaluate the likelihood of observations given the signals and the corresponding gaussian parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
observations | FloatTensor | Noisy observations. | required |
signals | FloatTensor | Underlying signals. | required |
Returns:
Name | Type | Description |
---|---|---|
value | p + tol | Likelihood of observations given the signals and the GMM noise model |
Source code in src/careamics/models/lvae/noise_models.py
normalDens(x, m_=0.0, std_=None)
#
Evaluates the normal probability density at x
given the mean m
and standard deviation std
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | Tensor | Observations (i.e., noisy image). | required |
m_ | Tensor | Pixel-wise mean. | 0.0 |
std_ | Tensor | Pixel-wise standard deviation. | None |
Returns:
Name | Type | Description |
---|---|---|
tmp | Tensor | Normal probability density of |
Source code in src/careamics/models/lvae/noise_models.py
polynomialRegressor(weightParams, signals)
#
Combines weightParams
and signal signals
to regress for the gaussian parameter values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
weightParams | FloatTensor | Corresponds to specific rows of the | required |
signals | FloatTensor | Signals | required |
Returns:
Name | Type | Description |
---|---|---|
value | FloatTensor | Corresponds to either of mean, standard deviation or weight, evaluated at |
Source code in src/careamics/models/lvae/noise_models.py
train_noise_model(signal, observation, learning_rate=0.1, batchSize=250000, n_epochs=2000, name='GMMNoiseModel.npz', lowerClip=0, upperClip=100)
#
Training to learn the noise model from signal - observation pairs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
signal | Clean Signal Data | required | |
observation | Noisy Observation Data | required | |
learning_rate | Learning rate. Default = 1e-1. | 0.1 | |
batchSize | Nini-batch size. Default = 250000. | 250000 | |
n_epochs | Number of epochs. Default = 2000. | 2000 | |
name | Model name. Default is | 'GMMNoiseModel.npz' | |
lowerClip | int | Lower percentile for clipping. Default is 0. | 0 |
upperClip | int | Upper percentile for clipping. Default is 100. | 100 |
Source code in src/careamics/models/lvae/noise_models.py
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 |
|
MultiChannelNoiseModel
#
Bases: Module
Source code in src/careamics/models/lvae/noise_models.py
__init__(nmodels)
#
Constructor.
To handle noise models and the relative likelihood computation for multiple output channels (e.g., muSplit, denoiseSplit).
This class: - receives as input a variable number of noise models, one for each channel. - computes the likelihood of observations given signals for each channel. - returns the concatenation of these likelihoods.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nmodels | list[GaussianMixtureNoiseModel] | List of noise models, one for each output channel. | required |
Source code in src/careamics/models/lvae/noise_models.py
likelihood(obs, signal)
#
Compute the likelihood of observations given signals for each channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obs | Tensor | Noisy observations, i.e., the target(s). Specifically, the input noisy image for HDN, or the noisy unmixed images used for supervision for denoiSplit. Shape: (B, C, [Z], Y, X), where C is the number of unmixed channels. | required |
signal | Tensor | Underlying signals, i.e., the (clean) output of the model. Specifically, the denoised image for HDN, or the unmixed images for denoiSplit. Shape: (B, C, [Z], Y, X), where C is the number of unmixed channels. | required |
Source code in src/careamics/models/lvae/noise_models.py
fastShuffle(series, num)
#
summary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
series | _type_ | description | required |
num | _type_ | description | required |
Returns:
Type | Description |
---|---|
_type_ | description |
Source code in src/careamics/models/lvae/noise_models.py
noise_model_factory(model_config)
#
Noise model factory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_config | Optional[MultiChannelNMConfig] | Noise model configuration, a | required |
Returns:
Type | Description |
---|---|
Optional[MultiChannelNoiseModel] | A noise model instance. |
Raises:
Type | Description |
---|---|
NotImplementedError | If the chosen noise model |
Source code in src/careamics/models/lvae/noise_models.py
train_gm_noise_model(model_config)
#
Train a Gaussian mixture noise model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_config | GaussianMixtureNoiseModel | description | required |
Returns:
Type | Description |
---|---|
_description_ | |