API Reference¶
The following sections summarize all individual functions and classes contained in the library.
Model builder pipeline¶
MRI2FE.Pipelines.FEModelbuilder
¶
Source code in src/MRI2FE/Pipelines/new_model.py
12 13 14 15 16 17 18 19 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 | |
__init__(title='', source='', imgout=None)
¶
Initialize the FEModel object to store model data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Optional title for the model which will be written to output solver decks. Defaults to "". |
''
|
source
|
str
|
Optional source folder for model for internal tracking. Defaults to "". |
''
|
Source code in src/MRI2FE/Pipelines/new_model.py
13 14 15 16 17 18 19 20 21 22 | |
build()
¶
Return generated FEModel
Source code in src/MRI2FE/Pipelines/new_model.py
145 146 147 | |
map_mre(target_label=4, MRE_type='stiffness_damping', MRE_geom=None, MRE_mask=None, MRE_frequency=None, MRE_to_transform=None, n_segs=5, **kwargs)
¶
Calculate material model coefficients and map MRE material assignments onto an ROI on the mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_label
|
int
|
Target integer label on the labeled image to map MRE material properties to. Defaults to 4. |
4
|
MRE_type
|
stiffness_damping or complex_shear
|
Specify whether MRE files are provided as shear stiffness and damping ratio or as storage and loss moduli. Defaults to "stiffness_damping". |
'stiffness_damping'
|
MRE_geom
|
List[str | Any]
|
List of images or paths to images for MRE geometries at each frequency. Defaults to None. |
None
|
MRE_mask
|
str | Any
|
ROI mask for MRE geometry. Defaults to None. |
None
|
MRE_frequency
|
List[float]
|
List of frequencies for each MRE geometry image. Defaults to None. |
None
|
MRE_to_transform
|
List[Tuple[str | Any]]
|
List of tuples of strings or MRE images. Each tuple represents either shear/damping or storage/loss moduli at a frequency given in MRE_frequency. Defaults to None. |
None
|
n_segs
|
int
|
Number of segments to discretize the MRE material properties into. Defaults to 5. |
5
|
Source code in src/MRI2FE/Pipelines/new_model.py
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 | |
mesh(img_path, img_labels=None, optimize=False, **kwargs)
¶
Generate a tetrahedral mesh from labeled MRI data and store in the FEModel object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img_path
|
str
|
Path to segmented, labeled MRI image. |
required |
img_labels
|
List[str]
|
Optional labels providing names for each region of the labeled image. Defaults to None. |
None
|
optimize
|
bool
|
Whether to perform post-process optimization on the tetrahedral mesh. Increases quality and run time. Defaults to False. |
False
|
Source code in src/MRI2FE/Pipelines/new_model.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
write(fpath, type='lsdyna')
¶
Write model to output solver deck
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fpath
|
str
|
File path to save output to. |
required |
type
|
lsdyna
|
Output type to be saved. Currently, only LS-DYNA is supported. Defaults to "lsdyna". |
'lsdyna'
|
Source code in src/MRI2FE/Pipelines/new_model.py
132 133 134 135 136 137 138 139 140 141 142 143 | |
Meshing¶
MRI2FE.mesh_from_nifti(filepath, optimize=False, facetAngle=30.0, facetSize=1.0, facetDistance=4.0, cellRadiusEdgeRatio=3.0, cellSize=1.0)
¶
Source code in src/MRI2FE/generate_mesh.py
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 | |
MRE Coregistration¶
MRI2FE.MRE.coregister_MRE_images(segmented_geom, target_label=4, segmented_mask=None, MRE_geom=None, MRE_mask=None, MRE_to_transform=None, imgout=None, type_of_transform='Affine')
¶
Coregister MRE geometry image to segmented geometry image, and transform corresponding MRE images.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
segmented_geom
|
Union[str, ANTsImage]
|
Segmented geometry image used for mesh creation |
required |
target_label
|
int
|
Label for ROI on geometry image. Used to create geometry mask if one is not provided. Defaults to 4. |
4
|
segmented_mask
|
Union[str, ANTsImage]
|
Binary mask for ROI on geometry image. Defaults to None. |
None
|
MRE_geom
|
List[Union[str, ANTsImage]]
|
List of geometry images associated with MRE at different frequencies. Defaults to None. |
None
|
MRE_mask
|
Union[str, ANTsImage]
|
Binary mask associated with ROI in MRE images. Defaults to None. |
None
|
MRE_to_transform
|
List[Tuple[Union[str, ANTsImage]]]
|
List of tuples, each tuple containing MRE images associated with one of the MRE_geom images provided. Defaults to None. |
None
|
imgout
|
str
|
Filepath to save validation images of the transformations applied. Defaults to None. |
None
|
type_of_transform
|
str
|
Type of transform, see Antspy registration documentation for guidance. Defaults to "Affine". |
'Affine'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
No MRE/segmented geometry image provided |
FileNotFoundError
|
MRE/segmented geometry files not found |
TypeError
|
Image files are not a filepath string or AntsImage |
ValueError
|
Transform could not be resolved |
ValueError
|
MRE_geom and MRE_to_Transform are different lengths |
ValueError
|
imgout path could not be found |
Returns:
| Name | Type | Description |
|---|---|---|
Transformations |
List
|
list of transformations |
Transformed_images |
List
|
list of transformed image tuples |
Source code in src/MRI2FE/MRE/MRE_coregistration.py
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 | |
MRI2FE.MRE.segment_MRE_regions(img_list, n_segs=5, imgout=None, imgout_geom=None)
¶
Kmeans segmentation of MRE images
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img_list
|
List[Tuple[ANTsImage]]
|
List of tuples of ANTsImage, each tuple representing the two images available for MRE at a given frequency. |
required |
n_segs
|
int
|
Number of segments to generate. Defaults to 5. |
5
|
imgout
|
str
|
optional directory path to save validation images. Defaults ot None. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Labels |
ANTsImage
|
Image containing integer labels for each region of the MRE images. |
km_ants |
dict
|
Dictionary containing average properties for each region. Keys are "1" and "2" for the two input images for each tuple, each key contains a list of length n_tuples which has the average properties for that cluster |
Source code in src/MRI2FE/MRE/MRE_coregistration.py
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 | |
MRI2FE.MRE.calculate_prony
¶
calculate_prony(gp=None, gpp=None, mu=None, xi=None, w=None, tol=0.001)
¶
Calculate the 1st order prony series equivalent to the complex shear modulus representation of brain tissue viscoelasticity
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gp
|
array - like
|
storage moduli at different frequencies. If gp is provided, gpp must also be provided. |
None
|
gpp
|
array - like
|
loss moduli at different frequencies. If gpp is provided, gp must also be provided. |
None
|
mu
|
array - like
|
Shear stiffness at different frequencies. If mu is provided, xi must also be provided. |
None
|
xi
|
array - like
|
Damping ratio at different frequencies. If xi, is provided, mu must also be provided. |
None
|
w
|
array - like
|
MRE frequency for each gp/gpp or mu/xi value, must follow the same order. |
None
|
tol
|
float
|
Back calculation tolerance check. Defaults to 1.00e-3. |
0.001
|
Raises:
| Type | Description |
|---|---|
ValueError
|
gp/gpp or mu/xi not provided |
ValueError
|
number of inputs on each array do not match |
ValueError
|
Mu or Xi back-calculation out of range |
Returns:
| Name | Type | Description |
|---|---|---|
Ginf |
float
|
long-time shear modulus |
G1 |
float
|
short-time shear modulus |
tau |
float
|
short-time time constant |
gp |
float
|
Storage modulus |
gpp |
float
|
Loss modulus |
Source code in src/MRI2FE/MRE/calculate_prony.py
16 17 18 19 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 | |
prony_series(gp, gpp, w)
¶
Calculate the 1-term prony series constants for an equivalent complex shear modulus using least squares optimization
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gp
|
float
|
Storage modulus |
required |
gpp
|
float
|
Loss modulus |
required |
w
|
float
|
Modulus frequency |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Ginf |
float
|
Long-time shear modulus |
G1 |
float
|
short-time shear modulus |
tau |
float
|
time constant |
Source code in src/MRI2FE/MRE/calculate_prony.py
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 | |
MRI2FE.MRE.map_MRE_to_mesh(mdl, label_img, region_properties, target_region_id=4, label_background_id=0, region_prefix=None, imgout=None)
¶
Map MRE properties onto FE mesh and store associated material properties in the model material array
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mdl
|
FEModel
|
FE model to map MRE regions onto |
required |
label_img
|
ANTsImage
|
MRI image with integer labels for each MRE region |
required |
region_properties
|
List
|
List of prony series properties for each MRE region |
required |
target_region_id
|
int
|
Target PID in the FE model to replace with segmented MRE IDs . |
4
|
label_background_id
|
int
|
Integer label in the label_img associated with the background. Defaults to 0. |
0
|
region_prefix
|
str
|
name prefix for the new part assignment names |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
Input not the right type |
ValueError
|
negative target region |
Returns:
| Name | Type | Description |
|---|---|---|
FEModel |
FEModel
|
Model with updated PIDs for the target region and material properties added |
Source code in src/MRI2FE/MRE/MRE_mapping.py
11 12 13 14 15 16 17 18 19 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 | |
Model class and I/O¶
MRI2FE.FEModel
¶
Model object storing the generated FE model.
Source code in src/MRI2FE/models/femodel.py
8 9 10 11 12 13 14 15 16 17 18 19 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 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 | |
__init__(title='', source='', imgout=None, nodes=None, elements=None, parts=None, materials=None, sections=None)
¶
Initialize the FE model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Name for model, will be inserted as solver deck title on output. Defaults to "". |
''
|
source
|
str
|
Source file for model, optional. Defaults to "". |
''
|
imgout
|
str
|
Directory to save validation images to. Defaults to None. |
None
|
nodes
|
Union[list, ndarray]
|
Array with shape (n,4) containing node ID, x, y, z coordinates. Defaults to None. |
None
|
elements
|
Union[list, ndarray]
|
Array with shape (n,m+2) containing element ID, part/group ID, and m connected nodes. Defaults to None. |
None
|
parts
|
dict
|
Part definitions. Dictionary keys are the part ID. Each key is linked to a dictionary with entries "name" and "constants". Defaults to None. |
None
|
materials
|
List[dict]
|
Material definitions. List of dictionaries. Each dictionary must contain the keys "name", "ID", and "constants". Defaults to None. |
None
|
sections
|
List[dict]
|
Material section definitions. List of dictionaries. Each dictionary must contain the keys "ID" and "constants". Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Wrong input type. |
Source code in src/MRI2FE/models/femodel.py
11 12 13 14 15 16 17 18 19 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 | |
__repr__()
¶
String representation of the FEModel.
Source code in src/MRI2FE/models/femodel.py
307 308 309 310 311 312 313 314 | |
add_elements(element_id=None, part_id=None, nodes=None, element_array=None, force_insert=False)
¶
Add an element to the element table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
element_id
|
int
|
Element ID, must also provide part_id and nodes if not None. Defaults to None. |
None
|
part_id
|
int
|
Connected part ID, must also provide element_id and nodes if not None. Defaults to None. |
None
|
nodes
|
list
|
Connected node IDs, must also provide element_id and part_id. Defaults to None. |
None
|
element_array
|
ndarray
|
Array of shape (n+2,) containing element_id, part_id, n connected node ids. Defaults to None. |
None
|
force_insert
|
bool
|
Whether to overwrite if element already exists with the same ID. Defaults to False. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Wrong input type. |
ValueError
|
Input shape mismatch with element table. |
ValueError
|
Element ID already exists and force_insert is False. |
Source code in src/MRI2FE/models/femodel.py
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 | |
add_nodes(node_id=None, x=None, y=None, z=None, node_array=None, force_insert=False)
¶
Add a node to the node table
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_id
|
int
|
ID of the new node to add, must provide x-, y- and z- coordinates if specified. Defaults to None. |
None
|
x
|
float
|
x-coordinate of the node, must also provide y- and z-coordinates. Defaults to None. |
None
|
y
|
float
|
y-coordinate of the node, must also provide x- and z-coordinates. Defaults to None. |
None
|
z
|
float
|
z-coordinate of the node, must also provide x- and y-coordinates. Defaults to None. |
None
|
node_array
|
ndarray
|
(4,) array containing node_id,x,y,z coordinates. Defaults to None. |
None
|
force_insert
|
bool
|
Whether to overwrite existing node with the same ID. Defaults to False. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Wrong input type. |
ValueError
|
Wrong array size. |
ValueError
|
Node ID already exists and force_insert false. |
Source code in src/MRI2FE/models/femodel.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 | |
add_part(part_id, name, material_constants)
¶
Add part information (e.g., material constants).
Source code in src/MRI2FE/models/femodel.py
297 298 299 300 301 | |
from_meshio(mesh, element_type='tetra', region_names=None)
¶
Append mesh data from a meshio mesh object or file to the FEModel, offsetting IDs and updating metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
(Mesh, str)
|
Mesh object or filepath to mesh file. |
required |
element_type
|
tetra
|
Element type to import. Only "tetra" is supported. |
'tetra'
|
region_names
|
List[str]
|
Optional part names for each region. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the element type of the new mesh does not match the existing FEModel. |
ValueError
|
If no elements of the specified type are found in the mesh. |
Source code in src/MRI2FE/models/femodel.py
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 | |
get_part_info()
¶
Return the part information.
Source code in src/MRI2FE/models/femodel.py
303 304 305 | |
update_centroids()
¶
Update the centroid table with all elements in the element table.
Source code in src/MRI2FE/models/femodel.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
write_lsdyna(filename)
¶
Write FE model data to an LS-DYNA .k file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Output file path for the .k file. |
required |
Source code in src/MRI2FE/models/femodel.py
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 | |
Utilities¶
MRI2FE.COM_align(fixed, moving, fixed_mask=None, moving_mask=None)
¶
Align the centers of mass of two point clouds, operating either on the entire point cloud or on a masked region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fixed
|
ndarray
|
Reference point cloud to be aligned to. |
required |
moving
|
ndarray
|
Point cloud to align with fixed cloud. |
required |
fixed_mask
|
ndarray
|
Fixed point cloud subset to define COM by. Defaults to None. |
None
|
moving_mask
|
ndarray
|
Moving point cloud subset to define COM by. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numpy arrays when provided |
ValueError
|
If required inputs are None or have invalid dimensions |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: moving point cloud rigidly aligned to the fixed point cloud COM |
Source code in src/MRI2FE/utilities.py
8 9 10 11 12 13 14 15 16 17 18 19 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 | |
MRI2FE.point_cloud_spacing(dims, points=None, lims=None)
¶
Return the voxel spacing necessary to cover a point cloud with given voxel dimensions Can be called by either providing a point cloud or directly providing field limits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dims
|
tuple
|
tuple of voxel count along each of m dimensions |
required |
points
|
Union[list, tuple, ndarray]
|
locations of n points in m dimensions with shape (n,m) |
None
|
lims
|
ndarray
|
Min/max of point cloud space in m dimensions with shape (m,2) |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not of correct type |
ValueError
|
If dims is None or if neither points nor lims is provided |
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple
|
spacing in each dimension |
Source code in src/MRI2FE/utilities.py
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 | |
MRI2FE.ants_affine(img)
¶
Extract affine transformation matrix from ANTsImage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img
|
ANTsImage
|
Input ANTs image |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If img is not an ANTsImage |
ValueError
|
If img is None |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: 4x4 affine transformation matrix |
Source code in src/MRI2FE/utilities.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 | |
MRI2FE.spatial_map(infile)
¶
Convert data from NIFTI file to (4,n) array of x,y,z,voxel value in physical space
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
infile
|
nifti1
|
NIFTI file to convert |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If infile is not an ANTsImage |
ValueError
|
If infile is None |
Returns:
| Name | Type | Description |
|---|---|---|
coordinates_and_values |
ndarray
|
array of x,y,z coordinates in physical space with the corresponding voxel value |
Source code in src/MRI2FE/utilities.py
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 | |
MRI2FE.element_centroids(elnodes, node_coords)
¶
Calculate the centroid of an element
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elnodes
|
array
|
1D array containing EID, PID, and connected nodes |
required |
node_coords
|
array
|
2D array containing NID, xyz coordinates |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If inputs are not numpy arrays |
ValueError
|
If array dimensions or contents are invalid |
Returns:
| Name | Type | Description |
|---|---|---|
centroid |
array
|
(3,) array containing average coordinate of the element |
Source code in src/MRI2FE/utilities.py
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 | |