Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
jusack committed Sep 9, 2024
1 parent 9d21515 commit c47eaee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
14 changes: 3 additions & 11 deletions src/MDF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,9 @@ function rxTransferFunction(f::MDFFile)
return nothing
end
end
function rxTransferFunctionFileName(f::MDFFile)
parameter = "/acquisition/receiver/transferFunctionFileName"
if haskey(f.file, parameter)
return f[parameter]
else
return nothing
end
end
function rxHasTransferFunction(f::MDFFile)
haskey(f.file, "/acquisition/receiver/transferFunction")
end
rxTransferFunctionFileName(f::MDFFile) = @keyoptional f["/acquisition/receiver/transferFunctionFileName"]
rxHasTransferFunction(f::MDFFile) = haskey(f.file, "/acquisition/receiver/transferFunction")

rxInductionFactor(f::MDFFileV1) = nothing
rxInductionFactor(f::MDFFileV2) = @keyoptional f["/acquisition/receiver/inductionFactor"]

Expand Down
10 changes: 7 additions & 3 deletions src/TransferFunction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,9 @@ function setTF(b::BrukerFile, filenameTF::AbstractString)
return
end

setTF(f::MDFFile, filenameTF::AbstractString) = setTF(f, TransferFunction(filenameTF), filenameTF)

function setTF(f::MDFFile, filenameTF::AbstractString)
tmf = TransferFunction(filenameTF)
function setTF(f::MDFFile, tmf::TransferFunction, filenameTF::Union{AbstractString,Nothing}=nothing)
tf = sampleTF(tmf, f)

# We need to close the HDF5 file handle before we can write to it
Expand All @@ -302,7 +302,9 @@ function setTF(f::MDFFile, filenameTF::AbstractString)
if haskey(file, "/acquisition/receiver/transferFunctionFileName")
delete_object(file, "/acquisition/receiver/transferFunctionFileName")
end
write(file, "/acquisition/receiver/transferFunctionFileName", filenameTF)
if !isnothing(filenameTF)
write(file, "/acquisition/receiver/transferFunctionFileName", filenameTF)
end
if haskey(file, "/acquisition/receiver/transferFunction")
delete_object(file, "/acquisition/receiver/transferFunction")
end
Expand All @@ -312,6 +314,8 @@ function setTF(f::MDFFile, filenameTF::AbstractString)
end
write(file, "/acquisition/receiver/inductionFactor", tmf.inductionFactor)
end
# reopen filehandler so f stays usable
f.file = h5open(filepath(f), "r")
return
end

Expand Down

0 comments on commit c47eaee

Please sign in to comment.