diff --git a/_images/index_51_0.png b/_images/index_51_0.png deleted file mode 100644 index 3d46be8..0000000 Binary files a/_images/index_51_0.png and /dev/null differ diff --git a/index.html b/index.html index ce524ef..30a9db4 100644 --- a/index.html +++ b/index.html @@ -494,13 +494,11 @@

5     |     Process anat/T2starw (GRE)
%matplotlib inline
 
-# Make figure of CSF/SC signal ratio from T2starw scan
-
 # Go back to root data folder
 os.chdir(path_data)
 
@@ -529,15 +527,6 @@ 

5     |     Process anat/T2starw (GRE)# Number of subjects determines the number of rows in the subplot n_rows = len(subjects) -# Create a figure with multiple subplots -fig, axes = plt.subplots(n_rows, 1, figsize=(10, 6 * n_rows)) -font_size = 18 -line_width = 3 - -# Check if axes is an array or a single object -if n_rows == 1: - axes = [axes] - # Data storage for statistics data_stats = [] @@ -579,11 +568,6 @@

5     |     Process anat/T2starw (GRE)# If there's data for this shim method, plot it and compute stats if method_data: t2_data_plotly[subject][shim_mode]=method_data - - # Plotting each file's data separately - for resampled_data in method_data: - ax.plot(x_grid, resampled_data, label=f"{shim_mode}", linewidth=line_width) - # Compute stats on the non-resampled data (to avoid interpolation errors) mean_data = np.mean(data_sc_csf_ratio) @@ -591,33 +575,6 @@

5     |     Process anat/T2starw (GRE)data_stats.append([subject, shim_mode, mean_data, sd_data]) else: t2_data_plotly[subject][shim_mode]=None - - # Set x-ticks and labels for the bottom subplot - if i == n_rows - 1: # Check if it's the last subplot - # Create a secondary axis for vertebral level labels - secax = ax.secondary_xaxis('bottom') - secax.set_xticks(label_positions) - secax.set_xticklabels(vertebral_levels, fontsize=font_size-4) - secax.tick_params(axis='x', which='major', length=0) # Hide tick marks - - ax.set_xticks(custom_xticks) - ax.set_xticklabels([''] * len(custom_xticks)) - ax.tick_params(axis='x', which='major', length=0) # Hide tick marks for the primary axis - - ax.set_title(f'{subject}', fontsize=font_size) - ax.set_ylabel('CSF/Cord T2starw signal ratio', fontsize=font_size) - ax.tick_params(axis='y', which='major', labelsize=font_size-4) - - # Add legend only to the first subplot - if i == 0: - ax.legend(fontsize=font_size) - - ax.grid(True) - -# Adjust the layout so labels and titles do not overlap -plt.tight_layout() -plt.savefig(os.path.join(path_results, 'fig_gre_csf-sc_ratio.png'), dpi=300, format='png') -plt.show()

@@ -689,40 +646,6 @@

5     |     Process anat/T2starw (GRE) -
                 Anova
-=======================================
-          F Value Num DF  Den DF Pr > F
----------------------------------------
-Shim_Mode  9.0936 6.0000 24.0000 0.0000
-=======================================
-
-Paired t-tests:
-                 Pair   P-Value  Adjusted P-Value
-0       (CP, patient)  0.005972          0.025083
-1        (CP, volume)  0.075373          0.131902
-2         (CP, phase)  0.011296          0.033889
-3           (CP, CoV)  0.000156          0.003279
-4        (CP, target)  0.030643          0.080437
-5        (CP, SAReff)  0.197466          0.276452
-6   (patient, volume)  0.205065          0.269148
-7    (patient, phase)  0.296440          0.366191
-8      (patient, CoV)  0.001437          0.010061
-9   (patient, target)  0.154750          0.232125
-10  (patient, SAReff)  0.031202          0.072804
-11    (volume, phase)  0.413730          0.457281
-12      (volume, CoV)  0.404085          0.471432
-13   (volume, target)  0.552388          0.552388
-14   (volume, SAReff)  0.075590          0.122108
-15       (phase, CoV)  0.009898          0.034641
-16    (phase, target)  0.496343          0.521160
-17    (phase, SAReff)  0.005612          0.029461
-18      (CoV, target)  0.043267          0.082600
-19      (CoV, SAReff)  0.001394          0.014638
-20   (target, SAReff)  0.036743          0.077159
-
-
-
-

Make figure of B1+ values along the spinal cord across shim methods

+

Prepare data for figure of B1+ values along the spinal cord across shim methods

# Go back to root data folder
@@ -839,15 +762,6 @@ 

6     |     Process fmap/TFL (flip angle maps)# Number of subjects determines the number of rows in the subplot n_rows = len(subjects) -# Create a figure with multiple subplots -fig, axes = plt.subplots(n_rows, 1, figsize=(10, 6 * n_rows)) -font_size = 18 -line_width = 3 - -# Check if axes is an array or a single object -if n_rows == 1: - axes = [axes] - # Data storage for statistics data_stats = [] @@ -887,7 +801,6 @@

6     |     Process fmap/TFL (flip angle maps)# Plotting each file's data separately for resampled_data in method_data: b1_data_plotly[subject][shim_mode]=resampled_data - ax.plot(x_grid, resampled_data, label=f"{shim_mode}", linewidth=line_width) # Compute stats on the non-resampled data (to avoid interpolation errors) mean_data = np.mean(wa_data) @@ -895,35 +808,6 @@

6     |     Process fmap/TFL (flip angle maps)data_stats.append([subject, shim_mode, mean_data, sd_data]) else: b1_data_plotly[subject][shim_mode]=None - - - # Set x-ticks and labels for the bottom subplot - if i == n_rows - 1: # Check if it's the last subplot - # Create a secondary axis for vertebral level labels - secax = ax.secondary_xaxis('bottom') - secax.set_xticks(label_positions) - secax.set_xticklabels(vertebral_levels, fontsize=font_size-4) - secax.tick_params(axis='x', which='major', length=0) # Hide tick marks - - ax.set_xticks(custom_xticks) - ax.set_xticklabels([''] * len(custom_xticks)) - ax.tick_params(axis='x', which='major', length=0) # Hide tick marks for the primary axis - - ax.set_title(f'{subject}', fontsize=font_size) - ax.set_ylabel('B1+ efficiency [nT/V]', fontsize=font_size) - ax.tick_params(axis='y', which='major', labelsize=font_size-4) - - # Add legend only to the first subplot - if i == 0: - ax.legend(fontsize=font_size) - - ax.grid(True) - -# Adjust the layout so labels and titles do not overlap -plt.tight_layout() -plt.savefig(os.path.join(path_results, 'fig_b1plus.png'), dpi=300, format='png') - -plt.show()

@@ -993,40 +877,6 @@

6     |     Process fmap/TFL (flip angle maps)

-
-
                 Anova
-=======================================
-          F Value Num DF  Den DF Pr > F
----------------------------------------
-Shim_Mode 14.0743 6.0000 24.0000 0.0000
-=======================================
-
-Paired t-tests:
-                 Pair   P-Value  Adjusted P-Value
-0       (CP, patient)  0.007728          0.040570
-1        (CP, volume)  0.009006          0.037825
-2         (CP, phase)  0.079896          0.104863
-3           (CP, CoV)  0.318010          0.371012
-4        (CP, target)  0.010284          0.030853
-5        (CP, SAReff)  0.563249          0.622539
-6   (patient, volume)  0.821572          0.862651
-7    (patient, phase)  0.005550          0.116560
-8      (patient, CoV)  0.036644          0.059195
-9   (patient, target)  0.006302          0.066176
-10  (patient, SAReff)  0.010083          0.035289
-11    (volume, phase)  0.006565          0.045958
-12      (volume, CoV)  0.032112          0.056197
-13   (volume, target)  0.027717          0.052915
-14   (volume, SAReff)  0.012891          0.030078
-15       (phase, CoV)  0.989088          0.989088
-16    (phase, target)  0.011515          0.030226
-17    (phase, SAReff)  0.070778          0.099089
-18      (CoV, target)  0.236842          0.292570
-19      (CoV, SAReff)  0.061149          0.091724
-20   (target, SAReff)  0.018986          0.039871
-
-
-
-
-_images/index_51_0.png -

Figure 2. B1+ efficiency for one participant (sub-05) across all seven RF shimming conditions. The top left panel shows the tfl_b1map magnitude image with an overlay of the mask that was used to perform RF shimming. Text inserts show the mean (in nT/V) and CoV (in %) of B1+ efficiency along the spinal cord between C3 and T2.

-
-
- - -
-
- -

Figure 3. B1+ efficiency (A) and CSF/Cord signal ratio from the GRE scan (B) across subjects and across different RF shimming conditions. Data were measured in the spinal cord from C3 to T2 vertebral levels. To match the x-ticks across subjects, the C2-C3 and the T2-T3 intervertebral discs of each subject were aligned with that of the PAM50 template [De Leener et al., 2018], and the curves were linearly scaled.

diff --git a/reports/index.log b/reports/index.log new file mode 100644 index 0000000..0559129 --- /dev/null +++ b/reports/index.log @@ -0,0 +1,116 @@ +Traceback (most recent call last): + File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution + executenb( + File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/nbclient/client.py", line 1204, in execute + return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute() + File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/nbclient/util.py", line 84, in wrapped + return just_run(coro(*args, **kwargs)) + File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/nbclient/util.py", line 62, in just_run + return loop.run_until_complete(coro) + File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete + return future.result() + File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/nbclient/client.py", line 663, in async_execute + await self.async_execute_cell( + File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/nbclient/client.py", line 965, in async_execute_cell + await self._check_raise_for_error(cell, cell_index, exec_reply) + File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/nbclient/client.py", line 862, in _check_raise_for_error + raise CellExecutionError.from_cell_and_msg(cell, exec_reply_content) +nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell: +------------------ +%matplotlib inline + +# Go back to root data folder +os.chdir(path_data) + +def smooth_data(data, window_size=50): + """ Apply a simple moving average to smooth the data. """ + return uniform_filter1d(data, size=window_size, mode='nearest') + +# Fixed grid for x-axis +x_grid = np.linspace(0, 1, 100) + +# z-slices corresponding to levels C3 to T2 on the PAM50 template. These will be used to scale the x-label of each subject. +original_vector = np.array([907, 870, 833, 800, 769, 735, 692, 646]) + +# Normalize the PAM50 z-slice numbers to the 1-0 range (to show inferior-superior instead of superior-inferior) +min_val = original_vector.min() +max_val = original_vector.max() +normalized_vector = 1 - ((original_vector - min_val) / (max_val - min_val)) + +# Use this normalized vector as x-ticks +custom_xticks = normalized_vector + +# Vertebral level labels +vertebral_levels = ["C3", "C4", "C5", "C6", "C7", "T1", "T2"] +label_positions = normalized_vector[:-1] + np.diff(normalized_vector) / 2 + +# Number of subjects determines the number of rows in the subplot +n_rows = len(subjects) + +# Data storage for statistics +data_stats = [] + +# Data storage for Plotly +t2_data_plotly = {} + +# Iterate over each subject and create a subplot +for i, subject in enumerate(subjects): + ax = axes[i] + t2_data_plotly[subject]={} + for shim_mode in shim_modes: + # Initialize list to collect data for this shim method + method_data = [] + + # Get signal in SC + file_csv = os.path.join(path_results, f"{subject}_acq-{shim_mode}_T2starw_label-SC.csv") + df = pd.read_csv(file_csv) + data_sc = df['WA()'] + data_sc_smoothed = smooth_data(data_sc) + + # Get signal in CSF + file_csv = os.path.join(path_results, f"{subject}_acq-{shim_mode}_T2starw_label-CSF.csv") + df = pd.read_csv(file_csv) + data_csf = df['WA()'] + data_csf_smoothed = smooth_data(data_csf) + + # Compute ratio + data_sc_csf_ratio = data_csf_smoothed / data_sc_smoothed + + # Normalize the x-axis to a 1-0 scale for each subject (to go from superior-inferior direction) + x_subject = np.linspace(1, 0, len(data_sc_csf_ratio)) + + # Interpolate to the fixed grid + interp_func = interp1d(x_subject, data_sc_csf_ratio, kind='linear', bounds_error=False, fill_value='extrapolate') + resampled_data = interp_func(x_grid) + + method_data.append(resampled_data) + + # If there's data for this shim method, plot it and compute stats + if method_data: + t2_data_plotly[subject][shim_mode]=method_data + + # Compute stats on the non-resampled data (to avoid interpolation errors) + mean_data = np.mean(data_sc_csf_ratio) + sd_data = np.std(data_sc_csf_ratio) + data_stats.append([subject, shim_mode, mean_data, sd_data]) + else: + t2_data_plotly[subject][shim_mode]=None + + + + +------------------ + +--------------------------------------------------------------------------- +NameError Traceback (most recent call last) +Cell In[13], line 39 + 37 # Iterate over each subject and create a subplot + 38 for i, subject in enumerate(subjects): +---> 39 ax = axes[i] + 40 t2_data_plotly[subject]={} + 41 for shim_mode in shim_modes: + 42 # Initialize list to collect data for this shim method + +NameError: name 'axes' is not defined +NameError: name 'axes' is not defined +