Commit 3486ff21 authored by inhuszar's avatar inhuszar
Browse files

Evaluation: masks missing data automatically.

parent 710a658a
......@@ -20,7 +20,7 @@
import os
# Temporary working directory (use absolute path!)
TWD = "/tmp/TIRLTWD"
TWD = "/tmp/temp/TWD"
try:
if not os.path.isdir(TWD):
os.makedirs(TWD)
......@@ -126,6 +126,7 @@ TIMAGE_MASK_INTERPOLATOR = \
TIMAGE_PRESMOOTH = True
TIMAGE_PRESMOOTH_KERNELSIZE_NSIGMA = 3
TIMAGE_DEFAULT_SNAPSHOT_EXT = "png"
TIMAGE_MASK_MISSING_DATA = True # added 13 Aug 2020
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
# Operations #
......
......@@ -1814,6 +1814,21 @@ class TImage(TField):
if self.mask is not None:
mask = mask.reshape(target_domain.shape)
# Mask points that are outside the voxel grid
# Added on 13 August 2020
if ts.TIMAGE_MASK_MISSING_DATA:
if mask is None:
mask = np.ones(target_domain.shape, dtype=np.float32)
indices = [np.flatnonzero(np.any(vcoords < 0, axis=-1))]
for dim in range(self.vdim):
ix = np.flatnonzero(vcoords[:, dim] >= self.vshape[dim])
indices.append(ix)
else:
# These are the linear indices of all voxels outside
# the voxel grid
indices = np.unique(np.concatenate(indices))
mask.flat[indices] = 0
# Create new TImage
new_name = "%s.%s" % (self.name, target_domain.name)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment