-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Note this is not a proper test - this file probably belongs elsewhere - maybe can become the basis for a tutorial on motion correction.
- Loading branch information
1 parent
e8a27ed
commit dbfd7bd
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import os | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import mdreg | ||
|
||
from ukat.mapping.t1 import T1 | ||
|
||
|
||
def t1_maps(): | ||
|
||
# fetch data | ||
data = mdreg.fetch('MOLLI') | ||
array = data['array'][:,:,0,:] | ||
TI = np.array(data['TI']) | ||
|
||
# Calculate corrected uncorrected T1-map | ||
map = T1(array, TI, np.eye(4)) | ||
np.save(os.path.join(os.getcwd(), 't1_uncorr'), map.t1_map) | ||
|
||
# Calculate corrected corrected T1-map | ||
map = T1(array, TI, np.eye(4), mdr=True) | ||
np.save(os.path.join(os.getcwd(), 't1_corr'), map.t1_map) | ||
|
||
|
||
def plot_t1_maps(): | ||
|
||
# Plot corrected and uncorrected side by side | ||
t1_uncorr = np.load(os.path.join(os.getcwd(), 't1_uncorr.npy')) | ||
t1_corr = np.load(os.path.join(os.getcwd(), 't1_corr.npy')) | ||
fig, ax = plt.subplots(figsize=(10, 6), ncols=2, nrows=1) | ||
for i in range(2): | ||
ax[i].set_yticklabels([]) | ||
ax[i].set_xticklabels([]) | ||
ax[0].set_title('T1-map without MDR') | ||
ax[1].set_title('T1-map with MDR') | ||
im = ax[0].imshow(t1_uncorr.T, cmap='gray', vmin=0, vmax=2000) | ||
im = ax[1].imshow(t1_corr.T, cmap='gray', vmin=0, vmax=2000) | ||
fig.colorbar(im, ax=ax.ravel().tolist()) | ||
plt.savefig(os.path.join(os.getcwd(), 't1_mdr')) | ||
plt.show() | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
# t1_maps() | ||
plot_t1_maps() | ||
|
||
|
||
|
||
|