From 7ddd828084a0adb7a9619f0edfccbc6c6ff7380a Mon Sep 17 00:00:00 2001 From: chaithyagr Date: Wed, 12 Feb 2025 08:58:31 +0100 Subject: [PATCH] [docs] final updates and fixes and also try to fix #235 --- .github/workflows/test-ci.yml | 13 +++++++ examples/GPU/example_3d_trajectory_display.py | 39 +++++++++++++------ src/mrinufft/trajectories/display3D.py | 3 +- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-ci.yml b/.github/workflows/test-ci.yml index 4720af6ae..3bee7c07c 100644 --- a/.github/workflows/test-ci.yml +++ b/.github/workflows/test-ci.yml @@ -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 @@ -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 diff --git a/examples/GPU/example_3d_trajectory_display.py b/examples/GPU/example_3d_trajectory_display.py index eb185a7e3..4f59bda59 100644 --- a/examples/GPU/example_3d_trajectory_display.py +++ b/examples/GPU/example_3d_trajectory_display.py @@ -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. @@ -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): @@ -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, @@ -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), @@ -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() diff --git a/src/mrinufft/trajectories/display3D.py b/src/mrinufft/trajectories/display3D.py index 15b28ccda..dc0e7d51e 100644 --- a/src/mrinufft/trajectories/display3D.py +++ b/src/mrinufft/trajectories/display3D.py @@ -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