transforms
navis.transforms.AffineTransform #
Affine transformation of 3D spatial data.
| PARAMETER | DESCRIPTION |
|---|---|
matrix | TYPE: |
Examples:
A simple scaling transform
>>> from navis import transforms
>>> import numpy as np
>>> M = np.diag([1e3, 1e3, 1e3, 1])
>>> tr = transforms.affine.AffineTransform(M)
>>> points = np.array([[0, 0, 0], [1, 1, 1]])
>>> tr.xform(points)
array([[ 0., 0., 0.],
[1000., 1000., 1000.]])
Source code in navis/transforms/affine.py
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 | |
__init__ #
Initialize transform.
Source code in navis/transforms/affine.py
44 45 46 47 48 49 50 51 | |
copy #
Return copy of transform.
Source code in navis/transforms/affine.py
77 78 79 80 81 82 83 84 85 86 | |
xform #
Apply transform to points.
| PARAMETER | DESCRIPTION |
|---|---|
points | TYPE: |
invert | TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
pointsxf | The transformed points. |
Source code in navis/transforms/affine.py
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 | |
navis.transforms.AliasTransform #
Helper transform that simply passes points through.
Useful for defining aliases.
Source code in navis/transforms/base.py
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 | |
__init__ #
Initialize.
Source code in navis/transforms/base.py
79 80 81 | |
copy #
Return copy.
Source code in navis/transforms/base.py
93 94 95 96 97 | |
xform #
Pass through.
Note that the returned points are NOT a copy but the originals.
Source code in navis/transforms/base.py
99 100 101 102 103 104 | |
navis.transforms.CMTKtransform #
CMTK transforms of 3D spatial data.
Requires CMTK to be installed.
| PARAMETER | DESCRIPTION |
|---|---|
regs | TYPE: |
directions | TYPE: |
threads | TYPE: |
Examples:
>>> from navis import transforms
>>> tr = transforms.cmtk.CMTKtransform('/path/to/CMTK_directory.list')
>>> tr.xform(points)
Source code in navis/transforms/cmtk.py
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 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 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 | |
regargs: list property #
Generate regargs.
append #
Add another transform.
| PARAMETER | DESCRIPTION |
|---|---|
transform | TYPE: |
direction | TYPE: |
Source code in navis/transforms/cmtk.py
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 | |
check_if_possible #
Check if this transform is possible.
Source code in navis/transforms/cmtk.py
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | |
copy #
Return copy.
Source code in navis/transforms/cmtk.py
353 354 355 356 357 358 359 360 361 362 363 364 | |
from_file staticmethod #
Generate CMTKtransform from file.
| PARAMETER | DESCRIPTION |
|---|---|
filepath | TYPE: |
**kwargs | DEFAULT: |
| RETURNS | DESCRIPTION |
|---|---|
CMTKtransform | |
Source code in navis/transforms/cmtk.py
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
make_args #
Generate arguments passed to subprocess.
Source code in navis/transforms/cmtk.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |
parse_cmtk_output #
Parse CMTK output.
Briefly, CMTK output will be a byte literal like this:
b'311 63 23 \n275 54 25 \n'
In case of failed transforms we will get something like this where the original coordinates are returned with a "FAILED" flag
b'343 72 23 \n-10 -10 -10 FAILED \n'
Parameter
output : tuple of (b'', None) Stdout of CMTK call. fail_value Value to use for points that failed to transform. By default we use np.nan.
| RETURNS | DESCRIPTION |
|---|---|
pointsxf | The parse transformed points. TYPE: |
Source code in navis/transforms/cmtk.py
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 | |
to_dfield #
Convert transform to dense deformation field.
| PARAMETER | DESCRIPTION |
|---|---|
template | TYPE: |
out | TYPE: |
absolute | TYPE: |
verbose | TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
dfield | The dense deformation field as (3, Nx, Ny, Nz) numpy array with either absolute coordinates or offsets where the first dimension contains the x/y/z coordinates. Note that the coordinates stored in the field are in physical space (e.g. microns), not voxel space. |
header | The NRRD header associated with the deformation field. TYPE: |
See Also
CMTKtransform.to_grid_transform Method to directly convert to GridTransform. Please see that method's notes for details on how to handle the deformation field.
Source code in navis/transforms/cmtk.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 | |
to_grid_transform #
Convert to GridTransform via dense deformation field.
| PARAMETER | DESCRIPTION |
|---|---|
template | TYPE: |
absolute | TYPE: |
verbose | TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
transform | A few notes on using the resulting GridTransform: 1. The transform will expect input coordinates in voxel space. See the returned TYPE: |
voxel_size | The voxel size of the input space. This is important because the GridTransform will expect input coordinates in voxel space. TYPE: |
Source code in navis/transforms/cmtk.py
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 | |
xform #
Xform data.
| PARAMETER | DESCRIPTION |
|---|---|
points | TYPE: |
affine_only | TYPE: |
affine_fallback | TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
pointsxf | Transformed points. Points that failed to transform will be TYPE: |
Source code in navis/transforms/cmtk.py
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 | |
xform_image #
Transform an image using CMTK's reformatx.
| PARAMETER | DESCRIPTION |
|---|---|
im | TYPE: |
target | TYPE: |
out | TYPE: |
interpolation | TYPE: |
verbose | TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
np.ndarray | None | If out is None, returns the transformed image as np.ndarray. Otherwise, None. |
Source code in navis/transforms/cmtk.py
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 | |
navis.transforms.ElastixTransform #
Elastix transforms of 3D spatial data.
Requires Elastix. Based on code by Jasper Phelps (https://github.com/jasper-tms/pytransformix).
Note that elastix transforms can not be inverted!
| PARAMETER | DESCRIPTION |
|---|---|
file | TYPE: |
copy_files | TYPE: |
Examples:
>>> from navis import transforms
>>> tr = transforms.ElastixTransform('/path/to/transform/transform')
>>> tr.xform(points)
Source code in navis/transforms/elastix.py
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 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | |
check_if_possible #
Check if this transform is possible.
Source code in navis/transforms/elastix.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
copy #
Return copy.
Source code in navis/transforms/elastix.py
181 182 183 184 185 186 187 188 189 190 191 192 | |
read_output_file #
Load output file.
Parameter
filepath : str Filepath to output file.
| RETURNS | DESCRIPTION |
|---|---|
pointsxf | The parse transformed points. TYPE: |
Source code in navis/transforms/elastix.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
write_input_file #
Write a numpy array in format required by transformix.
Source code in navis/transforms/elastix.py
194 195 196 197 198 199 | |
xform #
Xform data.
| PARAMETER | DESCRIPTION |
|---|---|
points | TYPE: |
return_logs | TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
pointsxf | Transformed points. TYPE: |
Source code in navis/transforms/elastix.py
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 | |
navis.transforms.FunctionTransform #
Apply custom function as transform.
| PARAMETER | DESCRIPTION |
|---|---|
func | TYPE: |
Source code in navis/transforms/base.py
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 | |
__init__ #
Initialize.
Source code in navis/transforms/base.py
117 118 119 120 121 | |
copy #
Return copy.
Source code in navis/transforms/base.py
131 132 133 134 135 | |
xform #
Xform data.
| PARAMETER | DESCRIPTION |
|---|---|
points | TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
pointsxf | Transformed points. TYPE: |
Source code in navis/transforms/base.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
navis.transforms.GridTransform #
Deformation or coordinate field transform of 3D spatial data.
This is effectively a simpler version of the H5transform class and only supports deformation fields stored as numpy arrays in memory.
| PARAMETER | DESCRIPTION |
|---|---|
field | TYPE: |
type | TYPE: |
spacing | TYPE: |
offset | TYPE: |
Source code in navis/transforms/grid.py
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 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 | |
affine: AffineTransform property #
Return affine part of the transform.
shape: tuple property #
Return shape of the deformation field.
__init__ #
Init class.
Source code in navis/transforms/grid.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
calculate_affine #
Calculate affine part of the transform.
Source code in navis/transforms/grid.py
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 | |
copy #
Return copy.
Source code in navis/transforms/grid.py
166 167 168 169 170 171 | |
from_file classmethod #
Create GridTransform a file.
| PARAMETER | DESCRIPTION |
|---|---|
file | TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
GridTransform instance. | |
Source code in navis/transforms/grid.py
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 | |
from_warpfield classmethod #
Create GridTransform from a Warpfield deformation field.
| PARAMETER | DESCRIPTION |
|---|---|
warpfield | TYPE: |
Source code in navis/transforms/grid.py
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 | |
xform #
Xform data.
| PARAMETER | DESCRIPTION |
|---|---|
points | TYPE: |
affine_fallback | TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
pointsxf | Transformed points. Will contain TYPE: |
Source code in navis/transforms/grid.py
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 | |
navis.transforms.H5transform #
Hdf5 transform of 3D spatial data.
See here for specifications of the format.
| PARAMETER | DESCRIPTION |
|---|---|
f | TYPE: |
direction | TYPE: |
level | TYPE: |
cache | TYPE: |
full_ingest | TYPE: |
Source code in navis/transforms/h5reg.py
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 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 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 | |
quantization_multiplier property #
Quantization multiplier of the deformation field.
shape property writable #
Shape of the deformation field.
Note that the deformation field is likely to be (z, y, x, 3) where the last dimension contains the x/y/z offsets.
spacing property #
Voxel spacing of the deformation field (z, y, x).
use_cache property writable #
Whether to cache the deformation field.
__init__ #
Init class.
Source code in navis/transforms/h5reg.py
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 | |
copy #
Return copy.
Source code in navis/transforms/h5reg.py
237 238 239 240 241 242 243 244 245 | |
from_file staticmethod #
Generate H5transform from file.
| PARAMETER | DESCRIPTION |
|---|---|
filepath | TYPE: |
**kwargs | DEFAULT: |
| RETURNS | DESCRIPTION |
|---|---|
H5transform | |
Source code in navis/transforms/h5reg.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |
full_ingest #
Fully ingest the deformation field.
Source code in navis/transforms/h5reg.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
precache #
Cache deformation field for given bounding box.
| PARAMETER | DESCRIPTION |
|---|---|
bbox | TYPE: |
padding | TYPE: |
Source code in navis/transforms/h5reg.py
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 | |
xform #
Xform data.
| PARAMETER | DESCRIPTION |
|---|---|
points | TYPE: |
affine_fallback | TYPE: |
force_deform | TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
pointsxf | Transformed points. Points outside the deformation field will have only the affine part of the transform applied. TYPE: |
Source code in navis/transforms/h5reg.py
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 | |
xform_image #
Transform a 3D image using backward mapping.
If available, this method will use numba to accelerate the transformation. This is highly recommended as it can speed up the transformation by several orders of magnitude:
pip install numba
Note though that the numba-accelerated path only supports linear interpolation and constant-mode boundary handling (default).
| PARAMETER | DESCRIPTION |
|---|---|
image | TYPE: |
image_res | TYPE: |
out_res | TYPE: |
out_shape | TYPE: |
order | TYPE: |
mode | TYPE: |
cval | TYPE: |
chunk_size | TYPE: |
cache | TYPE: |
progress | TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
transformed | Transformed image in target space. The shape is determined by TYPE: |
Notes
This method uses backward mapping: for each output chunk, we compute where the voxels came from in the source image using the transformation, then interpolate the source image at those locations. So if your transform goes from A -> B, this method actually uses the inverse transform under the hood to figure out where in A the voxels in B come from.
Source code in navis/transforms/h5reg.py
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 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 | |
navis.transforms.TPStransform #
Thin Plate Spline transforms of 3D spatial data.
Notes
At least in my hands, TPStransforms are significantly faster than MovingLeastSquaresTransforms. The results are similar but not identical, so make sure to use the one that works best for your use case.
| PARAMETER | DESCRIPTION |
|---|---|
landmarks_source | TYPE: |
landmarks_target | TYPE: |
batch_size | TYPE: |
Examples:
>>> from navis import transforms
>>> import numpy as np
>>> # Generate some mock landmarks
>>> src = np.array([[0, 0, 0], [10, 10, 10], [100, 100, 100], [80, 10, 30]])
>>> trg = np.array([[1, 15, 5], [9, 18, 21], [80, 99, 120], [5, 10, 80]])
>>> tr = transforms.thinplate.TPStransform(src, trg)
>>> points = np.array([[0, 0, 0], [50, 50, 50]])
>>> tr.xform(points)
array([[ 1. , 15. , 5. ],
[40.55555556, 54. , 65. ]])
Source code in navis/transforms/thinplate.py
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 | |
matrix_rigid property #
Return the rigid transformation matrix.
__init__ #
Initialize class.
Source code in navis/transforms/thinplate.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
copy #
Make copy.
Source code in navis/transforms/thinplate.py
148 149 150 151 152 153 154 | |
xform #
Transform points.
| PARAMETER | DESCRIPTION |
|---|---|
points | TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
pointsxf | Transformed points. TYPE: |
Source code in navis/transforms/thinplate.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 | |