babelscan.volume

volume

Lazy Volume class

babelscan.volume.check_roi_op(volume, operation)[source]

Create new region of interest (roi) values from operation string The roi centre and size is defined by an operation:

operation = ‘nroi[210, 97, 75, 61]’ ‘nroi’ - creates a region of interest in the detector centre with size 31x31 ‘nroi[h,v]’ - creates a roi in the detector centre with size hxv, where h is horizontal, v is vertical ‘nroi[m,n,h,v] - create a roi with cen_h, cen_v, wid_h, wid_v = n, m, h, v

Parameters:
  • volume – Volume object or numpy.array with ndim==3

  • operation – str : operation string

Returns:

cen_h, cen_v, wid_h, wid_v, operation

find average position of bright points in image :param data: numpy array with ndims 1,2,3 :param peak_percentile: float from 0-100, percentile of image to use as peak area :return: i, j, k index of image[i,j,k]

babelscan.volume.roi(volume, cen_h=None, cen_v=None, wid_h=31, wid_v=31)[source]

Create new region of interest from detector images :param volume: Volume object or numpy.array with ndim==3 :param cen_h: int or None :param cen_v: int or None :param wid_h: int or None :param wid_v: int or None :return: l*wid_v*wid_h array

babelscan.volume.roi_op(volume, operation)[source]

Create new region of interest (roi) values from operation string The roi centre and size is defined by an operation:

operation = ‘nroi[210, 97, 75, 61]’ ‘nroi’ - creates a region of interest in the detector centre with size 31x31 ‘nroi[h,v]’ - creates a roi in the detector centre with size hxv, where h is horizontal, v is vertical ‘nroi[m,n,h,v] - create a roi with cen_h, cen_v, wid_h, wid_v = n, m, h, v

Parameters:
  • volume – Volume object or numpy.array with ndim==3

  • operation – str : operation string

Returns:

l*wid_v*wid_h array

babelscan.volume.roi_op_sum(volume, operation)[source]

Create new region of interest (roi) values from operation string The roi centre and size is defined by an operation:

operation = ‘nroi[210, 97, 75, 61]’ ‘nroi’ - creates a region of interest in the detector centre with size 31x31 ‘nroi[h,v]’ - creates a roi in the detector centre with size hxv, where h is horizontal, v is vertical ‘nroi[m,n,h,v] - create a roi with cen_h, cen_v, wid_h, wid_v = n, m, h, v

Parameters:
  • volume – Volume object or numpy.array with ndim==3

  • operation – str : operation string

Returns:

roi_sum, roi_max

babelscan.volume.roi_sum(volume, cen_h=None, cen_v=None, wid_h=31, wid_v=31)[source]

Create new region of interest from detector images, return sum and max of each image :param volume: Volume object or numpy.array with ndim==3 :param cen_h: int or None :param cen_v: int or None :param wid_h: int or None :param wid_v: int or None :return: roi_sum, roi_max

Class: Volume

class babelscan.volume.Volume[source]
Volume functions

Contains various functions to operate on 3D volumes

Class: ArrayVolume

class babelscan.volume.ArrayVolume(array)[source]
ArrayVolume for 3D Numpy arrays

Contains additional functions for 3D arrays

Usage:

array = np.array([[[1,2],[3,4]],[[5,6],[7,8]]]) lzvol = ArrayVolume(array) image = lzvol[0]

Supported indexing:
single dimension indexing, as numpy array:

vol = lzvol[:3] vol = lzvol[slice(1,-1,2)]

multi-dimension indexing, as numpy array:

vol = lzvol[3, 100:200] vol = lzvol[1:-1, 100:200, 100:200]

array operations

len(lzvol), np.shape(lzvol), np.size(lzvol), np.ndim(lzvol) np.sum(lzvol), np.mean(lzvol), np.percentile(lzvol)

boolean array operations

lzvol > 1 (<, <=, >, >=, ==, !=)

Class: ImageVolume

class babelscan.volume.ImageVolume(list_of_files)[source]
ImageVolume for images

Only loads images when called, reducing memory requirements

Usage:

lzvol = ImageVolume([file1.tiff, file2.tiff, file3.tiff,…]) image = lzvol[0]

Supported indexing:
single dimension indexing, as numpy array:

vol = lzvol[:3] vol = lzvol[slice(1,-1,2)]

multi-dimension indexing, as numpy array:

vol = lzvol[3, 100:200] vol = lzvol[1:-1, 100:200, 100:200]

array operations

len(lzvol), np.shape(lzvol), np.size(lzvol), np.ndim(lzvol) np.sum(lzvol), np.mean(lzvol), np.percentile(lzvol)

boolean array operations

lzvol > 1 (<, <=, >, >=, ==, !=)

Class: DatasetVolume

class babelscan.volume.Volume[source]
Volume functions

Contains various functions to operate on 3D volumes