BodenmillerGroup / steinbock

A toolkit for processing multiplexed tissue images
https://bodenmillergroup.github.io/steinbock
MIT License
49 stars 14 forks source link

expand_mask(mask, distance) #194

Closed eleonore-schneeg closed 8 months ago

eleonore-schneeg commented 1 year ago

Hi,

I've been trying to make the python function expand_mask work.

This is how I'm currently trying to implement it : (Maybe this isn't the way to implement it, but Im not sure how) I would like to expand the masks for an entire folder of tiff images.

expand_mask(mask='A138.12_001.tiff', distance=10)

Here is the error:


TypeError Traceback (most recent call last) Input In [50], in <cell line: 1>() ----> 1 expand_mask(mask='A138.12_001.tiff', distance=10)

File ~/Desktop/steinbock-main/steinbock/utils/expansion.py:12, in expand_mask(mask, distance) 11 def expand_mask(mask: np.ndarray, distance: int) -> np.ndarray: ---> 12 expanded_mask = expand_labels(mask, distance=distance) 13 return expanded_mask

File ~/opt/anaconda3/lib/python3.9/site-packages/skimage/segmentation/_expand_labels.py:104, in expand_labels(label_image, distance) 97 # build the coordinates to find nearest labels, 98 # in contrast to [1] this implementation supports label arrays 99 # of any dimension 100 masked_nearest_label_coords = [ 101 dimension_indices[dilate_mask] 102 for dimension_indices in nearest_label_coords 103 ] --> 104 nearest_labels = label_image[tuple(masked_nearest_label_coords)] 105 labels_out[dilate_mask] = nearest_labels 106 return labels_out

TypeError: string indices must be integers

Milad4849 commented 1 year ago

Hi @eleonore-schneeg

The function that you are trying to use takes an np.ndarray as a input (see here), so you need to first read-in the mask and then pass that to the function. These recent features are not yet well documented and we will update the relevant documentation int he future.