Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into JA/patchBrukerIMT
Browse files Browse the repository at this point in the history
  • Loading branch information
jusack committed May 16, 2024
2 parents 1c54b27 + 95f7383 commit 2ad927f
Show file tree
Hide file tree
Showing 14 changed files with 130 additions and 115 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jobs:
- x64
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v3
- uses: actions/cache@v4
env:
cache-name: cache-artifacts
with:
Expand All @@ -43,15 +43,15 @@ jobs:
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v4
with:
file: lcov.info
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: '1'
- run: |
Expand Down
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 <[email protected]>"]
version = "0.15.0"
version = "0.15.3"

[deps]
AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9"
Expand Down
4 changes: 2 additions & 2 deletions src/DatasetStore/SFDatabase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ function _innerGenerateSFDatabase(A,i,sf,b)
end
N = calibSize(b)
A[i,6] = N[1]
A[i,7] = N[2]
A[i,8] = N[3]
A[i,7] = try N[2]; catch; 0 end
A[i,8] = try N[3]; catch; 0 end
A[i,9] = rxBandwidth(b) / 1e6
A[i,10] = tracerName(b)[1]
A[i,11] = tracerBatch(b)[1]
Expand Down
8 changes: 7 additions & 1 deletion src/Derived.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,13 @@ function measDataTD(f, frames=1:acqNumFrames(f), periods=1:acqNumPeriodsPerFrame
end

if measIsFourierTransformed(f)
dataTD = irfft(data2, rxNumSamplingPoints(f), 1)
if measIsFrequencySelection(f)
dataPadded = zeros(eltype(data2), (rxNumFrequencies(f), size(data2, 2), size(data2, 3), size(data2, 4)))
dataPadded[measFrequencySelection(f), :, :, :] .= data2
dataTD = irfft(dataPadded, rxNumSamplingPoints(f), 1)
else
dataTD = irfft(data2, rxNumSamplingPoints(f), 1)
end
else
dataTD = data2
end
Expand Down
2 changes: 1 addition & 1 deletion src/FrequencyFilter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function filterFrequencies(f::MPIFile; SNRThresh=-1, minFreq=0,
idx = measIsFrequencySelection(f) ? measFrequencySelection(f) : idx = 1:nFreq

SNRAll = calibSNR(f)
if SNRAll != nothing
if !isnothing(SNRAll)
SNR[idx,:] = SNRAll[:,:,1]
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/MDF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ tracerVendor(f::MDFFileV1)::Union{Vector{String}, Missing} = @keyrequired [f["/t
tracerVendor(f::MDFFileV2)::Union{Vector{String}, Missing} = @keyrequired _makeStringArray(f["/tracer/vendor"])

# scanner parameters
scannerBoreSize(f::MDFFile)::Union{String, Nothing} = @keyoptional f["/scanner/boreSize"]
scannerBoreSize(f::MDFFile)::Union{Float64, Nothing} = @keyoptional f["/scanner/boreSize"]
scannerFacility(f::MDFFile)::Union{String, Missing} = @keyrequired f["/scanner/facility"]
scannerOperator(f::MDFFile)::Union{String, Missing} = @keyrequired f["/scanner/operator"]
scannerManufacturer(f::MDFFile)::Union{String, Missing} = @keyrequired f["/scanner/manufacturer"]
Expand Down
94 changes: 47 additions & 47 deletions src/MDFInMemory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -660,27 +660,27 @@ function check(part::MDFv2Acquisition, variables::MDFv2Variables)
# Check dimensions of `gradient` field
if !isnothing(part.gradient)
if isnothing(variables.J)
variables.J = size(part.gradient, 1)
variables.J = size(part.gradient, 4)
else
@assert variables.J == size(part.gradient, 1) "Inconsistent dimension J in `gradient` in `acquisition`."
@assert variables.J == size(part.gradient, 4) "Inconsistent dimension J in `gradient` in `acquisition`."
end

if isnothing(variables.Y)
variables.Y = size(part.gradient, 2)
variables.Y = size(part.gradient, 3)
else
@assert variables.Y == size(part.gradient, 1) "Inconsistent dimension Y in `gradient` in `acquisition`."
@assert variables.Y == size(part.gradient, 3) "Inconsistent dimension Y in `gradient` in `acquisition`."
end

@assert size(part.gradient, 3) == 3 "Inconsistent third dimension in `gradient` in `acquisition`."
@assert size(part.gradient, 4) == 3 "Inconsistent fourth dimension in `gradient` in `acquisition`."
@assert size(part.gradient, 1) == 3 "Inconsistent first dimension in `gradient` in `acquisition`."
@assert size(part.gradient, 2) == 3 "Inconsistent second dimension in `gradient` in `acquisition`."
end

# Check dimensions of `offsetField` field
if !isnothing(part.offsetField)
if isnothing(variables.J)
variables.J = size(part.offsetField, 1)
variables.J = size(part.offsetField, 3)
else
@assert variables.J == size(part.offsetField, 1) "Inconsistent dimension J in `offsetField` in `acquisition`."
@assert variables.J == size(part.offsetField, 3) "Inconsistent dimension J in `offsetField` in `acquisition`."
end

if isnothing(variables.Y)
Expand All @@ -689,7 +689,7 @@ function check(part::MDFv2Acquisition, variables::MDFv2Variables)
@assert variables.Y == size(part.offsetField, 2) "Inconsistent dimension Y in `offsetField` in `acquisition`."
end

@assert size(part.offsetField, 3) == 3 "Inconsistent third dimension in `offsetField` in `acquisition`."
@assert size(part.offsetField, 1) == 3 "Inconsistent first dimension in `offsetField` in `acquisition`."
end
end

Expand All @@ -699,26 +699,26 @@ function check(part::MDFv2Drivefield, variables::MDFv2Variables)
variables.D = part.numChannels
end
if isnothing(variables.F)
variables.F = size(part.divider, 2)
variables.F = size(part.divider, 1)
end
if isnothing(variables.J)
variables.J = size(part.phase, 1)
variables.J = size(part.phase, 3)
end

# Then check dimensions for multidimensional fields
@assert variables.D == size(part.divider, 1) "Inconsistent dimension D in `divider` in `drivefield`."
@assert variables.F == size(part.divider, 2) "Inconsistent dimension F in `divider` in `drivefield`."
@assert variables.F == size(part.divider, 1) "Inconsistent dimension F in `divider` in `drivefield`."
@assert variables.D == size(part.divider, 2) "Inconsistent dimension D in `divider` in `drivefield`."

@assert variables.J == size(part.phase, 1) "Inconsistent dimension J in `phase` in `drivefield`."
@assert variables.F == size(part.phase, 1) "Inconsistent dimension F in `phase` in `drivefield`."
@assert variables.D == size(part.phase, 2) "Inconsistent dimension D in `phase` in `drivefield`."
@assert variables.F == size(part.phase, 3) "Inconsistent dimension F in `phase` in `drivefield`."
@assert variables.J == size(part.phase, 3) "Inconsistent dimension J in `phase` in `drivefield`."

@assert variables.J == size(part.strength, 1) "Inconsistent dimension J in `strength` in `drivefield`."
@assert variables.F == size(part.strength, 1) "Inconsistent dimension F in `strength` in `drivefield`."
@assert variables.D == size(part.strength, 2) "Inconsistent dimension D in `strength` in `drivefield`."
@assert variables.F == size(part.strength, 3) "Inconsistent dimension F in `strength` in `drivefield`."
@assert variables.J == size(part.strength, 3) "Inconsistent dimension J in `strength` in `drivefield`."

@assert variables.D == size(part.waveform, 1) "Inconsistent dimension D in `waveform` in `drivefield`."
@assert variables.F == size(part.waveform, 2) "Inconsistent dimension F in `waveform` in `drivefield`."
@assert variables.F == size(part.waveform, 1) "Inconsistent dimension F in `waveform` in `drivefield`."
@assert variables.D == size(part.waveform, 2) "Inconsistent dimension D in `waveform` in `drivefield`."
end

function check(part::MDFv2Receiver, variables::MDFv2Variables)
Expand All @@ -732,21 +732,21 @@ function check(part::MDFv2Receiver, variables::MDFv2Variables)
end

if !isnothing(part.dataConversionFactor)
@assert variables.C == size(part.dataConversionFactor, 1) "Inconsistent dimension C in `dataConversionFactor` in `receiver`."
@assert size(part.dataConversionFactor, 2) == 2 "Inconsistent second dimension in `dataConversionFactor` in `receiver`."
@assert variables.C == size(part.dataConversionFactor, 2) "Inconsistent dimension C in `dataConversionFactor` in `receiver`."
@assert size(part.dataConversionFactor, 1) == 2 "Inconsistent first dimension in `dataConversionFactor` in `receiver`."
end

if !isnothing(part.inductionFactor)
@assert variables.C == size(part.inductionFactor, 1) "Inconsistent dimension C in `inductionFactor` in `receiver`."
@assert variables.C == length(part.inductionFactor) "Inconsistent dimension C in `inductionFactor` in `receiver`."
end

if !isnothing(part.transferFunction)
@assert variables.C == size(part.transferFunction, 1) "Inconsistent dimension C in `transferFunction` in `receiver`."
@assert variables.C == size(part.transferFunction, 2) "Inconsistent dimension C in `transferFunction` in `receiver`."

if isnothing(variables.K)
variables.K = size(part.transferFunction, 2)
variables.K = size(part.transferFunction, 1)
else
@assert variables.K == size(part.transferFunction, 2) "Inconsistent dimension K in `transferFunction` in `receiver`."
@assert variables.K == size(part.transferFunction, 1) "Inconsistent dimension K in `transferFunction` in `receiver`."
end
end
end
Expand All @@ -767,7 +767,7 @@ function check(part::MDFv2Measurement, variables::MDFv2Variables)
if isnothing(variables.E)
variables.E = length([x for x in part.isBackgroundFrame if x == true])
end
# E is defined by the number of `false` values in isBackgroundFrame here; should have been retrieved earlier
# O is defined by the number of `false` values in isBackgroundFrame here; should have been retrieved earlier
if isnothing(variables.O)
variables.O = length([x for x in part.isBackgroundFrame if x == false])
end
Expand All @@ -781,28 +781,28 @@ function check(part::MDFv2Measurement, variables::MDFv2Variables)

if isnothing(variables.J)
if !part.isSparsityTransformed
@warn "Can't determine variable J for measurement from `subsamplingIndices` since the dataset is not sparsity transformed."
@debug "Can't determine variable J for measurement from `subsamplingIndices` since the dataset is not sparsity transformed."
else
variables.J = size(part.subsamplingIndices, 1)
end
end
if isnothing(variables.C)
if !part.isSparsityTransformed
@warn "Can't determine variable C for measurement from `subsamplingIndices` since the dataset is not sparsity transformed. Should happen in receiver."
@debug "Can't determine variable C for measurement from `subsamplingIndices` since the dataset is not sparsity transformed. Should happen in receiver."
else
variables.C = size(part.subsamplingIndices, 2)
end
end
if isnothing(variables.K)
if !part.isSparsityTransformed
@warn "Can't determine variable K for measurement from `subsamplingIndices` since the dataset is not sparsity transformed. Should happen in receiver."
@debug "Can't determine variable K for measurement from `subsamplingIndices` since the dataset is not sparsity transformed. Should happen in receiver."
else
variables.K = size(part.subsamplingIndices, 3)
end
end
if isnothing(variables.B)
if !part.isSparsityTransformed
@warn "Can't determine variable B for measurement from `subsamplingIndices` since the dataset is not sparsity transformed. Should happen in receiver."
@debug "Can't determine variable B for measurement from `subsamplingIndices` since the dataset is not sparsity transformed. Should happen in receiver."
else
variables.B = size(part.subsamplingIndices, 4)
end
Expand All @@ -829,10 +829,10 @@ function check(part::MDFv2Measurement, variables::MDFv2Variables)

if part.isSparsityTransformed
# J, C, K and B should be defined by now
@assert variables.J == size(part.subsamplingIndices, 1) "Inconsistent dimension J in `subsamplingIndices` in `measurement`."
@assert variables.C == size(part.subsamplingIndices, 2) "Inconsistent dimension C in `subsamplingIndices` in `measurement`."
@assert variables.K == size(part.subsamplingIndices, 3) "Inconsistent dimension K in `subsamplingIndices` in `measurement`."
@assert variables.B == size(part.subsamplingIndices, 4) "Inconsistent dimension B in `subsamplingIndices` in `measurement`."
@assert variables.B == size(part.subsamplingIndices, 1) "Inconsistent dimension B in `subsamplingIndices` in `measurement`."
@assert variables.K == size(part.subsamplingIndices, 2) "Inconsistent dimension K in `subsamplingIndices` in `measurement`."
@assert variables.C == size(part.subsamplingIndices, 3) "Inconsistent dimension C in `subsamplingIndices` in `measurement`."
@assert variables.J == size(part.subsamplingIndices, 4) "Inconsistent dimension J in `subsamplingIndices` in `measurement`."
end
end

Expand All @@ -851,11 +851,11 @@ function check(part::MDFv2Calibration, variables::MDFv2Variables)

if !isnothing(part.offsetFields)
if isnothing(variables.O)
variables.O = size(part.offsetFields, 1)
variables.O = size(part.offsetFields, 2)
else
@assert variables.O == size(part.offsetFields, 1) "Inconsistent dimension O in `offsetFields` in `calibration`."
@assert variables.O == size(part.offsetFields, 2) "Inconsistent dimension O in `offsetFields` in `calibration`."
end
@assert size(part.offsetFields, 2) == 3 "Inconsistent second dimension in `offsetFields` in `calibration`."
@assert size(part.offsetFields, 1) == 3 "Inconsistent first dimension in `offsetFields` in `calibration`."
end

if !isnothing(part.order)
Expand All @@ -864,8 +864,8 @@ function check(part::MDFv2Calibration, variables::MDFv2Variables)

if !isnothing(part.positions)
# O must be defined by now
@assert variables.O == size(part.positions, 1) "Inconsistent dimension O in `positions` in `calibration`."
@assert size(part.positions, 2) == 3 "Inconsistent second dimension in `positions` in `calibration`."
@assert variables.O == size(part.positions, 2) "Inconsistent dimension O in `positions` in `calibration`."
@assert size(part.positions, 1) == 3 "Inconsistent first dimension in `positions` in `calibration`."
end

if !isnothing(part.size)
Expand All @@ -876,9 +876,9 @@ function check(part::MDFv2Calibration, variables::MDFv2Variables)

if !isnothing(part.snr)
if isnothing(variables.J)
variables.J = size(part.snr, 1)
variables.J = size(part.snr, 3)
else
@assert variables.J == size(part.snr, 1) "Inconsistent dimension J in `snr` in `calibration`."
@assert variables.J == size(part.snr, 3) "Inconsistent dimension J in `snr` in `calibration`."
end

if isnothing(variables.C)
Expand All @@ -888,17 +888,17 @@ function check(part::MDFv2Calibration, variables::MDFv2Variables)
end

if isnothing(variables.K)
variables.K = size(part.snr, 3)
variables.K = size(part.snr, 1)
else
@assert variables.K == size(part.snr, 3) "Inconsistent dimension K in `snr` in `calibration`."
@assert variables.K == size(part.snr, 1) "Inconsistent dimension K in `snr` in `calibration`."
end
end
end

function check(part::MDFv2Reconstruction, variables::MDFv2Variables)
# Pick variables first
if isnothing(variables.Q)
variables.Q = size(part.data, 1)
variables.Q = size(part.data, 3)
end
if isnothing(variables.P)
variables.P = size(part.data, 2)
Expand All @@ -924,8 +924,8 @@ function check(part::MDFv2Reconstruction, variables::MDFv2Variables)
end

if !isnothing(part.positions)
@assert variables.P == size(part.positions, 1) "Inconsistent dimension P in `positions` in `reconstruction`."
@assert size(part.positions, 2) == 3 "Inconsistent second dimension in `positions` in `reconstruction`."
@assert variables.P == size(part.positions, 2) "Inconsistent dimension P in `positions` in `reconstruction`."
@assert size(part.positions, 1) == 3 "Inconsistent first dimension in `positions` in `reconstruction`."
end

if !isnothing(part.size)
Expand Down Expand Up @@ -1382,7 +1382,7 @@ function inMemoryMDFFromMDFFileV2(mdfFile::MDFFileV2)::MDFv2InMemory
try
result = f(mdfFile)
catch e
@warn "Exception while reading symbol $(functionSymbol). Please check closely."
@warn "Exception while reading symbol $(functionSymbol). Please check closely. Exception was `$e`."
end

if !(isnothing(result) || ismissing(result))
Expand Down
4 changes: 2 additions & 2 deletions src/MPIFiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export tracerName, tracerBatch, tracerVolume, tracerConcentration,
tracerSolute, tracerInjectionTime, tracerVendor

# scanner parameters
export scannerFacility, scannerOperator, scannerManufacturer, scannerName,
scannerTopology
export scannerBoreSize, scannerFacility, scannerOperator, scannerManufacturer,
scannerName, scannerTopology

# acquisition parameters
export acqStartTime, acqNumFrames, acqNumAverages,
Expand Down
12 changes: 3 additions & 9 deletions src/Measurements.jl
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ Supported keyword arguments:
"""
function getMeasurementsFD(f::MPIFile, args...;
loadasreal=false, transposed=false, frequencies=nothing,
tfCorrection=rxHasTransferFunction(f), kargs...)
tfCorrection=rxHasTransferFunction(f), kargs...)

data = getMeasurements(f, args..., tfCorrection=false; kargs...)

Expand Down Expand Up @@ -354,13 +354,13 @@ function getMeasurementsFD(f::MPIFile, args...;
end
end

if frequencies != nothing
if !isnothing(frequencies)
# here we merge frequencies and channels
data = data[frequencies, :, :]
end

if transposed
if frequencies != nothing
if !isnothing(frequencies)
data = permutedims(data, [3,1,2])
else
data = permutedims(data, [4,1,2,3])
Expand All @@ -374,12 +374,6 @@ function getMeasurementsFD(f::MPIFile, args...;
return data
end







function spectralLeakageCorrectedData(dataIn)
@debug "Apply Spectral Cleaning"

Expand Down
Loading

0 comments on commit 2ad927f

Please sign in to comment.