|
5 | 5 | import argparse
|
6 | 6 | import os
|
7 | 7 | from utilities.data_simulation.Download_data import download_data
|
| 8 | +import pathlib |
8 | 9 |
|
9 | 10 | ##########
|
10 | 11 | # code written by Oliver J Gurney-Champion
|
11 | 12 | # code adapted from MAtlab code by Eric Schrauben: https://github.com/schrau24/XCAT-ERIC
|
12 | 13 | # This code generates a 4D IVIM phantom as nifti file
|
13 | 14 |
|
14 | 15 | def phantom(bvalue, noise, TR=3000, TE=40, motion=False, rician=False, interleaved=False,T1T2=True):
|
| 16 | + download_data() |
15 | 17 | np.random.seed(42)
|
16 | 18 | if motion:
|
17 | 19 | states = range(1,21)
|
18 | 20 | else:
|
19 | 21 | states = [1]
|
20 | 22 | for state in states:
|
21 | 23 | # Load the .mat file
|
22 |
| - mat_data = loadmat('../../download/Phantoms/XCAT_MAT_RESP/XCAT5D_RP_' + str(state) + '_CP_1.mat') |
| 24 | + project_root = pathlib.Path(__file__).resolve().parent.parent |
| 25 | + filename = f'XCAT5D_RP_{state}_CP_1.mat' |
| 26 | + mat_path = project_root / '..' /'download' / 'Phantoms' / 'XCAT_MAT_RESP' / filename |
| 27 | + mat_data = loadmat(mat_path) |
23 | 28 |
|
24 | 29 | # Access the variables in the loaded .mat file
|
25 | 30 | XCAT = mat_data['IMG']
|
26 | 31 | XCAT = XCAT[-1:0:-2,-1:0:-2,10:160:4]
|
27 | 32 |
|
28 | 33 | D, f, Ds = contrast_curve_calc()
|
29 |
| - S, Dim, fim, Dpim, legend = XCAT_to_MR_DCE(XCAT, TR, TE, bvalue, D, f, Ds,T1T2=T1T2) |
| 34 | + S, Dim, fim, Dpim, legend = XCAT_to_MR_IVIM(XCAT, TR, TE, bvalue, D, f, Ds,T1T2=T1T2) |
30 | 35 | if state == 1:
|
31 | 36 | Dim_out = Dim
|
32 | 37 | fim_out = fim
|
@@ -187,7 +192,7 @@ def contrast_curve_calc():
|
187 | 192 | return D, f, Ds
|
188 | 193 |
|
189 | 194 |
|
190 |
| -def XCAT_to_MR_DCE(XCAT, TR, TE, bvalue, D, f, Ds, b0=3, ivim_cont = True, T1T2=True): |
| 195 | +def XCAT_to_MR_IVIM(XCAT, TR, TE, bvalue, D, f, Ds, b0=3, ivim_cont = True, T1T2=True): |
191 | 196 | ###########################################################################################
|
192 | 197 | # This script converts XCAT tissue values to MR contrast based on the SSFP signal equation.
|
193 | 198 | # Christopher W. Roy 2018-12-04 # [email protected]
|
@@ -436,7 +441,6 @@ def parse_bvalues_file(file_path):
|
436 | 441 | motion = args.motion
|
437 | 442 | interleaved = args.interleaved
|
438 | 443 | T1T2 = args.T1T2
|
439 |
| - download_data() |
440 | 444 | for key, bvalue in bvalues.items():
|
441 | 445 | bvalue = np.array(bvalue)
|
442 | 446 | sig, XCAT, Dim, fim, Dpim, legend = phantom(bvalue, noise, motion=motion, interleaved=interleaved,T1T2=T1T2)
|
|
0 commit comments