Counting incidence of tracks in voxels of volume
Counts of points in tracks that pass through voxels in volume
We find whether a point passed through a track by rounding the mm point values to voxels. For a track that passes through a voxel more than once, we only record counts and elements for the first point in the line that enters the voxel.
Parameters : | tracks : sequence
vol_dims : sequence length 3
vox_sizes : optional, sequence length 3
return_elements : {True, False}, optional
|
---|---|
Returns : | tcs : ndarray shape vol_dim
tes : ndarray dtype np.object, shape vol_dim
|
Examples
Imagine you have a volume (voxel) space of dimension (10,20,30). Imagine you had voxel coordinate tracks in vs. To just fill an array with the counts of how many tracks pass through each voxel:
>>> vox_track0 = np.array([[0,0,0],[1.1,2.2,3.3],[2.2,4.4,6.6]])
>>> vox_track1 = np.array([[0,0,0],[0,0,1],[0,0,2]])
>>> vs = (vox_track0, vox_track1)
>>> vox_dim = (10, 20, 30) # original voxel array size
>>> tcs=track_counts(vs, vox_dim, (1,1,1), False)
>>> tcs.shape
(10, 20, 30)
>>> tcs[0,0,0:4]
array([2, 1, 1, 0])
>>> tcs[1,2,3], tcs[2,4,7]
(1, 1)
You can also use the routine to count into larger-than-voxel boxes. To do this, increase the voxel size and decrease the vox_dim accordingly:
>>> tcs=track_counts(vs, (10/2., 20/2., 30/2.), (2,2,2), False)
>>> tcs.shape
(5, 10, 15)
>>> tcs[1,1,2], tcs[1,2,3]
(1, 1)