Skip to content

Commit

Permalink
Merge pull request #43 from NordicMRspine/smallfixes
Browse files Browse the repository at this point in the history
Smallfixes
  • Loading branch information
Laura2305 authored Jan 11, 2024
2 parents f7f1954 + ccc9dbc commit 3b72bf2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
5 changes: 5 additions & 0 deletions src/NavData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,13 @@ end
mutable struct navOutput

navigator::Array{Float64, 4}
nav_time::Union{Array{Float64, 2}, Nothing}
trace_aligned::Union{Array{Float64, 1}, Nothing}
trace_time::Union{Array{Float64, 1}, Nothing}
trace_interpolated::Union{Array{Float64, 2}, Nothing}
centerline::Union{Array{Float64, 1}, Nothing}
correlation::Union{Array{Float64, 1}, Matrix{Float64}, Nothing}
wrapped_points::Union{Array{Int8, 2}, Nothing}


end
26 changes: 14 additions & 12 deletions src/Navigator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ function NavCorr!(nav::Array{Complex{T}, 4}, acqData::AcquisitionData, params::D
corr_type = split(params[:corr_type], "_")
if size(corr_type, 1) == 2
if corr_type[2] == "unwrap"
(wrapped_points, correlation) = find_wrapped(nav, addData.nav_time, addData.trace, addData.numslices)
(wrapped_points, correlation, trace_data, trace_time, trace_data_int) =
find_wrapped(nav, addData.nav_time, addData.trace, addData.numslices)
nav = wrap_corr!(nav, wrapped_points, correlation, addData.numslices)
end
end
Expand All @@ -77,7 +78,7 @@ function NavCorr!(nav::Array{Complex{T}, 4}, acqData::AcquisitionData, params::D
# Apply the correction to the data
apply_corr!(nav, acqData, addData.numechoes,addData.numlines, addData.numsamples, addData.numslices)

return navOutput(nav_return, centerline, correlation, wrapped_points)
return navOutput(nav_return, addData.nav_time, trace_data, trace_time, trace_data_int, centerline, correlation, wrapped_points)

end

Expand All @@ -97,20 +98,21 @@ function comp_weights(navabs::Array{T, 4}, noisestd::Matrix{T}, lines::Int64, sl

# weights[points, coils, lines, slices]
coils = size(navabs, 2)
weights = zeros(size(navabs))
for ii=1:coils
weights[:,ii,:,:] = navabs[:,ii,:,:] ./ noisestd[1,ii]
end
weights = ones(size(navabs))
if !any(noisestd .== 0)
for ii=1:coils
weights[:,ii,:,:] = navabs[:,ii,:,:] ./ noisestd[1,ii]
end

weightsnorm = sum(weights, dims=(1,2))
weightsnorm = sum(weights, dims=(1,2))

for ii=1:lines
for ll=1:slices
weights[:,:,ii,ll] = weights[:,:,ii,ll] ./ weightsnorm[1,1,ii,ll]
for ii=1:lines
for ll=1:slices
weights[:,:,ii,ll] = weights[:,:,ii,ll] ./ weightsnorm[1,1,ii,ll]
end
end
end
return weights

end

"""
Expand All @@ -126,7 +128,7 @@ function comp_centerline_pos(addData::additionalNavInput)
# Compute resolution and disc
freq_enc_ref_res = addData.freq_enc_FoV[1] / addData.freq_enc_samples[1]
freq_enc_img_res = addData.freq_enc_FoV[2] / addData.freq_enc_samples[2]
freq_enc_FoV_disc = Int64((addData.freq_enc_FoV[1] - addData.freq_enc_FoV[2]) / freq_enc_ref_res / 2)
freq_enc_FoV_disc = round(Int64,(addData.freq_enc_FoV[1] - addData.freq_enc_FoV[2]) / freq_enc_ref_res / 2)

start_voxel = div(addData.freq_enc_samples[1] - addData.phase_enc_samples[1], 2)

Expand Down
11 changes: 6 additions & 5 deletions src/Unwrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export find_wrapped
find_wrapped(nav::Array{Float64, 4}, nav_time::Array{Float64, 2}, trace::Array{Float64, 2}, slices::Int64)
Identify the position of the wrapped points in the navigator phase estimates. The respiratory belt recording is necessary.
Return the position of the wrapped points and the correlation between each navigator slice and the trace data.
Return the position of the wrapped points, the correlation between each navigator slice and the trace data, the aligned and interpolated trace data.
# Arguments
* `nav::Array{Float64, 4}` - navigator phase estimates
Expand Down Expand Up @@ -87,25 +87,26 @@ function find_wrapped(nav::Array{Float64, 4}, nav_time::Array{Float64, 2}, trace

nowrap_slices = findall(possible_wrap_slices .== false)
nav_norm[:, nowrap_slices] .= 1
trace_data_int[:, nowrap_slices] .= 1
trace_data_int_lim = deepcopy(trace_data_int)
trace_data_int_lim[:, nowrap_slices] .= 1

# renormalize nav data
for ii = 1:slices
nav_norm[:,ii] = nav_norm[:,ii] ./ findmax(nav_norm[:,ii], dims =1)[1]
end

# compute navigator baseline
nav_baseline = find_baseline(nav_norm, trace_data_int, slices)
nav_baseline = find_baseline(nav_norm, trace_data_int_lim, slices)

# reposition data to align the baseline
for ii = 1:slices
nav_norm[:,ii] = nav_norm[:,ii] .- nav_baseline[ii]
end

wrapped_points = find_wrapped_points(nav_norm, trace_data_int, slices)
wrapped_points = find_wrapped_points(nav_norm, trace_data_int_lim, slices)

# return position wrapped points and field shift direction
return wrapped_points, correlation
return wrapped_points, correlation, trace_data, trace_time, trace_data_int

end

Expand Down

0 comments on commit 3b72bf2

Please sign in to comment.