Open yyn10152333 opened 2 years ago
Hi there! Absolutely no bother at all - thanks for getting in touch! This code is in active development so please, any issues, get in touch! :-)
To better diagnose what is going on, could you please provide the steps leading up to this error, namely:
1) What the output of get_stain_matrix.py was for the image of interest
2) The shape of the input image you are trying to stain separate - you can get this by running the following within Python:
from skimage.io import imread
img = imread({insert filepath to your image here})
print(img.shape)
Looking forward to your reply, Volodymyr
To improve use for future, I will add an example Jupyter notebook - hopefully that will provide a scaffold for your work.
Thank you very much for your reply.
The format of image I use is .jpeg.
the overlay.png is like this:
thank you for your time!
Hi there!
1) More a general point - it's best to use .tiff or .png image extensions (lossless compression - no quality loss during compression) over .jpeg (lossy compression) in digital pathology. This reduces likelihood of artefacts in downstream processing and ensures that the important details in your medical images are retained. Hopefully using these formats will save trouble for you in future.
2) Everything in your inputs and outputs looks good. The clusters are quite close in your cxcy.png file but this is because you are separating the stains in a Haematoxylin (H) & Eosin (E) image. Just checking that your intention is to separate H and E?
3) Could you please provide the exact commands you use for deconvolve_image.py ?
4) Is the image openly available and if so, where can I find it? I want to see if the issue can be reproduced on my system.
Best wishes,
Volodymyr
Thank you for your time.
I tried an image with .tif format, and it can generate good result from the two steps. And I tried the Deconvolved.tiff in your project, the problem also exists(the shape is different in the error.). Maybe the inout image of deconvolve_image.py need to be the same as that of get_stain_matrix.py?
My intention is to do color unmixing of H and E stains. I think the result is not as good as that when I separate other stains?
the command is: python apply_color_deconv.py -i './001.jpeg' -c './config.json' -d './Test_output_images/test_001jpeg' -s './Test_output_images/test_001jpeg/stain_matrix.txt'
I 'm sorry that the image is not openly now, I cut one piece from a WSI and generate this jpeg image.
I will try other images with .tif. Thank you very much.
Yours sincerely, Yang Yinan
Hi again,
I have just tested apply_color_deconv.py on example input image 1 (IHC image) using the stain matrix provided in example outputs and config.json:
python apply_color_deconv.py -i Example_input_images/Small_128x128/1.png -c config.json -s Example_output_images/Smaller_image_1/stain_matrix.txt -d Example_output_images/Testing/1
I get this output showing successful processing of the RGB file:
Apply stain matrix on given image.es/Testing/1
Input path: Example_input_images/Small_128x128/1.png
Input path: config.json
Stain matrix path: Example_output_images/Smaller_image_1/stain_matrix.txt
Mask path:
Output path: Example_output_images/Testing/1
Workdir:
Number of processes: 1
Overwrite: False
Mode: file
Processing: 1
(128, 128, 3)
Processing took: 0.011642932891845703s
When trying with an image where height does not equal width:
python apply_color_deconv.py -i Example_output_images/Testing/TCGA-A2-A0CV-01Z-00-DX1_4.tif -c config.json -s Example_output_images/Smaller_image_1/stain_matrix.txt -d Example_output_images/Testing/1_error
I retrieve an error message about dimensions:
Traceback (most recent call last):
File "apply_color_deconv.py", line 166, in <module>
processing_pool.map(deconvolve_image.process_slide, process_list)
File "/home/volodymyr/miniconda3/envs/AutoUnmix/lib/python3.8/multiprocessing/pool.py", line 364, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "/home/volodymyr/miniconda3/envs/AutoUnmix/lib/python3.8/multiprocessing/pool.py", line 771, in get
raise self._value
ValueError: cannot reshape array of size 2082452 into shape (3)
This confirms that a bug exists in processing of non-square images. I will flag as a bug and work to resolve this.
Thank you reporting this to me! Best wishes, Volodymyr
Hi there,
Thank you so much for replying positively.
I will try images with equal high and width.
Wish you all the best.
Yours sincerely, Yang Yinan
excise me, i'm sorry to bother, and there exists sth wrong with my running result of deconvolve_image. The dimension of matrices "mask_tile" and "deconv" don't match, so the errors exists like this:
And I cannot reshape either of them. how can i solve this problem? Thank you very much.