John-P / wsic

Whole Slide image (WSI) conversion for brightfield histology images
MIT License
32 stars 4 forks source link

BUG: WSIC fails to read the first tile from a jp2 image #3

Closed ghadjigeorghiou closed 2 years ago

ghadjigeorghiou commented 2 years ago

1st Machine

2nd Machine

Description

I was trying to convert a JP2 image (size: 71.3Mb) to tiff. I tested the same command on two different machines

What I Did

wsic convert -i ${input} -o ${output} -rt 4096 4096 -w 4 --overwrite --no-ome -to 600
/home/giorgos-tia/.conda/envs/wsic/lib/python3.9/site-packages/wsic/readers.py:265: UserWarning: Failed to get next tile after 100 attempts. Dumping debug information.
  warnings.warn(
Reader Shape (161864, 88832, 3)
Read Tile Size (4096, 4096)
Yield Tile Size (256, 256)
Read Mosaic Shape (40, 22)
Yield Mosaic Shape (633, 347)
Read Index (0, 0)
Yield Index (0, 0)
Remaining Reads (:10) [(0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (0, 8), (0, 9), (0, 10), (0, 11)]
Enqueued {(0, 1), (0, 0)}
Reordering Dict (keys) dict_keys([])
Queue Size 0
Intermediate Read slices (slice(0, 256, None), slice(0, 256, None))
Traceback (most recent call last):
  File "/home/giorgos-tia/.conda/envs/wsic/bin/wsic", line 8, in <module>
    sys.exit(main())
  File "/home/giorgos-tia/.conda/envs/wsic/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/giorgos-tia/.conda/envs/wsic/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/giorgos-tia/.conda/envs/wsic/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/giorgos-tia/.conda/envs/wsic/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/giorgos-tia/.conda/envs/wsic/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/giorgos-tia/.conda/envs/wsic/lib/python3.9/site-packages/wsic/cli.py", line 126, in convert
    writer.copy_from_reader(reader, read_tile_size=read_tile_size, num_workers=workers)
  File "/home/giorgos-tia/.conda/envs/wsic/lib/python3.9/site-packages/wsic/writers.py", line 513, in copy_from_reader
    tif.write(
  File "/home/giorgos-tia/.conda/envs/wsic/lib/python3.9/site-packages/tifffile/tifffile.py", line 2660, in write
    for tileindex, chunk in enumerate(
  File "/home/giorgos-tia/.conda/envs/wsic/lib/python3.9/site-packages/tifffile/tifffile.py", line 16817, in encode_tiles
    tile = next(tileiter)
  File "/home/giorgos-tia/.conda/envs/wsic/lib/python3.9/site-packages/wsic/readers.py", line 284, in __next__
    raise Exception(f"Failed to yield tile {self.yield_index}")
Exception: Failed to yield tile (0, 0)
ghadjigeorghiou commented 2 years ago

This issue was caused by the tool reading the tile of the jp2 images too slow. It's fixed in this commit which added a timeout