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

fixes #17

parent c0a1abee
No related branches found
No related tags found
No related merge requests found
Pipeline #93883 passed
...@@ -271,17 +271,18 @@ function write_larva_dataset_hdf5(path, counts, files, refs, nsteps_before, nste ...@@ -271,17 +271,18 @@ function write_larva_dataset_hdf5(path, counts, files, refs, nsteps_before, nste
end end
end end
h5open(path, "w") do h5 h5open(path, "w") do h5
g = make_dataset(h5, "samples")
Threads.foreach(ch) do (file, refs, sampleid) Threads.foreach(ch) do (file, refs, sampleid)
@info "Sampling series of spines in run: $(runid(file))" @info "Sampling series of spines in run: $(runid(file))"
processfile(h5, file, refs, sampleid, nsteps_before, nsteps_after; processfile(g, file, refs, sampleid, nsteps_before, nsteps_after;
fixmwt=fixmwt, frameinterval=frameinterval) fixmwt=fixmwt, frameinterval=frameinterval)
end end
attributes(h5["samples"])["n_samples"] = sampleid attributes(g)["n_samples"] = sampleid
# extension # extension
h5["labels"] = collect(keys(counts)) h5["labels"] = collect(keys(counts))
#h5["files"] = [f.source for f in files] #h5["files"] = [f.source for f in files]
if !isnothing(frameinterval) if !isnothing(frameinterval)
attributes(h5["samples"])["frame_interval"] = frameinterval attributes(g)["frame_interval"] = frameinterval
end end
end end
end end
...@@ -363,7 +364,7 @@ function processfile(h5, file, refs, sampleid, nsteps_before, nsteps_after; ...@@ -363,7 +364,7 @@ function processfile(h5, file, refs, sampleid, nsteps_before, nsteps_after;
sample[:,8] = lengths sample[:,8] = lengths
sample[:,9:end] = spines sample[:,9:end] = spines
# #
name = "samples/sample_$sampleid" name = "sample_$sampleid"
# transpose for compatibility with h5py # transpose for compatibility with h5py
# see issue https://github.com/JuliaIO/HDF5.jl/issues/785 # see issue https://github.com/JuliaIO/HDF5.jl/issues/785
h5[name] = permutedims(sample, reverse(1:ndims(sample))) h5[name] = permutedims(sample, reverse(1:ndims(sample)))
...@@ -517,9 +518,6 @@ function write_larva_dataset_hdf5(output_dir::String, ...@@ -517,9 +518,6 @@ function write_larva_dataset_hdf5(output_dir::String,
h5open(output_file, "cw") do h5 h5open(output_file, "cw") do h5
attributes(h5["samples"])["len_traj"] = window_length attributes(h5["samples"])["len_traj"] = window_length
attributes(h5["samples"])["len_pred"] = window_length attributes(h5["samples"])["len_pred"] = window_length
if !isnothing(frameinterval)
attributes(h5["samples"])["frame_interval"] = frameinterval
end
end end
return output_file return output_file
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment