Skip to content
Snippets Groups Projects
Commit effabc10 authored by François  LAURENT's avatar François LAURENT
Browse files

mysterious bugfix (maybe not in this package...)

parent 2171897b
No related branches found
No related tags found
No related merge requests found
Pipeline #85674 passed
......@@ -109,10 +109,10 @@ function LarvaDatasets.labelcounts(
files::Vector{LarvaH5}, nsteps_before=nothing, nsteps_after=nothing;
unused...)
if isnothing(nsteps_before)
nsteps_before = isnothing(nsteps_after) ? 0 : nsteps_after
nsteps_before = isnothing(nsteps_after) ? 0 : nsteps_after + 1
end
if isnothing(nsteps_after)
nsteps_after = nsteps_before
nsteps_after = nsteps_before - 1
end
counts = Dict{String, Int}()
refs = Dict{String, Vector{Tuple{Int, Int, Int}}}()
......@@ -123,7 +123,7 @@ function LarvaDatasets.labelcounts(
h5open(file.source) do h5
labels = try
read(h5, "labels")
catch e
catch
@error "no \"labels\" record in file" file=file.source
push!(corrupted, file.source)
return
......@@ -137,11 +137,11 @@ function LarvaDatasets.labelcounts(
nsteps_before + nsteps_after < size(steps, 1) || continue
steps = steps[nsteps_before+1:end-nsteps_after, :]
counts′= sum(steps; dims=1)
for (j′, (label, count′)) in enumerate(zip(labels, counts′))
for (l, (label, count′)) in enumerate(zip(labels, counts′))
count = get(counts, label, 0)
counts[label] = count + count′
ref = get!(refs, label, Tuple{Int, Int, Int}[])
for k′ in findall(steps[:, j′])
for k′ in findall(steps[:, l])
k = nsteps_before + k′
push!(ref, (i, j, k))
end
......@@ -175,13 +175,16 @@ function LarvaDatasets.processfile(h5, file::LarvaH5, refs, sampleid, nsteps_bef
end
median_body_length = median(lengths)
@debug basename(file.source) median_body_length
labels = read(h5′, "labels") # testset #1
#
for (j, record) in enumerate(records)
trackid = parse(Int, record[7:end])
times = read(h5′, record * "/t")
track = read(h5′, record * "/spines")
behavior = read(h5′, record * "/labels") # testset #1
for (j′, k, label) in refs
j′==j || continue
@assert label in labels[behavior[k,:]] # testset #1
start_point = k-nsteps_before
spines = [aspoints(track[row,:,:]) for row in start_point:k+nsteps_after]
lengths = bodylength.(spines)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment