Skip to content

Commit

Permalink
example
Browse files Browse the repository at this point in the history
  • Loading branch information
fzimmermann89 committed Jan 8, 2025
1 parent 3420fc6 commit e395218
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
9 changes: 7 additions & 2 deletions docs/source/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ html {
max-width: 75% !important;
}


/* new line after each property */
dl.py.property {
/* new line after each property */
display: block !important;
}

/* example notebooks outputs */
.output>.highlight {
background: inherit !important;
color: inherit !important;
}
2 changes: 2 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@
'github_user': 'PTB-MR',
'github_repo': 'mrpro',
'github_version': 'main',
'github_url' : 'https://github.com/PTB-MR/mrpro/main'

}
linkcode_blob = html_context['github_version']

Expand Down
25 changes: 12 additions & 13 deletions examples/cartesian_reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# %% [markdown]
# ## Import MRpro and download data

# %%
# %% tags=["hide-cell"]
# Get the raw data from zenodo
import tempfile
from pathlib import Path
Expand All @@ -25,8 +25,7 @@
dataset = '14173489'
zenodo_get.zenodo_get([dataset, '-r', 5, '-o', data_folder]) # r: retries

# %%
# List the downloaded files
print('Downloaded files:')
for f in data_folder.iterdir():
print(f.name)

Expand Down Expand Up @@ -59,14 +58,17 @@

# %% [markdown]
# Now we can explore this data object.
# Simply calling ``print(kdata)``` gives us a basic overview of the KData object.

# %%
# Start with simply calling print(kdata), whichs gives us a nice overview of the KData object.
print(kdata)

# %%

# %% [markdown]
# We can also have a look at more specific header information like the 1H Lamor frequency
print(kdata.header.lamor_frequency_proton)

# %%
print('Lamor Frequency:', kdata.header.lamor_frequency_proton)

# %% [markdown]
# ## Reconstruction of fully sampled acquisition
Expand All @@ -88,7 +90,7 @@
# Let's have a look at the shape of the obtained tensor.

# %%
print(img.shape)
print('Shape:', img.shape)

# %% [markdown]
# We can see that the second dimension, which is the coil dimension, is 16. This means we still have a coil resolved
Expand All @@ -107,7 +109,7 @@
)

(img,) = fft_op.adjoint(kdata.data)
print(img.shape)
print('Shape:', img.shape)

# %% [markdown]
# Now, we have an image which is 256 x 256 voxel as we would expect. Let's combine the data from the different receiver
Expand All @@ -119,18 +121,17 @@
import torch

# Combine data from different coils
img_fully_sampled = torch.sqrt(torch.sum(img**2, dim=-4)).abs().squeeze()
img_fully_sampled = img.abs().square().sum(dim=-4).sqrt().squeeze()

# plot the image
plt.imshow(img_fully_sampled)

# %% [markdown]
# Great! That was very easy! Let's try to reconstruct the next dataset.

# %% [markdown]
# ## Reconstruction of acquisition with partial echo and partial Fourier

# %%
# %% inputHidden=true outputHidden=true tags=["remove-output"]
# Read in the data
kdata_pe_pf = KData.from_file(data_folder / 'cart_t1_partial_echo_partial_fourier.mrd', KTrajectoryCartesian())

Expand All @@ -151,8 +152,6 @@
fig, ax = plt.subplots(1, 2, squeeze=False)
ax[0, 0].imshow(img_fully_sampled)
ax[0, 1].imshow(img_pe_pf)


# %% [markdown]
# Well, we got an image, but when we compare it to the previous result, it seems like the head has shrunk.
# Since that's extremely unlikely, there's probably a mistake in our reconstruction.
Expand Down

0 comments on commit e395218

Please sign in to comment.