DIAGNijmegen / pathology-whole-slide-data

A package for working with whole-slide data including a fast batch iterator that can be used to train deep learning models.
https://diagnijmegen.github.io/pathology-whole-slide-data/
Apache License 2.0
86 stars 24 forks source link

changing image backend to pyvips #21

Closed 99snowleopards closed 2 years ago

99snowleopards commented 2 years ago

hello @martvanrijthoven - thank you for all of the effort in releasing this code.

I followed the instructions to change the image backend to pyvips

I added:

wholeslidedata:
    default:
        image_backend: pyvips

to the config file under wholeslidedata/configuration/config_files/config.yml

but keep getting this error:

RegistrantNotRegisteredError: 
        Registrant 'pyvips' is not found in the register of class 'WholeSlideImageBackend' with registrant names ('openslide',) and register classes (<class 'wholeslidedata.accessories.openslide.backend.OpenSlideWholeSlideImageBackend'>,).

could you help me add the configuration to the correct config file please, thank you

martvanrijthoven commented 2 years ago

Dear 99snowleopards,

Thank you, I appreciate your interest in this package!

It seems that you only have openslide installed. If you want to use the pyvips backend, you first need to install it. The easiest way to install pyvips is via conda:

conda install -c conda-forge pyvips

Also, please don't add or change things in wholeslidedata/configuration/config_files/config.yml. It is possible, but the recommended way is by using a user config file and using that as an argument to the create_batch_iterator function. You can create a user_config.yml as follows and the settings will automatically override the settings in wholeslidedata/configuration/config_files/config.yml:

content of user_config.yml:

wholeslidedata:
    default:
        image_backend: pyvips

I hope this helps. Please let me know if you still have problems or have any other questions.

Best wishes, Mart

99snowleopards commented 2 years ago

thank you so much for the quick and detailed response @martvanrijthoven .

I haven't gotten to the create_batch_iterator function yet.

I'm exploring the code in a notebook, and I'm trying to run this line:

wsi_1 = WholeSlideImage(local_wsi_1, backend='pyvips')

after installing pyvips , to run the above line, do I still need a user_config.yml and if so, how do I pass it to the above line? thank you agin

martvanrijthoven commented 2 years ago

Dear 99snowleopards,

Sure, you are welcome!

Configuration files are only needed to configure the batch iterator because it has many settings that you can configure. There is no configuration needed If you want to open an image with the WholeSlideImage class. After you have installed pyvips this line (as you posted) should work:

wsi_1 = WholeSlideImage(local_wsi_1, backend='pyvips')

Best wishes, Mart

99snowleopards commented 2 years ago

I was overcomplicating this! thank you so much again - very excited to understand this amazing library better!