diff --git a/src/NavData.jl b/src/NavData.jl index d554487..2b54603 100644 --- a/src/NavData.jl +++ b/src/NavData.jl @@ -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 \ No newline at end of file diff --git a/src/Navigator.jl b/src/Navigator.jl index df7718f..8d58ec5 100644 --- a/src/Navigator.jl +++ b/src/Navigator.jl @@ -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 @@ -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 @@ -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 """ @@ -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) diff --git a/src/Unwrap.jl b/src/Unwrap.jl index ee5627e..21cef74 100644 --- a/src/Unwrap.jl +++ b/src/Unwrap.jl @@ -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 @@ -87,7 +87,8 @@ 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 @@ -95,17 +96,17 @@ function find_wrapped(nav::Array{Float64, 4}, nav_time::Array{Float64, 2}, trace 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