Skip to content

Commit

Permalink
[docs] final updates and fixes and also try to fix #235
Browse files Browse the repository at this point in the history
  • Loading branch information
chaithyagr committed Feb 12, 2025
1 parent 12f120b commit 7ddd828
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/test-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ env:
BART_VERSION: "0.8.00"
ref_backend: "finufft"

permissions:
contents: write
pull-requests: write

jobs:
test-cpu:
runs-on: cpu
Expand Down Expand Up @@ -345,6 +349,15 @@ jobs:
path: 'docs_build'
retention-days: 5

- name: Comment the docs artifacts link
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ARTIFACT_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
COMMENT_BODY=":memo: API documentation has been built. You can download the artifacts [here](${ARTIFACT_URL})."
gh auth setup-git
gh pr comment ${{ github.event.pull_request.number }} --body "${COMMENT_BODY}"
CompileDocs:
name: Compile the coverage badge in docs
runs-on: ubuntu-latest
Expand Down
39 changes: 28 additions & 11 deletions examples/GPU/example_3d_trajectory_display.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
======================
3D Trajectory display
======================
=============================
3D Trajectory Gridded display
=============================
In this example, we show some tools available to display 3D trajectories.
It can be used to understand the k-space sampling patterns, visualize the trajectories, see the sampling times, gradient strengths, slew rates etc.
Expand All @@ -19,7 +19,8 @@


# %%

# Helper function to Displaying 3D Gridded Trajectories
# =====================================================
# Utility function to plot mid-plane slices for 3D volumes
def plot_slices(axs, volume, title=""):
def set_labels(ax, axis_num=None):
Expand All @@ -41,11 +42,14 @@ def set_labels(ax, axis_num=None):


# %%
# Helper function to Displaying 3D Trajectories
# =============================================
# Helper function to showcase the features of `get_gridded_trajectory` function
# This function will first grid the trajectory using the `get_gridded_trajectory`
# function and then plot the mid-plane slices of the gridded trajectory.
def create_grid(grid_type, trajectories, traj_params, **kwargs):
fig, axs = plt.subplots(3, 3, figsize=(10, 10))
plt.subplots_adjust(hspace=0.5)
for i, (name, traj) in enumerate(trajectories.items()):
grid = get_gridded_trajectory(
traj,
Expand All @@ -55,10 +59,11 @@ def create_grid(grid_type, trajectories, traj_params, **kwargs):
**kwargs,
)
plot_slices(axs[:, i], grid, title=name)
plt.tight_layout()


# %%
# Trajectories to display
# =======================
# Create a bunch of sampling trajectories
trajectories = {
"Radial": mtt.initialize_3D_phyllotaxis_radial(64 * 8, 64),
Expand All @@ -72,48 +77,60 @@ def create_grid(grid_type, trajectories, traj_params, **kwargs):
}

# %%
# Sampling density
# =================
# Display the density of the trajectories, along the 3 mid-planes. For this, make `grid_type="density"`.
create_grid("density", trajectories, traj_params)
plt.suptitle("Sampling Density")
plt.suptitle("Sampling Density", y=0.98, x=0.52, fontsize=20)
plt.show()


# %%
# Sampling time
# =============
# Display the sampling times over the trajectories. For this, make `grid_type="time"`.
# It helps to check the sampling times over the k-space trajectories, which can be responsible for excessive off-resonance artifacts.
# Note that this is just a relative visualization of sample times on a colour scale, and the actual sampling time.
create_grid("time", trajectories, traj_params)
plt.suptitle("Sampling Time")
plt.suptitle("Sampling Time", y=0.98, x=0.52, fontsize=20)
plt.show()

# %%
# Inversion time
# ==============
# Display the inversion time of the trajectories. For this, make `grid_type="inversion"`.
# This helps in obtaining the inversion time when particular region of k-space is sampled, assuming the trajectories are time ordered,
# and the argument `turbo_factor` is specified, which is the time between 2 inversion pulses.
create_grid("inversion", trajectories, traj_params, turbo_factor=64)
plt.suptitle("Inversion Time")
plt.suptitle("Inversion Time", y=0.98, x=0.52, fontsize=20)
plt.show()
# %%
# K-space holes
# =============
# Display the k-space holes in the trajectories. For this, make `grid_type="holes"`.
# K-space holes are areas with missing trajectory coverage, and can typically occur with learning-based trajectories when optimized using a specific loss.
# This feature can be used to identify the k-space holes, which could lead to Gibbs-like ringing artifacts in the images.
create_grid("holes", trajectories, traj_params, threshold=1e-2)
plt.suptitle("K-space Holes")
plt.suptitle("K-space Holes", y=0.98, x=0.52, fontsize=20)
plt.show()
# %%
# Gradient strength
# =================
# Display the gradient strength of the trajectories. For this, make `grid_type="gradients"`.
# This helps in displaying the gradient strength applied at specific k-space region,
# which can be used as a surrogate to k-space "velocity", i.e. how fast does trajectory pass through a given region in k-space.
# It could be useful while characterizing spatial SNR profile in k-space
create_grid("gradients", trajectories, traj_params)
plt.suptitle("Gradient Strength")
plt.suptitle("Gradient Strength", y=0.98, x=0.52, fontsize=20)
plt.show()

# %%
# Slew rates
# ===========
# Display the slew rates of the trajectories. For this, make `grid_type="slew"`.
# This helps in displaying the slew rates applied at specific k-space region,
# which can ne used as a surrogate to k-space "acceleration", i.e. how fast does trajectory change in a given region in k-space
# It could be useful to understand potential regions in k-space with eddy current artifacts and trajectories which could lead to peripheral nerve stimulations.
create_grid("slew", trajectories, traj_params)
plt.suptitle("Slew Rates")
plt.suptitle("Slew Rates", y=0.98, x=0.52, fontsize=20)
plt.show()
3 changes: 2 additions & 1 deletion src/mrinufft/trajectories/display3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def get_gridded_trajectory(
"inversion" : Relative inversion time at the sampling location. Needs
`turbo_factor` to be set. This is useful for analyzing the exact inversion
time when the k-space is acquired, for sequences like MP(2)RAGE.
"holes": Show the k-space missing coverage, or holes, within a ellipsoid of the k-space.
"holes": Show the k-space missing coverage, or holes, within a ellipsoid of the
k-space.
"gradients": Show the gradient strengths of the k-space trajectory.
"slew": Show the slew rate of the k-space trajectory.
osf : int, optional
Expand Down

0 comments on commit 7ddd828

Please sign in to comment.