Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
hofmannmartin committed Jul 2, 2021
2 parents 9198030 + e0c647c commit 934a5b1
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MPIFiles"
uuid = "371237a9-e6c1-5201-9adb-3d8cfa78fa9f"
authors = ["Tobias Knopp <tobias@knoppweb.de>"]
version = "0.11.8"
version = "0.11.10"

[deps]
AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9"
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ MPIFiles.jl is a Julia package for loading and storing magnetic particle imaging
[![Build status](https://github.com/MagneticParticleImaging/MPIFiles.jl/workflows/CI/badge.svg)](https://github.com/MagneticParticleImaging/MPIFiles.jl/actions)

[![codecov.io](http://codecov.io/github/MagneticParticleImaging/MPIFiles.jl/coverage.svg?branch=master)](http://codecov.io/github/MagneticParticleImaging/MPIFiles.jl?branch=master)

[![Build status](https://ci.appveyor.com/api/projects/status/mvkx2xoi21jssbin/branch/master?svg=true)](https://ci.appveyor.com/project/tknopp/mpifiles-jl/branch/master)
3 changes: 2 additions & 1 deletion src/DatasetStore/MDFDatasetStore.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export MDFDatasetStore, MDFStore, addStudy, getMDFStudyFolderName, calibdir, getMDFStore
export MDFDatasetStore, MDFStore, addStudy, getMDFStudyFolderName, calibdir, getMDFStore, getCalibStudy

struct MDFDatasetStore <: DatasetStore
path::String
Expand All @@ -9,6 +9,7 @@ struct MDFDatasetStore <: DatasetStore
mkpath(joinpath(path,"measurements"))
mkpath(joinpath(path,"reconstructions"))
mkpath(joinpath(path,"calibrations"))
#try_chmod(joinpath(path,"path"), 0o777, recursive=true) # we should get rid of this
return new(path)
end
end
Expand Down
15 changes: 11 additions & 4 deletions src/MDFInMemory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -892,13 +892,16 @@ function checkConsistency(mdf::MDFv2InMemory)
if !(fieldtype == MDFv2Variables || fieldname == :custom)
# At the moment, this should be a Union
fieldtype = (fieldtype.b <: MDFv2InMemoryPart) ? fieldtype.b : fieldtype.a

@debug "Checking consistency of `$fieldname`."

field = getproperty(mdf, fieldname)
@assert !ismissing(field) "The field `$fieldname` is missing in the given in-memory MDF."

checkMissing(field)
check(field, mdf.variables)

if !isnothing(field) # Only optional fields can be `nothing`
checkMissing(field)
check(field, mdf.variables)
end

# Check subgroups of acquisition
if fieldtype == MDFv2Acquisition
Expand Down Expand Up @@ -1224,7 +1227,11 @@ function saveasMDF(file::HDF5.File, mdf::MDFv2InMemory; failOnInconsistent::Bool
try
checkConsistency(mdf)
catch e
@warn "There is an inconsistency in the given in-memory MDF. The message is: `$(e.msg)`."
if e isa AssertionError
@warn "There is an inconsistency in the given in-memory MDF. The message is: `$(e.msg)`."
else
rethrow()
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions src/Measurements.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ function getMeasurements(f::MPIFile, neglectBGFrames=true;

J = size(data,1)
dataF = rfft(data, 1)
dataF ./= tf
dataF[2:end,:,:,:] ./= tf[2:end,:,:,:]
@warn "This measurement has been corrected with a Transfer Function. Name of TF: $(rxTransferFunctionFileName(f))"
if inductionFactor != nothing
for k=1:length(inductionFactor)
Expand Down Expand Up @@ -309,7 +309,7 @@ function getMeasurementsFD(f::MPIFile, args...;
if tfCorrection && !measIsTFCorrected(f)
tf = rxTransferFunction(f)
inductionFactor = rxInductionFactor(f)
data ./= tf
data[2:end,:,:,:] ./= tf[2:end,:,:,:]
@warn "This measurement has been corrected with a Transfer Function. Name of TF: $(rxTransferFunctionFileName(f))"
if inductionFactor != nothing
for k=1:length(inductionFactor)
Expand Down
11 changes: 7 additions & 4 deletions src/Positions/Positions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,10 @@ function getindex(grid::RegularGridPositions, i::Integer)
idx = [i]
elseif length(grid.shape) == 2
idx = collect(Tuple((CartesianIndices(tuple(grid.shape[1],grid.shape[2])))[i]))
else
elseif length(grid.shape) == 3
idx = collect(Tuple((CartesianIndices(tuple(grid.shape[1],grid.shape[2],grid.shape[3])))[i]))
else
idx = collect(Tuple((CartesianIndices(tuple(grid.shape...)))[i]))
end

for d=1:length(idx)
Expand Down Expand Up @@ -303,10 +305,11 @@ end

function indexPermutation(grid::MeanderingGridPositions, i::Integer)
dims = tuple(shape(grid)...)
ndims = length(dims)
idx = collect(Tuple(CartesianIndices(dims)[i]))
for d=2:3
if isodd(sum(idx[d:3])-length(idx[d:3]))
idx[d-1] = shape(grid)[d-1] + 1 - idx[d-1]
for d=1:ndims-1
if isodd(sum(idx[d+1:end])-(ndims-d))
idx[d] = -idx[d] + shape(grid)[d] + 1
end
end
linidx = (LinearIndices(dims))[idx...]
Expand Down
2 changes: 1 addition & 1 deletion test/General.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
@test size(getSystemMatrix(sm,1:10)) == (1936,10)
@test size(getSystemMatrix(sm,1:10,loadasreal=true)) == (1936,20)
@test size(getSystemMatrix(sm,1:10,bgCorrection=true)) == (1936,10)
# test on the data level if the conversion was successfull
# test on the data level if the conversion was successful
SNRThresh = 2
freq = filterFrequencies(smBruker,SNRThresh=SNRThresh)
SBruker = getSystemMatrix(smBruker,frequencies=freq)
Expand Down
6 changes: 6 additions & 0 deletions test/MDFInMemory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,12 @@ end
# See also: https://github.com/JuliaLang/julia/issues/18780
@test checkConsistency(mdf) # This call has a side-effect on the variables!

# Check if non-required fields make consistency checking fail
tracer = mdf.tracer
mdf.tracer = nothing
@test checkConsistency(mdf)
mdf.tracer = tracer

@testset "Derived variables" begin
@test mdf.variables.A == A
@test mdf.variables.N == N
Expand Down

0 comments on commit 934a5b1

Please sign in to comment.