Super-resolution artifacts
Super-resolution reconstruction algorithms are used commonly in fetal MRI imaging to improve the resolution of the images, due to specifics of fetal (brain) MRI acquisitions (see figure below [1]).
We implemented a SR artifact simulation framework to generate synthetic fetal brain MRI images with different types of artifacts. To enable it, simply pass corresponding classes described below to the generator class.
You can see examples of its application in the following notebook. It consists of following classes that each implement a specific type(s) of artifacts:
Cortex blur
Default configuration:
blur_cortex:
_target_: fetalsyngen.generator.augmentation.artifacts.BlurCortex
prob: 0.4
cortex_label: 2
nblur_min: 50
nblur_max: 200
sigma_gamma_loc: 3
sigma_gamma_scale: 1
std_blur_shape: 2
std_blur_scale: 1
fetalsyngen.generator.augmentation.artifacts.BlurCortex
Bases: RandTransform
Blurs the cortex in the image (like in cases with imprecise reconstructions).
Given a cortex_label
, blurs the cortex with a Gaussian blur (shape and scale defined
by std_blur_shape
and std_blur_scale
). Then, generates 3D Gaussian blobs (between nblur_min
and nblur_max
)
with a given width (parametrized by a gamma distribution with parameters sigma_gamma_loc
and sigma_gamma_scale
) defining where the blurring will be applied.
Source code in fetalsyngen/generator/augmentation/artifacts.py
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 |
|
__init__(prob, cortex_label, nblur_min, nblur_max, sigma_gamma_loc=3, sigma_gamma_scale=1, std_blur_shape=2, std_blur_scale=1)
Initialize the augmentation parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prob
|
float
|
Probability of applying the augmentation. |
required |
cortex_label
|
int
|
Label of the cortex in the segmentation. |
required |
nblur_min
|
int
|
Minimum number of blurs to apply. |
required |
nblur_max
|
int
|
Maximum number of blurs to apply. |
required |
sigma_gamma_loc
|
int
|
Location parameter of the gamma distribution for the blurring width. |
3
|
sigma_gamma_scale
|
int
|
Scale parameter of the gamma distribution for the blurring width. |
1
|
std_blur_shape
|
int
|
Shape parameter of the gamma distribution defining the Gaussian blur standard deviation. |
2
|
std_blur_scale
|
int
|
Scale parameter of the gamma distribution defining the Gaussian blur blur standard deviation. |
1
|
Source code in fetalsyngen/generator/augmentation/artifacts.py
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 |
|
blur_proba(shape, cortex, device)
Generate the probability map for the blurring based on the cortex segmentation. This functions puts more probability of a blurring occuring in the frontal region of the brain, as observed empirically.
Source code in fetalsyngen/generator/augmentation/artifacts.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
__call__(output, seg, device, genparams={}, **kwargs)
Apply the blurring to the input image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output
|
Tensor
|
Input image to resample. |
required |
seg
|
Tensor
|
Input segmentation corresponding to the image. |
required |
device
|
str
|
Device to use for computation. |
required |
genparams
|
dict
|
Generation parameters. Default: {}. Should contain the key "spacing" if the spacing is fixed. |
{}
|
Returns:
Type | Description |
---|---|
tuple[Tensor, dict]
|
Resampled image and Metadata containing the blurring parameters. |
Source code in fetalsyngen/generator/augmentation/artifacts.py
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 |
|
Skull stripping artifacts
Default configuration:
_target_: fetalsyngen.generator.augmentation.artifacts.SimulatedBoundaries
prob_no_mask: 0.5
prob_if_mask_halo: 0.5
prob_if_mask_fuzzy: 0.5
fetalsyngen.generator.augmentation.artifacts.SimulatedBoundaries
Bases: RandTransform
Simulates various types of boundaries in the image, either doing no masking
(with probability prob_no_mask
), adding a halo around the mask (with probability
prob_if_mask_halo
), or adding fuzzy boundaries to the mask (with probability prob_if_mask_fuzzy
).
Source code in fetalsyngen/generator/augmentation/artifacts.py
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 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
|
__init__(prob_no_mask, prob_if_mask_halo, prob_if_mask_fuzzy)
Initialize the augmentation parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prob_no_mask
|
float
|
Probability of not applying any mask. |
required |
prob_if_mask_halo
|
float
|
Probability of applying a halo around the mask (in case masking is enabled). |
required |
prob_if_mask_fuzzy
|
float
|
Probability of applying fuzzy boundaries to the mask (in case masking is enabled). |
required |
Source code in fetalsyngen/generator/augmentation/artifacts.py
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
|
reset_seeds()
Reset the seeds for the augmentation.
Source code in fetalsyngen/generator/augmentation/artifacts.py
400 401 402 403 404 405 406 407 408 409 410 |
|
sample_seeds()
Sample the seeds for the augmentation.
Source code in fetalsyngen/generator/augmentation/artifacts.py
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
|
build_halo(mask, radius)
Build a halo around the mask with a given radius.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mask
|
Tensor
|
Input mask. |
required |
radius
|
int
|
Radius of the halo. |
required |
Returns:
Type | Description |
---|---|
Tensor
|
Mask with the halo. |
Source code in fetalsyngen/generator/augmentation/artifacts.py
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 |
|
generate_fuzzy_boundaries(mask, kernel_size=7, threshold_filter=3)
Generate fuzzy boundaries around the mask.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mask
|
Tensor
|
Input mask. |
required |
kernel_size
|
int
|
Size of the kernel for the dilation. |
7
|
threshold_filter
|
int
|
Threshold for the count of neighboring voxels. |
3
|
Returns:
Type | Description |
---|---|
Tensor
|
Mask with fuzzy boundaries. |
Source code in fetalsyngen/generator/augmentation/artifacts.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 |
|
__call__(output, seg, device, genparams={}, **kwargs)
Apply the simulated boundaries to the input image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output
|
Tensor
|
Input image to resample. |
required |
seg
|
Tensor
|
Input segmentation corresponding to the image. |
required |
device
|
str
|
Device to use for computation. |
required |
genparams
|
dict
|
Generation parameters. |
{}
|
Returns:
Type | Description |
---|---|
tuple[Tensor, dict]
|
Image with structured noise and metadata containing the structured noise parameters. |
Source code in fetalsyngen/generator/augmentation/artifacts.py
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 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
|
Structural noise
Default configuration:
struct_noise:
_target_: fetalsyngen.generator.augmentation.artifacts.StructNoise
prob: 0.4
wm_label: 3
std_min: 0.2
std_max: 0.4
nloc_min: 5
nloc_max: 15
fetalsyngen.generator.augmentation.artifacts.StructNoise
Bases: RandTransform
Adds a structured noise to the white matter in the image, similar to what can be seen with NeSVoR reconstructions without prior denoising.
Given a wm_label
, generates a multi-scale noise (between nstages_min
and nstages_max
stages)
with a standard deviation between std_min
and std_max
.
The noise is then added in a spatially varying manner at nloc
locations (
between n_loc_min
and n_loc_max
locations) in the white matter. The merging
is done as a weighted sum of the original image and the noisy image, with the weights
defined by a MoG with centers at the nloc
locations and sigmas defined by sigma_mu
and
sigma_std
.
Source code in fetalsyngen/generator/augmentation/artifacts.py
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 |
|
__init__(prob, wm_label, std_min, std_max, nloc_min, nloc_max, nstages_min=1, nstages_max=5, sigma_mu=25, sigma_std=5)
Initialize the augmentation parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prob
|
float
|
Probability of applying the augmentation. |
required |
wm_label
|
int
|
Label of the white matter in the segmentation. |
required |
std_min
|
float
|
Minimum standard deviation of the noise. |
required |
std_max
|
float
|
Maximum standard deviation of the noise. |
required |
nloc_min
|
int
|
Minimum number of locations to add noise. |
required |
nloc_max
|
int
|
Maximum number of locations to add noise. |
required |
nstages_min
|
int
|
Minimum number of stages for the noise. |
1
|
nstages_max
|
int
|
Maximum number of stages for the noise. |
5
|
sigma_mu
|
int
|
Mean of the sigmas for the MoG. |
25
|
sigma_std
|
int
|
Standard deviation of the sigmas for the MoG. |
5
|
Source code in fetalsyngen/generator/augmentation/artifacts.py
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 |
|
__call__(output, seg, device, genparams={}, **kwargs)
Apply the structured noise to the input image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output
|
Tensor
|
Input image to resample. |
required |
seg
|
Tensor
|
Input segmentation corresponding to the image. |
required |
device
|
str
|
Device to use for computation. |
required |
genparams
|
dict
|
Generation parameters. |
{}
|
Returns:
Type | Description |
---|---|
tuple[Tensor, dict]
|
Image with structured noise and metadata containing the structured noise parameters. |
Source code in fetalsyngen/generator/augmentation/artifacts.py
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 |
|
Artifacts related to the wrong fetal motion estimation during SR reconstruction
Default configuration:
simulate_motion:
_target_: fetalsyngen.generator.augmentation.artifacts.SimulateMotion
prob: 0.4
scanner_params:
_target_: fetalsyngen.generator.artifacts.utils.ScannerParams
resolution_slice_fac_min: 0.5
resolution_slice_fac_max: 2
resolution_slice_max: 1.5
slice_thickness_min: 1.5
slice_thickness_max: 3.5
gap_min: 1.5
gap_max: 5.5
min_num_stack: 2
max_num_stack: 6
max_num_slices: 250
noise_sigma_min: 0
noise_sigma_max: 0.1
TR_min: 1
TR_max: 2
prob_gamma: 0.1
gamma_std: 0.05
prob_void: 0.2
slice_size: null
restrict_transform: False
txy: 3.0
recon_params:
_target_: fetalsyngen.generator.artifacts.utils.ReconParams
prob_misreg_slice: 0.08
slices_misreg_ratio: 0.1
prob_misreg_stack: 0.08
txy: 3.0
prob_merge: 0.8
merge_ngaussians_min: 2
merge_ngaussians_max: 4
prob_smooth: 0.2
prob_rm_slices: 0.3
rm_slices_min: 0.1
rm_slices_max: 0.4
fetalsyngen.generator.augmentation.artifacts.SimulateMotion
Bases: RandTransform
Simulates motion in the image by simulating low-resolution slices (based
on the scanner_params
and then doing a simple point-spread function based
on the low-resolution slices (using recon_params
).
Source code in fetalsyngen/generator/augmentation/artifacts.py
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 |
|
__init__(prob, scanner_params, recon_params)
Initialize the augmentation parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prob
|
float
|
Probability of applying the augmentation. |
required |
scanner_params
|
ScannerParams
|
Dataclass of parameters for the scanner. |
required |
recon_params
|
ReconParams
|
Dataclass of parameters for the reconstructor. |
required |
Source code in fetalsyngen/generator/augmentation/artifacts.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
|
__call__(output, seg, device, genparams={}, **kwargs)
Apply the motion simulation to the input image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output
|
Tensor
|
Input image to resample. |
required |
seg
|
Tensor
|
Input segmentation corresponding to the image. |
required |
device
|
str
|
Device to use for computation. |
required |
genparams
|
dict
|
Generation parameters. |
{}
|
Returns:
Type | Description |
---|---|
tuple[Tensor, dict]
|
Image with simulated motion and metadata containing the motion simulation parameters. |
Source code in fetalsyngen/generator/augmentation/artifacts.py
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 |
|
References
- Sanchez, Thomas, et al. "Assessing data quality on fetal brain MRI reconstruction: a multi-site and multi-rater study." International Workshop on Preterm, Perinatal and Paediatric Image Analysis. Cham: Springer Nature Switzerland, 2024.