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

Smallfixes #43

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/NavData.jl
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea to have timing information in the navigator output

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know for sure an explicit value of 0 is always given? I.e it couldn't be 1e-31 or something by accident?

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
Loading