MagneticParticleImaging / MPIFiles.jl

Julia Package for reading and writing MPI Files
MIT License
1 stars 2 forks source link

Bug in the `appendBGDataset` function #115

Open atsanda opened 5 days ago

atsanda commented 5 days ago

I encountered with an error while attempting to save a Brucker measurement together with a background measurement as one MDF. I used the saveasMDF with a keyword for the background file. It failed here https://github.com/MagneticParticleImaging/MPIFiles.jl/blob/a6601c352b8e15fbfef999e7e2ae27e0183aa272/src/Conversion.jl#L163

paramsBG[:measIsBGFrame][:] is an array and cannot be assigned with a constant true without .=. Moreover, down the code here is cat(4, params[:measData], paramsBG[:measData]) which also should produce an error.

I ended up implementing that by myself. Here is my implementation in case it is useful for a fix.

MPIFile(raw_measurement_path) do raw_measurement_file; MPIFile(bg_measurement_path) do background_file
    params = loadDataset(raw_measurement_file)

    frames=1:acqNumFrames(background_file)
    params_background = loadDataset(background_file, frames=frames)
    params_background[:measIsBGFrame] .= true
    params[:measData] = cat(params[:measData], params_background[:measData], dims=4)
    params[:measIsBGFrame] = cat(params[:measIsBGFrame], params_background[:measIsBGFrame], dims=1)
    params[:acqNumFrames] += params_background[:acqNumFrames]

    h5open(measurement_path, "w") do file
        saveasMDF(file, params)
    end
end;end
jusack commented 1 day ago

Hi, I encountered the same error some time ago, it should be fixed in #71