Skip to content

Commit

Permalink
Fixing plot function argument mentioned in issue #25.
Browse files Browse the repository at this point in the history
  • Loading branch information
nbwuzhe committed Feb 19, 2024
1 parent d3d59f7 commit 09fe1dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 1 addition & 2 deletions docs/lit/examples/joss_demo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ sensitivity = mapslices(x -> imresize(x, params_spiral[:recon_size][1], params_s
# Optional: Plot the sensitivity maps of each coil on a given slice.
if params_general[:do_plot_recon]
plotlyjs()
plot_sense_maps(sensitivity,20)
plot_sense_maps(sensitivity, 20)
end

# Optional: Coil compression to further reduce the time of recon
Expand Down Expand Up @@ -344,7 +344,6 @@ if params_general[:do_plot_recon]
reco,
1:length(selected_slice),
resized_b0_maps,
fig_handles = ["Original Magnitude", "Original Phase", "B0"],
is_slice_interleaved = false,
rotation = 90,
)
Expand Down
13 changes: 9 additions & 4 deletions src/utils/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,27 @@ end

"""
plot_sense_maps(sensitivity, num_channels; slice_index = 1)
Plots coil sensitivity maps from the channels, for a total of num_channels plots
Plots coil sensitivity maps from the channels, for a given number of num_channels plots on a given slice index.
# Arguments
* `sensitivity` - sensitivity maps, a 4D array: [nX, nY, nZ, nCoil]
* `num_channels` - number of coils (usually the last dimension of sensitivity)
* `num_channels` - number of coils to be displayed.
* `slice_index` - The index of the slice to be displayed (if multislice)
"""
function plot_sense_maps(sensitivity; slice_index = 1)
function plot_sense_maps(sensitivity, num_channels; slice_index = 1)
if ndims(sensitivity) == 4
num_slices = size(sensitivity, 3)
num_channels = size(sensitivity, 4)
num_channels_total = size(sensitivity, 4)
else
err_msg = @sprintf("sensitivity must be a 4D array with a size of [nX, nY, nZ, nCoil]. Current input has %d dimensions.", ndims(sensitivity))
error(err_msg)
end

if num_channels > num_channels_total
err_msg = @sprintf("The number of coils to be displayed is %d, but total available coil number is %d.", num_channels, num_channels_total)
error(err_msg)
end

if slice_index > num_slices
err_msg = @sprintf("The index of slice to be displayed is %d, but total slice number is %d.", slice_index, num_slices)
error(err_msg)
Expand Down

0 comments on commit 09fe1dd

Please sign in to comment.