-
If I wan to use espirit for 3D acquisition I guess I can first extract the k-space with Should I wrote a function for that ? |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 29 replies
-
Ok, I have something working kspace = extract3DKSpace(acq)
calibSize = parse.(Int,b["CenterMaskSize"]);
calibData = crop(kspace[:,:,:,2,:],(calibSize,calibSize,calibSize));
"""
Documentation extractKSpace
"""
function extract3DKSpace(acqData::AcquisitionData)
if !MRIReco.isCartesian(trajectory(acqData, 1))
@error "espirit does not yet support non-cartesian sampling"
end
nx, ny, nz = acqData.encodingSize[1:3]
numChan, numSl = MRIReco.numChannels(acqData), MRIReco.numSlices(acqData)
numEcho = length(acqData.traj)
kdata = zeros(ComplexF64, nx * ny * nz, numEcho,numChan)
for echo = 1:numEcho
for coil = 1:numChan
kdata[acqData.subsampleIndices[numEcho], numEcho,coil] .= kData(acqData, echo, coil, 1)
end
end
return reshape(kdata, nx, ny, nz, numEcho, numChan)
end
"""
Documentation : Crop the central area
"""
function crop(A::Array{T,4}, s::NTuple{3,Int64}) where {T}
nx, ny, nz = size(A)
idx_x = div(nx, 2)-div(s[1], 2)+1:div(nx, 2)-div(s[1], 2)+s[1]
idx_y = div(ny, 2)-div(s[2], 2)+1:div(ny, 2)-div(s[2], 2)+s[2]
idx_z = div(nz, 2)-div(s[3], 2)+1:div(nz, 2)-div(s[3], 2)+s[3]
return A[idx_x, idx_y, idx_z,:]
end
For now the espirit is taking too long to compute... I had to kill the process. I don't know why |
Beta Was this translation helpful? Give feedback.
-
Hi,
|
Beta Was this translation helpful? Give feedback.
-
@JakobAsslaender If you mention me, you are already talking to me. We only use power iteration for the second step and not the first. But we use single precision as this is generally sufficient for MRI. This alone would make a huge difference. And there are some other steps one can do to make it faster which may not be implemented in the Matlab code. I also had discussions with @spinicist when he implemented it in C++, maybe he remembers exactly what those steps were. |
Beta Was this translation helpful? Give feedback.
-
We use an eigen decomposition in the first step which reduces problem size a lot, but then there are also some other tricks... One thing none needs to watch out for with single precision is that one does not exceed the range due bad scaling of the data. |
Beta Was this translation helpful? Give feedback.
-
The threshold acts on the eigenvalues (relative to the largest), i.e. on the square of the singular value of the original matrix. I think the debug output is the singular values. I just remembered the other thing we do which has a much bigger impact: We do not zeropad the kernels to full size before transforming them to the image domain. Instead we zeropad to only the double size, then FFT and multiply with the conjugate and only then only transform this much smaller matrix to full size using FFTs and zero padding. Left as an exercise to the reader why it works ;-) |
Beta Was this translation helpful? Give feedback.
-
Mathematics == Magics Yes, the final eigendecomposition is done on the full size (but if you are really limited in memory, there is another trick you can do...) |
Beta Was this translation helpful? Give feedback.
-
Hello, Thanks @uecker for the introduction - @JakobAsslaender we haven't met, but literally today I was planning to e-mail you about how to get Proton Density estimates from finger-printing type reconstructions. But this isn't that place for that conversation. As Martin mentioned, I have a C++ implementation of ESPIRiT here https://github.com/spinicist/riesling/blob/main/src/espirit.cpp. I think Martin has answered most of your questions already, and frankly it sounds like my implementation needs a good deal of work. The one thing that I think hasn't been discussed here explicitly is that, at Martin's suggestion, I do the upsampling and image-space PCA/eigendecomposition step slice-by-slice. I'm dealing with oversampled 3D acquisitions and doing the image-space analysis on fully upsampled images was very impractical. Slice-by-slice made it feasible, but my implementation is still slow. |
Beta Was this translation helpful? Give feedback.
-
Hi @JakobAsslaender, I had a look at optimizations of espirit and tested some things where it would be good if we could move this forward together. My work can be found here: https://github.com/MagneticResonanceImaging/MRIReco.jl/blob/tk/espiritSpeedup/src/Tools/CoilSensitivity.jl Remarks / questions:
This is just some initial brain dump. I have to say that I am not deeply in that paper and basically was just looking at the code. |
Beta Was this translation helpful? Give feedback.
-
Crossref MagneticResonanceImaging/MRIRecoBenchmarks#6 for the related benchmark. |
Beta Was this translation helpful? Give feedback.
Crossref MagneticResonanceImaging/MRIRecoBenchmarks#6 for the related benchmark.