A set of methods to get coordinate maps which represent slices in space.
Determine a valid bounding box from a CoordinateMap and a shape.
Parameters : | coordmap : CoordinateMap or AffineTransform
shape : sequence of int
|
---|---|
Returns : | limits : (N,) tuple of (2,) tuples of float
|
Examples
>>> A = AffineTransform.from_start_step('ijk', lps_output_coordnames, [2,4,6], [1,3,5])
>>> bounding_box(A, (30,40,20))
((2.0, 31.0), (4.0, 121.0), (6.0, 101.0))
Return an LPS slice through a 3d box with x fixed.
Parameters : | x : float
y_spec : sequence
z_spec : sequence
output_space : str, optional
|
---|---|
Returns : | affine_transform : AffineTransform
|
Examples
>>> y_spec = ([-114,114], 115) # voxels of size 2 in y, starting at -114, ending at 114
>>> z_spec = ([-70,100], 86) # voxels of size 2 in z, starting at -70, ending at 100
>>> x30 = xslice(30, y_spec, z_spec)
>>> x30([0,0])
array([ 30., -114., -70.])
>>> x30([114,85])
array([ 30., 114., 100.])
>>> x30
AffineTransform(
function_domain=CoordinateSystem(coord_names=('i_y', 'i_z'), name='slice', coord_dtype=float64),
function_range=CoordinateSystem(coord_names=('x+LR', 'y+PA', 'z+SI'), name='', coord_dtype=float64),
affine=array([[ 0., 0., 30.],
[ 2., 0., -114.],
[ 0., 2., -70.],
[ 0., 0., 1.]])
)
>>> bounding_box(x30, (y_spec[1], z_spec[1]))
((30.0, 30.0), (-114.0, 114.0), (-70.0, 100.0))
Return a slice through a 3d box with y fixed.
Parameters : | y : float
x_spec : sequence
z_spec : sequence
output_space : str, optional
|
---|---|
Returns : | affine_transform : AffineTransform
|
Examples
>>> x_spec = ([-92,92], 93) # voxels of size 2 in x, starting at -92, ending at 92
>>> z_spec = ([-70,100], 86) # voxels of size 2 in z, starting at -70, ending at 100
>>> y70 = yslice(70, x_spec, z_spec)
>>> y70
AffineTransform(
function_domain=CoordinateSystem(coord_names=('i_x', 'i_z'), name='slice', coord_dtype=float64),
function_range=CoordinateSystem(coord_names=('x+LR', 'y+PA', 'z+SI'), name='', coord_dtype=float64),
affine=array([[ 2., 0., -92.],
[ 0., 0., 70.],
[ 0., 2., -70.],
[ 0., 0., 1.]])
)
>>> y70([0,0])
array([-92., 70., -70.])
>>> y70([92,85])
array([ 92., 70., 100.])
>>>
>>> bounding_box(y70, (x_spec[1], z_spec[1]))
((-92.0, 92.0), (70.0, 70.0), (-70.0, 100.0))
Return a slice through a 3d box with z fixed.
Parameters : | z : float
x_spec : sequence
y_spec : sequence
output_space : str, optional
|
---|---|
Returns : | affine_transform : AffineTransform
|
Examples
>>> x_spec = ([-92,92], 93) # voxels of size 2 in x, starting at -92, ending at 92
>>> y_spec = ([-114,114], 115) # voxels of size 2 in y, starting at -114, ending at 114
>>> z40 = zslice(40, x_spec, y_spec)
>>> z40
AffineTransform(
function_domain=CoordinateSystem(coord_names=('i_x', 'i_y'), name='slice', coord_dtype=float64),
function_range=CoordinateSystem(coord_names=('x+LR', 'y+PA', 'z+SI'), name='', coord_dtype=float64),
affine=array([[ 2., 0., -92.],
[ 0., 2., -114.],
[ 0., 0., 40.],
[ 0., 0., 1.]])
)
>>> z40([0,0])
array([ -92., -114., 40.])
>>> z40([92,114])
array([ 92., 114., 40.])
>>> bounding_box(z40, (x_spec[1], y_spec[1]))
((-92.0, 92.0), (-114.0, 114.0), (40.0, 40.0))