Skip to content

Commit a6cd114

Browse files
committed
Add ASLPrep figures.
1 parent 6a32d67 commit a6cd114

File tree

9 files changed

+151
-8
lines changed

9 files changed

+151
-8
lines changed

analysis/plot_aslprep_cbf.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""Plot scalar maps from QSIRecon."""
2+
3+
import os
4+
from glob import glob
5+
6+
import matplotlib.pyplot as plt
7+
from nilearn import image, plotting
8+
9+
10+
if __name__ == "__main__":
11+
in_dir = "/cbica/projects/pafin/derivatives/aslprep"
12+
out_dir = "../figures"
13+
14+
patterns = {
15+
"ASLPrep CBF": "sub-*/ses-1/perf/*_space-MNI152NLin6Asym_cbf.nii.gz",
16+
"BASIL ATT": "sub-*/ses-1/perf/*_space-MNI152NLin6Asym_desc-basil_att.nii.gz",
17+
"BASIL CBF": "sub-*/ses-1/perf/*_space-MNI152NLin6Asym_desc-basil_cbf.nii.gz",
18+
"BASIL GM CBF": "sub-*/ses-1/perf/*_space-MNI152NLin6Asym_desc-basilGM_cbf.nii.gz",
19+
"BASIL WM CBF": "sub-*/ses-1/perf/*_space-MNI152NLin6Asym_desc-basilWM_cbf.nii.gz",
20+
}
21+
for title, pattern in patterns.items():
22+
# Get all scalar maps
23+
scalar_maps = sorted(glob(os.path.join(in_dir, pattern)))
24+
scalar_maps = [f for f in scalar_maps if "PILOT" not in f]
25+
print(f"{title}: {len(scalar_maps)}")
26+
27+
mean_img = image.mean_img(scalar_maps, copy_header=True)
28+
sd_img = image.math_img("np.std(img, axis=3)", img=scalar_maps)
29+
30+
# Plot mean and SD
31+
fig, axs = plt.subplots(2, 1, figsize=(10, 5))
32+
plotting.plot_stat_map(
33+
mean_img,
34+
display_mode="z",
35+
cut_coords=[-30, -15, 0, 15, 30, 45, 60],
36+
title="Mean",
37+
axes=axs[0],
38+
figure=fig,
39+
)
40+
plotting.plot_stat_map(
41+
sd_img,
42+
display_mode="z",
43+
cut_coords=[-30, -15, 0, 15, 30, 45, 60],
44+
title="Standard Deviation",
45+
axes=axs[1],
46+
figure=fig,
47+
)
48+
fig.suptitle(title)
49+
plt.savefig(os.path.join(out_dir, f"{title.replace(' ', '_')}.png"))
50+
plt.close()
51+

figures/ASLPrep_CBF.png

145 KB
Loading

figures/BASIL_ATT.png

131 KB
Loading

figures/BASIL_CBF.png

151 KB
Loading

figures/BASIL_GM_CBF.png

133 KB
Loading

figures/BASIL_WM_CBF.png

132 KB
Loading

processing/run_tedana.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def run_tedana(raw_dir, fmriprep_dir, aroma_dir, temp_dir, tedana_out_dir):
153153
"func",
154154
f"{mask_base}_space-boldref_T2starmap.nii.gz",
155155
)
156-
assert os.path.isfile(t2star), t2star
156+
assert os.path.isfile(t2star), t2star
157157

158158
mixing = os.path.join(
159159
aroma_dir,

processing/slurm-6025805.out

Lines changed: 0 additions & 7 deletions
This file was deleted.

processing/slurm-6025857.out

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/var/spool/slurmd/job6025857/slurm_script: line 9: /cbica/projects/pafin/.bashrc: Permission denied
2+
Run 'mamba init' to be able to run mamba activate/deactivate
3+
and start a new shell session. Or use conda to activate/deactivate.
4+
5+
INFO tedana:tedana_workflow:569 Using output directory: /cbica/projects/pafin/derivatives/tedana/sub-24053/ses-1/func
6+
INFO tedana:tedana_workflow:587 Initializing and validating component selection tree
7+
WARNING component_selector:validate_tree:141 Decision tree includes fields that are not used or logged ['_comment']
8+
INFO component_selector:__init__:326 Performing component selection with minimal_decision_tree
9+
INFO component_selector:__init__:327 first version of minimal decision tree
10+
INFO tedana:tedana_workflow:590 Loading input data: ['/cbica/comp_space/pafin/tedana_temp/sub-24053_ses-1_task-bao_dir-AP_run-01_echo-1_part-mag_desc-preproc_bold.nii.gz', '/cbica/comp_space/pafin/tedana_temp/sub-24053_ses-1_task-bao_dir-AP_run-01_echo-2_part-mag_desc-preproc_bold.nii.gz', '/cbica/comp_space/pafin/tedana_temp/sub-24053_ses-1_task-bao_dir-AP_run-01_echo-3_part-mag_desc-preproc_bold.nii.gz', '/cbica/comp_space/pafin/tedana_temp/sub-24053_ses-1_task-bao_dir-AP_run-01_echo-4_part-mag_desc-preproc_bold.nii.gz', '/cbica/comp_space/pafin/tedana_temp/sub-24053_ses-1_task-bao_dir-AP_run-01_echo-5_part-mag_desc-preproc_bold.nii.gz']
11+
INFO io:__init__:155 Generating figures directory: /cbica/projects/pafin/derivatives/tedana/sub-24053/ses-1/func/figures
12+
INFO tedana:tedana_workflow:676 Combining user-defined mask and T2* map to generate mask
13+
INFO utils:make_adaptive_mask:198 Echo-wise intensity thresholds for adaptive mask: [5653.23669131 3592.6570638 2310.65512346 1458.94702855 771.71095011]
14+
WARNING utils:make_adaptive_mask:227 527 voxels in user-defined mask do not have good signal. Removing voxels from mask.
15+
INFO combine:make_optcom:192 Optimally combining data with voxel-wise T2* estimates
16+
INFO tedana:tedana_workflow:758 Writing optimally combined data set: /cbica/projects/pafin/derivatives/tedana/sub-24053/ses-1/func/sub-24053_ses-1_task-bao_dir-AP_run-01_desc-optcom_bold.nii.gz
17+
INFO tedana:tedana_workflow:854 Using supplied mixing matrix from ICA
18+
INFO collect:generate_metrics:150 Calculating weight maps
19+
INFO collect:generate_metrics:162 Calculating parameter estimate maps for optimally combined data
20+
INFO collect:generate_metrics:182 Calculating z-statistic maps
21+
INFO collect:generate_metrics:192 Calculating F-statistic maps
22+
INFO collect:generate_metrics:216 Thresholding z-statistic maps
23+
INFO collect:generate_metrics:226 Calculating T2* F-statistic maps
24+
INFO collect:generate_metrics:236 Calculating S0 F-statistic maps
25+
INFO collect:generate_metrics:247 Counting significant voxels in T2* F-statistic maps
26+
INFO collect:generate_metrics:253 Counting significant voxels in S0 F-statistic maps
27+
INFO collect:generate_metrics:260 Thresholding optimal combination beta maps to match T2* F-statistic maps
28+
INFO collect:generate_metrics:269 Thresholding optimal combination beta maps to match S0 F-statistic maps
29+
INFO collect:generate_metrics:279 Calculating kappa and rho
30+
INFO collect:generate_metrics:288 Calculating variance explained
31+
INFO collect:generate_metrics:294 Calculating normalized variance explained
32+
INFO collect:generate_metrics:301 Calculating DSI between thresholded T2* F-statistic and optimal combination beta maps
33+
INFO collect:generate_metrics:311 Calculating DSI between thresholded S0 F-statistic and optimal combination beta maps
34+
WARNING utils:dice:309 2 of 39 components have empty maps, resulting in Dice values of 0. Please check your component table for dice columns with 0-values.
35+
/gpfs/fs001/cbica/projects/pafin/miniforge3/envs/processing/lib/python3.11/site-packages/tedana/utils.py:319: RuntimeWarning: invalid value encountered in divide
36+
dsi = (2.0 * intersection.sum(axis=axis)) / arr_sum
37+
INFO collect:generate_metrics:322 Calculating signal-noise t-statistics
38+
/gpfs/fs001/cbica/projects/pafin/miniforge3/envs/processing/lib/python3.11/site-packages/tedana/metrics/dependence.py:573: SmallSampleWarning: One or more sample arguments is too small; all returned values will be NaN. See documentation for sample size requirements.
39+
(signal_minus_noise_t[i_comp], signal_minus_noise_p[i_comp]) = stats.ttest_ind(
40+
INFO tedica:automatic_selection:56 Performing ICA component selection with tree: minimal
41+
INFO selection_nodes:manual_classify:104 Step 0: manual_classify: Set all to unclassified
42+
INFO selection_utils:log_decision_tree_step:436 Step 0: manual_classify applied to 39 components. 39 True -> unclassified. 0 False -> nochange.
43+
INFO selection_nodes:manual_classify:136 Step 0: manual_classify component classification tags are cleared
44+
INFO selection_utils:log_classification_counts:481 Step 0: Total component classifications: 39 unclassified
45+
INFO selection_nodes:dec_left_op_right:389 Step 1: left_op_right: rejected if rho>kappa, else nochange
46+
INFO selection_utils:log_decision_tree_step:436 Step 1: left_op_right applied to 39 components. 3 True -> rejected. 36 False -> nochange.
47+
INFO selection_utils:log_classification_counts:481 Step 1: Total component classifications: 3 rejected, 36 unclassified
48+
INFO selection_nodes:dec_left_op_right:389 Step 2: left_op_right: rejected if ['countsigFS0>countsigFT2 & countsigFT2>0'], else nochange
49+
INFO selection_utils:log_decision_tree_step:436 Step 2: left_op_right applied to 39 components. 6 True -> rejected. 33 False -> nochange.
50+
INFO selection_utils:log_classification_counts:481 Step 2: Total component classifications: 7 rejected, 32 unclassified
51+
INFO selection_nodes:calc_median:653 Step 3: calc_median: Median(median_varex)
52+
INFO selection_utils:log_decision_tree_step:448 Step 3: calc_median calculated: median_varex=2.1241346596054345
53+
INFO selection_utils:log_classification_counts:481 Step 3: Total component classifications: 7 rejected, 32 unclassified
54+
INFO selection_nodes:dec_left_op_right:389 Step 4: left_op_right: rejected if ['dice_FS0>dice_FT2 & variance explained>2.12'], else nochange
55+
INFO selection_utils:log_decision_tree_step:436 Step 4: left_op_right applied to 39 components. 5 True -> rejected. 34 False -> nochange.
56+
INFO selection_utils:log_classification_counts:481 Step 4: Total component classifications: 9 rejected, 30 unclassified
57+
INFO selection_nodes:dec_left_op_right:389 Step 5: left_op_right: rejected if ['0>signal-noise_t & variance explained>2.12'], else nochange
58+
INFO selection_utils:comptable_classification_changer:282 Step 5: No components fit criterion True to change classification
59+
INFO selection_utils:log_decision_tree_step:436 Step 5: left_op_right applied to 39 components. 0 True -> rejected. 39 False -> nochange.
60+
INFO selection_utils:log_classification_counts:481 Step 5: Total component classifications: 9 rejected, 30 unclassified
61+
INFO selection_nodes:calc_kappa_elbow:757 Step 6: calc_kappa_elbow: Calc Kappa Elbow
62+
INFO selection_utils:kappa_elbow_kundu:651 Calculating kappa elbow based on min of all and nonsig components.
63+
INFO selection_utils:log_decision_tree_step:448 Step 6: calc_kappa_elbow calculated: kappa_elbow_kundu=18.691522021231375, kappa_allcomps_elbow=18.691522021231375, kappa_nonsig_elbow=18.691522021231375, varex_upper_p=2.309179573436346
64+
INFO selection_utils:log_classification_counts:481 Step 6: Total component classifications: 9 rejected, 30 unclassified
65+
INFO selection_nodes:calc_rho_elbow:882 Step 7: calc_rho_elbow: Calc Rho Elbow
66+
INFO selection_utils:log_decision_tree_step:448 Step 7: calc_rho_elbow calculated: rho_elbow_liberal=10.626998975053048, rho_allcomps_elbow=10.626998975053048, rho_unclassified_elbow=8.886598126292633, elbow_f05=7.708647422176786
67+
INFO selection_utils:log_classification_counts:481 Step 7: Total component classifications: 9 rejected, 30 unclassified
68+
INFO selection_nodes:dec_left_op_right:389 Step 8: left_op_right: provisionalaccept if kappa>=18.69, else provisionalreject
69+
INFO selection_utils:log_decision_tree_step:436 Step 8: left_op_right applied to 30 components. 9 True -> provisionalaccept. 21 False -> provisionalreject.
70+
INFO selection_utils:log_classification_counts:481 Step 8: Total component classifications: 9 provisionalaccept, 21 provisionalreject, 9 rejected
71+
INFO selection_nodes:dec_left_op_right:389 Step 9: left_op_right: accepted if kappa>2*rho, else nochange
72+
INFO selection_utils:log_decision_tree_step:436 Step 9: left_op_right applied to 9 components. 6 True -> accepted. 3 False -> nochange.
73+
INFO selection_utils:log_classification_counts:481 Step 9: Total component classifications: 6 accepted, 3 provisionalaccept, 21 provisionalreject, 9 rejected
74+
INFO selection_nodes:dec_left_op_right:389 Step 10: left_op_right: provisionalreject if rho>10.63, else nochange
75+
INFO selection_utils:log_decision_tree_step:436 Step 10: left_op_right applied to 24 components. 3 True -> provisionalreject. 21 False -> nochange.
76+
INFO selection_utils:log_classification_counts:481 Step 10: Total component classifications: 6 accepted, 24 provisionalreject, 9 rejected
77+
INFO selection_nodes:dec_variance_lessthan_thresholds:533 Step 11: variance_lt_thresholds: accepted if variance explained<0.1. All variance<1.0, else nochange
78+
INFO selection_utils:comptable_classification_changer:282 Step 11: No components fit criterion True to change classification
79+
INFO selection_utils:log_decision_tree_step:436 Step 11: variance_lt_thresholds applied to 24 components. 0 True -> accepted. 24 False -> nochange.
80+
INFO selection_utils:log_classification_counts:481 Step 11: Total component classifications: 6 accepted, 24 provisionalreject, 9 rejected
81+
INFO selection_nodes:manual_classify:104 Step 12: manual_classify: Set provisionalaccept to accepted
82+
INFO selection_utils:log_decision_tree_step:430 Step 12: manual_classify not applied because no remaining components were classified as provisionalaccept
83+
INFO selection_utils:log_classification_counts:481 Step 12: Total component classifications: 6 accepted, 24 provisionalreject, 9 rejected
84+
INFO selection_nodes:manual_classify:104 Step 13: manual_classify: Set ['provisionalreject', 'unclassified'] to rejected
85+
INFO selection_utils:log_decision_tree_step:436 Step 13: manual_classify applied to 24 components. 24 True -> rejected. 0 False -> nochange.
86+
INFO selection_utils:log_classification_counts:481 Step 13: Total component classifications: 6 accepted, 33 rejected
87+
INFO io:denoise_ts:560 Variance explained by decomposition: 64.45%
88+
INFO io:write_split_ts:647 Writing denoised time series: /cbica/projects/pafin/derivatives/tedana/sub-24053/ses-1/func/sub-24053_ses-1_task-bao_dir-AP_run-01_desc-denoised_bold.nii.gz
89+
INFO io:writeresults:696 Writing full ICA coefficient feature set: /cbica/projects/pafin/derivatives/tedana/sub-24053/ses-1/func/sub-24053_ses-1_task-bao_dir-AP_run-01_desc-ICA_components.nii.gz
90+
INFO io:writeresults:700 Writing denoised ICA coefficient feature set: /cbica/projects/pafin/derivatives/tedana/sub-24053/ses-1/func/sub-24053_ses-1_task-bao_dir-AP_run-01_desc-ICAAccepted_components.nii.gz
91+
INFO io:writeresults:706 Writing Z-normalized spatial component maps: /cbica/projects/pafin/derivatives/tedana/sub-24053/ses-1/func/sub-24053_ses-1_task-bao_dir-AP_run-01_desc-ICAAccepted_stat-z_components.nii.gz
92+
INFO gscontrol:minimum_image_regression:207 Performing minimum image regression to remove spatially-diffuse noise
93+
WARNING gscontrol:minimum_image_regression:219 Decision tree does not contain classification tags indicating low variance components (low variance, accept borderline).
94+
INFO tedana:tedana_workflow:1025 Making figures folder with static component maps and timecourse plots.
95+
INFO io:denoise_ts:560 Variance explained by decomposition: 64.45%
96+
/gpfs/fs001/cbica/projects/pafin/miniforge3/envs/processing/lib/python3.11/site-packages/tedana/io.py:833: UserWarning: Data array used to create a new image contains 64-bit ints. This is likely due to creating the array with numpy and passing `int` as the `dtype`. Many tools such as FSL and SPM cannot deal with int64 in Nifti images, so for compatibility the data has been converted to int32.
97+
nii = new_img_like(ref_img, newdata, affine=affine, copy_header=copy_header)
98+
/gpfs/fs001/cbica/projects/pafin/miniforge3/envs/processing/lib/python3.11/site-packages/tedana/io.py:833: UserWarning: Data array used to create a new image contains 64-bit ints. This is likely due to creating the array with numpy and passing `int` as the `dtype`. Many tools such as FSL and SPM cannot deal with int64 in Nifti images, so for compatibility the data has been converted to int32.
99+
nii = new_img_like(ref_img, newdata, affine=affine, copy_header=copy_header)

0 commit comments

Comments
 (0)