Skip to content

Commit 1099bf9

Browse files
authored
Merge pull request #70 from BrainLesion/68-update-brats-tutorial
Update example to latest brats version
2 parents df5455b + f3a4464 commit 1099bf9

File tree

2 files changed

+812
-170
lines changed

2 files changed

+812
-170
lines changed

BraTS/tutorial.ipynb

Lines changed: 782 additions & 170 deletions
Large diffs are not rendered by default.

BraTS/utils.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,33 @@ def visualize_inpainting(t1n_voided: str, prediction: str):
8888
for ax in ax:
8989
ax.axis("off")
9090
plt.tight_layout()
91+
92+
93+
def visualize_missing_mri_t2w(
94+
synthesized_t2w: str,
95+
data_folder: str = DATA_FOLDER,
96+
subject_id: str = "BraTS-GLI-00001-000",
97+
slice_index: int = 75,
98+
):
99+
"""Visualize the MRI modalities for a given slice index
100+
101+
Args:
102+
data_folder (str, optional): Path to the folder containing the t1, t1c, t2 & flair file. Defaults to DATA_FOLDER.
103+
slice_index (int, optional): Slice to be visualized (first index in data of shape (155, 240, 240)). Defaults to 75.
104+
"""
105+
_, axes = plt.subplots(1, 5, figsize=(12, 10))
106+
107+
subject_path = Path(data_folder) / subject_id
108+
modalities = ["t1n", "t1c", "t2f", "t2w"]
109+
for i, mod in enumerate(modalities):
110+
modality_file = subject_path / f"{subject_id}-{mod}.nii.gz"
111+
modality_np = nib.load(modality_file).get_fdata().transpose(2, 1, 0)
112+
axes[i].set_title(mod)
113+
axes[i].imshow(modality_np[slice_index, :, :], cmap="gray")
114+
axes[i].axis("off")
115+
116+
# show synthetic T2w
117+
synthetic_t2w_np = nib.load(synthesized_t2w).get_fdata().transpose(2, 1, 0)
118+
axes[4].set_title("Synthesized t2w")
119+
axes[4].imshow(synthetic_t2w_np[slice_index, :, :], cmap="gray")
120+
axes[4].axis("off")

0 commit comments

Comments
 (0)