spam.kalisphera package#

Submodules#

spam.kalisphera.kalisphera module#

Library of SPAM functions for generating partial volume balls, see Tengattini et al. 2015 Copyright (C) 2020 SPAM Contributors

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

spam.kalisphera.kalisphera.makeSphere(vol, centre, radius)[source]#

This function creates a sphere in a given 3D volume, with analytically-calculated partial-volume effects. Background is assumed to have a greyvalue of zero, and a fully-occupied sphere voxel is considered to have a greyvalue of 1.

Greyvalues are added to the volume, so spheres can be added to an existing background.

Parameters:
  • vol (3D numpy array of doubles) – A 3D image of greylevels (typically zeros) into which sphere(s) should be added

  • centre (1D or 2D numpy array) – Either a 3-component vector, or an Nx3 matrix of sphere centres to draw with respect to 0,0,0 in vol

  • radius (float or 1D numpy array) – Raduis(ii) of spheres to draw in vol

Returns:

None

Return type:

function updates vol

spam.kalisphera.kalisphera.makeBlurryNoisySphere(dims, centre, radius, blur=0, noise=0, flatten=True, background=0.25, foreground=0.75)[source]#

This function creates a sphere or series of spheres in a 3D volume, with analytically-calculated partial-volume effects.

This function can flattens overlaps, then adds gaussian blur and then gaussian noise to makeSphere.

Parameters:
  • dims (3-component list) – Dimensions of volume to create

  • centre (1D or 2D numpy array) – Either a 3-component vector, or an Nx3 array of sphere centres to draw with respect to 0,0,0 in vol

  • radius (float or 1D numpy array) – Radius(ii) of spheres to draw in vol

  • blur (float, optional) – Standard deviation of the blur kernel (in ~pixels) Default = 0

  • noise (float, optional) – Standard devitaion of the noise (in greylevels), noise is on the scale: background=0 and sphere=1 Default = 0

  • flatten (bool, optional) – Flatten greyvalues >1 to 1 (caused by overlaps)? Default = True

  • background (float, optional) – Desired mean greyvalue of the background Default = 0.25

  • foreground (float, optional) – Desired mean greyvalue of the background Default = 0.75

Returns:

vol – Note this is different return behaviour than makeSphere, which doesn’t return anything!!

Return type:

the input array

spam.kalisphera.spheroid module#

Library of SPAM functions for generating 3D spheroids Copyright (C) 2020 SPAM Contributors

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

spam.kalisphera.spheroid.makeBlurryNoisySpheroid(dims, centres, axisLengthsAC, orientations, blur=0, noise=0, flatten=True, background=0.25, foreground=0.75)[source]#

This function creates a sheroid or series of spheroids in a 3D volume, adding noise and blur if requested. Note that this does not handle the partial volume effect like kalisphera, and so some blur or downscaling is recommended!

The base code is from https://sbrisard.github.io/posts/20150930-orientation_correlations_among_rice_grains-06.html

Parameters:
  • dims (3-component list) – Dimensions of volume to create

  • centre (1D or 2D numpy array) – Either a 3-component vector, or an Nx3 array of centres to draw with respect to 0,0,0 in vol

  • axisLengthsAC (1D or 2D numpy array of floats) – Half-axis lengths for each spheroid. If c>a, a prolate (rice-like) is generated; while a>c yields an oblate (lentil-like). This is either a 2-component array for 1 particle, or a Nx2 array of values.

  • orientations (1D or 2D numpy array of floats) – Orientation vectors of the axis of rotational symmetry for the spheroid. This is either a 3-component ZYX array for 1 particle, or a Nx3 array of values.

  • blur (float, optional) – Standard deviation of the blur kernel (in ~pixels) Default = 0

  • noise (float, optional) – Standard devitaion of the noise (in greylevels), reminder background=0 and sphere=1 Default = 0

  • flatten (bool, optional) – Flatten greyvalues >1 to 1 (caused by overlaps)? Default = True

  • background (float, optional) – Desired mean greyvalue of the background Default = 0.25

  • foreground (float, optional) – Desired mean greyvalue of the background Default = 0.75

Returns:

vol

Return type:

the input array

Module contents#