designer.system.utils.clipImage(img, range)

Clips input matrix within desired range. Min and max values are inclusive of range Classification: Function

Parameters
  • img (ndarray(dtype=float)) – Input 3D image array

  • range (array_like) – [1 x 2] vector specifying range to clip

Returns

clippedImage

Return type

clipped image; same size as img

Examples

clippedImage = clipImage(image, [0 3]) Clips input matrix in the range 0 to 3

designer.system.utils.highprecisionexp(array, maxp=1e+32)

Prevents overflow warning with numpy.exp by assigning overflows to a maxumum precision value Classification: Function

Parameters
  • array (ndarray) – Array or scalar of number to run np.exp on

  • maxp (float, optional) – Maximum preicison to assign if overflow (Default: 1e32)

Return type

exponent or max-precision

Examples

a = highprecisionexp(array)

designer.system.utils.highprecisionpower(x1, x2, maxp=1e+32)

Prevents overflow warning with numpy.powerr by assigning overflows to a maxumum precision value Classification: Function

Parameters
  • x1 (array_like) – The bases

  • x2 (array_like) – The exponents

  • maxp (float, optional) – Maximum preicison to assign if overflow (Default: 1e32)

Return type

x1 raised to x2 power, or max precision defined by maxp

Examples

a = highprecisionexp(array)

designer.system.utils.vectorize(img, mask)

Returns vectorized image based on brain mask, requires no input parameters If the input is 1D or 2D, unpatch it to 3D or 4D using a mask If the input is 3D or 4D, vectorize it using a mask Classification: Function

Parameters
  • img (ndarray) – 1D, 2D, 3D or 4D image array to vectorize

  • mask (ndarray) – 3D image array for masking

Returns

vec – of DWI volumes

Return type

N X number_of_voxels vector or array, where N is the number

Examples

vec = vectorize(img) if there’s no mask vec = vectorize(img, mask) if there’s a mask

designer.system.utils.writeNii(map, hdr, outDir, range=None)

Write clipped NifTi images

Parameters
  • map (ndarray(dtype=float)) – 3D array to write

  • header (class) – Nibabel class header file containing NifTi properties

  • outDir (str) – Output file name

  • range (array_like) – [1 x 2] vector specifying range to clip, inclusive of value in range, e.g. range = [0, 1] for FA map

Return type

None; writes out file

Examples

writeNii(matrix, header, output_directory, [0, 2])

See Also clipImage(img, range) : this function is wrapped around