@@ -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