Deformable#
The deformable registration page groups the main deformable object with its supporting side and visualization classes.
- class medicalimageanalysis.structure.deformable.Deformable(dvf=None, origin=None, spacing=None, dimensions=None, roi_names=None, rigid_matrix=None, dvf_matrix=None, registration_name=None, reference_name=None, moving_name=None, reference_meshes=None, moving_meshes=None, reference_model=None, moving_model=None, local_uid=None, deformable_id=None)[source]#
Bases:
objectDeformable registration between the frames of reference of a reference and a moving image: the moving image is deformed onto the reference by a DVF on top of a rigid pre-alignment.
The display API mirrors Rigid so the same viewer code can drive either:
compute_array(),compute_mesh_slice(),compute_aspect()andget_view_center()take (plane, position) of the base image’s view and name their images withbase_name/image_name.compute_grid()adds the DVF itself on the same grid.- Parameters:
dvf ((Z, Y, X, 3) ndarray, optional) – Reference -> moving displacement field, (dx, dy, dz) in mm, on a grid in the reference world (see the module conventions). None until
compute_registration().origin (array_like, optional) – DVF grid origin and spacing, (x, y, z).
spacing (array_like, optional) – DVF grid origin and spacing, (x, y, z).
dimensions (tuple, optional) – DVF grid dimensions, (z, y, x).
roi_names (list of str or int, optional) – Default ROIs (names or ids) whose masks guide
compute_registration()(must exist on both images). Kept asroi_ids.rigid_matrix ((4, 4) array_like, optional) – Rigid pre-alignment, reference world -> moving world (
Rigid.get_combined_matrix()). Defaults to identity.dvf_matrix ((3, 3) array_like, optional) – Direction of the supplied DVF, rows = index axes in world (same as
image.matrix). Anything other than identity is resampled onto an identity grid withcorrect_dvf_direction().registration_name (str, optional) – User name in
Data.deformable. None builds one from the current image names (a plain label).reference_name (str or int) – Images in
Data.image(name or id) used to compute the registration: the moving image is deformed onto the reference. Their frames define what the registration applies to. Only the ids are kept.moving_name (str or int) – Images in
Data.image(name or id) used to compute the registration: the moving image is deformed onto the reference. Their frames define what the registration applies to. Only the ids are kept.reference_meshes (pyvista.PolyData, optional) – Surfaces used for registration (stored as
reference.mesh/moving.mesh).moving_meshes (pyvista.PolyData, optional) – Surfaces used for registration (stored as
reference.mesh/moving.mesh).reference_model (str or int, optional) – Model (name or id, on that side’s image) the registration is computed with; see
set_model().moving_model (str or int, optional) – Model (name or id, on that side’s image) the registration is computed with; see
set_model().local_uid (str, optional) – Existing uid when loading (
load()). None generates a new one.deformable_id (int, optional) – Existing id in
Data.deformablewhen loading. None (or an id already in use) gets a new one.
- deformable_name#
User name, mirrored from
Data.deformable. Change it withData.rename_deformable.- Type:
- reference, moving
Image id, frame, registration surface and Model (id, build and frozen mesh) of each side.
- Type:
- roi_ids#
Default ROIs guiding
compute_registration().
- visual#
Display settings, including the default deformation
percent.- Type:
- roi#
ROI id -> moving ROI mesh deformed into the reference world at
visual.percent, for the 3D view (built byupdate_rois()). The 2D views usecompute_mesh_slice()instead.- Type:
Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Deformable(reference_name='CT 01', moving_name='CBCT 01', roi_names=['Liver'], ... rigid_matrix=mia.Data.rigid['CT 01_CBCT 01'].get_combined_matrix()) >>> deform.compute_registration('itk_diffeomorphic') >>> deform = mia.Data.deformable['DVF_CT 01_CBCT 01']
- SCHEMA_VERSION = 3#
- ITK_METHODS = {'elastix': 'elastix', 'itk_bspline': 'bspline', 'itk_demons': 'demons', 'itk_diffeomorphic': 'diffeomorphic', 'itk_fast_demons': 'fast_demons', 'itk_field': 'displacement_field', 'itk_level_set': 'level_set_motion', 'itk_symmetric_demons': 'symmetric_demons'}#
- INVERT_ITERATIONS = 10#
- INVERT_TOLERANCE = 0.01#
- static find_deformables(image_a, image_b)[source]#
Names of every registration in
Data.deformablethat connects the frames of two images (either direction).Examples
>>> import medicalimageanalysis as mia >>> mia.Deformable.find_deformables('Dose 01', 'CT 01') ['DVF_CT 01_CBCT 01']
- add_deformable(deformable_name, deformable_id=None)[source]#
Store this registration in
Data.deformableand return its name; None builds a unique name from the current image names. A name already in use is replaced and its id taken over.Examples
>>> import medicalimageanalysis as mia >>> mia.Deformable(reference_name='CT 01', moving_name='CBCT 01').deformable_name 'DVF_CT 01_CBCT 01' >>> mia.Deformable(reference_name='CT 01', moving_name='CBCT 01').deformable_name # second one 'DVF_CT 01_CBCT 01_1'
- static correct_dvf_direction(dvf, spacing, origin, matrix)[source]#
Resample a DVF stored on a rotated grid onto an identity-direction grid covering the same region.
The new grid keeps the spacing and is the axis-aligned bounding box of the old grid’s voxel centers. Each new voxel takes the trilinearly interpolated displacement at its world point; voxels the old grid doesn’t cover get zero displacement. The vectors themselves are not rotated: DICOM, SimpleITK and ANTs store displacements in world (patient) coordinates, independent of the grid direction.
Called by
__init__whendvf_matrixis not identity, and bycompute_registration()when the reference image is oblique.- Parameters:
dvf ((Z, Y, X, 3) ndarray)
spacing (array_like) – (x, y, z).
origin (array_like) – (x, y, z).
matrix ((3, 3) array_like) – Direction of the input DVF, rows = index axes in world (same as
image.matrix): world = origin + matrix.T @ (index * spacing).
- Returns:
(dvf, spacing, origin, dimensions) for the identity-direction grid.
- Return type:
Examples
>>> import medicalimageanalysis as mia >>> dvf, spacing, origin, dimensions = mia.Deformable.correct_dvf_direction(dvf, spacing, origin, direction)
- compute_array(plane, position, base_name=None, image_name=None, spacing=None, percent=None, background=None)[source]#
image_name rigidly + deformably mapped onto base_name’s view. Same call as Rigid.compute_array.
- Parameters:
plane (str) – View plane, e.g. ‘Axial’.
position (array_like) – The widget’s position (base image’s view).
base_name (str, optional) – Image whose view is shown. Any image in either frame. None = the registered reference image.
image_name (str, optional) – Image deformed onto the view. Any image in either frame. None = the registered moving image. An image on the same side as the base is in the same world, so it is sampled with no deformation.
spacing (None, 'native', float or (sx, sy), optional) – None = base image grid, ‘native’ = image_name’s spacing, or any spacing. Use the same value in
compute_grid(),compute_mesh_slice()andcompute_aspect().percent (float, optional) – Deformation level (0 = rigid only, 100 = full). None =
self.visual.percent. Scalesdvfthe same way in both directions, so the image and the contours (compute_mesh_slice()) agree at any level.background (float, optional) – Value for pixels that fall outside image_name. None = image_name’s
background(-3001 for images, 0 Gy for a dose).
- Returns:
‘array’ (h, w) float32, ‘dimensions’ (w, h), ‘spacing’, ‘pixel_spacing’ (sx, sy), ‘x_axis’, ‘y_axis’, ‘normal’, ‘origin’, ‘grid’, ‘scale’ (sample spacing / base spacing) and ‘pixel_offset’ (always (0, 0)). None when the images are on opposite sides and there is no DVF yet.
- Return type:
dict or None
Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Data.deformable['DVF_CT 01_CBCT 01'] >>> res = deform.compute_array('Axial', ct_position) # CBCT deformed onto the CT >>> res = deform.compute_array('Axial', ct_position, percent=0) # rigid only >>> res = deform.compute_array('Axial', cbct_position, base_name='CBCT 01', image_name='CT 01') >>> res = deform.compute_array('Sagittal', ct_position, spacing='native') # at the CBCT's spacing >>> res = deform.compute_array('Axial', ct_position, image_name='Dose 01') # moving-frame dose on the CT
- compute_aspect(plane, base_name=None, image_name=None, spacing=None)[source]#
Pixel aspect (sx / sy) of the view, matching compute_array with the same images and spacing. The default keeps the base image’s aspect.
Examples
>>> import medicalimageanalysis as mia >>> mia.Data.deformable['DVF_CT 01_CBCT 01'].compute_aspect('Sagittal')
- compute_components(roi_name)[source]#
Connected components of a deformed ROI mesh (
self.roi, ROI name or id), or None if it has not been warped.Examples
>>> import medicalimageanalysis as mia >>> parts = mia.Data.deformable['DVF_CT 01_CBCT 01'].compute_components('Liver')
- compute_folding()[source]#
Fraction of DVF voxels where the map r -> r + dvf(r) folds (Jacobian determinant <= 0).
0.0 means the field is invertible everywhere, so every “solve” (moving -> reference: reference-side images on a moving-side view, moving-side contours and 3D meshes) converges to the exact point. Anything above 0 marks regions where those are only approximate. The direct direction (the moving image deformed onto the reference) is exact either way.
Examples
>>> import medicalimageanalysis as mia >>> mia.Data.deformable['DVF_CT 01_CBCT 01'].compute_folding() 0.0
- compute_grid(plane, position, base_name=None, image_name=None, vector='magnitude', spacing=None, outside=0.0)[source]#
One DVF component or its magnitude (mm) on the same view grid as compute_array, for overlaying the field on base_name’s view.
Each pixel shows
dvf(reference -> moving, in world axes, full deformation) at the reference point of the tissue it shows, so the same tissue has the same value whichever side the base image is on. On a reference-side view that point is the pixel itself (direct); on a moving-side view it is solved from the pixel. image_name only matters for spacing=’native’.- Parameters:
plane (str) – View plane, e.g. ‘Axial’.
position (array_like) – The widget’s position (base image’s view).
base_name (str, optional) – Same meaning as in
compute_array().image_name (str, optional) – Same meaning as in
compute_array().vector ({'x', 'y', 'z', 'magnitude'}, default 'magnitude')
spacing (None, 'native', float or (sx, sy), optional) – Same meaning as in
compute_array().outside (float, default 0.0) – Value for pixels outside the DVF grid.
- Returns:
‘array’, ‘dimensions’, ‘pixel_spacing’, ‘grid’, ‘scale’, ‘pixel_offset’. None when there is no DVF yet.
- Return type:
dict or None
Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Data.deformable['DVF_CT 01_CBCT 01'] >>> magnitude = deform.compute_grid('Axial', ct_position) >>> dz = deform.compute_grid('Coronal', cbct_position, base_name='CBCT 01', vector='z', outside=np.nan)
- compute_inverted_dvf(iterations=50, mean_tolerance=0.001, max_tolerance=0.1)[source]#
Full moving -> reference field (the inverse of
dvf, same grid, (Z, Y, X, 3), (dx, dy, dz)), for export.Returned and never stored: nothing in this class needs it, since the moving -> reference direction is solved per point where it is used.
- Parameters:
- Return type:
(Z, Y, X, 3) float32 ndarray
Examples
>>> import medicalimageanalysis as mia >>> inverted = mia.Data.deformable['DVF_CT 01_CBCT 01'].compute_inverted_dvf()
- compute_mesh_slice(roi_name, plane, position, base_name=None, image_name=None, percent=None, return_pixel=True, use_cache=True, spacing=None)[source]#
Slice one of image_name’s ROIs, deformed onto base_name’s view, on the same grid compute_array samples, so image and contour line up.
Pixel output is (col, row) floats relative to the view’s top-left corner, pixel centers at integers; each contour is closed (first point repeated).
Results are cached per view (plane + base image), keyed by (image, roi, percent, position rounded to 1 um, return_pixel). An entry is reused only if it was cut from the same deformed mesh object, so a new DVF / rigid / percent / ROI edit (which builds a new mesh in get_display_mesh) is picked up automatically. The returned list is the cached object; copy it before modifying it in place.
- Parameters:
plane (str) – View plane, e.g. ‘Axial’.
position (array_like) – The widget’s position (base image’s view).
base_name (str, optional) – Same meaning as in
compute_array().image_name (str, optional) – Same meaning as in
compute_array().percent (float, optional) – Deformation level (0 = rigid only, 100 = full). None =
self.visual.percent.return_pixel (bool, default True) – False returns the raw pyvista slice (world coordinates).
use_cache (bool, default True) – Pass False while dragging or animating.
spacing (None, 'native', float or (sx, sy), optional) – Same value as in
compute_array().
- Return type:
list of (N, 2) ndarray, or pyvista.PolyData when return_pixel=False
Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Data.deformable['DVF_CT 01_CBCT 01'] >>> contours = deform.compute_mesh_slice('Liver', 'Axial', ct_position) # CBCT Liver on the CT >>> contours = deform.compute_mesh_slice('Liver', 'Axial', cbct_position, base_name='CBCT 01', ... image_name='CT 01') # CT Liver on the CBCT >>> world = deform.compute_mesh_slice('Liver', 'Axial', ct_position, percent=50, return_pixel=False)
- compute_registration(method='itk_fast_demons', reference_rois=None, moving_rois=None, reference_mask=None, moving_mask=None, reference_points=None, moving_points=None, **kwargs)[source]#
Run a deformable registration on the registered images and store the result in
dvf.The moving image (and its mask) is first resampled into the rigid frame with
rigid_matrix, so every method only has to find the deformation on top of the rigid pre-alignment. The reference is the fixed image, so the backend’s field (reference point r -> moving point r + f(r)) isdvfexactly and is stored as is. The 3D ROI meshes (roi) are rebuilt afterwards.- Parameters:
method (str, default 'itk_fast_demons') –
SimpleITK / Elastix (
DeformableITK):’itk_bspline’ : multi-resolution B-spline,
DeformableITK.bspline.’itk_field’ : dense displacement field, any metric,
DeformableITK.displacement_field.’itk_demons’ : Thirion Demons,
DeformableITK.demons.’itk_symmetric_demons’ : symmetric forces Demons,
DeformableITK.symmetric_demons.’itk_fast_demons’ : fast symmetric forces Demons,
DeformableITK.fast_demons.’itk_diffeomorphic’ : diffeomorphic Demons,
DeformableITK.diffeomorphic.’itk_level_set’ : level set motion,
DeformableITK.level_set_motion.’elastix’ : Elastix B-spline / spline kernel,
DeformableITK.elastix. Uses the points when given.’itk_landmark’ : B-spline fitted to the points only,
DeformableITK.landmark.
ANTs (
DeformableANTs, needsantspyx):’ants’ : any ANTs deformable transform / metric / preset,
DeformableANTs.registration(e.g.transform='SyN',metric='CC',label_weight=1.0,preset='SyNOnly').’ants_landmark’ : field fitted to the points only,
DeformableANTs.landmark.
reference_rois (str or list of str, optional) – ROIs whose masks restrict the metric (ANTs: also the default labels for
label_weight), paired by position. reference_rois None =roi_ids; moving_rois None = the same ROIs. Names or ids. Pairs missing on either image are skipped.moving_rois (str or list of str, optional) – ROIs whose masks restrict the metric (ANTs: also the default labels for
label_weight), paired by position. reference_rois None =roi_ids; moving_rois None = the same ROIs. Names or ids. Pairs missing on either image are skipped.reference_mask (numpy.ndarray, optional) – Binary (z, y, x) masks on each image’s own grid; override the ROI masks.
moving_mask (numpy.ndarray, optional) – Binary (z, y, x) masks on each image’s own grid; override the ROI masks.
reference_points ((N, 3) array_like, optional) – Paired world points (mm): reference points in the reference world, moving points in the moving image’s native world. Required for the landmark methods; optional for ‘elastix’.
moving_points ((N, 3) array_like, optional) – Paired world points (mm): reference points in the reference world, moving points in the moving image’s native world. Required for the landmark methods; optional for ‘elastix’.
**kwargs – Passed straight to the backend method (e.g.
iterations,metric,crop,cross_modality,control_spacing,transform).
Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Deformable(reference_name='CT 01', moving_name='CBCT 01', roi_names=['Liver'], ... rigid_matrix=mia.Data.rigid['CT 01_CBCT 01'].get_combined_matrix()) >>> deform.compute_registration() # fast Demons, Liver masks >>> deform.compute_registration('itk_bspline', control_spacing=(15, 15, 15), metric='ANTS') >>> deform.compute_registration('itk_diffeomorphic', iterations=200, crop=20) >>> deform.compute_registration('elastix', transform='RecursiveBSpline', bending_weight=0.1) >>> deform.compute_registration('ants', transform='SyN', metric='CC', label_weight=1.0) >>> deform.compute_registration('ants', preset='antsRegistrationSyNQuick[so]') >>> deform.compute_registration('ants_landmark', reference_points=ct_points, moving_points=cbct_points, ... transform='tps')
- create_image(ratio=1)[source]#
Moving image rigidly + deformably resampled onto the reference grid (full 3D, for export).
Runs the same kernel as the display (direct case) one reference slice at a time, so the export matches what is shown and needs no extra field in memory.
- Parameters:
ratio (float, default 1) – Displacement scale (0 = rigid only, 1 = full).
- Returns:
Float32 image with the reference image’s geometry; the moving image’s
background(-3001) outside it.- Return type:
SimpleITK.Image
Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Data.deformable['DVF_CT 01_CBCT 01'] >>> image = deform.create_image() >>> halfway = deform.create_image(ratio=0.5)
- create_roi_image(roi_name, sitk_image=True)[source]#
Binary mask of a deformed ROI (
self.roi) on the reference image grid.- Parameters:
Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Data.deformable['DVF_CT 01_CBCT 01'] >>> mask_image = deform.create_roi_image('Liver') >>> mask = deform.create_roi_image('Liver', sitk_image=False)
- get_display_mesh(roi_name, base_name=None, image_name=None, percent=None)[source]#
image_name’s ROI warped into base_name’s world, or None (no mesh, or no DVF yet).
A moving-side ROI on a reference-side view is solved per vertex; a reference-side ROI on a moving-side view is direct. Same side: the ROI’s own mesh. Cached per direction / image / percent / dvf / ROI mesh / rigid, so repeated calls are free.
Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Data.deformable['DVF_CT 01_CBCT 01'] >>> mesh = deform.get_display_mesh('Liver') # CBCT Liver on the CT, for a 3D view >>> halfway = deform.get_display_mesh('Liver', percent=50) >>> on_cbct = deform.get_display_mesh('Liver', base_name='CBCT 01', image_name='CT 01')
- get_model(side='reference')[source]#
The live Model a side was computed with, or None (no model, or it was deleted). The frozen copy of the mesh actually used is always
self.<side>.model_mesh.Warns (
UserWarning) when the live model has been rebuilt sinceset_model(), since its mesh is then not the one this registration was computed with. Seecheck_model().Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Data.deformable['DVF_CT 01_CT 02'] >>> model = deform.get_model('reference') >>> if deform.check_model('reference') == 'stale': ... print('Liver ROI edited after this registration was computed')
- get_view_center(plane, position, base_name=None)[source]#
base_name’s crosshair in view pixel coords (pixel centers at integers), for crosshair / zoom anchors.
Examples
>>> import medicalimageanalysis as mia >>> col, row = mia.Data.deformable['DVF_CT 01_CBCT 01'].get_view_center('Axial', ct_position)
- warp_points(points, to_reference=True, percent=100)[source]#
World points carried across the registration: moving native world -> reference world (to_reference=True, solved per point) or reference world -> moving native world (False, direct). The same relation the display and the ROI warping use;
Data.map_pointsuses it for chains of registrations.- Parameters:
- Return type:
(N, 3) ndarray
- Raises:
ValueError – If there is no DVF yet.
Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Data.deformable['DVF_CT 01_CBCT 01'] >>> on_ct = deform.warp_points(cbct_points) # CBCT -> CT >>> on_cbct = deform.warp_points(ct_points, to_reference=False) # CT -> CBCT
- map_mesh(roi_name, set_moving=True, return_mesh=False)[source]#
Map a deformed ROI (
self.roi, reference world) back into the moving image’s native world.Use after editing the deformed contour on the reference, so the edit lands on the moving image.
- Parameters:
Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Data.deformable['DVF_CT 01_CBCT 01'] >>> deform.map_mesh('Liver') # update the CBCT's Liver >>> mesh = deform.map_mesh('Liver', set_moving=False, return_mesh=True) # just look at it
- set_model(model_name, side='reference')[source]#
Record the Model a side is computed with and freeze a copy of its mesh (
side.model_mesh).Call it when the model is used (e.g. before running the FEBio registration). Rebuilding or deleting the model afterwards does not change this registration (
check_model()reports it); call set_model again, and recompute, to take the new mesh.- Parameters:
Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Data.deformable['DVF_CT 01_CT 02'] >>> deform.set_model('Liver FE', side='reference') >>> deform.reference.model_mesh.n_points
- set_percent(percent)[source]#
Deformation level used by compute_array / compute_mesh_slice / get_display_mesh when no percent is passed (0-100).
Warped meshes cached for other levels are dropped, so dragging a slider doesn’t pile up mesh copies.
Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Data.deformable['DVF_CT 01_CBCT 01'] >>> deform.set_percent(50) >>> res = deform.compute_array('Axial', ct_position) # halfway between rigid and full deformation
- update_rois(roi_name=None)[source]#
Warp the visible moving ROI meshes into the reference world at
visual.percent(rigid^-1, then solve r + dvf(r) per vertex) and store them inself.roifor the 3D view. Call again after the DVF, rigid or percent changes.Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Data.deformable['DVF_CT 01_CBCT 01'] >>> deform.update_rois() >>> deform.update_rois('Liver') >>> liver_on_ct = deform.roi[mia.Data.get_roi_id('Liver')]
- classmethod load(path)[source]#
Rebuild a registration from
save()output and register it inData.deformable.Works before (or without) its images being loaded: the saved frames and ids are kept (the image ids must be the ones the images are restored with), the reference and moving meshes come from the file, and the warped ROIs (
roi) are only built when the moving image is present.Schema 1 files (saved with image and ROI names) are read too: the names are looked up, so their images and ROIs must be loaded first. Schema 2 files simply have no models.
Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Deformable.load('C:/Data/ct_cbct.npz') >>> deform.reference.mesh # still viewable if 'CT 01' was deleted
- export_image(path=None)[source]#
Write the deformed moving image (create_image) to any format SimpleITK can write. Nothing is written when path is None.
Examples
>>> import medicalimageanalysis as mia >>> mia.Data.deformable['DVF_CT 01_CBCT 01'].export_image('C:/Data/cbct_deformed.mhd')
- save(path)[source]#
Write the registration to one .npz file: the JSON state, the DVF, the reference / moving meshes (points and faces) and the frozen copy of each side’s Model mesh. Written to a temporary name and swapped in, so a crash never leaves a half-written file. No pickle, so loading never runs code from the file.
Warped ROIs (
roi), display settings and caches are not saved; they are rebuilt on demand.Examples
>>> import medicalimageanalysis as mia >>> mia.Data.deformable['DVF_CT 01_CBCT 01'].save('C:/Data/ct_cbct.npz')
- check_model(side='reference')[source]#
Whether the live Model is still the mesh this side was computed with.
- Returns:
None when the side has no model. Otherwise:
’current’ : same build, and its source ROIs are unchanged.
’rebuilt’ : the model was rebuilt (or given another mesh) since
set_model(); this registration still holds the old mesh inside.model_mesh.’stale’ : same build, but a source ROI was edited since the model was built.
’deleted’ : the model is gone (or its image is not loaded);
side.model_meshis all that is left.
- Return type:
str or None
Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Data.deformable['DVF_CT 01_CT 02'] >>> deform.check_model('reference') 'rebuilt'
- clear_mesh_slice_cache(plane=None)[source]#
Drop cached mesh slices for one plane, or all planes when plane is None.
Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Data.deformable['DVF_CT 01_CBCT 01'] >>> deform.clear_mesh_slice_cache('Axial') >>> deform.clear_mesh_slice_cache()
- connects(image_a, image_b)[source]#
True when the two images are on opposite sides of this registration (by name or frame of reference).
Examples
>>> import medicalimageanalysis as mia >>> mia.Data.deformable['DVF_CT 01_CBCT 01'].connects('Dose 01', 'CT 01') True
- invalidate_display()[source]#
Drop cached display fields and warped meshes. Only needed after editing
dvforrigid_matrixin place (replacing them is detected automatically).Examples
>>> import medicalimageanalysis as mia >>> deform = mia.Data.deformable['DVF_CT 01_CBCT 01'] >>> deform.dvf *= 0.5 >>> deform.invalidate_display()
- class medicalimageanalysis.structure.deformable.DeformableSide(image_id, frame=None, mesh=None, model_id=None, model_build=None, model_mesh=None)[source]#
Bases:
objectOne side (reference or moving) of a deformable registration. Built by
Deformable, not created directly.- Parameters:
- image_id#
Permanent id of the image this side was registered with (
Data.image[image_id]).- Type:
int or None
- frame#
Frame of Reference UID shared by every image on this side; ‘volume:<id>’ when the image has none.
- Type:
str or None
- mesh#
Surface used for the registration on this side, if any. Saved, so it stays viewable if the image is deleted.
- Type:
pyvista.PolyData, optional
- model_id#
Permanent id of the Model (on this side’s image) the registration was computed with, if any.
- Type:
int or None
- model_build#
That model’s
build_countwhen it was used: a different live value means it was rebuilt since.- Type:
int or None
- model_mesh#
Frozen copy of that model’s mesh, with its data arrays. Saved.
- Type:
pyvista.UnstructuredGrid or pyvista.PolyData, optional
- class medicalimageanalysis.structure.deformable.DeformableVisual(opacity=0.5, vector=None, percent=100.0)[source]#
Bases:
objectDisplay settings for a deformable registration.
- vector#
DVF overlay shown: None, ‘x’, ‘y’, ‘z’ or ‘magnitude’ (see
Deformable.compute_grid()).- Type:
str or None
- percent#
Deformation level used when a call passes no percent: 0 = rigid only, 100 = full. Set it with
Deformable.set_percent()so stale warped meshes are dropped.- Type: