DigitalSlideArchive / HistomicsTK

A Python toolkit for pathology image analysis algorithms.
https://digitalslidearchive.github.io/HistomicsTK/
Apache License 2.0
389 stars 116 forks source link

Find the same stain vector for hematoxylin and eosin #556

Open joelive opened 5 years ago

joelive commented 5 years ago

when I run find_stain_index like the example code: w_est = htk.preprocessing.color_deconvolution.rgb_separate_stains_macenko_pca(imInput, I_0) Perform color deconvolution

deconv_result = htk.preprocessing.color_deconvolution.color_deconvolution(imInput, w_est, I_0)

print('Estimated stain colors (rows):', w_est.T[:2], sep='\n') Display results

for i in 0, 1: plt.figure()

Unlike SNMF, we're not guaranteed the order of the different stains.

find_stain_index guesses which one we want

channel = htk.preprocessing.color_deconvolution.find_stain_index( stain_color_map[stains[i]], w_est) plt.imshow(deconvresult.Stains[:, :, channel]) = plt.title(stains[i], fontsize=titlesize)

It works in most images. But in one image it find_stain_index point to the same index when I try to find the stain vectors for hematoxylin and eosin.Can anyone help me with the issue. Thanks.

The stain vectors for hematoxylin and eosin: 'hematoxylin': [0.65, 0.70, 0.29], 'eosin': [0.07, 0.99, 0.11],

The output of rgb_separate_stains_macenko_pca: [[ 0.04452724 0.41049417 -0.3624586 ] [ 0.77551179 0.78978495 0.59997259] [ 0.6297609 0.45577876 -0.71320169]]

For the stain vectors for hematoxylin and eosin, find_stain_index returns index 1 and index 1

cdeepakroy commented 5 years ago

@joelive Thank you for reporting this. I will try to look into it. Could you please share a sample image to help with debugging?

alessiamarcolini commented 3 years ago

Hello @cdeepakroy, I'm replying here because I bumped into the same issue.

My resulting stain vector

np.array(
    [
        [-0.38326727, 0.55173352, -0.19168126],
        [0.68482841, 0.72174826, 0.59742868],
        [0.61977113, 0.41793489, -0.77867662],
    ]
)

Unfortunately I cannot provide an example image because I use a slighly different way of finding the stain vector and then I'm using _reorder_stains

cooperlab commented 3 years ago

@kheffah have you been working with this function? Any comments?

cooperlab commented 1 year ago

Note on this topic - instead of evaluating the match between an individual stain vector and the columns of a stain matrix, we should look at the global distortion for an injective mapping between one set of stain vectors and another and find a global minimum solution.