mmt_dipole_cuboid_inversion.tools.cuboid_decompose
#
Cuboid decomposition of microCT particle voxel data @author: Karl Fabian, NTNU Licensed under MIT License, 2021
Module Contents#
Functions#
|
Given two lists a and b, returns True only if all elements of a are less |
|
Sorts a list of sequences to find locations to generate largest cuboid |
|
Converts a list lst of 0,1 values to the lengths of cosecutive 1's |
|
Reads voxel file and returns system properties to start decomposition |
|
Find maximum |
|
|
|
|
|
|
|
Perform cuboid aggregation decomposition of pixel data from a text file |
- mmt_dipole_cuboid_inversion.tools.cuboid_decompose.LEQ(a, b)#
Given two lists a and b, returns True only if all elements of a are less or equal than the elements of b. Return False when at least one element of a is >= than an element of b
- mmt_dipole_cuboid_inversion.tools.cuboid_decompose.TupleMaxima(lst)#
Sorts a list of sequences to find locations to generate largest cuboid
Given a list of sequences (or 2-sequences) perform:
Sort them by their minimum value and invert sorting
- Choose the one with the largest minimum (first element in sorted list)and append it to a list, say MAX
Iterate through the other sequences
- If one of the iterated seq is not LEQ with the first element in MAX(largest minimum) then append it to the MAX list. The next iterationwill have to compare if the seq is not LEQ with the two (or more)elements in MAX (and so on, MAX can grow during iteration)
- Parameters:
- lst
Sequence of lists
- mmt_dipole_cuboid_inversion.tools.cuboid_decompose.tolen(lst)#
Converts a list lst of 0,1 values to the lengths of cosecutive 1’s to the right up to an element containing a 0 tolen( [0,0,1,1,1,0,0,1,1,0,1]) -> [0,0,3,2,1,0,0,2,1,0,1]
- mmt_dipole_cuboid_inversion.tools.cuboid_decompose.get_voxel_file(fn)#
Reads voxel file and returns system properties to start decomposition
- Parameters:
- fn
Text file with 4 columns: index, x, y, z. First row is skipped. The data is in integer format, which represent the grain-index and pixel coordinates. Column headers can have any name but should be in order.
- Returns:
- A 4-elements tuple: (min, max, count, zeros_array) where
min -> minimum of x y z positions ..max -> maximum of x y z positions ..count -> number of voxels ..zeros_array -> a 3D matrix with zeros and ones, with the dimensions ..according to the grain size, e.g. max_x - min_x ..Values 1 are placed where x y z positions are located ..
- mmt_dipole_cuboid_inversion.tools.cuboid_decompose.findmax(layer, ldim, a, b)#
Find maximum
For a layer (2D array) with dimensions (ldim[0], ldim[1]) layer is a 2D array with the number of consecutive 1s to the right at positions row=a, col=b
- mmt_dipole_cuboid_inversion.tools.cuboid_decompose.findmax3(arr, adim, maxdir, a, b, c)#
- mmt_dipole_cuboid_inversion.tools.cuboid_decompose.max_cuboid(zarr)#
- mmt_dipole_cuboid_inversion.tools.cuboid_decompose.cuboid_decomposition_method(mn, zarr)#
- mmt_dipole_cuboid_inversion.tools.cuboid_decompose.CuboidDecomposition(fn, fnout, format_output=False)#
Perform cuboid aggregation decomposition of pixel data from a text file
- Parameters:
- fn
Text file with 4 columns: index, x, y, z. First row is skipped. The data is in integer format, which represent the index and pixel coordinates. Column headers can have any name but should be in order.
- fnout
File name for output CSV text file with cuboid decomposition.
- format_output
If False, the output file contains the lower and upper corners defining the cuboids in pixel coordinates (pixel centers). If True, the output contains the center coordinates of every cuboid, half the cuboid lenghts in every spatial dimension and the indexes as x, y, z, dx, dy, dz, index