BodenmillerGroup / steinbock

A toolkit for processing multiplexed tissue images
https://bodenmillergroup.github.io/steinbock
MIT License
49 stars 14 forks source link

Running with -e STEINBOCK_MASK_DTYPE=uint32 flag error #132

Closed leonorss closed 2 years ago

leonorss commented 2 years ago

Hi, I am currently running steinbock using (on ubuntu virtual machine):

alias steinbock="docker run -e STEINBOCK_MASK_DTYPE=uint32 -v ${BASEDIR}:/data -u $(id -u):$(id -g) ghcr.io/bodenmillergroup/steinbock:0.14.1"

The first few steps work fine (eg.):

steinbock preprocess imc panel --imcpanel config/TH152_panel.csv --mcd mcd/1 -o steinbock/panel.csv
steinbock preprocess imc images --hpf 50 --mcd mcd/1 --txt mcd/1 --panel steinbock/panel.csv --imgout steinbock/img --infoout steinbock/images.csv

But when I try to run the deepcell segmentation:

steinbock segment deepcell --minmax --panel steinbock/panel.csv --img steinbock/img -o steinbock/masks_deepcell

I get the following error:

2022-06-23 11:42:17,986 ERROR steinbock.segmentation.deepcell - Error segmenting objects in steinbock/img/20220520_TsH_th152_cisi1_001.tiff
Traceback (most recent call last):
  File "/app/steinbock/steinbock/segmentation/deepcell.py", line 113, in try_segment_objects
    yield Path(img_file), mask
GeneratorExit
Exception ignored in: <generator object try_segment_objects at 0x7f30909d19e0>
Traceback (most recent call last):
  File "/app/steinbock/steinbock/segmentation/_cli/deepcell.py", line 184, in deepcell_cmd
    io.write_mask(mask, mask_file)
RuntimeError: generator ignored GeneratorExit
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 "/app/steinbock/steinbock/__main__.py", line 17, in <module>
    steinbock_cmd_group(prog_name="steinbock")
  File "/opt/venv/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/opt/venv/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/venv/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/venv/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/venv/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/venv/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/app/steinbock/steinbock/_cli/utils.py", line 35, in wrapper
    return func(*args, **kwargs)
  File "/app/steinbock/steinbock/segmentation/_cli/deepcell.py", line 184, in deepcell_cmd
    io.write_mask(mask, mask_file)
  File "/app/steinbock/steinbock/io.py", line 293, in write_mask
    tifffile.imwrite(
  File "/opt/venv/lib/python3.8/site-packages/tifffile/tifffile.py", line 1145, in imwrite
    result = tif.write(
  File "/opt/venv/lib/python3.8/site-packages/tifffile/tifffile.py", line 2022, in write
    raise ValueError(
ValueError: the ImageJ format does not support data type 'I'

Any help with this would be greatly appreciated.

jwindhager commented 2 years ago

Hi @leonorss, thanks for checking in! Indeed, the ImageJ TIFF format only supports uint8, uint16 and float32, but not uint32: https://github.com/cgohlke/tifffile/blob/master/tifffile/tifffile.py#L1348-L1357. I will adapt steinbock to only write TIFF files in ImageJ format when supported, and otherwise resort to "generic" TIFF files.

leonorss commented 2 years ago

Thank you very much for your help, it is working now!