PyAimsAlgo programming documentation

Overview

Many classes of AimsAlgo are actually found in the soma.aims module, after importing soma.aimsalgo (mainly because of the C++ namespace aims being merged by SIP bindings). The additional soma.aimsalgo module contains C++ algorithms which do ne reside inside the aims C++ namespace, and additional python submodules.

A more complete API is in Module: soma.aimsalgo.

Contents

In soma.aims module

class soma.aims.ResamplerFactory_FLOAT

ResamplerFactory classes are used to instantiate a Resampler object for the chosen interpolation type. The main method is getResampler().

getResampler(order) → resampler

Instantiate a Resampler of the given order.

Parameters:order (int) – order of interpolation: 0 is nearest neighbour (no interpolation), 1 is linear, 3 is cubic, etc. up to 7th order.
Returns:result – a new instance of the selected resampler type
Return type:Resampler_FLOAT
class soma.aims.FastMarching

Fast marching algorithm implementation, for images.

The fast marching is a propagation algorithm which is typically used to perform distance maps. It may use a speed map to locally change the propagation speed and distance. It may also be used to perform a Voronoi diagam, and to get Voronoi regions boundaries.

It is used the following way:

  • instantiate a FastMarching object, with specified connectivity
  • if needed, set the speed map (or inverse speed map) using setSpeedMap() or setInvSpeedMap()
  • propagate using one of the doit() methods. It will return the distanc map.
  • Voronoi and boundaries can then be retreived using voronoiVol(), midInterface() or midInterfaceVol()
doit(vol, worklabel, inlabel, outlabel)

Perform fast marching propagation from a label image “vol”.

This is a simplified interface to the other, more general, doit() method.

Propagation will take place in the region “worklabel”, from seeds “inlabel” and “outlabel”.

Parameters:
  • vol (rc_ptr_Volume_S16) – label volume to build distance map from. Contains seeds, propagation (work) region, and possibly forbidden regions
  • worklabel (int16) –
  • inlabel (int16) –
  • outlabel (int16) –
  • vol – label volume to build distance map from. Contains seeds, propagation (work) region, and possibly forbidden regions
  • worklabels (set_S16) – WARNING: the propagation labels in worklabels should be positive
  • seedlabels (set_S16) –
Returns:

  • distance_map (rc_ptr_Volume_FLOAT) – resulting distance map
  • doit(vol, worklabels, seedlabels)
  • Perform fast marching propagation from a label image “vol”.
  • Propagation will take place in the regions listed in “worklabels”, from
  • all seeds in the “seedlabels” list.

Returns:

distance_map – resulting distance map

Return type:

rc_ptr_Volume_FLOAT

midInterface(label1, label2)

get the interface between Voronoi regions label1 and label2, as a bucket.

The mid_interface option must have been used when instantiating the FastMarching object, and propagation maust have taken place.

midInterfaceLabels()

Voronoi interfaces labels. Given as a vector of pairs of labels

Returns:labels – in the shape ((label1, label2), (label3, label4), …)
Return type:tuple of tuples
midInterfaceVol(label1, label2)

get the interface between Voronoi regions label1 and label2, as a volume.

the mid_interface option must have been used when instantiating the FastMarching object, and propagation maust have taken place.

setInvSpeedMap(invspeed)

Sets an initialized inverse speed map (overrides any previous speed map).

Once a speed map (or inverse speed map) has been setup manually, it will be used during propagation in doit(), for only one run. The speed map data contents will be modified during the process, and the map will not be reusable for other data (seed voxels will be printed in it). The input inverse speed map object will also be modified since it is a shared reference, the algorithm will directly work in it.

Parameters:invspeed (rc_ptr_Volume_FLOAT) –
setSpeedMap(speed)

Sets an initialized speed map. The inverse speed will be deduced from it.

Once a speed map (or inverse speed map) has been setup manually, it will be used during propagation in doit(), for only one run. The speed map data contents will be modified during the process, and the map will not be reusable for other data (seed voxels will be printed in it).

Parameters:speed (rc_ptr_Volume_FLOAT) –
voronoiVol()

get the resulting Voronoi regions (after propagation)

class soma.aims.FastMarching_BucketMap_S16

Fast marching algorithm implementation, for buckets.

The fast marching is a propagation algorithm which is typically used to perform distance maps. It may use a speed map to locally change the propagation speed and distance. It may also be used to perform a Voronoi diagam, and to get Voronoi regions boundaries.

It is used the following way:

  • instantiate a FastMarching object, with specified connectivity
  • if needed, set the speed map (or inverse speed map) using setSpeedMap() or setInvSpeedMap()
  • propagate using one of the doit() methods. It will return the distanc map.
  • Voronoi and boundaries can then be retreived using voronoiVol(), midInterface() or midInterfaceVol()
doit(vol, worklabel, inlabel, outlabel)

Perform fast marching propagation from a label bucket “vol”.

This is a simplified interface to the other, more general, doit() method.

Propagation will take place in the region “worklabel”, from seeds “inlabel” and “outlabel”.

Parameters:
  • vol (rc_ptr_BucketMap_S16) – label bucket to build distance map from. Contains seeds, propagation (work) region. Propagation outside the bucket will be forbidden.
  • worklabel (int16) –
  • inlabel (int16) –
  • outlabel (int16) –
  • vol – label bucket to build distance map from. Contains seeds, propagation (work) region, and possibly forbidden regions
  • worklabels (set_S16) –
  • seedlabels (set_S16) –
Returns:

  • distance_map (rc_ptr_Volume_FLOAT) – resulting distance map
  • doit(vol, worklabels, seedlabels)
  • Perform fast marching propagation from a label bucket “vol”.
  • Propagation will take place in the regions listed in “worklabels”, from
  • all seeds in the “seedlabels” list.

Returns:

distance_map – resulting distance map

Return type:

rc_ptr_Volume_FLOAT

midInterface(label1, label2)

get the interface between Voronoi regions label1 and label2, as a bucket.

The mid_interface option must have been used when instantiating the FastMarching object, and propagation maust have taken place.

midInterfaceLabels()

Voronoi interfaces labels. Given as a vector of pairs of labels

Returns:labels – in the shape ((label1, label2), (label3, label4), …)
Return type:tuple of tuples
midInterfaceVol(label1, label2)

get the interface between Voronoi regions label1 and label2, as a volume.

the mid_interface option must have been used when instantiating the FastMarching object, and propagation maust have taken place.

setInvSpeedMap(invspeed)

Sets an initialized inverse speed map (overrides any previous speed map).

Parameters:invspeed (rc_ptr_BucketMap_FLOAT) –
setSpeedMap(speed)

Sets an initialized speed map. The inverse speed will be deduced from it.

Parameters:speed (rc_ptr_BucketMap_FLOAT) –
voronoiVol()

get the resulting Voronoi regions (after propagation)

class soma.aims.FoldArgOverSegment
class soma.aims.FoldGraphAttributes
setMaxThreads()

Sets the maxumum number of threads used in multithreaded-enabled parts. 1 means mono-threaded, 0 means une thread per CPU. A negative value means one thread per CPU, but never use more CPUs than the absolute value of the given number.

class soma.aims.GradientAdvection
class soma.aims.MeshInterpoler
class soma.aims.RegularBinnedHistogram_FLOAT

** MESHDISTANCE**

class soma.aims.meshdistance
MeshVoronoi(mesh, inittex, background, forbidden, dist, connexity, object)

MeshVoronoi( mesh, inittex, dist, connexity, object )

Compute a geodesic voronoi diagram (dist = MAX_FLOAT,object=true ) of objects defined in inittex. The background has the label Back and the objects have a positive label. The distance can be euclidean geodesic (connexity=false) or just the connexity of the triangulation(connexity=true) This function can as well be used for dilation(object=true) / erosion(object=false) using the parameter dist as the size of the structuring element.

Parameters:
Returns:

voronoi_texture

Return type:

TimeTexture_S16

soma.aims.meshdistance.MeshDilation()
soma.aims.meshdistance.MeshDistance()
soma.aims.meshdistance.MeshErosion()
soma.aims.meshdistance.MeshVoronoiStepbyStep()
class soma.aims.GeodesicPath

Geodesic paths or distance maps, using the Dijkstra algorithm

Ex:

from soma import aims, aimsalgo
mesh = aims.read('mesh.gii')
gp = GeodesicPath(mesh, 0, 0)
dmap = TimeTexture('FLOAT')
// get a distance map from vertex no 12
dmax = gp.distanceMap_1_N_ind(12, dmap[0].data(), 0)
aims.write(dmax, 'distance.gii')

It is possible to get distance maps, or paths between two or more points.

distanceMap_1_N_ind()

Compute a distance map from a given point

Parameters:
  • source (int) – index of the starting point (vertex number)
  • distanceMap (vector_FLOAT) – output distance map, the vector can be empty, it will be filled with as many values as the mesh vertices number.
  • type_distance (int) –
    0:
    weighted distance,
    1:
    euclidean distance
Returns:

length – max distance

Return type:

float

longestPath_1_N_ind(source, targets, type_distance)
Parameters:
  • source (unsigned) –
  • targets (vector_U32) –
  • type_distance (int) –
Returns:

  • target (unsigned)
  • length (float)

longestPath_N_N_ind(points, type_distance)
Parameters:
Returns:

  • s (int)
  • d (int)
  • length (float)

shortestPath_1_1_1_ind(source, middle, target)
Parameters:
  • source (unsigned) –
  • middle (unsigned) –
  • target (unsigned) –
Returns:

path

Return type:

vector_U32

shortestPath_1_1_ind(source, target)
Parameters:
  • source (unsigned) –
  • target (unsigned) –
  • source
  • target
  • subset (TimeTexture_S16) –
Returns:

  • path (vector_U32)
  • shortestPath_1_1_ind(source, target, subset)

Returns:

path

Return type:

vector_U32

shortestPath_1_1_ind_xyz(source, target, indice, coord3D)
Parameters:
shortestPath_1_1_len(source, target)
Parameters:
  • source (unsigned) –
  • target (unsigned) –
Returns:

length

Return type:

float

shortestPath_1_1_tex(source, target, texturevalue, tex)
Parameters:
  • source (unsigned) –
  • target (unsigned) –
  • texturevalue (float) –
  • tex (TimeTexture_S16 (output)) –
shortestPath_1_N_ind(source, targets)
Parameters:
Returns:

  • target (unsigned)
  • length (float)

class soma.aims.Spam
class soma.aims.SpamBase
class soma.aims.SpamFromLikelihood
class soma.aims.SplineFfd(*args)

FFD vector field deformation transform

Free Form Deformation is the registration technique used to build the vector fields. This class is dedicated to the application of the vector field deformation to transform coordinates.

Vector fields are stored in volumes AimsData_POINT3DF.

This Spline FFD uses cubic spline interpolation between displacement vectors to process transformed coordinates. See TrilinearFfd for a variant using trilinear interpolation.

This class is the “base” vector field deformation class, which can perform point-to-point transformation. It is used by various higher-level classes or functions to work on higher-level objects:

To resample full 2D or 3D images, see the Resampler class and its derived classes (see also ResamplerFactory).

As a Transformation3d specialization, the main method of this class is the transform() method, which actually performs 3D coordinates transformation. The other methods can be seen as “internal machinery”.

see transformMesh, transformBucket, transformGraph and BundleTransformer to apply vector field deformations to various types of objects.

class soma.aims.TrilinearFfd(*args)

FFD vector field deformation transform

Free Form Deformation is the registration technique used to build the vector fields. This class is dedicated to the application of the vector field deformation to transform coordinates.

This is a variant of SplineFfd which is performing trilinear interpolation between displacement vectors. See SplineFfd for details.

soma.aimsalgo module

soma.aimsalgo.AimsDistanceFrontPropagation()
soma.aimsalgo.AimsMorphoChamferClosing()

Please use preferably MorphoGreyLevel_* classes.

soma.aimsalgo.AimsMorphoChamferDilation()

Please use preferably MorphoGreyLevel_* classes.

soma.aimsalgo.AimsMorphoChamferErosion()

Please use preferably MorphoGreyLevel_* classes.

soma.aimsalgo.AimsMorphoChamferOpening()

Please use preferably MorphoGreyLevel_* classes.

soma.aimsalgo.AimsMorphoClosing()
soma.aimsalgo.AimsMorphoDilation()
soma.aimsalgo.AimsMorphoErosion()
soma.aimsalgo.AimsMorphoOpening()
soma.aimsalgo.AimsVoronoiFrontPropagation()
soma.aimsalgo.AimsMeshLabelConnectedComponent()
class soma.aimsalgo.DiffusionSmoother_S16
class soma.aimsalgo.DiffusionSmoother_FLOAT
class soma.aimsalgo.Gaussian2DSmoothing_DOUBLE
class soma.aimsalgo.Gaussian2DSmoothing_FLOAT
class soma.aimsalgo.Gaussian2DSmoothing_S16
class soma.aimsalgo.Gaussian2DSmoothing_S32
class soma.aimsalgo.Gaussian2DSmoothing_U16
class soma.aimsalgo.Gaussian2DSmoothing_U32
class soma.aimsalgo.Gaussian2DSmoothing_U8
class soma.aimsalgo.Gaussian3DSmoothing_DOUBLE

3D Deriche’s recursive gaussian smoothing filter

doit(volume)

Actually perform the smoothing on the given data.

Parameters:volume (Volume or AimsData) – data to be smoothed
Returns:smoothed – smoothed volume
Return type:AimsData
class soma.aimsalgo.Gaussian3DSmoothing_FLOAT

3D Deriche’s recursive gaussian smoothing filter

class soma.aimsalgo.Gaussian3DSmoothing_S16

3D Deriche’s recursive gaussian smoothing filter

class soma.aimsalgo.Gaussian3DSmoothing_S32

3D Deriche’s recursive gaussian smoothing filter

class soma.aimsalgo.Gaussian3DSmoothing_U16

3D Deriche’s recursive gaussian smoothing filter

class soma.aimsalgo.Gaussian3DSmoothing_U32

3D Deriche’s recursive gaussian smoothing filter

class soma.aimsalgo.Gaussian3DSmoothing_U8

3D Deriche’s recursive gaussian smoothing filter

class soma.aimsalgo.GeneralSampler_FLOAT_3
class soma.aimsalgo.GeometricMoment_DOUBLE
class soma.aimsalgo.AimsGradient_FLOAT
class soma.aimsalgo.Histogram_FLOAT
class soma.aimsalgo.MedianSmoothing_DOUBLE
class soma.aimsalgo.MedianSmoothing_FLOAT
class soma.aimsalgo.MedianSmoothing_S16
class soma.aimsalgo.MedianSmoothing_S32
class soma.aimsalgo.MedianSmoothing_U16
class soma.aimsalgo.MedianSmoothing_U32
class soma.aimsalgo.MedianSmoothing_U8
class soma.aimsalgo.Mesher

Mesh binary objects in a volume and produce surface meshes.

doit(volume, filename_base, write_mode="binar")

Mesh every interface of objects in the input label volume. Each mesh is written in a separate file. Files are numbered according to objects interfaces (label1_label2) and an interface number for this pair of objects. write_mode is an old flag to write files in ascii or binary modes. It’s obsolete.

class soma.aimsalgo.MomentInvariant_FLOAT
class soma.aimsalgo.Moment_FLOAT
class soma.aimsalgo.TriangulationMoment
soma.aimsalgo.transformGraph()
transformGraph(graph, direct_transformation, inverse_transformation,
vs=aims.Point3df(0., 0., 0.))

Apply a spatial transformation to all objects contained in a Graph.

The graph is modified in-place.

An inverse transformation is necessary for correctly transforming Buckets (see resampleBucket). If inverse_transformation is NULL, buckets will be transformed with the push-forward method only (transformBucketDirect).

Warning

Volumes are not transformed, neither are graph attributes. Please run AimsFoldArgAtt to fix the values of basic attributes, or the CorticalFoldsGraphUpgradeFromOld BrainVisa process, which can be found under Morphologist/Sulci/graphmanipulation, for a complete update.

soma.aimsalgo.transformMesh(mesh, direct_transformation)

Apply a spatial transformation to a segments mesh (AimsTimeSurface).

The mesh is transformed in-place and modified.

Each vertex of the mesh is transformed according to the supplied transformation. Normals are re-calculated from the new vertex positions. transformMesh(mesh, direct_transformation)

Apply a spatial transformation to a triangles mesh (AimsTimeSurface)

The mesh is transformed in-place and modified.

Each vertex of the mesh is transformed according to the supplied transformation. Normals are re-calculated from the new vertex positions. transformMesh(mesh, direct_transformation)

Apply a spatial transformation to a quads mesh (AimsTimeSurface)

The mesh is transformed in-place and modified.

Each vertex of the mesh is transformed according to the supplied transformation. Normals are re-calculated from the new vertex positions.

soma.aimsalgo.transformBucketDirect(bck, direct_transformation, vs=aims.Point3df(0., 0., 0.))

Apply a spatial transformation to a BucketMap

Each voxel of the input bucket is transformed with direct_transformation, and the closest voxel of the output bucket is set. The voxel size of the output bucket can optionally be specified in vs. By default, the same voxel size as the input bucket is used.

Warning

This method provides no guarantees of topology preservation; in fact it will create holes in the resulting bucket, particularly when upsampling. When possible, you should use resampleBucket() instead, which performs nearest-neighbour resampling.

soma.aimsalgo.resampleBucket()
resampleBucket(bck, direct_transformation, inverse_transformation,
vs=aims.Point3df(0., 0., 0.), also_pushforward=True)

Apply a spatial transformation to a BucketMap.

The bucket is transformed by resampling, using a pull-back method in the same way as nearest neighbour resampling of a Volume.

Pure pull-back resampling does not behave well when downsampling (it introduces holes), so by default this function returns the union of voxels transformed using the pushforward and pullback methods. Set also_pushforward to false to disable this behaviour and only perform pure pullback.

The voxel size of the output bucket can optionally be specified in vs. By default, the same voxel size as the input bucket is used.

Warning

Alhtough this method is more reliable than transformBucketDirect, it still provides no guarantees of topology preservation.

class soma.aimsalgo.CubicResampler_DOUBLE(*args)

Volume resampler using cubic interpolation.

The resampling API is described in the base classes, Resampler_DOUBLE and SplineResampler_DOUBLE.

class soma.aimsalgo.CubicResampler_FLOAT(*args)

Volume resampler using cubic interpolation.

The resampling API is described in the base classes, Resampler_FLOAT and SplineResampler_FLOAT.

class soma.aimsalgo.CubicResampler_HSV(*args)

Volume resampler using cubic interpolation.

The resampling API is described in the base classes, Resampler_HSV and SplineResampler_HSV.

class soma.aimsalgo.CubicResampler_POINT3DF(*args)

Volume resampler using cubic interpolation.

The resampling API is described in the base classes, Resampler_POINT3DF and SplineResampler_POINT3DF.

class soma.aimsalgo.CubicResampler_RGB(*args)

Volume resampler using cubic interpolation.

The resampling API is described in the base classes, Resampler_RGB and SplineResampler_RGB.

class soma.aimsalgo.CubicResampler_RGBA(*args)

Volume resampler using cubic interpolation.

The resampling API is described in the base classes, Resampler_RGBA and SplineResampler_RGBA.

class soma.aimsalgo.CubicResampler_S16(*args)

Volume resampler using cubic interpolation.

The resampling API is described in the base classes, Resampler_S16 and SplineResampler_S16.

class soma.aimsalgo.CubicResampler_S32(*args)

Volume resampler using cubic interpolation.

The resampling API is described in the base classes, Resampler_S32 and SplineResampler_S32.

class soma.aimsalgo.CubicResampler_U16(*args)

Volume resampler using cubic interpolation.

The resampling API is described in the base classes, Resampler_U16 and SplineResampler_U16.

class soma.aimsalgo.CubicResampler_U32(*args)

Volume resampler using cubic interpolation.

The resampling API is described in the base classes, Resampler_U32 and SplineResampler_U32.

class soma.aimsalgo.CubicResampler_U8(*args)

Volume resampler using cubic interpolation.

The resampling API is described in the base classes, Resampler_U8 and SplineResampler_U8.

class soma.aimsalgo.Gaussian3DSmoothing_DOUBLE

3D Deriche’s recursive gaussian smoothing filter

doit(volume)

Actually perform the smoothing on the given data.

Parameters:volume (Volume or AimsData) – data to be smoothed
Returns:smoothed – smoothed volume
Return type:AimsData
class soma.aimsalgo.Gaussian3DSmoothing_FLOAT

3D Deriche’s recursive gaussian smoothing filter

doit(volume)

Actually perform the smoothing on the given data.

Parameters:volume (Volume or AimsData) – data to be smoothed
Returns:smoothed – smoothed volume
Return type:AimsData
class soma.aimsalgo.Gaussian3DSmoothing_S16

3D Deriche’s recursive gaussian smoothing filter

doit(volume)

Actually perform the smoothing on the given data.

Parameters:volume (Volume or AimsData) – data to be smoothed
Returns:smoothed – smoothed volume
Return type:AimsData
class soma.aimsalgo.Gaussian3DSmoothing_S32

3D Deriche’s recursive gaussian smoothing filter

doit(volume)

Actually perform the smoothing on the given data.

Parameters:volume (Volume or AimsData) – data to be smoothed
Returns:smoothed – smoothed volume
Return type:AimsData
class soma.aimsalgo.Gaussian3DSmoothing_U16

3D Deriche’s recursive gaussian smoothing filter

doit(volume)

Actually perform the smoothing on the given data.

Parameters:volume (Volume or AimsData) – data to be smoothed
Returns:smoothed – smoothed volume
Return type:AimsData
class soma.aimsalgo.Gaussian3DSmoothing_U32

3D Deriche’s recursive gaussian smoothing filter

doit(volume)

Actually perform the smoothing on the given data.

Parameters:volume (Volume or AimsData) – data to be smoothed
Returns:smoothed – smoothed volume
Return type:AimsData
class soma.aimsalgo.Gaussian3DSmoothing_U8

3D Deriche’s recursive gaussian smoothing filter

doit(volume)

Actually perform the smoothing on the given data.

Parameters:volume (Volume or AimsData) – data to be smoothed
Returns:smoothed – smoothed volume
Return type:AimsData
class soma.aimsalgo.LinearResampler_DOUBLE(*args)

Volume resampler using linear (order 1) interpolation.

The resampling API is described in the base classes, Resampler_DOUBLE and SplineResampler_DOUBLE.

class soma.aimsalgo.LinearResampler_FLOAT(*args)

Volume resampler using linear (order 1) interpolation.

The resampling API is described in the base classes, Resampler_FLOAT and SplineResampler_FLOAT.

class soma.aimsalgo.LinearResampler_HSV(*args)

Volume resampler using linear (order 1) interpolation.

The resampling API is described in the base classes, Resampler_HSV and SplineResampler_HSV.

class soma.aimsalgo.LinearResampler_POINT3DF(*args)

Volume resampler using linear (order 1) interpolation.

The resampling API is described in the base classes, Resampler_POINT3DF and SplineResampler_POINT3DF.

class soma.aimsalgo.LinearResampler_RGB(*args)

Volume resampler using linear (order 1) interpolation.

The resampling API is described in the base classes, Resampler_RGB and SplineResampler_RGB.

class soma.aimsalgo.LinearResampler_RGBA(*args)

Volume resampler using linear (order 1) interpolation.

The resampling API is described in the base classes, Resampler_RGBA and SplineResampler_RGBA.

class soma.aimsalgo.LinearResampler_S16(*args)

Volume resampler using linear (order 1) interpolation.

The resampling API is described in the base classes, Resampler_S16 and SplineResampler_S16.

class soma.aimsalgo.LinearResampler_S32(*args)

Volume resampler using linear (order 1) interpolation.

The resampling API is described in the base classes, Resampler_S32 and SplineResampler_S32.

class soma.aimsalgo.LinearResampler_U16(*args)

Volume resampler using linear (order 1) interpolation.

The resampling API is described in the base classes, Resampler_U16 and SplineResampler_U16.

class soma.aimsalgo.LinearResampler_U32(*args)

Volume resampler using linear (order 1) interpolation.

The resampling API is described in the base classes, Resampler_U32 and SplineResampler_U32.

class soma.aimsalgo.LinearResampler_U8(*args)

Volume resampler using linear (order 1) interpolation.

The resampling API is described in the base classes, Resampler_U8 and SplineResampler_U8.

class soma.aimsalgo.MajorityLabelResampler_DOUBLE(*args)

Volume resampler using majority vote interpolation.

The resampling API is described in the base classes, Resampler_DOUBLE and SplineResampler_DOUBLE.

class soma.aimsalgo.MajorityLabelResampler_FLOAT(*args)

Volume resampler using majority vote interpolation.

The resampling API is described in the base classes, Resampler_FLOAT and SplineResampler_FLOAT.

class soma.aimsalgo.MajorityLabelResampler_HSV(*args)

Volume resampler using majority vote interpolation.

The resampling API is described in the base classes, Resampler_HSV and SplineResampler_HSV.

class soma.aimsalgo.MajorityLabelResampler_POINT3DF(*args)

Volume resampler using majority vote interpolation.

The resampling API is described in the base classes, Resampler_POINT3DF and SplineResampler_POINT3DF.

class soma.aimsalgo.MajorityLabelResampler_RGB(*args)

Volume resampler using majority vote interpolation.

The resampling API is described in the base classes, Resampler_RGB and SplineResampler_RGB.

class soma.aimsalgo.MajorityLabelResampler_RGBA(*args)

Volume resampler using majority vote interpolation.

The resampling API is described in the base classes, Resampler_RGBA and SplineResampler_RGBA.

class soma.aimsalgo.MajorityLabelResampler_S16(*args)

Volume resampler using majority vote interpolation.

The resampling API is described in the base classes, Resampler_S16 and SplineResampler_S16.

class soma.aimsalgo.MajorityLabelResampler_S32(*args)

Volume resampler using majority vote interpolation.

The resampling API is described in the base classes, Resampler_S32 and SplineResampler_S32.

class soma.aimsalgo.MajorityLabelResampler_U16(*args)

Volume resampler using majority vote interpolation.

The resampling API is described in the base classes, Resampler_U16 and SplineResampler_U16.

class soma.aimsalgo.MajorityLabelResampler_U32(*args)

Volume resampler using majority vote interpolation.

The resampling API is described in the base classes, Resampler_U32 and SplineResampler_U32.

class soma.aimsalgo.MajorityLabelResampler_U8(*args)

Volume resampler using majority vote interpolation.

The resampling API is described in the base classes, Resampler_U8 and SplineResampler_U8.

class soma.aimsalgo.MaskLinearResampler_S16(*args)

Volume resampler using linear (order 1) interpolation.

This resampler shows unreliable behaviour: depending of the platform it does not always resample the last element along each axis correctly. Also, it uses some clever optimizations that do not check for overflow. If you need such a masked resampler, please consider contributing a fixed version.

This resampler will consider input voxels that are equal to -32768 (hard-coded) as masked. The mask value (-32768) will always be returned for any interpolation involving a masked voxel.

The default background value for this resampler is -32768 (same as the mask value).

The resampling API is described in the base class, Resampler_S16.

class soma.aimsalgo.MedianResampler_DOUBLE(*args)

Volume resampler using median interpolation.

The resampling API is described in the base classes, Resampler_DOUBLE and SplineResampler_DOUBLE.

class soma.aimsalgo.MedianResampler_FLOAT(*args)

Volume resampler using median interpolation.

The resampling API is described in the base classes, Resampler_FLOAT and SplineResampler_FLOAT.

class soma.aimsalgo.MedianResampler_HSV(*args)

Volume resampler using median interpolation.

The resampling API is described in the base classes, Resampler_HSV and SplineResampler_HSV.

class soma.aimsalgo.MedianResampler_POINT3DF(*args)

Volume resampler using median interpolation.

The resampling API is described in the base classes, Resampler_POINT3DF and SplineResampler_POINT3DF.

class soma.aimsalgo.MedianResampler_RGB(*args)

Volume resampler using median interpolation.

The resampling API is described in the base classes, Resampler_RGB and SplineResampler_RGB.

class soma.aimsalgo.MedianResampler_RGBA(*args)

Volume resampler using median interpolation.

The resampling API is described in the base classes, Resampler_RGBA and SplineResampler_RGBA.

class soma.aimsalgo.MedianResampler_S16(*args)

Volume resampler using median interpolation.

The resampling API is described in the base classes, Resampler_S16 and SplineResampler_S16.

class soma.aimsalgo.MedianResampler_S32(*args)

Volume resampler using median interpolation.

The resampling API is described in the base classes, Resampler_S32 and SplineResampler_S32.

class soma.aimsalgo.MedianResampler_U16(*args)

Volume resampler using median interpolation.

The resampling API is described in the base classes, Resampler_U16 and SplineResampler_U16.

class soma.aimsalgo.MedianResampler_U32(*args)

Volume resampler using median interpolation.

The resampling API is described in the base classes, Resampler_U32 and SplineResampler_U32.

class soma.aimsalgo.MedianResampler_U8(*args)

Volume resampler using median interpolation.

The resampling API is described in the base classes, Resampler_U8 and SplineResampler_U8.

class soma.aimsalgo.Mesher

Mesh binary objects in a volume and produce surface meshes.

doit(volume, filename_base, write_mode="binar")

Mesh every interface of objects in the input label volume. Each mesh is written in a separate file. Files are numbered according to objects interfaces (label1_label2) and an interface number for this pair of objects. write_mode is an old flag to write files in ascii or binary modes. It’s obsolete.

class soma.aimsalgo.MorphoGreyLevel_DOUBLE

Grey-level mathematical morphology.

when enabled, on binary images, the chamfer-based morphomath is used instead of the grey-level one. This is the default as it is way faster (see setChamferBinaryMorphoEnabled).

In binary mode, the input data (volume) should contain a border of “sufficent” size. The border size will be checked, and a new volume with larger border will be temporarily allocated and used if needed, but it is more efficient (and consumes less memory) if this border is already allocated in the input image.

Grey-level operations do not need a border in input images, the test is included in the algorithm (which makes it even slower).

See the method neededBorderWidth().

This class thus regroups all basic morphological operations, and makes obsolete direct calls to AimsMorphoChamferErosion(), AimsMorphoChamferDilation(), AimsMorphoChamferClosing(), AimsMorphoChamferOpening().

chamferFactor()

chamfer factor is used to store chamfer distances as int with a sufficient precision. Used only in binary operations. The default is 50.

chamferMaskSize()

Get the chamfer mask size used in binary operations. The default is 3x3x3.

Returns:mask_size – size in the 3 directions, in voxels
Return type:Point3df
doClosing(dataIn, radius)

Closing operation (dilation + erosion)

Parameters:
  • dataIn (rc_ptr_Volume_DOUBLE) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_DOUBLE

doDilation(dataIn, radius)

Dilation operation

Parameters:
  • dataIn (rc_ptr_Volume_DOUBLE) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_DOUBLE

doErosion(dataIn, radius)

Erosion operation

Parameters:
  • dataIn (rc_ptr_Volume_DOUBLE) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_DOUBLE

doOpening(dataIn, radius)

Opening operation (erosion + dilation)

Parameters:
  • dataIn (rc_ptr_Volume_DOUBLE) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_DOUBLE

isBinary()

Tells if the given volume is considered a binary volume and thus is compatible with binary fast operators.

isChamferBinaryMorphoEnabled()

True if binary moprhological operations are allowed (when binary input data are detected)

neededBorderWidth()

border width needed to perform chamfer mask operations, in binary mode (int).

setChamferBinaryMorphoEnabled(enabled)

Enable or disable binary moprhological operations (when binary input data are detected)

Parameters:enabled (bool) –
setChamferFactor(factor)

Set the chamfer distance factor, used in binary operations.

setChamferMaskSize(size)

Set the chamfer mask size (for binary operations)

Parameters:size (Point3d) – mask size triplet, in voxels
class soma.aimsalgo.MorphoGreyLevel_FLOAT

Grey-level mathematical morphology.

when enabled, on binary images, the chamfer-based morphomath is used instead of the grey-level one. This is the default as it is way faster (see setChamferBinaryMorphoEnabled).

In binary mode, the input data (volume) should contain a border of “sufficent” size. The border size will be checked, and a new volume with larger border will be temporarily allocated and used if needed, but it is more efficient (and consumes less memory) if this border is already allocated in the input image.

Grey-level operations do not need a border in input images, the test is included in the algorithm (which makes it even slower).

See the method neededBorderWidth().

This class thus regroups all basic morphological operations, and makes obsolete direct calls to AimsMorphoChamferErosion(), AimsMorphoChamferDilation(), AimsMorphoChamferClosing(), AimsMorphoChamferOpening().

chamferFactor()

chamfer factor is used to store chamfer distances as int with a sufficient precision. Used only in binary operations. The default is 50.

chamferMaskSize()

Get the chamfer mask size used in binary operations. The default is 3x3x3.

Returns:mask_size – size in the 3 directions, in voxels
Return type:Point3df
doClosing(dataIn, radius)

Closing operation (dilation + erosion)

Parameters:
  • dataIn (rc_ptr_Volume_FLOAT) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_FLOAT

doDilation(dataIn, radius)

Dilation operation

Parameters:
  • dataIn (rc_ptr_Volume_FLOAT) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_FLOAT

doErosion(dataIn, radius)

Erosion operation

Parameters:
  • dataIn (rc_ptr_Volume_FLOAT) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_FLOAT

doOpening(dataIn, radius)

Opening operation (erosion + dilation)

Parameters:
  • dataIn (rc_ptr_Volume_FLOAT) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_FLOAT

isBinary()

Tells if the given volume is considered a binary volume and thus is compatible with binary fast operators.

isChamferBinaryMorphoEnabled()

True if binary moprhological operations are allowed (when binary input data are detected)

neededBorderWidth()

border width needed to perform chamfer mask operations, in binary mode (int).

setChamferBinaryMorphoEnabled(enabled)

Enable or disable binary moprhological operations (when binary input data are detected)

Parameters:enabled (bool) –
setChamferFactor(factor)

Set the chamfer distance factor, used in binary operations.

setChamferMaskSize(size)

Set the chamfer mask size (for binary operations)

Parameters:size (Point3d) – mask size triplet, in voxels
class soma.aimsalgo.MorphoGreyLevel_S16

Grey-level mathematical morphology.

when enabled, on binary images, the chamfer-based morphomath is used instead of the grey-level one. This is the default as it is way faster (see setChamferBinaryMorphoEnabled).

In binary mode, the input data (volume) should contain a border of “sufficent” size. The border size will be checked, and a new volume with larger border will be temporarily allocated and used if needed, but it is more efficient (and consumes less memory) if this border is already allocated in the input image.

Grey-level operations do not need a border in input images, the test is included in the algorithm (which makes it even slower).

See the method neededBorderWidth().

This class thus regroups all basic morphological operations, and makes obsolete direct calls to AimsMorphoChamferErosion(), AimsMorphoChamferDilation(), AimsMorphoChamferClosing(), AimsMorphoChamferOpening().

chamferFactor()

chamfer factor is used to store chamfer distances as int with a sufficient precision. Used only in binary operations. The default is 50.

chamferMaskSize()

Get the chamfer mask size used in binary operations. The default is 3x3x3.

Returns:mask_size – size in the 3 directions, in voxels
Return type:Point3df
doClosing(dataIn, radius)

Closing operation (dilation + erosion)

Parameters:
  • dataIn (rc_ptr_Volume_S16) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_S16

doDilation(dataIn, radius)

Dilation operation

Parameters:
  • dataIn (rc_ptr_Volume_S16) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_S16

doErosion(dataIn, radius)

Erosion operation

Parameters:
  • dataIn (rc_ptr_Volume_S16) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_S16

doOpening(dataIn, radius)

Opening operation (erosion + dilation)

Parameters:
  • dataIn (rc_ptr_Volume_S16) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_S16

isBinary()

Tells if the given volume is considered a binary volume and thus is compatible with binary fast operators.

isChamferBinaryMorphoEnabled()

True if binary moprhological operations are allowed (when binary input data are detected)

neededBorderWidth()

border width needed to perform chamfer mask operations, in binary mode (int).

setChamferBinaryMorphoEnabled(enabled)

Enable or disable binary moprhological operations (when binary input data are detected)

Parameters:enabled (bool) –
setChamferFactor(factor)

Set the chamfer distance factor, used in binary operations.

setChamferMaskSize(size)

Set the chamfer mask size (for binary operations)

Parameters:size (Point3d) – mask size triplet, in voxels
class soma.aimsalgo.MorphoGreyLevel_S32

Grey-level mathematical morphology.

when enabled, on binary images, the chamfer-based morphomath is used instead of the grey-level one. This is the default as it is way faster (see setChamferBinaryMorphoEnabled).

In binary mode, the input data (volume) should contain a border of “sufficent” size. The border size will be checked, and a new volume with larger border will be temporarily allocated and used if needed, but it is more efficient (and consumes less memory) if this border is already allocated in the input image.

Grey-level operations do not need a border in input images, the test is included in the algorithm (which makes it even slower).

See the method neededBorderWidth().

This class thus regroups all basic morphological operations, and makes obsolete direct calls to AimsMorphoChamferErosion(), AimsMorphoChamferDilation(), AimsMorphoChamferClosing(), AimsMorphoChamferOpening().

chamferFactor()

chamfer factor is used to store chamfer distances as int with a sufficient precision. Used only in binary operations. The default is 50.

chamferMaskSize()

Get the chamfer mask size used in binary operations. The default is 3x3x3.

Returns:mask_size – size in the 3 directions, in voxels
Return type:Point3df
doClosing(dataIn, radius)

Closing operation (dilation + erosion)

Parameters:
  • dataIn (rc_ptr_Volume_S32) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_S32

doDilation(dataIn, radius)

Dilation operation

Parameters:
  • dataIn (rc_ptr_Volume_S32) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_S32

doErosion(dataIn, radius)

Erosion operation

Parameters:
  • dataIn (rc_ptr_Volume_S32) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_S32

doOpening(dataIn, radius)

Opening operation (erosion + dilation)

Parameters:
  • dataIn (rc_ptr_Volume_S32) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_S32

isBinary()

Tells if the given volume is considered a binary volume and thus is compatible with binary fast operators.

isChamferBinaryMorphoEnabled()

True if binary moprhological operations are allowed (when binary input data are detected)

neededBorderWidth()

border width needed to perform chamfer mask operations, in binary mode (int).

setChamferBinaryMorphoEnabled(enabled)

Enable or disable binary moprhological operations (when binary input data are detected)

Parameters:enabled (bool) –
setChamferFactor(factor)

Set the chamfer distance factor, used in binary operations.

setChamferMaskSize(size)

Set the chamfer mask size (for binary operations)

Parameters:size (Point3d) – mask size triplet, in voxels
class soma.aimsalgo.MorphoGreyLevel_U16

Grey-level mathematical morphology.

when enabled, on binary images, the chamfer-based morphomath is used instead of the grey-level one. This is the default as it is way faster (see setChamferBinaryMorphoEnabled).

In binary mode, the input data (volume) should contain a border of “sufficent” size. The border size will be checked, and a new volume with larger border will be temporarily allocated and used if needed, but it is more efficient (and consumes less memory) if this border is already allocated in the input image.

Grey-level operations do not need a border in input images, the test is included in the algorithm (which makes it even slower).

See the method neededBorderWidth().

This class thus regroups all basic morphological operations, and makes obsolete direct calls to AimsMorphoChamferErosion(), AimsMorphoChamferDilation(), AimsMorphoChamferClosing(), AimsMorphoChamferOpening().

chamferFactor()

chamfer factor is used to store chamfer distances as int with a sufficient precision. Used only in binary operations. The default is 50.

chamferMaskSize()

Get the chamfer mask size used in binary operations. The default is 3x3x3.

Returns:mask_size – size in the 3 directions, in voxels
Return type:Point3df
doClosing(dataIn, radius)

Closing operation (dilation + erosion)

Parameters:
  • dataIn (rc_ptr_Volume_U16) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_U16

doDilation(dataIn, radius)

Dilation operation

Parameters:
  • dataIn (rc_ptr_Volume_U16) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_U16

doErosion(dataIn, radius)

Erosion operation

Parameters:
  • dataIn (rc_ptr_Volume_U16) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_U16

doOpening(dataIn, radius)

Opening operation (erosion + dilation)

Parameters:
  • dataIn (rc_ptr_Volume_U16) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_U16

isBinary()

Tells if the given volume is considered a binary volume and thus is compatible with binary fast operators.

isChamferBinaryMorphoEnabled()

True if binary moprhological operations are allowed (when binary input data are detected)

neededBorderWidth()

border width needed to perform chamfer mask operations, in binary mode (int).

setChamferBinaryMorphoEnabled(enabled)

Enable or disable binary moprhological operations (when binary input data are detected)

Parameters:enabled (bool) –
setChamferFactor(factor)

Set the chamfer distance factor, used in binary operations.

setChamferMaskSize(size)

Set the chamfer mask size (for binary operations)

Parameters:size (Point3d) – mask size triplet, in voxels
class soma.aimsalgo.MorphoGreyLevel_U32

Grey-level mathematical morphology.

when enabled, on binary images, the chamfer-based morphomath is used instead of the grey-level one. This is the default as it is way faster (see setChamferBinaryMorphoEnabled).

In binary mode, the input data (volume) should contain a border of “sufficent” size. The border size will be checked, and a new volume with larger border will be temporarily allocated and used if needed, but it is more efficient (and consumes less memory) if this border is already allocated in the input image.

Grey-level operations do not need a border in input images, the test is included in the algorithm (which makes it even slower).

See the method neededBorderWidth().

This class thus regroups all basic morphological operations, and makes obsolete direct calls to AimsMorphoChamferErosion(), AimsMorphoChamferDilation(), AimsMorphoChamferClosing(), AimsMorphoChamferOpening().

chamferFactor()

chamfer factor is used to store chamfer distances as int with a sufficient precision. Used only in binary operations. The default is 50.

chamferMaskSize()

Get the chamfer mask size used in binary operations. The default is 3x3x3.

Returns:mask_size – size in the 3 directions, in voxels
Return type:Point3df
doClosing(dataIn, radius)

Closing operation (dilation + erosion)

Parameters:
  • dataIn (rc_ptr_Volume_U32) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_U32

doDilation(dataIn, radius)

Dilation operation

Parameters:
  • dataIn (rc_ptr_Volume_U32) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_U32

doErosion(dataIn, radius)

Erosion operation

Parameters:
  • dataIn (rc_ptr_Volume_U32) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_U32

doOpening(dataIn, radius)

Opening operation (erosion + dilation)

Parameters:
  • dataIn (rc_ptr_Volume_U32) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_U32

isBinary()

Tells if the given volume is considered a binary volume and thus is compatible with binary fast operators.

isChamferBinaryMorphoEnabled()

True if binary moprhological operations are allowed (when binary input data are detected)

neededBorderWidth()

border width needed to perform chamfer mask operations, in binary mode (int).

setChamferBinaryMorphoEnabled(enabled)

Enable or disable binary moprhological operations (when binary input data are detected)

Parameters:enabled (bool) –
setChamferFactor(factor)

Set the chamfer distance factor, used in binary operations.

setChamferMaskSize(size)

Set the chamfer mask size (for binary operations)

Parameters:size (Point3d) – mask size triplet, in voxels
class soma.aimsalgo.MorphoGreyLevel_U8

Grey-level mathematical morphology.

when enabled, on binary images, the chamfer-based morphomath is used instead of the grey-level one. This is the default as it is way faster (see setChamferBinaryMorphoEnabled).

In binary mode, the input data (volume) should contain a border of “sufficent” size. The border size will be checked, and a new volume with larger border will be temporarily allocated and used if needed, but it is more efficient (and consumes less memory) if this border is already allocated in the input image.

Grey-level operations do not need a border in input images, the test is included in the algorithm (which makes it even slower).

See the method neededBorderWidth().

This class thus regroups all basic morphological operations, and makes obsolete direct calls to AimsMorphoChamferErosion(), AimsMorphoChamferDilation(), AimsMorphoChamferClosing(), AimsMorphoChamferOpening().

chamferFactor()

chamfer factor is used to store chamfer distances as int with a sufficient precision. Used only in binary operations. The default is 50.

chamferMaskSize()

Get the chamfer mask size used in binary operations. The default is 3x3x3.

Returns:mask_size – size in the 3 directions, in voxels
Return type:Point3df
doClosing(dataIn, radius)

Closing operation (dilation + erosion)

Parameters:
  • dataIn (rc_ptr_Volume_U8) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_U8

doDilation(dataIn, radius)

Dilation operation

Parameters:
  • dataIn (rc_ptr_Volume_U8) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_U8

doErosion(dataIn, radius)

Erosion operation

Parameters:
  • dataIn (rc_ptr_Volume_U8) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_U8

doOpening(dataIn, radius)

Opening operation (erosion + dilation)

Parameters:
  • dataIn (rc_ptr_Volume_U8) – volume to perform the operation on
  • radius (float) – radius of the morphological operation (in mm)
Returns:

result

Return type:

rc_ptr_Volume_U8

isBinary()

Tells if the given volume is considered a binary volume and thus is compatible with binary fast operators.

isChamferBinaryMorphoEnabled()

True if binary moprhological operations are allowed (when binary input data are detected)

neededBorderWidth()

border width needed to perform chamfer mask operations, in binary mode (int).

setChamferBinaryMorphoEnabled(enabled)

Enable or disable binary moprhological operations (when binary input data are detected)

Parameters:enabled (bool) –
setChamferFactor(factor)

Set the chamfer distance factor, used in binary operations.

setChamferMaskSize(size)

Set the chamfer mask size (for binary operations)

Parameters:size (Point3d) – mask size triplet, in voxels
class soma.aimsalgo.NearestNeighborResampler_DOUBLE(*args)

Volume resampler using nearest-neighbour interpolation.

The Resampling API is described in the base Resampler class.

class soma.aimsalgo.NearestNeighborResampler_FLOAT(*args)

Volume resampler using nearest-neighbour interpolation.

The Resampling API is described in the base Resampler class.

class soma.aimsalgo.NearestNeighborResampler_HSV(*args)

Volume resampler using nearest-neighbour interpolation.

The Resampling API is described in the base Resampler class.

class soma.aimsalgo.NearestNeighborResampler_POINT3DF(*args)

Volume resampler using nearest-neighbour interpolation.

The Resampling API is described in the base Resampler class.

class soma.aimsalgo.NearestNeighborResampler_RGB(*args)

Volume resampler using nearest-neighbour interpolation.

The Resampling API is described in the base Resampler class.

class soma.aimsalgo.NearestNeighborResampler_RGBA(*args)

Volume resampler using nearest-neighbour interpolation.

The Resampling API is described in the base Resampler class.

class soma.aimsalgo.NearestNeighborResampler_S16(*args)

Volume resampler using nearest-neighbour interpolation.

The Resampling API is described in the base Resampler class.

class soma.aimsalgo.NearestNeighborResampler_S32(*args)

Volume resampler using nearest-neighbour interpolation.

The Resampling API is described in the base Resampler class.

class soma.aimsalgo.NearestNeighborResampler_U16(*args)

Volume resampler using nearest-neighbour interpolation.

The Resampling API is described in the base Resampler class.

class soma.aimsalgo.NearestNeighborResampler_U32(*args)

Volume resampler using nearest-neighbour interpolation.

The Resampling API is described in the base Resampler class.

class soma.aimsalgo.NearestNeighborResampler_U8(*args)

Volume resampler using nearest-neighbour interpolation.

The Resampling API is described in the base Resampler class.

class soma.aimsalgo.QuarticResampler_DOUBLE(*args)

Volume resampler using quartic (order 4) interpolation.

The resampling API is described in the base classes, Resampler_DOUBLE and SplineResampler_DOUBLE.

class soma.aimsalgo.QuarticResampler_FLOAT(*args)

Volume resampler using quartic (order 4) interpolation.

The resampling API is described in the base classes, Resampler_FLOAT and SplineResampler_FLOAT.

class soma.aimsalgo.QuarticResampler_HSV(*args)

Volume resampler using quartic (order 4) interpolation.

The resampling API is described in the base classes, Resampler_HSV and SplineResampler_HSV.

class soma.aimsalgo.QuarticResampler_POINT3DF(*args)

Volume resampler using quartic (order 4) interpolation.

The resampling API is described in the base classes, Resampler_POINT3DF and SplineResampler_POINT3DF.

class soma.aimsalgo.QuarticResampler_RGB(*args)

Volume resampler using quartic (order 4) interpolation.

The resampling API is described in the base classes, Resampler_RGB and SplineResampler_RGB.

class soma.aimsalgo.QuarticResampler_RGBA(*args)

Volume resampler using quartic (order 4) interpolation.

The resampling API is described in the base classes, Resampler_RGBA and SplineResampler_RGBA.

class soma.aimsalgo.QuarticResampler_S16(*args)

Volume resampler using quartic (order 4) interpolation.

The resampling API is described in the base classes, Resampler_S16 and SplineResampler_S16.

class soma.aimsalgo.QuarticResampler_S32(*args)

Volume resampler using quartic (order 4) interpolation.

The resampling API is described in the base classes, Resampler_S32 and SplineResampler_S32.

class soma.aimsalgo.QuarticResampler_U16(*args)

Volume resampler using quartic (order 4) interpolation.

The resampling API is described in the base classes, Resampler_U16 and SplineResampler_U16.

class soma.aimsalgo.QuarticResampler_U32(*args)

Volume resampler using quartic (order 4) interpolation.

The resampling API is described in the base classes, Resampler_U32 and SplineResampler_U32.

class soma.aimsalgo.QuarticResampler_U8(*args)

Volume resampler using quartic (order 4) interpolation.

The resampling API is described in the base classes, Resampler_U8 and SplineResampler_U8.

class soma.aimsalgo.QuinticResampler_DOUBLE(*args)

Volume resampler using quintic (order 5) interpolation.

The resampling API is described in the base classes Resampler_DOUBLE and SplineResampler_DOUBLE.

class soma.aimsalgo.QuinticResampler_FLOAT(*args)

Volume resampler using quintic (order 5) interpolation.

The resampling API is described in the base classes Resampler_FLOAT and SplineResampler_FLOAT.

class soma.aimsalgo.QuinticResampler_HSV(*args)

Volume resampler using quintic (order 5) interpolation.

The resampling API is described in the base classes Resampler_HSV and SplineResampler_HSV.

class soma.aimsalgo.QuinticResampler_POINT3DF(*args)

Volume resampler using quintic (order 5) interpolation.

The resampling API is described in the base classes Resampler_POINT3DF and SplineResampler_POINT3DF.

class soma.aimsalgo.QuinticResampler_RGB(*args)

Volume resampler using quintic (order 5) interpolation.

The resampling API is described in the base classes Resampler_RGB and SplineResampler_RGB.

class soma.aimsalgo.QuinticResampler_RGBA(*args)

Volume resampler using quintic (order 5) interpolation.

The resampling API is described in the base classes Resampler_RGBA and SplineResampler_RGBA.

class soma.aimsalgo.QuinticResampler_S16(*args)

Volume resampler using quintic (order 5) interpolation.

The resampling API is described in the base classes Resampler_S16 and SplineResampler_S16.

class soma.aimsalgo.QuinticResampler_S32(*args)

Volume resampler using quintic (order 5) interpolation.

The resampling API is described in the base classes Resampler_S32 and SplineResampler_S32.

class soma.aimsalgo.QuinticResampler_U16(*args)

Volume resampler using quintic (order 5) interpolation.

The resampling API is described in the base classes Resampler_U16 and SplineResampler_U16.

class soma.aimsalgo.QuinticResampler_U32(*args)

Volume resampler using quintic (order 5) interpolation.

The resampling API is described in the base classes Resampler_U32 and SplineResampler_U32.

class soma.aimsalgo.QuinticResampler_U8(*args)

Volume resampler using quintic (order 5) interpolation.

The resampling API is described in the base classes Resampler_U8 and SplineResampler_U8.

class soma.aimsalgo.Reader_FfdTransformation

FFD vector field transformation reader. It actually reads a volume of Point3df.

soma.aimsalgo.ResamplerFactory(volume)[source]

Factory function to instantiate a ResamplerFactory_<type> object. It builds from an existing volume to gets its voxel type.

See also

ResamplerFactory_S16, ResamplerFactory_FLOAT etc.

class soma.aimsalgo.Resampler_DOUBLE(*args)

Resampling of data from a volume, applying a transformation.

The doit() and resample() methods can be used to apply an affine transformation (aims::AffineTransformation3d). They take a direct transformation, i.e. the transformation goes from the space of the input image (unit: mm) to the space of the output image (unit: mm). The transformation is inverted and normalized internally as needed, because the resamplers “pull” data by transforming output coordinates into input coordinates.

The doit() methods work on input data passed to the setRef() method. setDefaultValue() can also be called to set the background value.

The resample() methods provide stateless alternatives.

You can also use arbitrary non-affine transformations (inheriting soma::Transformation3d) by using the resample_inv() family of methods. In this case, you must pass the backward transformation (from output space to input space), because of the “pulling” mechanism described above.

Beware that contrary to the other methods, the resample_inv_to_vox() overloads take a transformation that maps to voxel coordinates of the input image. These methods can be slightly faster than resample_inv() because they map directly to the API of the actual resamplers are implementing (doResample()). This is especially true of the overload that performs resampling for a single point only.

defaultValue()

Background value used by the doit() methods

Returns:
Return type:double
doit(transform, output_data)

Resample the input volume set with setRef() into an existing volume.

The background value (to be used for regions that are outside of the input volume) can be set with setDefaultValue().

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

The level of verbosity is taken from carto::verbose (i.e. the –verbose command-line argument is honoured).

Parameters:
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • output_data (Volume_DOUBLE) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • transform – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • dimY, dimZ (dimX,) – dimensions of the newly allocated volume
  • voxel_size (Point3df (list of 3 floats)) – voxel size of the newly allocated volume (unit: mm)
Raises:
  • RuntimeError – if no input volume has been set with setRef.
  • doit(transform, dimx, dimy, dimz, voxel_size)
  • =============================================
  • Resample the input volume set with setRef() in a newly allocated volume.
  • The background value (to be used for regions that are outside of the
  • input volume) can be set with setDefaultValue().
  • The level of verbosity is taken from carto::verbose (i.e. the
  • –verbose command-line argument is honoured).
  • The transformations, referentials, and referential header attributes of
  • the new volume are reset if transform.isIdentity() is false:
    • the referential attribute is removed
  • - each transformation in transformations is composed with transform so – that the output volume still points to the original space. If that is not possible (e.g. the transformations attribute is missing or invalid), then a new transformation is added that points to the input volume.
Returns:

a newly allocated volume containing the resampled data (its size along the t axis is the same as the input volume).

Return type:

Volume_DOUBLE

Raises:

RuntimeError: if no input volume has been set with setRef.

ref()

Input data to be resampled by the doit() methods

Returns:
Return type:Volume_DOUBLE
resample(input_data, transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_DOUBLE) – data to be resampled (its voxel size is taken into account)
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • background (double) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_DOUBLE) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • transform, background, output_location, timestep) -> output_value (resample(input_data,) –
  • ======================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • transform – transformation from coordinates of the input volume (unit: mm), to output coordinates (its inverse is used for resampling)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

double

resample_inv(input_data, inverse_transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Parameters:
  • input_data (Volume_DOUBLE) – data to be resampled (its voxel size is taken into account)
  • inverse_transform (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: mm)
  • background (double) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_DOUBLE) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform, background, output_location, timestep) -> output_value (resample_inv(input_data,) –
  • ==================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform – transformation from output coordinates to coordinates of the input volume (unit: mm)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

double

resample_inv_to_vox(input_data, inverse_transform_to_vox, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_DOUBLE) – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: voxel)
  • background (double) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_DOUBLE) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform_to_vox, background, output_location, timestep) -> output_value (resample_inv_to_vox(input_data,) –
  • ================================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox – transformation from output coordinates to coordinates of the input volume (unit: voxel)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

double

setDefaultValue(value)

Set the background value to be used by the doit() methods

Parameters:value (double) – background value
setRef(input_data)

Set the input data to be resampled by the doit() methods

Parameters:input_data (Volume_DOUBLE) – volume to be resampled
class soma.aimsalgo.Resampler_FLOAT(*args)

Resampling of data from a volume, applying a transformation.

The doit() and resample() methods can be used to apply an affine transformation (aims::AffineTransformation3d). They take a direct transformation, i.e. the transformation goes from the space of the input image (unit: mm) to the space of the output image (unit: mm). The transformation is inverted and normalized internally as needed, because the resamplers “pull” data by transforming output coordinates into input coordinates.

The doit() methods work on input data passed to the setRef() method. setDefaultValue() can also be called to set the background value.

The resample() methods provide stateless alternatives.

You can also use arbitrary non-affine transformations (inheriting soma::Transformation3d) by using the resample_inv() family of methods. In this case, you must pass the backward transformation (from output space to input space), because of the “pulling” mechanism described above.

Beware that contrary to the other methods, the resample_inv_to_vox() overloads take a transformation that maps to voxel coordinates of the input image. These methods can be slightly faster than resample_inv() because they map directly to the API of the actual resamplers are implementing (doResample()). This is especially true of the overload that performs resampling for a single point only.

defaultValue()

Background value used by the doit() methods

Returns:
Return type:float
doit(transform, output_data)

Resample the input volume set with setRef() into an existing volume.

The background value (to be used for regions that are outside of the input volume) can be set with setDefaultValue().

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

The level of verbosity is taken from carto::verbose (i.e. the –verbose command-line argument is honoured).

Parameters:
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • output_data (Volume_FLOAT) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • transform – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • dimY, dimZ (dimX,) – dimensions of the newly allocated volume
  • voxel_size (Point3df (list of 3 floats)) – voxel size of the newly allocated volume (unit: mm)
Raises:
  • RuntimeError – if no input volume has been set with setRef.
  • doit(transform, dimx, dimy, dimz, voxel_size)
  • =============================================
  • Resample the input volume set with setRef() in a newly allocated volume.
  • The background value (to be used for regions that are outside of the
  • input volume) can be set with setDefaultValue().
  • The level of verbosity is taken from carto::verbose (i.e. the
  • –verbose command-line argument is honoured).
  • The transformations, referentials, and referential header attributes of
  • the new volume are reset if transform.isIdentity() is false:
    • the referential attribute is removed
  • - each transformation in transformations is composed with transform so – that the output volume still points to the original space. If that is not possible (e.g. the transformations attribute is missing or invalid), then a new transformation is added that points to the input volume.
Returns:

a newly allocated volume containing the resampled data (its size along the t axis is the same as the input volume).

Return type:

Volume_FLOAT

Raises:

RuntimeError: if no input volume has been set with setRef.

ref()

Input data to be resampled by the doit() methods

Returns:
Return type:Volume_FLOAT
resample(input_data, transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_FLOAT) – data to be resampled (its voxel size is taken into account)
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • background (float) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_FLOAT) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • transform, background, output_location, timestep) -> output_value (resample(input_data,) –
  • ======================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • transform – transformation from coordinates of the input volume (unit: mm), to output coordinates (its inverse is used for resampling)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

float

resample_inv(input_data, inverse_transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Parameters:
  • input_data (Volume_FLOAT) – data to be resampled (its voxel size is taken into account)
  • inverse_transform (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: mm)
  • background (float) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_FLOAT) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform, background, output_location, timestep) -> output_value (resample_inv(input_data,) –
  • ==================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform – transformation from output coordinates to coordinates of the input volume (unit: mm)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

float

resample_inv_to_vox(input_data, inverse_transform_to_vox, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_FLOAT) – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: voxel)
  • background (float) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_FLOAT) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform_to_vox, background, output_location, timestep) -> output_value (resample_inv_to_vox(input_data,) –
  • ================================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox – transformation from output coordinates to coordinates of the input volume (unit: voxel)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

float

setDefaultValue(value)

Set the background value to be used by the doit() methods

Parameters:value (float) – background value
setRef(input_data)

Set the input data to be resampled by the doit() methods

Parameters:input_data (Volume_FLOAT) – volume to be resampled
class soma.aimsalgo.Resampler_HSV(*args)

Resampling of data from a volume, applying a transformation.

The doit() and resample() methods can be used to apply an affine transformation (aims::AffineTransformation3d). They take a direct transformation, i.e. the transformation goes from the space of the input image (unit: mm) to the space of the output image (unit: mm). The transformation is inverted and normalized internally as needed, because the resamplers “pull” data by transforming output coordinates into input coordinates.

The doit() methods work on input data passed to the setRef() method. setDefaultValue() can also be called to set the background value.

The resample() methods provide stateless alternatives.

You can also use arbitrary non-affine transformations (inheriting soma::Transformation3d) by using the resample_inv() family of methods. In this case, you must pass the backward transformation (from output space to input space), because of the “pulling” mechanism described above.

Beware that contrary to the other methods, the resample_inv_to_vox() overloads take a transformation that maps to voxel coordinates of the input image. These methods can be slightly faster than resample_inv() because they map directly to the API of the actual resamplers are implementing (doResample()). This is especially true of the overload that performs resampling for a single point only.

defaultValue()

Background value used by the doit() methods

Returns:
Return type:AimsHSV
doit(transform, output_data)

Resample the input volume set with setRef() into an existing volume.

The background value (to be used for regions that are outside of the input volume) can be set with setDefaultValue().

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

The level of verbosity is taken from carto::verbose (i.e. the –verbose command-line argument is honoured).

Parameters:
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • output_data (Volume_HSV) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • transform – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • dimY, dimZ (dimX,) – dimensions of the newly allocated volume
  • voxel_size (Point3df (list of 3 floats)) – voxel size of the newly allocated volume (unit: mm)
Raises:
  • RuntimeError – if no input volume has been set with setRef.
  • doit(transform, dimx, dimy, dimz, voxel_size)
  • =============================================
  • Resample the input volume set with setRef() in a newly allocated volume.
  • The background value (to be used for regions that are outside of the
  • input volume) can be set with setDefaultValue().
  • The level of verbosity is taken from carto::verbose (i.e. the
  • –verbose command-line argument is honoured).
  • The transformations, referentials, and referential header attributes of
  • the new volume are reset if transform.isIdentity() is false:
    • the referential attribute is removed
  • - each transformation in transformations is composed with transform so – that the output volume still points to the original space. If that is not possible (e.g. the transformations attribute is missing or invalid), then a new transformation is added that points to the input volume.
Returns:

a newly allocated volume containing the resampled data (its size along the t axis is the same as the input volume).

Return type:

Volume_HSV

Raises:

RuntimeError: if no input volume has been set with setRef.

ref()

Input data to be resampled by the doit() methods

Returns:
Return type:Volume_HSV
resample(input_data, transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_HSV) – data to be resampled (its voxel size is taken into account)
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • background (AimsHSV) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_HSV) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • transform, background, output_location, timestep) -> output_value (resample(input_data,) –
  • ======================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • transform – transformation from coordinates of the input volume (unit: mm), to output coordinates (its inverse is used for resampling)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

AimsHSV

resample_inv(input_data, inverse_transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Parameters:
  • input_data (Volume_HSV) – data to be resampled (its voxel size is taken into account)
  • inverse_transform (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: mm)
  • background (AimsHSV) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_HSV) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform, background, output_location, timestep) -> output_value (resample_inv(input_data,) –
  • ==================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform – transformation from output coordinates to coordinates of the input volume (unit: mm)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

AimsHSV

resample_inv_to_vox(input_data, inverse_transform_to_vox, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_HSV) – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: voxel)
  • background (AimsHSV) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_HSV) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform_to_vox, background, output_location, timestep) -> output_value (resample_inv_to_vox(input_data,) –
  • ================================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox – transformation from output coordinates to coordinates of the input volume (unit: voxel)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

AimsHSV

setDefaultValue(value)

Set the background value to be used by the doit() methods

Parameters:value (AimsHSV) – background value
setRef(input_data)

Set the input data to be resampled by the doit() methods

Parameters:input_data (Volume_HSV) – volume to be resampled
class soma.aimsalgo.Resampler_POINT3DF(*args)

Resampling of data from a volume, applying a transformation.

The doit() and resample() methods can be used to apply an affine transformation (aims::AffineTransformation3d). They take a direct transformation, i.e. the transformation goes from the space of the input image (unit: mm) to the space of the output image (unit: mm). The transformation is inverted and normalized internally as needed, because the resamplers “pull” data by transforming output coordinates into input coordinates.

The doit() methods work on input data passed to the setRef() method. setDefaultValue() can also be called to set the background value.

The resample() methods provide stateless alternatives.

You can also use arbitrary non-affine transformations (inheriting soma::Transformation3d) by using the resample_inv() family of methods. In this case, you must pass the backward transformation (from output space to input space), because of the “pulling” mechanism described above.

Beware that contrary to the other methods, the resample_inv_to_vox() overloads take a transformation that maps to voxel coordinates of the input image. These methods can be slightly faster than resample_inv() because they map directly to the API of the actual resamplers are implementing (doResample()). This is especially true of the overload that performs resampling for a single point only.

defaultValue()

Background value used by the doit() methods

Returns:
Return type:Point3df
doit(transform, output_data)

Resample the input volume set with setRef() into an existing volume.

The background value (to be used for regions that are outside of the input volume) can be set with setDefaultValue().

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

The level of verbosity is taken from carto::verbose (i.e. the –verbose command-line argument is honoured).

Parameters:
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • output_data (Volume_POINT3DF) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • transform – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • dimY, dimZ (dimX,) – dimensions of the newly allocated volume
  • voxel_size (Point3df (list of 3 floats)) – voxel size of the newly allocated volume (unit: mm)
Raises:
  • RuntimeError – if no input volume has been set with setRef.
  • doit(transform, dimx, dimy, dimz, voxel_size)
  • =============================================
  • Resample the input volume set with setRef() in a newly allocated volume.
  • The background value (to be used for regions that are outside of the
  • input volume) can be set with setDefaultValue().
  • The level of verbosity is taken from carto::verbose (i.e. the
  • –verbose command-line argument is honoured).
  • The transformations, referentials, and referential header attributes of
  • the new volume are reset if transform.isIdentity() is false:
    • the referential attribute is removed
  • - each transformation in transformations is composed with transform so – that the output volume still points to the original space. If that is not possible (e.g. the transformations attribute is missing or invalid), then a new transformation is added that points to the input volume.
Returns:

a newly allocated volume containing the resampled data (its size along the t axis is the same as the input volume).

Return type:

Volume_POINT3DF

Raises:

RuntimeError: if no input volume has been set with setRef.

ref()

Input data to be resampled by the doit() methods

Returns:
Return type:Volume_POINT3DF
resample(input_data, transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_POINT3DF) – data to be resampled (its voxel size is taken into account)
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • background (Point3df) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_POINT3DF) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • transform, background, output_location, timestep) -> output_value (resample(input_data,) –
  • ======================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • transform – transformation from coordinates of the input volume (unit: mm), to output coordinates (its inverse is used for resampling)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

Point3df

resample_inv(input_data, inverse_transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Parameters:
  • input_data (Volume_POINT3DF) – data to be resampled (its voxel size is taken into account)
  • inverse_transform (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: mm)
  • background (Point3df) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_POINT3DF) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform, background, output_location, timestep) -> output_value (resample_inv(input_data,) –
  • ==================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform – transformation from output coordinates to coordinates of the input volume (unit: mm)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

Point3df

resample_inv_to_vox(input_data, inverse_transform_to_vox, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_POINT3DF) – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: voxel)
  • background (Point3df) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_POINT3DF) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform_to_vox, background, output_location, timestep) -> output_value (resample_inv_to_vox(input_data,) –
  • ================================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox – transformation from output coordinates to coordinates of the input volume (unit: voxel)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

Point3df

setDefaultValue(value)

Set the background value to be used by the doit() methods

Parameters:value (Point3df) – background value
setRef(input_data)

Set the input data to be resampled by the doit() methods

Parameters:input_data (Volume_POINT3DF) – volume to be resampled
class soma.aimsalgo.Resampler_RGB(*args)

Resampling of data from a volume, applying a transformation.

The doit() and resample() methods can be used to apply an affine transformation (aims::AffineTransformation3d). They take a direct transformation, i.e. the transformation goes from the space of the input image (unit: mm) to the space of the output image (unit: mm). The transformation is inverted and normalized internally as needed, because the resamplers “pull” data by transforming output coordinates into input coordinates.

The doit() methods work on input data passed to the setRef() method. setDefaultValue() can also be called to set the background value.

The resample() methods provide stateless alternatives.

You can also use arbitrary non-affine transformations (inheriting soma::Transformation3d) by using the resample_inv() family of methods. In this case, you must pass the backward transformation (from output space to input space), because of the “pulling” mechanism described above.

Beware that contrary to the other methods, the resample_inv_to_vox() overloads take a transformation that maps to voxel coordinates of the input image. These methods can be slightly faster than resample_inv() because they map directly to the API of the actual resamplers are implementing (doResample()). This is especially true of the overload that performs resampling for a single point only.

defaultValue()

Background value used by the doit() methods

Returns:
Return type:AimsRGB
doit(transform, output_data)

Resample the input volume set with setRef() into an existing volume.

The background value (to be used for regions that are outside of the input volume) can be set with setDefaultValue().

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

The level of verbosity is taken from carto::verbose (i.e. the –verbose command-line argument is honoured).

Parameters:
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • output_data (Volume_RGB) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • transform – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • dimY, dimZ (dimX,) – dimensions of the newly allocated volume
  • voxel_size (Point3df (list of 3 floats)) – voxel size of the newly allocated volume (unit: mm)
Raises:
  • RuntimeError – if no input volume has been set with setRef.
  • doit(transform, dimx, dimy, dimz, voxel_size)
  • =============================================
  • Resample the input volume set with setRef() in a newly allocated volume.
  • The background value (to be used for regions that are outside of the
  • input volume) can be set with setDefaultValue().
  • The level of verbosity is taken from carto::verbose (i.e. the
  • –verbose command-line argument is honoured).
  • The transformations, referentials, and referential header attributes of
  • the new volume are reset if transform.isIdentity() is false:
    • the referential attribute is removed
  • - each transformation in transformations is composed with transform so – that the output volume still points to the original space. If that is not possible (e.g. the transformations attribute is missing or invalid), then a new transformation is added that points to the input volume.
Returns:

a newly allocated volume containing the resampled data (its size along the t axis is the same as the input volume).

Return type:

Volume_RGB

Raises:

RuntimeError: if no input volume has been set with setRef.

ref()

Input data to be resampled by the doit() methods

Returns:
Return type:Volume_RGB
resample(input_data, transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_RGB) – data to be resampled (its voxel size is taken into account)
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • background (AimsRGB) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_RGB) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • transform, background, output_location, timestep) -> output_value (resample(input_data,) –
  • ======================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • transform – transformation from coordinates of the input volume (unit: mm), to output coordinates (its inverse is used for resampling)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

AimsRGB

resample_inv(input_data, inverse_transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Parameters:
  • input_data (Volume_RGB) – data to be resampled (its voxel size is taken into account)
  • inverse_transform (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: mm)
  • background (AimsRGB) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_RGB) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform, background, output_location, timestep) -> output_value (resample_inv(input_data,) –
  • ==================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform – transformation from output coordinates to coordinates of the input volume (unit: mm)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

AimsRGB

resample_inv_to_vox(input_data, inverse_transform_to_vox, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_RGB) – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: voxel)
  • background (AimsRGB) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_RGB) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform_to_vox, background, output_location, timestep) -> output_value (resample_inv_to_vox(input_data,) –
  • ================================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox – transformation from output coordinates to coordinates of the input volume (unit: voxel)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

AimsRGB

setDefaultValue(value)

Set the background value to be used by the doit() methods

Parameters:value (AimsRGB) – background value
setRef(input_data)

Set the input data to be resampled by the doit() methods

Parameters:input_data (Volume_RGB) – volume to be resampled
class soma.aimsalgo.Resampler_RGBA(*args)

Resampling of data from a volume, applying a transformation.

The doit() and resample() methods can be used to apply an affine transformation (aims::AffineTransformation3d). They take a direct transformation, i.e. the transformation goes from the space of the input image (unit: mm) to the space of the output image (unit: mm). The transformation is inverted and normalized internally as needed, because the resamplers “pull” data by transforming output coordinates into input coordinates.

The doit() methods work on input data passed to the setRef() method. setDefaultValue() can also be called to set the background value.

The resample() methods provide stateless alternatives.

You can also use arbitrary non-affine transformations (inheriting soma::Transformation3d) by using the resample_inv() family of methods. In this case, you must pass the backward transformation (from output space to input space), because of the “pulling” mechanism described above.

Beware that contrary to the other methods, the resample_inv_to_vox() overloads take a transformation that maps to voxel coordinates of the input image. These methods can be slightly faster than resample_inv() because they map directly to the API of the actual resamplers are implementing (doResample()). This is especially true of the overload that performs resampling for a single point only.

defaultValue()

Background value used by the doit() methods

Returns:
Return type:AimsRGBA
doit(transform, output_data)

Resample the input volume set with setRef() into an existing volume.

The background value (to be used for regions that are outside of the input volume) can be set with setDefaultValue().

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

The level of verbosity is taken from carto::verbose (i.e. the –verbose command-line argument is honoured).

Parameters:
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • output_data (Volume_RGBA) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • transform – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • dimY, dimZ (dimX,) – dimensions of the newly allocated volume
  • voxel_size (Point3df (list of 3 floats)) – voxel size of the newly allocated volume (unit: mm)
Raises:
  • RuntimeError – if no input volume has been set with setRef.
  • doit(transform, dimx, dimy, dimz, voxel_size)
  • =============================================
  • Resample the input volume set with setRef() in a newly allocated volume.
  • The background value (to be used for regions that are outside of the
  • input volume) can be set with setDefaultValue().
  • The level of verbosity is taken from carto::verbose (i.e. the
  • –verbose command-line argument is honoured).
  • The transformations, referentials, and referential header attributes of
  • the new volume are reset if transform.isIdentity() is false:
    • the referential attribute is removed
  • - each transformation in transformations is composed with transform so – that the output volume still points to the original space. If that is not possible (e.g. the transformations attribute is missing or invalid), then a new transformation is added that points to the input volume.
Returns:

a newly allocated volume containing the resampled data (its size along the t axis is the same as the input volume).

Return type:

Volume_RGBA

Raises:

RuntimeError: if no input volume has been set with setRef.

ref()

Input data to be resampled by the doit() methods

Returns:
Return type:Volume_RGBA
resample(input_data, transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_RGBA) – data to be resampled (its voxel size is taken into account)
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • background (AimsRGBA) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_RGBA) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • transform, background, output_location, timestep) -> output_value (resample(input_data,) –
  • ======================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • transform – transformation from coordinates of the input volume (unit: mm), to output coordinates (its inverse is used for resampling)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

AimsRGBA

resample_inv(input_data, inverse_transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Parameters:
  • input_data (Volume_RGBA) – data to be resampled (its voxel size is taken into account)
  • inverse_transform (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: mm)
  • background (AimsRGBA) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_RGBA) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform, background, output_location, timestep) -> output_value (resample_inv(input_data,) –
  • ==================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform – transformation from output coordinates to coordinates of the input volume (unit: mm)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

AimsRGBA

resample_inv_to_vox(input_data, inverse_transform_to_vox, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_RGBA) – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: voxel)
  • background (AimsRGBA) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_RGBA) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform_to_vox, background, output_location, timestep) -> output_value (resample_inv_to_vox(input_data,) –
  • ================================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox – transformation from output coordinates to coordinates of the input volume (unit: voxel)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

AimsRGBA

setDefaultValue(value)

Set the background value to be used by the doit() methods

Parameters:value (AimsRGBA) – background value
setRef(input_data)

Set the input data to be resampled by the doit() methods

Parameters:input_data (Volume_RGBA) – volume to be resampled
class soma.aimsalgo.Resampler_S16(*args)

Resampling of data from a volume, applying a transformation.

The doit() and resample() methods can be used to apply an affine transformation (aims::AffineTransformation3d). They take a direct transformation, i.e. the transformation goes from the space of the input image (unit: mm) to the space of the output image (unit: mm). The transformation is inverted and normalized internally as needed, because the resamplers “pull” data by transforming output coordinates into input coordinates.

The doit() methods work on input data passed to the setRef() method. setDefaultValue() can also be called to set the background value.

The resample() methods provide stateless alternatives.

You can also use arbitrary non-affine transformations (inheriting soma::Transformation3d) by using the resample_inv() family of methods. In this case, you must pass the backward transformation (from output space to input space), because of the “pulling” mechanism described above.

Beware that contrary to the other methods, the resample_inv_to_vox() overloads take a transformation that maps to voxel coordinates of the input image. These methods can be slightly faster than resample_inv() because they map directly to the API of the actual resamplers are implementing (doResample()). This is especially true of the overload that performs resampling for a single point only.

defaultValue()

Background value used by the doit() methods

Returns:
Return type:short
doit(transform, output_data)

Resample the input volume set with setRef() into an existing volume.

The background value (to be used for regions that are outside of the input volume) can be set with setDefaultValue().

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

The level of verbosity is taken from carto::verbose (i.e. the –verbose command-line argument is honoured).

Parameters:
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • output_data (Volume_S16) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • transform – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • dimY, dimZ (dimX,) – dimensions of the newly allocated volume
  • voxel_size (Point3df (list of 3 floats)) – voxel size of the newly allocated volume (unit: mm)
Raises:
  • RuntimeError – if no input volume has been set with setRef.
  • doit(transform, dimx, dimy, dimz, voxel_size)
  • =============================================
  • Resample the input volume set with setRef() in a newly allocated volume.
  • The background value (to be used for regions that are outside of the
  • input volume) can be set with setDefaultValue().
  • The level of verbosity is taken from carto::verbose (i.e. the
  • –verbose command-line argument is honoured).
  • The transformations, referentials, and referential header attributes of
  • the new volume are reset if transform.isIdentity() is false:
    • the referential attribute is removed
  • - each transformation in transformations is composed with transform so – that the output volume still points to the original space. If that is not possible (e.g. the transformations attribute is missing or invalid), then a new transformation is added that points to the input volume.
Returns:

a newly allocated volume containing the resampled data (its size along the t axis is the same as the input volume).

Return type:

Volume_S16

Raises:

RuntimeError: if no input volume has been set with setRef.

ref()

Input data to be resampled by the doit() methods

Returns:
Return type:Volume_S16
resample(input_data, transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_S16) – data to be resampled (its voxel size is taken into account)
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • background (short) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_S16) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • transform, background, output_location, timestep) -> output_value (resample(input_data,) –
  • ======================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • transform – transformation from coordinates of the input volume (unit: mm), to output coordinates (its inverse is used for resampling)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

short

resample_inv(input_data, inverse_transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Parameters:
  • input_data (Volume_S16) – data to be resampled (its voxel size is taken into account)
  • inverse_transform (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: mm)
  • background (short) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_S16) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform, background, output_location, timestep) -> output_value (resample_inv(input_data,) –
  • ==================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform – transformation from output coordinates to coordinates of the input volume (unit: mm)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

short

resample_inv_to_vox(input_data, inverse_transform_to_vox, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_S16) – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: voxel)
  • background (short) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_S16) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform_to_vox, background, output_location, timestep) -> output_value (resample_inv_to_vox(input_data,) –
  • ================================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox – transformation from output coordinates to coordinates of the input volume (unit: voxel)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

short

setDefaultValue(value)

Set the background value to be used by the doit() methods

Parameters:value (short) – background value
setRef(input_data)

Set the input data to be resampled by the doit() methods

Parameters:input_data (Volume_S16) – volume to be resampled
class soma.aimsalgo.Resampler_S32(*args)

Resampling of data from a volume, applying a transformation.

The doit() and resample() methods can be used to apply an affine transformation (aims::AffineTransformation3d). They take a direct transformation, i.e. the transformation goes from the space of the input image (unit: mm) to the space of the output image (unit: mm). The transformation is inverted and normalized internally as needed, because the resamplers “pull” data by transforming output coordinates into input coordinates.

The doit() methods work on input data passed to the setRef() method. setDefaultValue() can also be called to set the background value.

The resample() methods provide stateless alternatives.

You can also use arbitrary non-affine transformations (inheriting soma::Transformation3d) by using the resample_inv() family of methods. In this case, you must pass the backward transformation (from output space to input space), because of the “pulling” mechanism described above.

Beware that contrary to the other methods, the resample_inv_to_vox() overloads take a transformation that maps to voxel coordinates of the input image. These methods can be slightly faster than resample_inv() because they map directly to the API of the actual resamplers are implementing (doResample()). This is especially true of the overload that performs resampling for a single point only.

defaultValue()

Background value used by the doit() methods

Returns:
Return type:int
doit(transform, output_data)

Resample the input volume set with setRef() into an existing volume.

The background value (to be used for regions that are outside of the input volume) can be set with setDefaultValue().

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

The level of verbosity is taken from carto::verbose (i.e. the –verbose command-line argument is honoured).

Parameters:
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • output_data (Volume_S32) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • transform – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • dimY, dimZ (dimX,) – dimensions of the newly allocated volume
  • voxel_size (Point3df (list of 3 floats)) – voxel size of the newly allocated volume (unit: mm)
Raises:
  • RuntimeError – if no input volume has been set with setRef.
  • doit(transform, dimx, dimy, dimz, voxel_size)
  • =============================================
  • Resample the input volume set with setRef() in a newly allocated volume.
  • The background value (to be used for regions that are outside of the
  • input volume) can be set with setDefaultValue().
  • The level of verbosity is taken from carto::verbose (i.e. the
  • –verbose command-line argument is honoured).
  • The transformations, referentials, and referential header attributes of
  • the new volume are reset if transform.isIdentity() is false:
    • the referential attribute is removed
  • - each transformation in transformations is composed with transform so – that the output volume still points to the original space. If that is not possible (e.g. the transformations attribute is missing or invalid), then a new transformation is added that points to the input volume.
Returns:

a newly allocated volume containing the resampled data (its size along the t axis is the same as the input volume).

Return type:

Volume_S32

Raises:

RuntimeError: if no input volume has been set with setRef.

ref()

Input data to be resampled by the doit() methods

Returns:
Return type:Volume_S32
resample(input_data, transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_S32) – data to be resampled (its voxel size is taken into account)
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • background (int) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_S32) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • transform, background, output_location, timestep) -> output_value (resample(input_data,) –
  • ======================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • transform – transformation from coordinates of the input volume (unit: mm), to output coordinates (its inverse is used for resampling)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

int

resample_inv(input_data, inverse_transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Parameters:
  • input_data (Volume_S32) – data to be resampled (its voxel size is taken into account)
  • inverse_transform (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: mm)
  • background (int) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_S32) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform, background, output_location, timestep) -> output_value (resample_inv(input_data,) –
  • ==================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform – transformation from output coordinates to coordinates of the input volume (unit: mm)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

int

resample_inv_to_vox(input_data, inverse_transform_to_vox, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_S32) – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: voxel)
  • background (int) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_S32) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform_to_vox, background, output_location, timestep) -> output_value (resample_inv_to_vox(input_data,) –
  • ================================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox – transformation from output coordinates to coordinates of the input volume (unit: voxel)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

int

setDefaultValue(value)

Set the background value to be used by the doit() methods

Parameters:value (int) – background value
setRef(input_data)

Set the input data to be resampled by the doit() methods

Parameters:input_data (Volume_S32) – volume to be resampled
class soma.aimsalgo.Resampler_U16(*args)

Resampling of data from a volume, applying a transformation.

The doit() and resample() methods can be used to apply an affine transformation (aims::AffineTransformation3d). They take a direct transformation, i.e. the transformation goes from the space of the input image (unit: mm) to the space of the output image (unit: mm). The transformation is inverted and normalized internally as needed, because the resamplers “pull” data by transforming output coordinates into input coordinates.

The doit() methods work on input data passed to the setRef() method. setDefaultValue() can also be called to set the background value.

The resample() methods provide stateless alternatives.

You can also use arbitrary non-affine transformations (inheriting soma::Transformation3d) by using the resample_inv() family of methods. In this case, you must pass the backward transformation (from output space to input space), because of the “pulling” mechanism described above.

Beware that contrary to the other methods, the resample_inv_to_vox() overloads take a transformation that maps to voxel coordinates of the input image. These methods can be slightly faster than resample_inv() because they map directly to the API of the actual resamplers are implementing (doResample()). This is especially true of the overload that performs resampling for a single point only.

defaultValue()

Background value used by the doit() methods

Returns:
Return type:uint16_t
doit(transform, output_data)

Resample the input volume set with setRef() into an existing volume.

The background value (to be used for regions that are outside of the input volume) can be set with setDefaultValue().

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

The level of verbosity is taken from carto::verbose (i.e. the –verbose command-line argument is honoured).

Parameters:
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • output_data (Volume_U16) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • transform – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • dimY, dimZ (dimX,) – dimensions of the newly allocated volume
  • voxel_size (Point3df (list of 3 floats)) – voxel size of the newly allocated volume (unit: mm)
Raises:
  • RuntimeError – if no input volume has been set with setRef.
  • doit(transform, dimx, dimy, dimz, voxel_size)
  • =============================================
  • Resample the input volume set with setRef() in a newly allocated volume.
  • The background value (to be used for regions that are outside of the
  • input volume) can be set with setDefaultValue().
  • The level of verbosity is taken from carto::verbose (i.e. the
  • –verbose command-line argument is honoured).
  • The transformations, referentials, and referential header attributes of
  • the new volume are reset if transform.isIdentity() is false:
    • the referential attribute is removed
  • - each transformation in transformations is composed with transform so – that the output volume still points to the original space. If that is not possible (e.g. the transformations attribute is missing or invalid), then a new transformation is added that points to the input volume.
Returns:

a newly allocated volume containing the resampled data (its size along the t axis is the same as the input volume).

Return type:

Volume_U16

Raises:

RuntimeError: if no input volume has been set with setRef.

ref()

Input data to be resampled by the doit() methods

Returns:
Return type:Volume_U16
resample(input_data, transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_U16) – data to be resampled (its voxel size is taken into account)
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • background (uint16_t) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_U16) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • transform, background, output_location, timestep) -> output_value (resample(input_data,) –
  • ======================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • transform – transformation from coordinates of the input volume (unit: mm), to output coordinates (its inverse is used for resampling)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

uint16_t

resample_inv(input_data, inverse_transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Parameters:
  • input_data (Volume_U16) – data to be resampled (its voxel size is taken into account)
  • inverse_transform (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: mm)
  • background (uint16_t) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_U16) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform, background, output_location, timestep) -> output_value (resample_inv(input_data,) –
  • ==================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform – transformation from output coordinates to coordinates of the input volume (unit: mm)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

uint16_t

resample_inv_to_vox(input_data, inverse_transform_to_vox, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_U16) – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: voxel)
  • background (uint16_t) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_U16) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform_to_vox, background, output_location, timestep) -> output_value (resample_inv_to_vox(input_data,) –
  • ================================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox – transformation from output coordinates to coordinates of the input volume (unit: voxel)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

uint16_t

setDefaultValue(value)

Set the background value to be used by the doit() methods

Parameters:value (uint16_t) – background value
setRef(input_data)

Set the input data to be resampled by the doit() methods

Parameters:input_data (Volume_U16) – volume to be resampled
class soma.aimsalgo.Resampler_U32(*args)

Resampling of data from a volume, applying a transformation.

The doit() and resample() methods can be used to apply an affine transformation (aims::AffineTransformation3d). They take a direct transformation, i.e. the transformation goes from the space of the input image (unit: mm) to the space of the output image (unit: mm). The transformation is inverted and normalized internally as needed, because the resamplers “pull” data by transforming output coordinates into input coordinates.

The doit() methods work on input data passed to the setRef() method. setDefaultValue() can also be called to set the background value.

The resample() methods provide stateless alternatives.

You can also use arbitrary non-affine transformations (inheriting soma::Transformation3d) by using the resample_inv() family of methods. In this case, you must pass the backward transformation (from output space to input space), because of the “pulling” mechanism described above.

Beware that contrary to the other methods, the resample_inv_to_vox() overloads take a transformation that maps to voxel coordinates of the input image. These methods can be slightly faster than resample_inv() because they map directly to the API of the actual resamplers are implementing (doResample()). This is especially true of the overload that performs resampling for a single point only.

defaultValue()

Background value used by the doit() methods

Returns:
Return type:unsigned
doit(transform, output_data)

Resample the input volume set with setRef() into an existing volume.

The background value (to be used for regions that are outside of the input volume) can be set with setDefaultValue().

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

The level of verbosity is taken from carto::verbose (i.e. the –verbose command-line argument is honoured).

Parameters:
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • output_data (Volume_U32) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • transform – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • dimY, dimZ (dimX,) – dimensions of the newly allocated volume
  • voxel_size (Point3df (list of 3 floats)) – voxel size of the newly allocated volume (unit: mm)
Raises:
  • RuntimeError – if no input volume has been set with setRef.
  • doit(transform, dimx, dimy, dimz, voxel_size)
  • =============================================
  • Resample the input volume set with setRef() in a newly allocated volume.
  • The background value (to be used for regions that are outside of the
  • input volume) can be set with setDefaultValue().
  • The level of verbosity is taken from carto::verbose (i.e. the
  • –verbose command-line argument is honoured).
  • The transformations, referentials, and referential header attributes of
  • the new volume are reset if transform.isIdentity() is false:
    • the referential attribute is removed
  • - each transformation in transformations is composed with transform so – that the output volume still points to the original space. If that is not possible (e.g. the transformations attribute is missing or invalid), then a new transformation is added that points to the input volume.
Returns:

a newly allocated volume containing the resampled data (its size along the t axis is the same as the input volume).

Return type:

Volume_U32

Raises:

RuntimeError: if no input volume has been set with setRef.

ref()

Input data to be resampled by the doit() methods

Returns:
Return type:Volume_U32
resample(input_data, transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_U32) – data to be resampled (its voxel size is taken into account)
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • background (unsigned) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_U32) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • transform, background, output_location, timestep) -> output_value (resample(input_data,) –
  • ======================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • transform – transformation from coordinates of the input volume (unit: mm), to output coordinates (its inverse is used for resampling)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

unsigned

resample_inv(input_data, inverse_transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Parameters:
  • input_data (Volume_U32) – data to be resampled (its voxel size is taken into account)
  • inverse_transform (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: mm)
  • background (unsigned) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_U32) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform, background, output_location, timestep) -> output_value (resample_inv(input_data,) –
  • ==================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform – transformation from output coordinates to coordinates of the input volume (unit: mm)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

unsigned

resample_inv_to_vox(input_data, inverse_transform_to_vox, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_U32) – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: voxel)
  • background (unsigned) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_U32) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform_to_vox, background, output_location, timestep) -> output_value (resample_inv_to_vox(input_data,) –
  • ================================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox – transformation from output coordinates to coordinates of the input volume (unit: voxel)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

unsigned

setDefaultValue(value)

Set the background value to be used by the doit() methods

Parameters:value (unsigned) – background value
setRef(input_data)

Set the input data to be resampled by the doit() methods

Parameters:input_data (Volume_U32) – volume to be resampled
class soma.aimsalgo.Resampler_U8(*args)

Resampling of data from a volume, applying a transformation.

The doit() and resample() methods can be used to apply an affine transformation (aims::AffineTransformation3d). They take a direct transformation, i.e. the transformation goes from the space of the input image (unit: mm) to the space of the output image (unit: mm). The transformation is inverted and normalized internally as needed, because the resamplers “pull” data by transforming output coordinates into input coordinates.

The doit() methods work on input data passed to the setRef() method. setDefaultValue() can also be called to set the background value.

The resample() methods provide stateless alternatives.

You can also use arbitrary non-affine transformations (inheriting soma::Transformation3d) by using the resample_inv() family of methods. In this case, you must pass the backward transformation (from output space to input space), because of the “pulling” mechanism described above.

Beware that contrary to the other methods, the resample_inv_to_vox() overloads take a transformation that maps to voxel coordinates of the input image. These methods can be slightly faster than resample_inv() because they map directly to the API of the actual resamplers are implementing (doResample()). This is especially true of the overload that performs resampling for a single point only.

defaultValue()

Background value used by the doit() methods

Returns:
Return type:unsigned short
doit(transform, output_data)

Resample the input volume set with setRef() into an existing volume.

The background value (to be used for regions that are outside of the input volume) can be set with setDefaultValue().

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

The level of verbosity is taken from carto::verbose (i.e. the –verbose command-line argument is honoured).

Parameters:
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • output_data (Volume_U8) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • transform – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • dimY, dimZ (dimX,) – dimensions of the newly allocated volume
  • voxel_size (Point3df (list of 3 floats)) – voxel size of the newly allocated volume (unit: mm)
Raises:
  • RuntimeError – if no input volume has been set with setRef.
  • doit(transform, dimx, dimy, dimz, voxel_size)
  • =============================================
  • Resample the input volume set with setRef() in a newly allocated volume.
  • The background value (to be used for regions that are outside of the
  • input volume) can be set with setDefaultValue().
  • The level of verbosity is taken from carto::verbose (i.e. the
  • –verbose command-line argument is honoured).
  • The transformations, referentials, and referential header attributes of
  • the new volume are reset if transform.isIdentity() is false:
    • the referential attribute is removed
  • - each transformation in transformations is composed with transform so – that the output volume still points to the original space. If that is not possible (e.g. the transformations attribute is missing or invalid), then a new transformation is added that points to the input volume.
Returns:

a newly allocated volume containing the resampled data (its size along the t axis is the same as the input volume).

Return type:

Volume_U8

Raises:

RuntimeError: if no input volume has been set with setRef.

ref()

Input data to be resampled by the doit() methods

Returns:
Return type:Volume_U8
resample(input_data, transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_U8) – data to be resampled (its voxel size is taken into account)
  • transform (AffineTransformation3d) – transformation from coordinates of the input volume (unit: mm), to coordinates of the output volume (unit: mm) (its inverse is used for resampling)
  • background (unsigned short) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_U8) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • transform, background, output_location, timestep) -> output_value (resample(input_data,) –
  • ======================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • transform – transformation from coordinates of the input volume (unit: mm), to output coordinates (its inverse is used for resampling)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

unsigned short

resample_inv(input_data, inverse_transform, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Parameters:
  • input_data (Volume_U8) – data to be resampled (its voxel size is taken into account)
  • inverse_transform (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: mm)
  • background (unsigned short) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_U8) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform, background, output_location, timestep) -> output_value (resample_inv(input_data,) –
  • ==================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform – transformation from output coordinates to coordinates of the input volume (unit: mm)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

unsigned short

resample_inv_to_vox(input_data, inverse_transform_to_vox, background, output_data, verbose=False)

Resample a volume into an existing output volume.

The transformations, referentials, and referential header attributes of output_data are not touched; it is up to the calling code to update them accordingly.

This method does not use the instance state set by setRef() or setDefaultValue().

Derived classes can override this method to optimize interpolation of a full volume. The base class method simply calls doResample for each point.

Parameters:
  • input_data (Volume_U8) – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox (Transformation3d) – transformation from coordinates of the output volume (unit: mm), to coordinates of the input volume (unit: voxel)
  • background (unsigned short) – value set in output regions that are outside of the transformed input volume
  • output_data (Volume_U8) – existing volume to be filled with resampled data (its pre-existing dimensions and voxel size are used)
  • verbose (bool) – print progress to stdout
  • inverse_transform_to_vox, background, output_location, timestep) -> output_value (resample_inv_to_vox(input_data,) –
  • ================================================================================================================
  • a volume at a single location. (Resample) –
  • method does not use the instance state set by setRef() or (This) –
  • setDefaultValue()
  • input_data – data to be resampled (its voxel size is taken into account)
  • inverse_transform_to_vox – transformation from output coordinates to coordinates of the input volume (unit: voxel)
  • background – value set in output regions that are outside of the transformed input volume
  • output_location (Point3df (list of 3 floats)) – coordinates in output space (destination space of transform)
  • timestep (int) – for 4D volume, time step to be used
Returns:

resampled value

Return type:

unsigned short

setDefaultValue(value)

Set the background value to be used by the doit() methods

Parameters:value (unsigned short) – background value
setRef(input_data)

Set the input data to be resampled by the doit() methods

Parameters:input_data (Volume_U8) – volume to be resampled
class soma.aimsalgo.SeventhOrderResampler_DOUBLE(*args)

Volume resampler using seventh-order interpolation.

The resampling API is described in the base classes, Resampler_DOUBLE and SplineResampler_DOUBLE.

class soma.aimsalgo.SeventhOrderResampler_FLOAT(*args)

Volume resampler using seventh-order interpolation.

The resampling API is described in the base classes, Resampler_FLOAT and SplineResampler_FLOAT.

class soma.aimsalgo.SeventhOrderResampler_HSV(*args)

Volume resampler using seventh-order interpolation.

The resampling API is described in the base classes, Resampler_HSV and SplineResampler_HSV.

class soma.aimsalgo.SeventhOrderResampler_POINT3DF(*args)

Volume resampler using seventh-order interpolation.

The resampling API is described in the base classes, Resampler_POINT3DF and SplineResampler_POINT3DF.

class soma.aimsalgo.SeventhOrderResampler_RGB(*args)

Volume resampler using seventh-order interpolation.

The resampling API is described in the base classes, Resampler_RGB and SplineResampler_RGB.

class soma.aimsalgo.SeventhOrderResampler_RGBA(*args)

Volume resampler using seventh-order interpolation.

The resampling API is described in the base classes, Resampler_RGBA and SplineResampler_RGBA.

class soma.aimsalgo.SeventhOrderResampler_S16(*args)

Volume resampler using seventh-order interpolation.

The resampling API is described in the base classes, Resampler_S16 and SplineResampler_S16.

class soma.aimsalgo.SeventhOrderResampler_S32(*args)

Volume resampler using seventh-order interpolation.

The resampling API is described in the base classes, Resampler_S32 and SplineResampler_S32.

class soma.aimsalgo.SeventhOrderResampler_U16(*args)

Volume resampler using seventh-order interpolation.

The resampling API is described in the base classes, Resampler_U16 and SplineResampler_U16.

class soma.aimsalgo.SeventhOrderResampler_U32(*args)

Volume resampler using seventh-order interpolation.

The resampling API is described in the base classes, Resampler_U32 and SplineResampler_U32.

class soma.aimsalgo.SeventhOrderResampler_U8(*args)

Volume resampler using seventh-order interpolation.

The resampling API is described in the base classes, Resampler_U8 and SplineResampler_U8.

class soma.aimsalgo.SixthOrderResampler_DOUBLE(*args)

Volume resampler using sixth-order interpolation.

The resampling API is described in the base classes, Resampler_DOUBLE and SplineResampler_DOUBLE.

class soma.aimsalgo.SixthOrderResampler_FLOAT(*args)

Volume resampler using sixth-order interpolation.

The resampling API is described in the base classes, Resampler_FLOAT and SplineResampler_FLOAT.

class soma.aimsalgo.SixthOrderResampler_HSV(*args)

Volume resampler using sixth-order interpolation.

The resampling API is described in the base classes, Resampler_HSV and SplineResampler_HSV.

class soma.aimsalgo.SixthOrderResampler_POINT3DF(*args)

Volume resampler using sixth-order interpolation.

The resampling API is described in the base classes, Resampler_POINT3DF and SplineResampler_POINT3DF.

class soma.aimsalgo.SixthOrderResampler_RGB(*args)

Volume resampler using sixth-order interpolation.

The resampling API is described in the base classes, Resampler_RGB and SplineResampler_RGB.

class soma.aimsalgo.SixthOrderResampler_RGBA(*args)

Volume resampler using sixth-order interpolation.

The resampling API is described in the base classes, Resampler_RGBA and SplineResampler_RGBA.

class soma.aimsalgo.SixthOrderResampler_S16(*args)

Volume resampler using sixth-order interpolation.

The resampling API is described in the base classes, Resampler_S16 and SplineResampler_S16.

class soma.aimsalgo.SixthOrderResampler_S32(*args)

Volume resampler using sixth-order interpolation.

The resampling API is described in the base classes, Resampler_S32 and SplineResampler_S32.

class soma.aimsalgo.SixthOrderResampler_U16(*args)

Volume resampler using sixth-order interpolation.

The resampling API is described in the base classes, Resampler_U16 and SplineResampler_U16.

class soma.aimsalgo.SixthOrderResampler_U32(*args)

Volume resampler using sixth-order interpolation.

The resampling API is described in the base classes, Resampler_U32 and SplineResampler_U32.

class soma.aimsalgo.SixthOrderResampler_U8(*args)

Volume resampler using sixth-order interpolation.

The resampling API is described in the base classes, Resampler_U8 and SplineResampler_U8.

class soma.aimsalgo.SplineResampler_DOUBLE(*args)

B-Spline-based resampling.

This is the base class for all resamplers based on B-spline interpolation as described by Unser, Aldroubi & Eden in IEEE PAMI (1991). A class computing the actual spline coefficient is derived for each spline order (1 to 7).

See : LinearResampler, CubicResampler, QuadraticResampler,
QuinticResampler, SixthOrderResampler, SeventhOrderResampler

Coefficients are computed through a recursive scheme from an input reference volume. This recursive algorithm is fast for whole volume resampling, but slower for single points. A cache mechanism has thus been implemented so that coefficients are not recomputed if the input volume did not change.

The Resampling API is described in the base class, Resampler_DOUBLE.

getOrder()

order = getOrder()

Spline order (1 to 7)

Returns:order
Return type:int (1 to 7)
reset()

Computes spline coefficients corresponding to an input volume.

Spline coefficients are recomputed only if one of these conditions is satisfied: - inVolume is different from the last volume used for coefficients

computation (in the sense that they share the same adress)
  • t is different from the last t used for coefficients computation
  • A call to reset() has previously been made

This method actually calls updateParameters() and returns the coeff container

Parameters:
  • inVolume (Volume_DOUBLE) – input image
  • t (int) – volume to use in the T dimension in the case where inVolume is a time series.
  • verbose (bool) – print progress on stdout
Returns:

Volume of double containing the coefficients in the image domain. Border coefficient need to be retrieved by mirror.

Return type:

Volume_DOUBLE

class soma.aimsalgo.SplineResampler_FLOAT(*args)

B-Spline-based resampling.

This is the base class for all resamplers based on B-spline interpolation as described by Unser, Aldroubi & Eden in IEEE PAMI (1991). A class computing the actual spline coefficient is derived for each spline order (1 to 7).

See : LinearResampler, CubicResampler, QuadraticResampler,
QuinticResampler, SixthOrderResampler, SeventhOrderResampler

Coefficients are computed through a recursive scheme from an input reference volume. This recursive algorithm is fast for whole volume resampling, but slower for single points. A cache mechanism has thus been implemented so that coefficients are not recomputed if the input volume did not change.

The Resampling API is described in the base class, Resampler_FLOAT.

getOrder()

order = getOrder()

Spline order (1 to 7)

Returns:order
Return type:int (1 to 7)
reset()

Computes spline coefficients corresponding to an input volume.

Spline coefficients are recomputed only if one of these conditions is satisfied: - inVolume is different from the last volume used for coefficients

computation (in the sense that they share the same adress)
  • t is different from the last t used for coefficients computation
  • A call to reset() has previously been made

This method actually calls updateParameters() and returns the coeff container

Parameters:
  • inVolume (Volume_FLOAT) – input image
  • t (int) – volume to use in the T dimension in the case where inVolume is a time series.
  • verbose (bool) – print progress on stdout
Returns:

Volume of double containing the coefficients in the image domain. Border coefficient need to be retrieved by mirror.

Return type:

Volume_DOUBLE

class soma.aimsalgo.SplineResampler_HSV(*args)

B-Spline-based resampling.

This is the base class for all resamplers based on B-spline interpolation as described by Unser, Aldroubi & Eden in IEEE PAMI (1991). A class computing the actual spline coefficient is derived for each spline order (1 to 7).

See : LinearResampler, CubicResampler, QuadraticResampler,
QuinticResampler, SixthOrderResampler, SeventhOrderResampler

Coefficients are computed through a recursive scheme from an input reference volume. This recursive algorithm is fast for whole volume resampling, but slower for single points. A cache mechanism has thus been implemented so that coefficients are not recomputed if the input volume did not change.

The Resampling API is described in the base class, Resampler_HSV.

getOrder()

order = getOrder()

Spline order (1 to 7)

Returns:order
Return type:int (1 to 7)
reset()

Computes spline coefficients corresponding to an input volume.

Spline coefficients are recomputed only if one of these conditions is satisfied: - inVolume is different from the last volume used for coefficients

computation (in the sense that they share the same adress)
  • t is different from the last t used for coefficients computation
  • A call to reset() has previously been made

This method actually calls updateParameters() and returns the coeff container

Parameters:
  • inVolume (Volume_HSV) – input image
  • t (int) – volume to use in the T dimension in the case where inVolume is a time series.
  • verbose (bool) – print progress on stdout
Returns:

Volume of double containing the coefficients in the image domain. Border coefficient need to be retrieved by mirror.

Return type:

Volume_DOUBLE

class soma.aimsalgo.SplineResampler_POINT3DF(*args)

B-Spline-based resampling.

This is the base class for all resamplers based on B-spline interpolation as described by Unser, Aldroubi & Eden in IEEE PAMI (1991). A class computing the actual spline coefficient is derived for each spline order (1 to 7).

See : LinearResampler, CubicResampler, QuadraticResampler,
QuinticResampler, SixthOrderResampler, SeventhOrderResampler

Coefficients are computed through a recursive scheme from an input reference volume. This recursive algorithm is fast for whole volume resampling, but slower for single points. A cache mechanism has thus been implemented so that coefficients are not recomputed if the input volume did not change.

The Resampling API is described in the base class, Resampler_POINT3DF.

getOrder()

order = getOrder()

Spline order (1 to 7)

Returns:order
Return type:int (1 to 7)
reset()

Computes spline coefficients corresponding to an input volume.

Spline coefficients are recomputed only if one of these conditions is satisfied: - inVolume is different from the last volume used for coefficients

computation (in the sense that they share the same adress)
  • t is different from the last t used for coefficients computation
  • A call to reset() has previously been made

This method actually calls updateParameters() and returns the coeff container

Parameters:
  • inVolume (Volume_POINT3DF) – input image
  • t (int) – volume to use in the T dimension in the case where inVolume is a time series.
  • verbose (bool) – print progress on stdout
Returns:

Volume of double containing the coefficients in the image domain. Border coefficient need to be retrieved by mirror.

Return type:

Volume_DOUBLE

class soma.aimsalgo.SplineResampler_RGB(*args)

B-Spline-based resampling.

This is the base class for all resamplers based on B-spline interpolation as described by Unser, Aldroubi & Eden in IEEE PAMI (1991). A class computing the actual spline coefficient is derived for each spline order (1 to 7).

See : LinearResampler, CubicResampler, QuadraticResampler,
QuinticResampler, SixthOrderResampler, SeventhOrderResampler

Coefficients are computed through a recursive scheme from an input reference volume. This recursive algorithm is fast for whole volume resampling, but slower for single points. A cache mechanism has thus been implemented so that coefficients are not recomputed if the input volume did not change.

The Resampling API is described in the base class, Resampler_RGB.

getOrder()

order = getOrder()

Spline order (1 to 7)

Returns:order
Return type:int (1 to 7)
reset()

Computes spline coefficients corresponding to an input volume.

Spline coefficients are recomputed only if one of these conditions is satisfied: - inVolume is different from the last volume used for coefficients

computation (in the sense that they share the same adress)
  • t is different from the last t used for coefficients computation
  • A call to reset() has previously been made

This method actually calls updateParameters() and returns the coeff container

Parameters:
  • inVolume (Volume_RGB) – input image
  • t (int) – volume to use in the T dimension in the case where inVolume is a time series.
  • verbose (bool) – print progress on stdout
Returns:

Volume of double containing the coefficients in the image domain. Border coefficient need to be retrieved by mirror.

Return type:

Volume_DOUBLE

class soma.aimsalgo.SplineResampler_RGBA(*args)

B-Spline-based resampling.

This is the base class for all resamplers based on B-spline interpolation as described by Unser, Aldroubi & Eden in IEEE PAMI (1991). A class computing the actual spline coefficient is derived for each spline order (1 to 7).

See : LinearResampler, CubicResampler, QuadraticResampler,
QuinticResampler, SixthOrderResampler, SeventhOrderResampler

Coefficients are computed through a recursive scheme from an input reference volume. This recursive algorithm is fast for whole volume resampling, but slower for single points. A cache mechanism has thus been implemented so that coefficients are not recomputed if the input volume did not change.

The Resampling API is described in the base class, Resampler_RGBA.

getOrder()

order = getOrder()

Spline order (1 to 7)

Returns:order
Return type:int (1 to 7)
reset()

Computes spline coefficients corresponding to an input volume.

Spline coefficients are recomputed only if one of these conditions is satisfied: - inVolume is different from the last volume used for coefficients

computation (in the sense that they share the same adress)
  • t is different from the last t used for coefficients computation
  • A call to reset() has previously been made

This method actually calls updateParameters() and returns the coeff container

Parameters:
  • inVolume (Volume_RGBA) – input image
  • t (int) – volume to use in the T dimension in the case where inVolume is a time series.
  • verbose (bool) – print progress on stdout
Returns:

Volume of double containing the coefficients in the image domain. Border coefficient need to be retrieved by mirror.

Return type:

Volume_DOUBLE

class soma.aimsalgo.SplineResampler_S16(*args)

B-Spline-based resampling.

This is the base class for all resamplers based on B-spline interpolation as described by Unser, Aldroubi & Eden in IEEE PAMI (1991). A class computing the actual spline coefficient is derived for each spline order (1 to 7).

See : LinearResampler, CubicResampler, QuadraticResampler,
QuinticResampler, SixthOrderResampler, SeventhOrderResampler

Coefficients are computed through a recursive scheme from an input reference volume. This recursive algorithm is fast for whole volume resampling, but slower for single points. A cache mechanism has thus been implemented so that coefficients are not recomputed if the input volume did not change.

The Resampling API is described in the base class, Resampler_S16.

getOrder()

order = getOrder()

Spline order (1 to 7)

Returns:order
Return type:int (1 to 7)
reset()

Computes spline coefficients corresponding to an input volume.

Spline coefficients are recomputed only if one of these conditions is satisfied: - inVolume is different from the last volume used for coefficients

computation (in the sense that they share the same adress)
  • t is different from the last t used for coefficients computation
  • A call to reset() has previously been made

This method actually calls updateParameters() and returns the coeff container

Parameters:
  • inVolume (Volume_S16) – input image
  • t (int) – volume to use in the T dimension in the case where inVolume is a time series.
  • verbose (bool) – print progress on stdout
Returns:

Volume of double containing the coefficients in the image domain. Border coefficient need to be retrieved by mirror.

Return type:

Volume_DOUBLE

class soma.aimsalgo.SplineResampler_S32(*args)

B-Spline-based resampling.

This is the base class for all resamplers based on B-spline interpolation as described by Unser, Aldroubi & Eden in IEEE PAMI (1991). A class computing the actual spline coefficient is derived for each spline order (1 to 7).

See : LinearResampler, CubicResampler, QuadraticResampler,
QuinticResampler, SixthOrderResampler, SeventhOrderResampler

Coefficients are computed through a recursive scheme from an input reference volume. This recursive algorithm is fast for whole volume resampling, but slower for single points. A cache mechanism has thus been implemented so that coefficients are not recomputed if the input volume did not change.

The Resampling API is described in the base class, Resampler_S32.

getOrder()

order = getOrder()

Spline order (1 to 7)

Returns:order
Return type:int (1 to 7)
reset()

Computes spline coefficients corresponding to an input volume.

Spline coefficients are recomputed only if one of these conditions is satisfied: - inVolume is different from the last volume used for coefficients

computation (in the sense that they share the same adress)
  • t is different from the last t used for coefficients computation
  • A call to reset() has previously been made

This method actually calls updateParameters() and returns the coeff container

Parameters:
  • inVolume (Volume_S32) – input image
  • t (int) – volume to use in the T dimension in the case where inVolume is a time series.
  • verbose (bool) – print progress on stdout
Returns:

Volume of double containing the coefficients in the image domain. Border coefficient need to be retrieved by mirror.

Return type:

Volume_DOUBLE

class soma.aimsalgo.SplineResampler_U16(*args)

B-Spline-based resampling.

This is the base class for all resamplers based on B-spline interpolation as described by Unser, Aldroubi & Eden in IEEE PAMI (1991). A class computing the actual spline coefficient is derived for each spline order (1 to 7).

See : LinearResampler, CubicResampler, QuadraticResampler,
QuinticResampler, SixthOrderResampler, SeventhOrderResampler

Coefficients are computed through a recursive scheme from an input reference volume. This recursive algorithm is fast for whole volume resampling, but slower for single points. A cache mechanism has thus been implemented so that coefficients are not recomputed if the input volume did not change.

The Resampling API is described in the base class, Resampler_U16.

getOrder()

order = getOrder()

Spline order (1 to 7)

Returns:order
Return type:int (1 to 7)
reset()

Computes spline coefficients corresponding to an input volume.

Spline coefficients are recomputed only if one of these conditions is satisfied: - inVolume is different from the last volume used for coefficients

computation (in the sense that they share the same adress)
  • t is different from the last t used for coefficients computation
  • A call to reset() has previously been made

This method actually calls updateParameters() and returns the coeff container

Parameters:
  • inVolume (Volume_U16) – input image
  • t (int) – volume to use in the T dimension in the case where inVolume is a time series.
  • verbose (bool) – print progress on stdout
Returns:

Volume of double containing the coefficients in the image domain. Border coefficient need to be retrieved by mirror.

Return type:

Volume_DOUBLE

class soma.aimsalgo.SplineResampler_U32(*args)

B-Spline-based resampling.

This is the base class for all resamplers based on B-spline interpolation as described by Unser, Aldroubi & Eden in IEEE PAMI (1991). A class computing the actual spline coefficient is derived for each spline order (1 to 7).

See : LinearResampler, CubicResampler, QuadraticResampler,
QuinticResampler, SixthOrderResampler, SeventhOrderResampler

Coefficients are computed through a recursive scheme from an input reference volume. This recursive algorithm is fast for whole volume resampling, but slower for single points. A cache mechanism has thus been implemented so that coefficients are not recomputed if the input volume did not change.

The Resampling API is described in the base class, Resampler_U32.

getOrder()

order = getOrder()

Spline order (1 to 7)

Returns:order
Return type:int (1 to 7)
reset()

Computes spline coefficients corresponding to an input volume.

Spline coefficients are recomputed only if one of these conditions is satisfied: - inVolume is different from the last volume used for coefficients

computation (in the sense that they share the same adress)
  • t is different from the last t used for coefficients computation
  • A call to reset() has previously been made

This method actually calls updateParameters() and returns the coeff container

Parameters:
  • inVolume (Volume_U32) – input image
  • t (int) – volume to use in the T dimension in the case where inVolume is a time series.
  • verbose (bool) – print progress on stdout
Returns:

Volume of double containing the coefficients in the image domain. Border coefficient need to be retrieved by mirror.

Return type:

Volume_DOUBLE

class soma.aimsalgo.SplineResampler_U8(*args)

B-Spline-based resampling.

This is the base class for all resamplers based on B-spline interpolation as described by Unser, Aldroubi & Eden in IEEE PAMI (1991). A class computing the actual spline coefficient is derived for each spline order (1 to 7).

See : LinearResampler, CubicResampler, QuadraticResampler,
QuinticResampler, SixthOrderResampler, SeventhOrderResampler

Coefficients are computed through a recursive scheme from an input reference volume. This recursive algorithm is fast for whole volume resampling, but slower for single points. A cache mechanism has thus been implemented so that coefficients are not recomputed if the input volume did not change.

The Resampling API is described in the base class, Resampler_U8.

getOrder()

order = getOrder()

Spline order (1 to 7)

Returns:order
Return type:int (1 to 7)
reset()

Computes spline coefficients corresponding to an input volume.

Spline coefficients are recomputed only if one of these conditions is satisfied: - inVolume is different from the last volume used for coefficients

computation (in the sense that they share the same adress)
  • t is different from the last t used for coefficients computation
  • A call to reset() has previously been made

This method actually calls updateParameters() and returns the coeff container

Parameters:
  • inVolume (Volume_U8) – input image
  • t (int) – volume to use in the T dimension in the case where inVolume is a time series.
  • verbose (bool) – print progress on stdout
Returns:

Volume of double containing the coefficients in the image domain. Border coefficient need to be retrieved by mirror.

Return type:

Volume_DOUBLE

class soma.aimsalgo.Writer_FfdTransformation

FFD vector field transformation writer. It actually reads a volume of Point3df.

soma.aimsalgo.resampleBucket()
resampleBucket(bck, direct_transformation, inverse_transformation,
vs=aims.Point3df(0., 0., 0.), also_pushforward=True)

Apply a spatial transformation to a BucketMap.

The bucket is transformed by resampling, using a pull-back method in the same way as nearest neighbour resampling of a Volume.

Pure pull-back resampling does not behave well when downsampling (it introduces holes), so by default this function returns the union of voxels transformed using the pushforward and pullback methods. Set also_pushforward to false to disable this behaviour and only perform pure pullback.

The voxel size of the output bucket can optionally be specified in vs. By default, the same voxel size as the input bucket is used.

Warning

Alhtough this method is more reliable than transformBucketDirect, it still provides no guarantees of topology preservation.

soma.aimsalgo.transformBucketDirect(bck, direct_transformation, vs=aims.Point3df(0., 0., 0.))

Apply a spatial transformation to a BucketMap

Each voxel of the input bucket is transformed with direct_transformation, and the closest voxel of the output bucket is set. The voxel size of the output bucket can optionally be specified in vs. By default, the same voxel size as the input bucket is used.

Warning

This method provides no guarantees of topology preservation; in fact it will create holes in the resulting bucket, particularly when upsampling. When possible, you should use resampleBucket() instead, which performs nearest-neighbour resampling.

soma.aimsalgo.transformGraph()
transformGraph(graph, direct_transformation, inverse_transformation,
vs=aims.Point3df(0., 0., 0.))

Apply a spatial transformation to all objects contained in a Graph.

The graph is modified in-place.

An inverse transformation is necessary for correctly transforming Buckets (see resampleBucket). If inverse_transformation is NULL, buckets will be transformed with the push-forward method only (transformBucketDirect).

Warning

Volumes are not transformed, neither are graph attributes. Please run AimsFoldArgAtt to fix the values of basic attributes, or the CorticalFoldsGraphUpgradeFromOld BrainVisa process, which can be found under Morphologist/Sulci/graphmanipulation, for a complete update.

soma.aimsalgo.transformMesh(mesh, direct_transformation)

Apply a spatial transformation to a segments mesh (AimsTimeSurface).

The mesh is transformed in-place and modified.

Each vertex of the mesh is transformed according to the supplied transformation. Normals are re-calculated from the new vertex positions. transformMesh(mesh, direct_transformation)

Apply a spatial transformation to a triangles mesh (AimsTimeSurface)

The mesh is transformed in-place and modified.

Each vertex of the mesh is transformed according to the supplied transformation. Normals are re-calculated from the new vertex positions. transformMesh(mesh, direct_transformation)

Apply a spatial transformation to a quads mesh (AimsTimeSurface)

The mesh is transformed in-place and modified.

Each vertex of the mesh is transformed according to the supplied transformation. Normals are re-calculated from the new vertex positions.

soma.aimsalgo.t1mapping module

Reconstruct magnetic resonance parametres.

This is mainly a re-implementation of scripts provided by Alexandre Vignaud, plus a few improvements functions (such as mask and B1 map holes filling).

class soma.aimsalgo.t1mapping.BAFIData(amplitude_volume, phase_volume)[source]

B1 map reconstruction class using the VFA (Variable Flip Angle) method.

Pass the BAFI data as two amplitude-phase 4D AIMS volumes.

The last dimension of both arrays represents the different echos.

static correctB0(FA_map, FA_phase, B0_map, tau, echo_time)[source]

Apply B0 correction to a B1 map.

This is a re-implementation of correctB0.m, courtesy of Alexandre Vignaud.

fix_b1_map(b1map, smooth_type='median', gaussian=False, output_median=False)[source]

Fix/improve the B1 map by filling holes, smoothing, and extending it a little bit spacially so as to use it on the complete whole brain.

Parameters:
  • b1map (volume) – the B1 map to be corrected, may be the output of self.make_flip_angle_map()
  • smooth_type (str (optional)) – smoothing correction type. default: ‘median’ median: dilated:
  • gaussian (float (optional)) – default: 0 (not applied) perform an additional gaussian filtering of given stdev
  • output_median (bool (optional)) – if set, the output will be a tuple including a 2nd volume: the median-filtered B1 map. Only valid if smooth_type is ‘median’.
Returns:

  • The corrected B1 map.
  • If output_median is set, the return value is a tuple
  • (corrected B1 map, median-filtered B1 map)

make_B0_map()[source]

Build a map of B0 in Hz from BAFI data.

Return the map as a numpy array.

This is a re-implementation of Phase2B0Map.m, courtesy of Alexandre Vignaud.

make_B1_map(B0_correction=False)[source]

Build a map of B1 (in radians) from BAFI data.

Return a numpy array of complex type.

This is a re-implementation of BAFI2B1map.m, courtesy of Alexandre Vignaud.

  • The method is Yarnykh’s (MRM 57:192-200 (2007)) +
  • Amadon ISMRM2008 (MAFI sequence: simultaneaous cartography of B0

and B1)

make_flip_angle_map()[source]

Build a map of actual flip angle (in radians) from BAFI data.

This is a re-implementation of BAFI2FAmap.m (courtesy of Alexandre Vignaud) modified to return only the real flip angle (omitting the phase).

  • The method is Yarnykh’s (MRM 57:192-200 (2007)) +
  • Amadon ISMRM2008 (MAFI sequence: simultaneaous cartography of B0

and B1)

class soma.aimsalgo.t1mapping.GREData2FlipAngles(min_FA_volume, max_FA_volume)[source]
soma.aimsalgo.t1mapping.correct_bias(biased_vol, b1map, dp_gre_low_contrast=None, field_threshold=None)[source]

Apply bias correction on biased_vol according to the B1 map, and possibly a GRE low contrast image.

Without dp_gre_low_contrast image:

\[unbiased\_vol = biased\_vol / b1map\]

(plus improvements)

With dp_gre_low_contrast image:

\[unbiased\_vol = biased\_vol / (lowpass(dp\_gre\_low\_contrast) * b1map)\]

(roughly)

\(lowpass\) is currently a gaussian filter with sigma=8mm.

method: courtesy of Alexandre Vignaud.

ref: ISMRM abstract Mauconduit et al.

All input images are expected to contain transformation information to a common space in their header (1st transformation, normally to the scanner-based referential). They are thus not expected to have the same field of view or voxel size, all are resampled to the biased_vol space.

The returned value is a tuple containing 2 images: the corrected image, and the multiplicative correction field.

Parameters:
  • biased_vol (volume) – volume to be corrected
  • b1map (volume) – B1 map as flip angles in degrees, generally returned by BAFIData.make_flip_angle_map. May be improved (holes filled, dilated) using BAFIData.fix_b1_map() which is generally better.
  • dp_gre_low_contrast (volume (optional)) – GRE low contrast image
  • field_threshold (float (optional)) – Threshold for the corrective field before inversion: the biased image will be divided by this field. To avoid too high values, field values under this threshold are clamped. Null values are masked out, so the threshold applies only to non-null values. If not specified, the threshold is 100 if the dp_gre_low_contrast is not provided, and 3000 when dp_gre_low_contrast is used. If field_threshold is 0, then no thresholding is applied.
Returns:

  • unbiased_vol (volume) – according to the calculations explained above. The returned image has the same voxel type as the input one (althrough calculations are performed in float in the function), and the grey levels are roughly adjusted to the level of input data (unless it produces overflow, in which case the max value is adjusted to fit in the voxel type).
  • field (volume) – The correction field applied to the image (multiplicatively)

soma.aimsalgo.t1mapping.correct_sensitivity_map(sensitivity_map, flip_angle_map)[source]

Factor out the effect of the transmit field from a sensitivity map.

soma.aimsalgo.t1mapping.t1mapping_VFA(flip_angle_factor, GRE_data)[source]

Reconstruct a T1 relaxometry map from DESPOT1 data (2 flip angles).

This is a re-implementation of GetT1_VAFI3Dp_Brebis.m, courtesy of Alexandre Vignaud.

soma.wip.aimsalgo module

class soma.wip.aimsalgo.foldsgraphthickness.FoldsGraphThickness(fold_graph, lgw_vol, gm_wm_mesh, gm_lcr_mesh, voronoi=None)[source]
class soma.wip.aimsalgo.moment.Moment[source]
class soma.wip.aimsalgo.samplables.SuperQuadricSamplable(coefficients, bending=True, tapering=True, checkActivated=True, maxBoundingBoxVolume=10000000)[source]

Constructor of the class.

@type coefficients: list @param checkActivated: list of the 10 deformable superquadric coefficients.

  • e1 : first shape parameter
  • e2 : second shape parameter
  • a1 : x axis ray
  • a2 : y axis ray
  • a3 : z axis ray
  • k1 : first tapering parameter
  • k2 : second tapering parameter
  • k3 : third tapering parameter
  • alpha : angle of bending plan
  • kapa : curvature radius for the bending transform
class soma.wip.aimsalgo.transform.BendingTransform(coefficients)[source]
class soma.wip.aimsalgo.transform.TaperingTransform(coefficients)[source]