computationalpathologygroup / ASAP

Program for the analysis and visualization of whole-slide images in digital pathology
https://computationalpathologygroup.github.io/ASAP/
GNU General Public License v2.0
616 stars 165 forks source link

MultiResolutionImageReader.open(file_name) will return None #50

Closed zengyh1900 closed 7 years ago

zengyh1900 commented 7 years ago

I try

import multiresolutionimageinterface as mir
reader = mir.MultiResolutionImageReader()
mr_image = reader.open('camelyon17/centre_0/patient_000_node_0.tif')

there is no error message but when I print the mr_image, it will be None.

It is ASAP-1.7-Linux-python27.deb on Ubuntu16.04 (python2.7)

GeertLitjens commented 7 years ago

Could you try putting in the full path to the file instead of a relative one?

zengyh1900 commented 7 years ago

@GeertLitjens I once tried that but failed. The data is a tif file from Camelyon16. Can ASAP open the files defined by in Camelyon16 or not ?

MultiResolutionImage* MultiResolutionImageFactory::openImage(const std::string& fileName) {
  MultiResolutionImageFactory::registerExternalFileFormats();
  std::string extension = core::extractFileExtension(fileName);
  for (std::map<std::string, MultiResolutionImageFactory*>::const_iterator it = registry().begin(); it != registry().end(); ++it) {
    std::vector<std::string> factoryExtensions;
    core::split(it->first, factoryExtensions, ";");
    if (std::find(factoryExtensions.begin(), factoryExtensions.end(), extension) != factoryExtensions.end()) {
      MultiResolutionImage* img = it->second->readImage(fileName);
      if (img) {

#ifdef HAS_MULTIRESOLUTIONIMAGEINTERFACE_VSI_SUPPORT
        if ((img->getNumberOfLevels() > 1 || dynamic_cast<VSIImage*>(img) != NULL) || (img->getNumberOfLevels() == 1 && img->getLevelDimensions(0)[0] < 4096)) {
#else
        if ((img->getNumberOfLevels() > 1) || (img->getNumberOfLevels() == 1 && img->getLevelDimensions(0)[0] < 4096)) {
#endif
          return img;
        }
        else {
          delete img;
        }
      }
    }
  }
  return NULL;
}

I guess ASAP cannot deal with the data from Camelyon because of the format. But why it could work in Windows? I have no idea.

GeertLitjens commented 7 years ago

Yes, it can open those files. Which file specifically are you trying to open? My guess is that you have an old version of OpenSlide. See this ticket and others for solutions:

https://github.com/GeertLitjens/ASAP/issues/33

zengyh1900 commented 7 years ago

@GeertLitjens Thanks a lot! I have installed the latest openslide and everything goes well now.

Openslide Installation Instruction: http://openslide.org/download/

tomi2077 commented 3 years ago

Yes, it can open those files. Which file specifically are you trying to open? My guess is that you have an old version of OpenSlide. See this ticket and others for solutions:

33

Hi, Please I want to read large very biomedical images. I can currently open and view them via Openslide but I want to use ASAP to prepare them. Do you know how ASAP is downloaded?

Thanks, Tom