DIAGNijmegen / pathology-hooknet-tls

MIT License
10 stars 2 forks source link

pyramidal tiff from save_image_at_spacing.py raises ValueError(f"cant open image {path}") #13

Open goterm opened 2 weeks ago

goterm commented 2 weeks ago

Hi,

I have generated the pyramidal .tiff with your script save_image_at_spacing.py (https://github.com/DIAGNijmegen/pathology-whole-slide-data/blob/main/scripts/save_image_at_spacing.py). and the mask from the .svs file via QuPath/Fiji.

when I run:

python3 -m hooknettls \ hooknettls.default.image_path=/Volumes/hooknet_test/1A1_script.tif \ hooknettls.default.mask_path=/Volumes/hooknet_test/1A1_mask.tif

I get this error: Traceback (most recent call last): File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/user/pathology-hooknet-tls/hooknettls/main.py", line 8, in objects = build_config(config_reader.read()["default"]) File "/usr/local/lib/python3.8/dist-packages/dicfg/factory.py", line 124, in build_config return _ObjectFactory(deepcopy(config)).build_config() File "/usr/local/lib/python3.8/dist-packages/dicfg/factory.py", line 26, in build_config return self._build(self._configuration) File "/usr/lib/python3.8/functools.py", line 912, in _method return method.get(obj, cls)(*args, *kwargs) File "/usr/local/lib/python3.8/dist-packages/dicfg/factory.py", line 38, in _build_dict config[key] = self._build_object(value) File "/usr/local/lib/python3.8/dist-packages/dicfg/factory.py", line 67, in _build_object return attribute(args, **kwargs) File "/usr/local/lib/python3.8/dist-packages/wholeslidedata/iterators/patchiterator.py", line 46, in create_patch_iterator commander = commander_class( File "/usr/local/lib/python3.8/dist-packages/wholeslidedata/buffer/patchcommander.py", line 41, in init wsi = WholeSlideImage(image_path, backend=backend) File "/usr/local/lib/python3.8/dist-packages/wholeslidedata/image/wholeslideimage.py", line 35, in init self._backend = get_backend(backend)(path=self._path) File "/usr/local/lib/python3.8/dist-packages/wholeslidedata/interoperability/asap/backend.py", line 15, in init raise ValueError(f"cant open image {path}") ValueError: cant open image /Volumes/hooknet_test/1A1_script.tif

I am unsure if the error is caused but the pyramidal tif or the mask? what is the best way to generate the mask in a pyramidal format?

any help would be greatly appreciated! thank you so much in advance

martvanrijthoven commented 2 weeks ago

Dear Goterm,

Thank you for your interest in HookNet-TLS!

I am not sure what kind of file QuPath/Fiji outputs for the mask. But the mask needs to be a pyramidal tiff file. Please checkout the preprocessing notebook to get such a mask: https://github.com/DIAGNijmegen/pathology-hooknet-tls/blob/main/hooknettls/preprocessing.ipynb

Please let me know if you have any further questions.

Best wishes, Mart

goterm commented 2 weeks ago

Hi,

thanks for the quick feedback.

I have now both pyramidal tifs from both scripts (save_image_at_spacing.py and preprocessing.ipynb).

However, I still get the same error after running (within the provided docker container):

python3 -m hooknettls \ hooknettls.default.image_path=/Volumes/hooknet_test/1A1_script.tif \ hooknettls.default.mask_path=/Volumes/hooknet_test/1A1_script_mask_script.tif

root@8bd7dc239b13:/# python3 -m hooknettls \

hooknettls.default.image_path=/Volumes/hooknet_test/1A1_script.tif \
hooknettls.default.mask_path=/Volumes/hooknet_test/1A1_script_mask_script.tif

Traceback (most recent call last): File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/user/pathology-hooknet-tls/hooknettls/main.py", line 8, in objects = build_config(config_reader.read()["default"]) File "/usr/local/lib/python3.8/dist-packages/dicfg/factory.py", line 124, in build_config return _ObjectFactory(deepcopy(config)).build_config() File "/usr/local/lib/python3.8/dist-packages/dicfg/factory.py", line 26, in build_config return self._build(self._configuration) File "/usr/lib/python3.8/functools.py", line 912, in _method return method.get(obj, cls)(*args, *kwargs) File "/usr/local/lib/python3.8/dist-packages/dicfg/factory.py", line 38, in _build_dict config[key] = self._build_object(value) File "/usr/local/lib/python3.8/dist-packages/dicfg/factory.py", line 67, in _build_object return attribute(args, **kwargs) File "/usr/local/lib/python3.8/dist-packages/wholeslidedata/iterators/patchiterator.py", line 46, in create_patch_iterator commander = commander_class( File "/usr/local/lib/python3.8/dist-packages/wholeslidedata/buffer/patchcommander.py", line 41, in init wsi = WholeSlideImage(image_path, backend=backend) File "/usr/local/lib/python3.8/dist-packages/wholeslidedata/image/wholeslideimage.py", line 35, in init self._backend = get_backend(backend)(path=self._path) File "/usr/local/lib/python3.8/dist-packages/wholeslidedata/interoperability/asap/backend.py", line 15, in init raise ValueError(f"cant open image {path}") ValueError: cant open image /Volumes/hooknet_test/1A1_script.tif

martvanrijthoven commented 2 weeks ago

Dear goterm,

Are you running it in a docker? If so can you double check if /Volumes/hooknet_test/1A1_script.tif exists. Maybe something went wrong when mounting the /Volumes/ in de docker? Otherwise it might be that your file cannot be opened. Could you double check that with

from wholeslidedata import WholeSlideImage
wsi = WholeSlideImage("/Volumes/hooknet_test/1A1_script.tif")
print(wsi.spacings)

If all is good, can you send me the original image file before converting to .tif (to mart.vanrijthoven@gmail.com). Then I will try to reproduce your problem.

Best wishes, Mart