Closed rmaram33 closed 1 month ago
Hi rmaram33, thank you for the kind words! Based on the stack trace it seems that the images did not load properly, as self.raw_image returned a NoneType. Has this also happened for any other cases or is this the first case you tried? In any case, you can manually verify whether the image can be loaded properly through the ASAP backend with:
import multiresolutionimageinterface as mir
opener = mir.MultiResolutionImageReader()
image = opener.open(path_to_your_file)
If that works as expected, you may also want to check whether the image can also be loaded through Pyvips:
import pyvips
image = pyvips.Image.new_from_file(path_to_your_file)
I'd be curious to hear whether this works as expected for your files. I'd also recommend trying this out for a variety of whole slide image files, even if you do not intend to stitch them, to get an idea of which files may or may not be parsed correctly with PythoStitcher.
Hi, thank you so much for the reply. I tried pythoSticher with the prostate_4.rar sample data (link provided on ReadMe). It has .mrxs format raw_images and .tiff masks and runs smoothly. When I tried running with my .tiff raw_images, I got this NoneType object error.
Sure, I will try loading the images through Pyvips and will get back to you with more details. Thank you again for your response and support.
Best, Ritish Maram
Hello @dnschouten , here are the sequence of steps that I followed to perform checks.
magick convert "D:\MATLAB_Scripts_WSI\Image1\fragment1.tiff" -compress jpeg -quality 85 -define tiff:tile-geometry=0 "D:\MATLAB_Scripts_WSI\Image1\fragment1_non_tiled.tiff"
in the command prompt.
Following step 2, I loaded the non_tiled.tiff image using ASAP mir and it worked.
I loaded this image using pyvips and here is the following output.
I followed the above steps for my second fragment and masks. I was able to successfully load images and masks using both ASAP's mir and pyvips. Then, I proceeded to run pythostitcher docker container and got the following error:
Traceback (most recent call last):
File "/home/user/pythostitcher-0.3.1/src/main.py", line 287, in <module>
main()
File "/home/user/pythostitcher-0.3.1/src/main.py", line 267, in main
run_case(data_dir, save_dir, output_res)
File "/home/user/pythostitcher-0.3.1/src/main.py", line 208, in run_case
prepare_data(parameters=parameters)
File "/home/user/pythostitcher-0.3.1/src/preprocessing_utils/prepare_data.py", line 232, in prepare_data
data_processor.load()
File "/home/user/pythostitcher-0.3.1/src/preprocessing_utils/prepare_data.py", line 48, in load
self.image = self.raw_image.getUCharPatch(0, 0, *self.new_dims, self.new_level)
TypeError: getUCharPatch() missing 2 required positional arguments: 'height' and 'level'
Pyvips retrieved the image height and level information, as shown in the screen shots. But when I run the docker container, I am getting the TypeError: getUCharPatch() missing 2 required positional arguments: 'height' and 'level'.
It would be a great help if you could look into this and suggest next steps in resolving this error. Thank you!
I also tried the following based on the error given by Traceback. I am also attaching the meta data of the image file.
Here is the meta_data of the image:
Number of levels in the TIFF file: 5
--- Metadata for Level 0 ---
Width: 69719
Height: 39808
Bands: 3
Format: uchar
width: 69719
height: 39808
bands: 3
format: uchar
coding: none
interpretation: srgb
xoffset: 0
yoffset: 0
xres: 1.0
yres: 1.0
filename: D:\MATLAB_Scripts_WSI\Image1\fragment1_non_tiled.tiff
vips-loader: tiffload
n-pages: 5
bits-per-sample: 8
orientation: 1
--- Metadata for Level 1 ---
Width: 17429
Height: 9952
Bands: 3
Format: uchar
width: 17429
height: 9952
bands: 3
format: uchar
coding: none
interpretation: srgb
xoffset: 0
yoffset: 0
xres: 1.0
yres: 1.0
filename: D:\MATLAB_Scripts_WSI\Image1\fragment1_non_tiled.tiff
vips-loader: tiffload
n-pages: 5
bits-per-sample: 8
orientation: 1
--- Metadata for Level 2 ---
Width: 4357
Height: 2488
Bands: 3
Format: uchar
width: 4357
height: 2488
bands: 3
format: uchar
coding: none
interpretation: srgb
xoffset: 0
yoffset: 0
xres: 1.0
yres: 1.0
filename: D:\MATLAB_Scripts_WSI\Image1\fragment1_non_tiled.tiff
vips-loader: tiffload
n-pages: 5
bits-per-sample: 8
orientation: 1
--- Metadata for Level 3 ---
Width: 2178
Height: 1244
Bands: 3
Format: uchar
width: 2178
height: 1244
bands: 3
format: uchar
coding: none
interpretation: srgb
xoffset: 0
yoffset: 0
xres: 1.0
yres: 1.0
filename: D:\MATLAB_Scripts_WSI\Image1\fragment1_non_tiled.tiff
vips-loader: tiffload
n-pages: 5
bits-per-sample: 8
orientation: 1
--- Metadata for Level 4 ---
Width: 1024
Height: 584
Bands: 3
Format: uchar
width: 1024
height: 584
bands: 3
format: uchar
coding: none
interpretation: srgb
xoffset: 0
yoffset: 0
xres: 1.0
yres: 1.0
filename: D:\MATLAB_Scripts_WSI\Image1\fragment1_non_tiled.tiff
vips-loader: tiffload
n-pages: 5
bits-per-sample: 8
orientation: 1
Hi Ritish, apologies for my late reply, I was out-of-office for a few days. I'm glad to hear that you were able to progress a step by converting your images to a non-tiled .tiff.
Based on your latest stack trace, it seems that self.new_dims is not getting picked up adequately as argument resulting in exactly two missing positional arguments. I did some digging and I believe the root cause is that the config file in config/parameter_config.json defaults to an image_level of 7 (since my training data had ~9-10 levels). As your data has 5 levels, I'd imagine that self.new_dims = self.raw_image.getLevelDimensions(self.new_level)
with an image level out of this range returns None. Especially given that image_level 4 in your example retrieves the correct metadata, this would explain both scenarios.
Hence, I'd recommend changing image_level in the config.json from 7 to 4 to see if that solves it. I'll also implement an assertion to ensure that the image_level in the config file corresponds with an available level in the input data. Thanks for catching that!
Please let me know if the above solved your issue so I can close it if solved.
Hi @dnschouten, No worries. Thank you so much for your response.
I have a quick question: I was using the pythostitcher docker image, pulled from the docker hub, to run the commands provided in the readme. Would you recommend editing the config.json file in the container, or shall I try downloading the GitHub repo, making changes to the config.json, and running locally? If the later is better, could you briefly tell me how?
Thank you Again.
Depending on what IDE you use, you may be able to use a sort of hybrid approach. If you happen to use VScode, you should be able to run it as dev container, make any changes in either a locally cloned version or the version in the container, and then run any version within that dev container. Alternatively, you could try building the image with the provided Dockerfile in WSL to directly incorporate any changes in the container.
As a truly permanent fix I should also update the Docker image to incorporate some additional recent changes. I'll try to find some time to fix this soon, prepare a new release and update the image on GHCR accordingly.
Thanks again for your thorough investigation to improve PythoStitcher!
Thank you so much, @dnschouten; it is running very smoothly now! We truly appreciate your time and support in resolving the problem. Thank you again!
Hello, First of all, thank you for making this repository open source, and congratulations on publication at https://doi.org/10.1038/s41598-024-52007-5. We are deeply thankful for your contributions and support in digital pathology.
My raw_images folder under patient_2 had two .tiff (multi-res) images, and I was wondering why I am getting this error: The loaded image was not valid. I would really appreciate it if you could help me resolve this error.
(The masks under raw_masks are also multires .tiff files.)
Running job with following parameters:
Traceback (most recent call last): File "/home/user/pythostitcher-0.3.1/src/main.py", line 287, in
main()
File "/home/user/pythostitcher-0.3.1/src/main.py", line 267, in main
run_case(data_dir, save_dir, output_res)
File "/home/user/pythostitcher-0.3.1/src/main.py", line 208, in run_case
prepare_data(parameters=parameters)
File "/home/user/pythostitcher-0.3.1/src/preprocessing_utils/prepare_data.py", line 232, in prepare_data
data_processor.load()
File "/home/user/pythostitcher-0.3.1/src/preprocessing_utils/prepare_data.py", line 39, in load
assert self.raw_image.valid(), "Loaded image was not valid"
AttributeError: 'NoneType' object has no attribute 'valid'