Closed cookpa closed 1 month ago
Related to #641
@ncullen93 the matrix here was all zero because it was sampling a corner of the image, by adding the spacing arg I make the downsampled mask cover all of the image domain
s = [65]img.dimension mask2 = ants.from_numpy(np.random.randn(s), spacing=[4.0, 4.0]) mask2 = mask2 > mask2.mean() imgmat = ants.images_to_matrix(imglist, mask=mask2)
Still not sure what the Windows seg faults were about, but will revisit if they happen again
Great! My guess is the windows error was because there was a function within a function trying to access an image in the outer function environment.. perhaps something with the c++ references that is quit complicated. I removed that and it will hopefully be OK. Here is a simplified version:
def outer_fn(image, mask):
def inner_fn(image):
# mask not in "inner" environment but being accessed anyways
return image + mask
return inner_fn(image)
Prevents cryptic error if the mask is not binarized, because the threshold was being applied to the numpy matrix but not the mask itself.
Also add some more tests