Baysor icon indicating copy to clipboard operation
Baysor copied to clipboard

Prior segmentation doesn't work for not 16-bit tiffs

Open YubinXie opened this issue 2 years ago • 3 comments

Hi authors,

I am trying to run Baysor with a segmentation tif file where the background is 0, and all the indivudual cells are marked with 1,2,3,4...I noticed that Baysor gave error in this case, while it is ok with a binary image. Can authors confirm this issue? Thanks!

(base) bash-4.2$ cd data/
(base) bash-4.2$ ~/tool/Baysor/bin/baysor run -i 500 -p -c ~/project/sparcle/data/iss.toml -o ./output_dapi -p spot.csv segmentation.tif
[17:08:12] Info: (2021-07-16) Run Baysor v0.5.0
[17:08:12] Info: Loading data...
[17:08:37] Info: Loaded 71907 transcripts
[17:08:38] Info: Loading segmentation mask...
[17:08:39] Warning: some versions of ImageMagick give spurious low-order bits for 32-bit TIFFs
└ ImageMagick /home/vpetukhov/.julia/packages/ImageMagick/b8swT/src/ImageMagick.jl:100
[17:08:44] Warning: Minimum transcript coordinates are < 1: (10, -1). Filling it with 0.
└ Baysor /home/vpetukhov/.julia/dev/Baysor/src/data_processing/initialization.jl:279
[17:08:45] Error: ArgumentError("reducing over an empty collection is not allowed")
|                 
|                 _empty_reduce_error() at reduce.jl:299
|                 reduce_empty(op::Function, #unused#::Type{UInt32}) at reduce.jl:309
|                 mapreduce_empty(#unused#::typeof(identity), op::Function, T::Type) at reduce.jl:343
|                 reduce_empty(op::Base.MappingRF{typeof(identity), typeof(max)}, #unused#::Type{UInt32}) at reduce.jl:329
|                 reduce_empty_iter at reduce.jl:355 [inlined]
|                 mapreduce_empty_iter(f::Function, op::Function, itr::Vector{UInt32}, ItrEltype::Base.HasEltype) at reduce.jl:351
|                 _mapreduce at reduce.jl:400 [inlined]
|                 _mapreduce_dim at reducedim.jl:318 [inlined]
|                 #mapreduce#672 at reducedim.jl:310 [inlined]
|                 mapreduce at reducedim.jl:310 [inlined]
|                 #_maximum#690 at reducedim.jl:878 [inlined]
|                 _maximum at reducedim.jl:878 [inlined]
|                 #_maximum#689 at reducedim.jl:877 [inlined]
|                 _maximum at reducedim.jl:877 [inlined]
|                 #maximum#687 at reducedim.jl:873 [inlined]
|                 maximum at reducedim.jl:873 [inlined]
|                 filter_segmentation_labels!(segmentation_labels::Vector{UInt32}, segment_per_transcript::Vector{Int64}; min_molecules_per_segment::Int64) at prior_segmentation.jl:74
|                 filter_segmentation_labels! at prior_segmentation.jl:74 [inlined]
|                 #filter_segmentation_labels!#91 at prior_segmentation.jl:68 [inlined]
|                 (::Baysor.var"#filter_segmentation_labels!##kw")(::NamedTuple{(:min_molecules_per_segment,), Tuple{Int64}}, ::typeof(Baysor.filter_segmentation_labels!), segmentation_labels::SparseArrays.SparseMatrixCSC{UInt32, Int64}, segment_per_transcript::Vector{Int64}) at prior_segmentation.jl:68
|                 load_prior_segmentation(df_spatial::DataFrames.DataFrame, args::Dict{String, Any}) at main.jl:280
|                 load_and_preprocess_data!(args::Dict{String, Any}) at main.jl:330
|                 run_cli_main(args::Vector{String}) at main.jl:433
|                 run_cli(args::Vector{String}) at common.jl:118
|                 run_cli at common.jl:103 [inlined]
|                 julia_main at common.jl:139 [inlined]
|                 julia_main() at none:36
└ Baysor /home/vpetukhov/.julia/dev/Baysor/src/cli/common.jl:132

YubinXie avatar Jul 16 '21 21:07 YubinXie

Hi Yubin, Could you please try it with 16-bit TIFF instead of 32-bit?

VPetukhov avatar Jul 19 '21 09:07 VPetukhov

You are right. 16 bit works! Thanks Viktor.

YubinXie avatar Jul 19 '21 14:07 YubinXie

Let's see if I can fix it for 32-bit, as well

VPetukhov avatar Jul 19 '21 16:07 VPetukhov

I changed image loading backend in the v0.6.0. So this hopefully should be fixed, though I didn't test properly. If anyone encounters this error, please, reopen the issue.

VPetukhov avatar Apr 21 '23 08:04 VPetukhov