vitessce / vitessceR

R API and htmlwidget for Vitessce
https://r-docs.vitessce.io
Other
38 stars 9 forks source link

OME-TIFFs fail to load with no error message #65

Open keller-mark opened 2 years ago

keller-mark commented 2 years ago

Describe the bug

The ome_tiff_remote.Rmd vignette fails to load its OME-TIFF and the loading indicator in the Spatial view just keeps spinning.

To Reproduce Steps to reproduce the behavior:

Run the ome_tiff_remote.Rmd vignette.

Expected behavior Expected an error in the console or a successfully loaded image.

It seems to be fixed by:

dkeitley commented 1 year ago

Is there a version of vitessceR I can downgrade to in order to get OME-TIF images loading correctly? Currently, I get a spinning icon as mentioned above and a warning in the developer console:

Cannot read properties of undefined (reading 'data') [index.js:1344]

The spatial component of my shiny app can be found here.

keller-mark commented 1 year ago

I just merged a pull request that upgrades the JavaScript package version used in the R package. Would you be able to check if the current implementation on the main branch fixes it?

dkeitley commented 1 year ago

Thanks Mark. I downloaded from the main branch but I get the following error in the R console when I start the shiny app:

Warning: Error in value[[3L]]: Couldn't normalize path in `addResourcePath`, with arguments: `prefix` = 'vitessceR-0.99.1'; `directoryPath` = ''
  [No stack trace available]
keller-mark commented 1 year ago

Are you intending to use the current directory by supplying an empty string for directoryPath = ""? If so, can you try directoryPath = "."?

dkeitley commented 1 year ago

I'm not sure where the addResourcePath function is called. I get this error when I run shiny::runApp(). Also, I'm not sure what's changed but I'm now getting the same error with directoryPath = 'C:/Users/Daniel Keitley/Documents/R/win-library/4.1/vitessceR/htmlwidgets/lib' if that's informative. I've tried updating packages and using R v4.2.2 but to no avail.

dkeitley commented 1 year ago

Hi Mark,

I just managed to overcome the Couldn't normalize path in 'addResourcePath' error by installing vitessceR from source. I now get the following warnings:

index.min.umd.js:46 -  [DEPRECATED] Please use `subscribeWithSelector` middleware[DEPRECATED] Please use `subscribeWithSelector` middleware
index.min.umd.js:7216 - Could not initialize coordinationValues.spatialImageLayer in RasterJsonAsObsSegmentationsLoader. This may be an indicator that the image could not be loaded.

i.e. https://github.com/vitessce/vitessce/blob/main/packages/file-types/json/src/raster-json-loaders/RasterJsonAsObsSegmentationsLoader.js#L24

index.min.umd.js:7216 - Could not initialize coordinationValues.spatialImageLayer in RasterJsonAsImageLoader. This may be an indicator that the image could not be loaded.

i.e. https://github.com/vitessce/vitessce/blob/main/packages/file-types/json/src/raster-json-loaders/RasterJsonAsImageLoader.js#L24

The images still don't display and just appear as black/white boxes. Any ideas on what could be causing this?

keller-mark commented 1 year ago

It seems like it could be an issue with the OME-TIFF organization or metadata (or with Vitessce being limited in the OME-TIFF files that can be loaded). Can you check that the file you are trying to use loads in avivator (should be able to drag and drop the file)? Are you able to share the OME-XML metadata (can be done by running the tiffcomment command line tool from bftools)? I also recently made a tutorial for converting TIFF to OME-TIFF, it is in python but maybe it can help https://github.com/vitessce/vitessce-python-tutorial/blob/main/tutorials/imaging/02_convert_data_manual.ipynb

dkeitley commented 1 year ago

Thanks for looking into this Mark. After a lot of debugging, I've finally worked out that the issue was because the renderLayers and image names didn't match in the file options.

i.e.

dataset$add_file(
      data_type = DataType$RASTER,
      file_type = FileType$RASTER_JSON,
      options = list(renderLayers = list("Something"),
                     schemaVersion = "0.0.2",
                     images = list(vitessceR::obj_list(name = "Something different",
                                                       url = image_url,
                                                       type = "ome-tiff",
                                                       metadata = list(omeTiffOffsetsUrl = offset_url)
                     ))
      ))

The images are now being displayed correctly. Sorry for any inconvenience caused!