Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirroring for MPS protocol #65

Open
jonschumacher opened this issue Jun 7, 2023 · 5 comments
Open

Mirroring for MPS protocol #65

jonschumacher opened this issue Jun 7, 2023 · 5 comments

Comments

@jonschumacher
Copy link
Member

Some MPS systems can only produce positive offsets. We should add an option to mirror the data.

@jonschumacher
Copy link
Member Author

@MandyA

@jonschumacher
Copy link
Member Author

The mirroring should be possible with the following script

using MPIFiles
using FFTW
using PyPlot

path = raw"K:\mpidata\Chimps\measurements\20230530_124924_SM_Perimag_100µT_res\6.mdf"

smResolution = 0.1e-3 # T
offsetIndex = 3

file = MPIFile(path)
mdf = MDFv2InMemory(file)
data = measDataRaw(mdf)
dataFD = rfft(data, 1)

numOffsets = size(dataFD, 3)*2-1
offsets = range(start=-size(dataFD, 3)+1, stop=size(dataFD, 3)-1, length=numOffsets) .* smResolution

SMChimpsFD = zeros(eltype(dataFD), size(dataFD, 1), size(dataFD, 2), numOffsets, size(dataFD, 4))
SMChimpsFD[:, :, 1:size(dataFD, 3)-1, :] .= dataFD[:, :, end:-1:2, :]
SMChimpsFD[:, 1, 1:size(dataFD, 3)-1, :] .= SMChimpsFD[:, 1, 1:size(dataFD, 3)-1, :] .* repeat((-1).^(1:size(dataFD, 1)), inner=(1, size(dataFD, 3)-1, 2))
SMChimpsFD[:, :, size(dataFD, 3):end, :] .= dataFD[:, :, 1:end, :]

SMChimps = irfft(SMChimpsFD, size(data, 1), 1)

calibOffsetFields_ = zeros(3, numOffsets)
calibOffsetFields_[offsetIndex, :] = collect(offsets)

MPIFiles.calibOffsetFields(mdf, calibOffsetFields_)
acqNumPeriodsPerFrame(mdf, numOffsets)
measDataRaw(mdf, SMChimps)

saveasMDF("baseSMPerimag100µTres.mdf", mdf)

The code is based on a publication by Alexander Weber from 2015 (https://ieeexplore.ieee.org/document/7067539), formula 5.

@tknopp
Copy link
Member

tknopp commented Sep 14, 2023

This is kind of a processing of mdf files and potentially it could be triggered by the protocol itself. Within the Robot-based SM calibration protocol we currently don't do this (but once did) because there are several kind of processings possible and therefore it is more flexible to do the processing within the SM dataset browser. There we also have infrastructure to group "raw" and "processed" pdfs together (using a tree widget in MPIUI).

How MPS /pMPS data fits into this setting? I actually don't know. When sweeping just offsets it would be natural to consider these datasets as SM calibration files. But what if also DF amplitude/frequency sweeps are planed? Then it get more tricky...

@jonschumacher
Copy link
Member Author

Hm, good point. So you mean that we should potentially have this as a loading option in MPIFiles instead of hardwiring it into the MPS protocol? Actually, sweeps are something that we definitely need to consider in the future due to the availability of various pMPSs. How do you think about adding a post-processing layer to getMeasurements? Ping @jusack @nHackel

@tknopp
Copy link
Member

tknopp commented Sep 14, 2023

Kind of. Right now everything you can do as a "processing" is accessible through getMeasurements. We have the ability to store the processed data in order to cache it. This caching is essential since some processings are very time intensive.

One other important step that needs to be taken into account is that pMPS systems will do dynamic sweeps where not all data is actually useful. The transition frames thus need to be dropped at some stage. Currently we store them in the raw MDF and thus they need to be dropped within the postprocessing. Also a clockwise averaging will be applied in that stage.

The protocol itself might want to have an option to not store the raw MDF since it can be huge compared to the posprocessed one. At the Bruker scanner, we have a field based sweeping method as well (see https://github.com/MagneticParticleImaging/MPIFiles.jl/blob/master/src/Conversion.jl#L425) and the raw files can be several hundreds of GB large, in which case we really delete them directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants