new functiont in Labels.jl
[?]
AEj8dahVWy718uSSFPe9VSRJ5qX5G8pC2zvFzJJ8yzBd
Nov 17, 2024, 8:27 PM
5M7JW5OVBMQ2EX5QDNJ2FRQPB3DIRG7FDW7DMXXTI2NDRTTSEJZACDependencies
- [2]
7KO4BAOGTidy up - [3]
ACUJ2OKIlabel summary now workt on cwd unless folder specified, note trailing / required if folder is specified - [4]
2UBDFCJHnew files tracked - [5]
QA2TJZRAripped ML out into the SkraakML repo, compiles quicker now - [6]
2O6SHIVYadded avianz_of_raven function to Labels.jl - [7]
YXAKJSDTadded check_change_avianz_species! function to Labels.jl - [8]
YODTMMPTadded a whole bunch of functions to Labels.jl for working with raven and avians labels - [9]
Y2LW6LAAdeduplicated an export in Labels.jl
Change contents
- replacement in src/Labels.jl at line 7
avianz_of_raven,avianz_of_raven, #not working right, 1 file per label I think - edit in src/Labels.jl at line 12
one_hot_labels, - replacement in src/Labels.jl at line 179
# Raven selections.txt to AviaNZ .data# ASSUMES 60 second files, also wav and txt file in same folder# Raven selections.txt to AviaNZ .data - replacement in src/Labels.jl at line 186
function avianz_of_raven(f::String)function avianz_of_raven(f::String) #not working right, check - edit in src/Labels.jl at line 214
duration = Float64[], - edit in src/Labels.jl at line 221
dur = data[1]["Duration"] - edit in src/Labels.jl at line 230
duration = dur, - replacement in src/Labels.jl at line 306
# if specified folder must include trailing /function label_summary(folder::String = "", avianz = true)# if specified folder must include trailing /, can be "" for current folderfunction label_summary(folder::String, avianz::Bool = true) - edit in src/Labels.jl at line 311
duration = Float64[], - replacement in src/Labels.jl at line 325
select!(df, [:File, :start_time, :end_time, :low_f, :high_f, :Species])select!(df, [:File, :duration, :start_time, :end_time, :low_f, :high_f, :Species]) - edit in src/Labels.jl at line 360
end#allow 0.2 overlap each side#round end_time down to nearest 5function et(end_time::Float64)end_time % 5 > 0.2 ? (c0 = ceil(end_time / 5) * 5) : c0 = floor(end_time / 5) * 5return c0end#allow 0.2 overlap each side#round start_time down to nearest 5function st(start_time::Float64)start_time % 5 < 4.8 ? (f = floor(start_time / 5) * 5) : f = ceil(start_time / 5) * 5return f - edit in src/Labels.jl at line 374[4.4284]
#labels must be a df loaded from label_summary run over avianz data (not raven)function one_hot_labels(labels::DataFrame)gdf = groupby(labels, :File)vdf = []for group in gdfdur = first(group.duration)nrows = dur ÷ 5seil = nrows * 5df = DataFrame(file = [first(group.File) for x = 1:nrows],start_time = collect(0:5:seil-1),end_time = collect(5:5:seil),)for row in eachrow(group)fst = st(row.start_time)@assert fst >= 0lst0 = et(row.end_time)#end time must not be greater than durationlst0 > dur ? lst = lst0 - 5 : lst = lst0@assert lst <= durf_idx = fst ÷ 5 + 1 |> Intl_idx = lst ÷ 5 |> Intvect = [false for x = 1:nrows]for idx = f_idx:l_idxvect[idx] = trueendcol_name = row.Speciesdf[!, Symbol(col_name)] = vectend#(names(df) |> length) > 4 && println(df)push!(vdf, df)endcdf1 = reduce((x, y) ->outerjoin(x, y, matchmissing = :equal, on = intersect(names(x), names(y))),vdf,)cdf2 = coalesce.(cdf1, false)end