Nucleus segmentation of WSI in PNG results in ValueError: MPP is None. Cannot determine scale in terms of MPP.
See original GitHub issue- TIA Toolbox version: 1.3.0
- Python version: 3.7
- Operating System: Cent OS
Description
Calling NucleusInstanceSegmentor.predict() with H&E (RGB, PNG) whole-slide image files result in the following error:
ValueError: MPP is None. Cannot determine scale in terms of MPP.
What I Did
I used the IOSegmentorConfig to specify the mpp of my inputs and outputs (H&E images in RGB and PNG format), but when I try to perform the segmentation I get an error saying that the MPP is None. Since PNG files don’t contain any metadata info, I was hoping that by specifying it in IOSegmentorConfig will provide that info.
objIOConfig = IOSegmentorConfig(
input_resolutions=[
{'units': 'mpp', 'resolution': 0.325},
],
output_resolutions=[
{'units': 'mpp', 'resolution': 0.325},
],
margin=128,
tile_shape=[1024, 1024],
patch_input_shape=(256, 256),
patch_output_shape=(256, 256),
stride_shape=(164, 164),
save_resolution={'units': 'mpp', 'resolution': 0.325}
)
# Instantiate the nucleus instance segmentor
objInstSegmentor = NucleusInstanceSegmentor(
pretrained_model="hovernet_fast-pannuke",
num_loader_workers=4,
num_postproc_workers=4,
batch_size=8,
auto_generate_mask=False,
verbose=False,
)
# WSI prediction (if ON_GPU=False, this part will take more than a couple of hours to process)
wsi_output = objInstSegmentor.predict(
['TestSet_ROI_6291_wsi_he.png'],
ioconfig=objIOConfig,
masks=None,
save_dir=f'./WSITest/',
mode="wsi",
on_gpu=ON_GPU,
crash_on_exception=True,
)
The error that I encountered in more detail:
Thank you!
Caleb
Issue Analytics
- State:
- Created a year ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Caleb Chan Calebium - GitHub
Nucleus segmentation of WSI in PNG results in ValueError: MPP is None. Cannot determine scale in terms of MPP. TIA Toolbox version: 1.3.0...
Read more >Segmentation of foci within nuclei - Image.sc Forum
What I need to do is to segment out the foci (cyan arrows), i.e. regions of higher density of this protein. The end...
Read more >the of and to a in for is on s that by this with i you it not
... officer driver businesses dead unknown respect specified restaurant mike trip ... kerry ghost nobody supposed ordinary configure violation mit stability ...
Read more >Click here to download - Computer Science
... terms before hotels did send right type because local those using results ... officer driver businesses dead respect unknown specified restaurant mike ......
Read more >File:Min'yō scale.png - Wikipedia
Scales, consisting of an ordering outside of time by pitch class (no "distinctiveness"), may be used in compositions by multiple composers ("common material"), ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Dear @Calebium
As you are trying to make predictions on image tiles, it is better to call the
predict
method intile
mode instead ofmode=wsi
. If you specify themode
to bewsi
, TIAToolbox requires the input to be a WSI structured file with metadata information.Therefore, an easy solution to your problem is to set the
mode
in the last method call totile
:[Extra Suggestion] I noticed you are trying to set the input resolution to “mpp resolution: 0.325” for your input. You should know, this
IOConfig
is to set the config of image reading with respect to the trained model, not the test data! So, whatever resolution the data has been captured with, if you want to get the best results using TIAToolbox’s HoVerNet, input images to the algorithm should be in “mpp resolution: 0.25”. Now, if your images are saved in a resolution that is different from the images used in the HoVerNet model training, I would suggest you resize the images to “mpp resolution: 0.255” before you process them in order to achieve the best segmentation resolution. However, even without resizing you should obtain acceptable results.If you use
tile
mode, TIAToolbox assumes the input is a plain image. If the input is a path to a png image, the toolbox tries to read it with a simplecv2.imread
function (which is not capable of reading WSIs) and append a predefined standard metadata to it. Therefore, reading a WSI in tile mode will raise an external exception (error). However, if you read a png in the WSI mode, because in WSI mode toolbox assumes there is some metadata associated with the input it would not change the metadata (does not append predefined standard metadata to WSI) and instead throws warnings that metadata is missing and won’t be able to do operations that are metadata dependant (such as reading from a specific mpp).