diff --git a/Manifest.toml b/Manifest.toml index 2b23b029f8d7c7584b90832b8b26e8cb1441dda2..846393d1bad59809863a236de83a9c78ec1155d4 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -312,7 +312,7 @@ version = "1.9.0" [[deps.PlanarLarvae]] deps = ["DelimitedFiles", "HDF5", "JSON3", "LinearAlgebra", "MAT", "Meshes", "OrderedCollections", "Random", "SHA", "StaticArrays", "Statistics", "StatsBase", "StructTypes"] -git-tree-sha1 = "bff9bdff96050dffcb681e950ac2547e33c53417" +git-tree-sha1 = "fe89d5f592c8ba763a13330cde6696f721f828c7" repo-rev = "dev" repo-url = "https://gitlab.pasteur.fr/nyx/planarlarvae.jl" uuid = "c2615984-ef14-4d40-b148-916c85b43307" diff --git a/src/LarvaDatasets.jl b/src/LarvaDatasets.jl index e80675b0ba8396b9947717e374a58c3b5686e4fb..fa8a0f1efc5b288759edd8d063978e59d4afbda4 100644 --- a/src/LarvaDatasets.jl +++ b/src/LarvaDatasets.jl @@ -628,12 +628,7 @@ function new_write_larva_dataset_hdf5(output_dir, input_data; output_file = joinpath(output_dir, output_file) c = Threads.Condition() h5open(output_file, "w") do h5 - lock(c) - g = try - create_group(h5, "samples") - finally - unlock(c) - end + create_group(h5, "samples") sample(loader, :spine) do _, file, counts, segments sampleid, nsegments = counts @assert length(segments) == nsegments @@ -662,45 +657,34 @@ function new_write_larva_dataset_hdf5(output_dir, input_data; name = "sample_$sampleid" # transpose for compatibility with h5py # see issue https://github.com/JuliaIO/HDF5.jl/issues/785 - lock(c) - try - g[name] = permutedims(sample, reverse(1:ndims(sample))) - sampleid += 1 - # - d = g[name] - attributes(d)["larva_number"] = convert(Int, trackid) - # we should set `start_point` instead of `reference_time`, to comply with - # the original format, but this would not make sense here due to - # interpolation: - attributes(d)["reference_time"] = anchortime - attributes(d)["behavior"] = string(label) - attributes(d)["path"] = file.source - finally - unlock(c) - end + g[name] = permutedims(sample, reverse(1:ndims(sample))) + sampleid += 1 + # + d = g[name] + attributes(d)["larva_number"] = convert(Int, trackid) + # we should set `start_point` instead of `reference_time`, to comply with the + # original format, but this would not make sense here due to interpolation: + attributes(d)["reference_time"] = anchortime + attributes(d)["behavior"] = string(label) + attributes(d)["path"] = file.source end end - lock(c) - try - attributes(g)["len_traj"] = window_length - attributes(g)["len_pred"] = window_length - attributes(g)["n_samples"] = total_sample_size - # extensions - counts = Dataloaders.total(index.targetcounts) - if isnothing(labels) - h5["labels"] = string.(keys(classcounts)) - h5["label_counts"] = collect(values(classcounts)) - else - # ensure labels are ordered as provided in input; - # see https://gitlab.pasteur.fr/nyx/TaggingBackends/-/issues/24 - h5["labels"] = labels - h5["label_counts"] = [classcounts[Symbol(label)] for label in labels] - end - if !isnothing(frameinterval) - attributes(g)["frame_interval"] = frameinterval - end - finally - unlock(c) + attributes(g)["len_traj"] = window_length + attributes(g)["len_pred"] = window_length + attributes(g)["n_samples"] = total_sample_size + # extensions + counts = Dataloaders.total(index.targetcounts) + if isnothing(labels) + h5["labels"] = string.(keys(classcounts)) + h5["label_counts"] = collect(values(classcounts)) + else + # ensure labels are ordered as provided in input; + # see https://gitlab.pasteur.fr/nyx/TaggingBackends/-/issues/24 + h5["labels"] = labels + h5["label_counts"] = [classcounts[Symbol(label)] for label in labels] + end + if !isnothing(frameinterval) + attributes(g)["frame_interval"] = frameinterval end end return output_file