Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise error if background value is found in multiple rows #18

Open
kbestak opened this issue Sep 4, 2024 · 1 comment
Open

Raise error if background value is found in multiple rows #18

kbestak opened this issue Sep 4, 2024 · 1 comment

Comments

@kbestak
Copy link
Collaborator

kbestak commented Sep 4, 2024

As an example, if the background value in the marker sheet points to multiple channels (pointing is done by matching to the marker_name value), the scalar critical for the subtraction calculation would be a list of multiple values (1 per matched row). As denoted in the documentation, it is important that the marker_name column only contains unique values as it is used for background channel matching and an error should be raised if this happens.

@kbestak
Copy link
Collaborator Author

kbestak commented Sep 4, 2024

Test marker sheet without biological significance:

channel_number,cycle_number,marker_name,filter,background,remove,exposure
1,1,PK,Alexa488,,,100
2,1,CD11c,Alexa594,,,100
3,1,PK,Alexa647,,TRUE,100
4,1,CD163,Cy7,PK,,100
5,1,DAPI_1,DAPI,CD11c,,100
6,1,AF_1,AF,,TRUE,100

Command output:

Command error:
  2024-09-04 07:38:43.522 | INFO     | __main__:write_pyramid:171 - Writing to small_test_backsub.ome.tif
  Pixel size overwrite not specified
  Channel PK (0) processed, no background subtraction
  Channel CD11c (1) processed, no background subtraction
  Channel PK (2) processed, no background subtraction
  Channel CD163 (3) processed, background subtraction
  Channel DAPI_1 (4) processed, background subtraction
  Channel AF_1 (5) processed, no background subtraction
  [(1024, 1024), (1024, 1024), (1024, 1024)]
  
  Assembling mosaic  1/ 1 (channel  1/ 4):   0%|          | 0/8 [00:00<?, ?it/s]
  Assembling mosaic  1/ 1 (channel  1/ 4): 100%|##########| 8/8 [00:00<00:00, 439.75it/s]
  
  Assembling mosaic  1/ 1 (channel  2/ 4):   0%|          | 0/8 [00:00<?, ?it/s]
  Assembling mosaic  1/ 1 (channel  2/ 4): 100%|##########| 8/8 [00:00<00:00, 520.51it/s]
  
  Assembling mosaic  1/ 1 (channel  3/ 4):   0%|          | 0/31 [00:00<?, ?it/s]
  Assembling mosaic  1/ 1 (channel  3/ 4):  77%|#######7  | 24/31 [00:00<00:00, 1523.42it/s]
  Traceback (most recent call last):
    File "/background_subtraction/background_sub.py", line 429, in <module>
      main(args)
    File "/background_subtraction/background_sub.py", line 416, in main
      write_pyramid(
    File "/background_subtraction/background_sub.py", line 180, in write_pyramid
      tif.write(
    File "/opt/conda/envs/backsub/lib/python3.9/site-packages/tifffile/tifffile.py", line 3049, in write
      iteritem, dataiter = peek_iterator(dataiter)
    File "/opt/conda/envs/backsub/lib/python3.9/site-packages/tifffile/tifffile.py", line 21409, in peek_iterator
      first = next(iterator)
    File "/opt/conda/envs/backsub/lib/python3.9/site-packages/tifffile/tifffile.py", line 21413, in newiter
      yield from iterator
    File "/opt/conda/envs/backsub/lib/python3.9/site-packages/tifffile/tifffile.py", line 21413, in newiter
      yield from iterator
    File "/background_subtraction/background_sub.py", line 241, in tile_from_combined_mosaics
      c = da_to_zarr(c) if save_RAM else c.compute()
    File "/opt/conda/envs/backsub/lib/python3.9/site-packages/dask/base.py", line 342, in compute
      (result,) = compute(self, traverse=False, **kwargs)
    File "/opt/conda/envs/backsub/lib/python3.9/site-packages/dask/base.py", line 628, in compute
      results = schedule(dsk, keys, **kwargs)
    File "/background_subtraction/background_sub.py", line 337, in scale_background
      background_channel = np.rint(ne.evaluate("background_channel * scalar"))
    File "/opt/conda/envs/backsub/lib/python3.9/site-packages/numexpr/necompiler.py", line 827, in evaluate
      return compiled_ex(*arguments, **kwargs)
  ValueError: operands could not be broadcast together with shapes (2793,1860) (2,) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant