|
14 | 14 | import matplotlib.pyplot as plt
|
15 | 15 | import pathlib
|
16 | 16 |
|
17 |
| -#Load some DWI data |
18 |
| -file=pathlib.Path(__file__) |
19 |
| -file_path = file.with_name('IVIM_b0_15_150_500.npy').as_posix() |
20 |
| -DWI_data = np.load(file_path) |
| 17 | +def example(): |
| 18 | + #Load some DWI data |
| 19 | + file=pathlib.Path(__file__) |
| 20 | + file_path = file.with_name('IVIM_b0_15_150_500.npy').as_posix() |
| 21 | + DWI_data = np.load(file_path) |
21 | 22 |
|
22 |
| -# Specify b values that are in the data |
23 |
| -bvalues = [0, 15, 150, 500] |
| 23 | + # Specify b values that are in the data |
| 24 | + bvalues = [0, 15, 150, 500] |
24 | 25 |
|
25 |
| -# Specifiy if you want to plot the results |
26 |
| -plot_results = False |
| 26 | + # Specifiy if you want to plot the results |
| 27 | + plot_results = False |
27 | 28 |
|
28 |
| -# Generate ADC map and define the min and max b value that will be used for ADC fitting |
29 |
| -ADClog, b0_intercept, used_bvalues = generate_ADC_standalone(DWI_data,bvalues, bmin=150, bmax=500) |
| 29 | + # Generate ADC map and define the min and max b value that will be used for ADC fitting |
| 30 | + ADClog, b0_intercept, used_bvalues = generate_ADC_standalone(DWI_data,bvalues, bmin=150, bmax=500) |
30 | 31 |
|
31 |
| -# Generate ADC and define the min and max b value that will be used for ADC fitting as well as the max b value |
32 |
| -# that will be used for separate Dstar fitting |
33 |
| -ADClog, perfFrac, Dstar = generate_IVIMmaps_standalone(DWI_data, bvalues, bminADC=150, bmaxADC=500, bmaxDstar=150) |
34 |
| -Slice = 5 |
| 32 | + # Generate ADC and define the min and max b value that will be used for ADC fitting as well as the max b value |
| 33 | + # that will be used for separate Dstar fitting |
| 34 | + ADClog, perfFrac, Dstar = generate_IVIMmaps_standalone(DWI_data, bvalues, bminADC=150, bmaxADC=500, bmaxDstar=150) |
| 35 | + Slice = 5 |
35 | 36 |
|
36 |
| -if plot_results == True: |
37 |
| - # Plot the ADC, f and D* maps |
38 |
| - fig, axes = plt.subplots(1, 3, figsize=(10, 5)) |
| 37 | + if plot_results == True: |
| 38 | + # Plot the ADC, f and D* maps |
| 39 | + fig, axes = plt.subplots(1, 3, figsize=(10, 5)) |
39 | 40 |
|
40 |
| - axes[0].imshow(ADClog[:,Slice,:], cmap='viridis', vmin=0, vmax=5) |
41 |
| - axes[0].set_title("ADC") |
42 |
| - axes[0].axis('off') |
| 41 | + axes[0].imshow(ADClog[:,Slice,:], cmap='viridis', vmin=0, vmax=5) |
| 42 | + axes[0].set_title("ADC") |
| 43 | + axes[0].axis('off') |
43 | 44 |
|
44 |
| - axes[1].imshow(perfFrac[:,Slice,:], cmap='viridis', vmin=0, vmax=1) |
45 |
| - axes[1].set_title("f map") |
46 |
| - axes[1].axis('off') |
| 45 | + axes[1].imshow(perfFrac[:,Slice,:], cmap='viridis', vmin=0, vmax=1) |
| 46 | + axes[1].set_title("f map") |
| 47 | + axes[1].axis('off') |
47 | 48 |
|
48 |
| - axes[2].imshow(Dstar[:,Slice,:], cmap='viridis', vmin=0, vmax=200) |
49 |
| - axes[2].set_title("D*") |
50 |
| - axes[2].axis('off') |
| 49 | + axes[2].imshow(Dstar[:,Slice,:], cmap='viridis', vmin=0, vmax=200) |
| 50 | + axes[2].set_title("D*") |
| 51 | + axes[2].axis('off') |
51 | 52 |
|
52 |
| - plt.tight_layout() # Adjust spacing between subplots |
53 |
| - plt.show() |
| 53 | + plt.tight_layout() # Adjust spacing between subplots |
| 54 | + plt.show() |
54 | 55 |
|
55 |
| -print("finish") |
| 56 | + print("finish") |
56 | 57 |
|
57 | 58 |
|
| 59 | +if __name__ == '__main__': |
| 60 | + example() |
0 commit comments