Skip to content

Commit

Permalink
Amended notebooks and template scripts for the new AFNI permutation a…
Browse files Browse the repository at this point in the history
…nalyses
  • Loading branch information
AlexBowring committed Jul 10, 2020
1 parent b745478 commit a16d73d
Show file tree
Hide file tree
Showing 7 changed files with 1,045 additions and 208 deletions.
860 changes: 860 additions & 0 deletions figures/ds001_notebook_amended.ipynb

Large diffs are not rendered by default.

233 changes: 79 additions & 154 deletions figures/ds109_notebook_amended.ipynb

Large diffs are not rendered by default.

68 changes: 46 additions & 22 deletions figures/lib/download_data_amended.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,44 @@ def download_data(nv_collection, study, output_dir):
)

if study not in ('ds120'):
euler_char_files = (
euler_char_files +
# There is no FSL analysis for ds120
((os.path.join('FSL', 'LEVEL2_amended', 'group.gfeat', 'cope1.feat', 'stats', 'euler_chars.csv'), 'fsl_euler_chars.csv'),) +
((os.path.join('FSL', 'LEVEL2_amended', 'permutation_test', 'euler_chars.csv'), 'fsl_perm_euler_chars.csv'),) +
# There is no permutation analysis for ds120
((os.path.join('AFNI', 'LEVEL2', 'permutation_test', 'euler_chars.csv'), 'afni_perm_euler_chars.csv'),) +
((os.path.join('SPM', 'LEVEL2', 'permutation_test', 'euler_chars.csv'), 'spm_perm_euler_chars.csv'),)
)
if study not in ('ds001'):
euler_char_files = (
euler_char_files +
# There is no FSL analysis for ds120
((os.path.join('FSL', 'LEVEL2_amended', 'group.gfeat', 'cope1.feat', 'stats', 'euler_chars.csv'), 'fsl_euler_chars.csv'),) +
((os.path.join('FSL', 'LEVEL2_amended', 'permutation_test', 'euler_chars.csv'), 'fsl_perm_euler_chars.csv'),) +
((os.path.join('AFNI', 'LEVEL2', 'permutation_test_AMENDED', 'euler_chars.csv'), 'afni_perm_euler_chars.csv'),) +
((os.path.join('SPM', 'LEVEL2', 'permutation_test', 'euler_chars.csv'), 'spm_perm_euler_chars.csv'),)
)

cluster_count_files = (
cluster_count_files +
# There is no FSL analysis for ds120
((os.path.join('FSL', 'LEVEL2_amended', 'group.gfeat', 'cope1.feat', 'stats', 'cluster_count.csv'), 'fsl_cluster_count.csv'),) +
((os.path.join('FSL', 'LEVEL2_amended', 'permutation_test', 'cluster_count.csv'), 'fsl_perm_cluster_count.csv'),) +
# There is no permutation analysis for ds120
((os.path.join('AFNI', 'LEVEL2', 'permutation_test_AMENDED', 'cluster_count.csv'), 'afni_perm_cluster_count.csv'),) +
((os.path.join('SPM', 'LEVEL2', 'permutation_test', 'cluster_count.csv'), 'spm_perm_cluster_count.csv'),)
)
else:
euler_char_files = (
euler_char_files +
# There is no FSL analysis for ds120
((os.path.join('FSL', 'LEVEL2', 'group.gfeat', 'cope1.feat', 'stats', 'euler_chars.csv'), 'fsl_euler_chars.csv'),) +
((os.path.join('FSL', 'LEVEL2', 'permutation_test', 'euler_chars.csv'), 'fsl_perm_euler_chars.csv'),) +
((os.path.join('AFNI', 'LEVEL2', 'permutation_test_AMENDED', 'euler_chars.csv'), 'afni_perm_euler_chars.csv'),) +
((os.path.join('SPM', 'LEVEL2', 'permutation_test', 'euler_chars.csv'), 'spm_perm_euler_chars.csv'),)
)

cluster_count_files = (
cluster_count_files +
# There is no FSL analysis for ds120
((os.path.join('FSL', 'LEVEL2_amended', 'group.gfeat', 'cope1.feat', 'stats', 'cluster_count.csv'), 'fsl_cluster_count.csv'),) +
((os.path.join('FSL', 'LEVEL2_amended', 'permutation_test', 'cluster_count.csv'), 'fsl_perm_cluster_count.csv'),) +
# There is no permutation analysis for ds120
((os.path.join('AFNI', 'LEVEL2', 'permutation_test', 'cluster_count.csv'), 'afni_perm_cluster_count.csv'),) +
((os.path.join('SPM', 'LEVEL2', 'permutation_test', 'cluster_count.csv'), 'spm_perm_cluster_count.csv'),)
)
cluster_count_files = (
cluster_count_files +
# There is no FSL analysis for ds120
((os.path.join('FSL', 'LEVEL2', 'group.gfeat', 'cope1.feat', 'stats', 'cluster_count.csv'), 'fsl_cluster_count.csv'),) +
((os.path.join('FSL', 'LEVEL2', 'permutation_test', 'cluster_count.csv'), 'fsl_perm_cluster_count.csv'),) +
# There is no permutation analysis for ds120
((os.path.join('AFNI', 'LEVEL2', 'permutation_test_AMENDED', 'cluster_count.csv'), 'afni_perm_cluster_count.csv'),) +
((os.path.join('SPM', 'LEVEL2', 'permutation_test', 'cluster_count.csv'), 'spm_perm_cluster_count.csv'),)
)


for euler_char_file, local_name in euler_char_files:
Expand Down Expand Up @@ -152,10 +171,15 @@ def download_data(nv_collection, study, output_dir):
to_download = (
afni_images + perm_images + r_squared_images)
else:
# BOLD maps
bold_images= (('afni_bold.nii.gz','afni_bold.nii.gz'),
('fsl_bold_amended.nii.gz','fsl_bold.nii.gz'),
('spm_bold.nii.gz','spm_bold.nii.gz'))
if study not in ('ds001'):
# BOLD maps
bold_images= (('afni_bold.nii.gz','afni_bold.nii.gz'),
('fsl_bold_amended.nii.gz','fsl_bold.nii.gz'),
('spm_bold.nii.gz','spm_bold.nii.gz'))
else:
bold_images= (('afni_bold.nii.gz','afni_bold.nii.gz'),
('fsl_bold.nii.gz','fsl_bold.nii.gz'),
('spm_bold.nii.gz','spm_bold.nii.gz'))

to_download = (
afni_images + perm_images + bold_images)
Expand Down
28 changes: 28 additions & 0 deletions scripts/ds001_euler_chars_amended.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
base_dir = '/home/maullz/NIDM-Ex/BIDS_Data/RESULTS/SOFTWARE_COMPARISON/';
study = 'ds001';
DF = 16-1;

if ~exist('euler_chars', 'file')
addpath(fullfile(fileparts(mfilename('fullpath')), 'lib'))
end

study_dir = fullfile(base_dir, study);
spm_stat_file = fullfile(study_dir, 'SPM', 'LEVEL2', 'spmT_0001.nii');
fsl_stat_file = fullfile(study_dir, 'FSL', 'LEVEL2', 'group.gfeat', 'cope1.feat', 'stats', 'tstat1.nii.gz');
afni_stat_file = fullfile(study_dir, 'AFNI', 'LEVEL2', '3dMEMA_result_t_stat_masked.nii.gz');
spm_perm_file = fullfile(study_dir, 'SPM', 'LEVEL2', 'permutation_test', 'snpmT+.img');
fsl_perm_file = fullfile(study_dir, 'FSL', 'LEVEL2', 'permutation_test', 'OneSampT_tstat1.nii.gz');
afni_perm_file = fullfile(study_dir, 'AFNI', 'LEVEL2', 'permutation_test_AMENDED', 'perm_ttest++_Clustsim_result_t_stat_masked.nii.gz');
spm_mask = fullfile(study_dir, 'SPM', 'LEVEL2', 'mask.nii');
fsl_mask = fullfile(study_dir, 'FSL', 'LEVEL2', 'group.gfeat', 'mask.nii.gz');
afni_mask = fullfile(study_dir, 'AFNI', 'LEVEL2', 'mask.nii.gz');

euler_array = {spm_stat_file, fsl_stat_file, afni_stat_file, spm_perm_file, fsl_perm_file};
mask_array = {spm_mask, fsl_mask, afni_mask, spm_mask, fsl_mask };


for i=1:length(euler_array)
euler_chars(euler_array{i}, mask_array{i});
end

euler_chars(afni_perm_file,afni_mask,DF);
2 changes: 1 addition & 1 deletion scripts/ds109_euler_chars_amended.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
afni_stat_file = fullfile(study_dir, 'AFNI', 'LEVEL2', '3dMEMA_result_t_stat_masked.nii.gz');
spm_perm_file = fullfile(study_dir, 'SPM', 'LEVEL2', 'permutation_test', 'snpmT+.img');
fsl_perm_file = fullfile(study_dir, 'FSL', 'LEVEL2_amended', 'permutation_test', 'OneSampT_tstat1.nii.gz');
afni_perm_file = fullfile(study_dir, 'AFNI', 'LEVEL2', 'permutation_test', 'perm_ttest++_Clustsim_result_t_stat_masked.nii.gz');
afni_perm_file = fullfile(study_dir, 'AFNI', 'LEVEL2', 'permutation_test_AMENDED', 'perm_ttest++_Clustsim_result_t_stat_masked.nii.gz');
spm_mask = fullfile(study_dir, 'SPM', 'LEVEL2', 'mask.nii');
fsl_mask = fullfile(study_dir, 'FSL', 'LEVEL2_amended', 'group.gfeat', 'mask.nii.gz');
afni_mask = fullfile(study_dir, 'AFNI', 'LEVEL2', 'mask.nii.gz');
Expand Down
58 changes: 29 additions & 29 deletions scripts/lib/template_ds001_AFNI_perm_test_AMENDED
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@ cd $perm_dir
-frac 1.0

# t-test analysis
3dttest++ \
-Clustsim 1 \
-prefix perm_ttest++_Clustsim_result.nii.gz \
-prefix_clustsim Clustsim \
-mask $perm_dir/mask.nii.gz \
-setA setA \
01 "$level1_dir/sub-01/sub01.results/stats.sub01_REML+tlrc.HEAD[30]" \
02 "$level1_dir/sub-02/sub02.results/stats.sub02_REML+tlrc.HEAD[30]" \
03 "$level1_dir/sub-03/sub03.results/stats.sub03_REML+tlrc.HEAD[30]" \
04 "$level1_dir/sub-04/sub04.results/stats.sub04_REML+tlrc.HEAD[30]" \
05 "$level1_dir/sub-05/sub05.results/stats.sub05_REML+tlrc.HEAD[30]" \
06 "$level1_dir/sub-06/sub06.results/stats.sub06_REML+tlrc.HEAD[30]" \
07 "$level1_dir/sub-07/sub07.results/stats.sub07_REML+tlrc.HEAD[30]" \
08 "$level1_dir/sub-08/sub08.results/stats.sub08_REML+tlrc.HEAD[30]" \
09 "$level1_dir/sub-09/sub09.results/stats.sub09_REML+tlrc.HEAD[30]" \
10 "$level1_dir/sub-10/sub10.results/stats.sub10_REML+tlrc.HEAD[30]" \
11 "$level1_dir/sub-11/sub11.results/stats.sub11_REML+tlrc.HEAD[30]" \
12 "$level1_dir/sub-12/sub12.results/stats.sub12_REML+tlrc.HEAD[30]" \
13 "$level1_dir/sub-13/sub13.results/stats.sub13_REML+tlrc.HEAD[30]" \
14 "$level1_dir/sub-14/sub14.results/stats.sub14_REML+tlrc.HEAD[30]" \
15 "$level1_dir/sub-15/sub15.results/stats.sub15_REML+tlrc.HEAD[30]" \
16 "$level1_dir/sub-16/sub16.results/stats.sub16_REML+tlrc.HEAD[30]"
#3dttest++ \
# -Clustsim 1 \
# -prefix perm_ttest++_Clustsim_result.nii.gz \
# -prefix_clustsim Clustsim \
# -mask $perm_dir/mask.nii.gz \
# -setA setA \
# 01 "$level1_dir/sub-01/sub01.results/stats.sub01_REML+tlrc.HEAD[30]" \
# 02 "$level1_dir/sub-02/sub02.results/stats.sub02_REML+tlrc.HEAD[30]" \
# 03 "$level1_dir/sub-03/sub03.results/stats.sub03_REML+tlrc.HEAD[30]" \
# 04 "$level1_dir/sub-04/sub04.results/stats.sub04_REML+tlrc.HEAD[30]" \
# 05 "$level1_dir/sub-05/sub05.results/stats.sub05_REML+tlrc.HEAD[30]" \
# 06 "$level1_dir/sub-06/sub06.results/stats.sub06_REML+tlrc.HEAD[30]" \
# 07 "$level1_dir/sub-07/sub07.results/stats.sub07_REML+tlrc.HEAD[30]" \
# 08 "$level1_dir/sub-08/sub08.results/stats.sub08_REML+tlrc.HEAD[30]" \
# 09 "$level1_dir/sub-09/sub09.results/stats.sub09_REML+tlrc.HEAD[30]" \
# 10 "$level1_dir/sub-10/sub10.results/stats.sub10_REML+tlrc.HEAD[30]" \
# 11 "$level1_dir/sub-11/sub11.results/stats.sub11_REML+tlrc.HEAD[30]" \
# 12 "$level1_dir/sub-12/sub12.results/stats.sub12_REML+tlrc.HEAD[30]" \
# 13 "$level1_dir/sub-13/sub13.results/stats.sub13_REML+tlrc.HEAD[30]" \
# 14 "$level1_dir/sub-14/sub14.results/stats.sub14_REML+tlrc.HEAD[30]" \
# 15 "$level1_dir/sub-15/sub15.results/stats.sub15_REML+tlrc.HEAD[30]" \
# 16 "$level1_dir/sub-16/sub16.results/stats.sub16_REML+tlrc.HEAD[30]"

# This can be used to obtain cluster extent threshold from the ClustSim.*.1D table for AFNI versions > 18.2.04
clust_thrvol=`1d_tool.py -verb 0 \
-infile Clustsim.CSimA.NN1_1sided.1D \
-csim_pthr 0.010 \
-csim_alpha "0.05"`
echo "++ The final cluster volume threshold is: $$clust_thrvol"
#clust_thrvol=`1d_tool.py -verb 0 \
# -infile Clustsim.CSimA.NN1_1sided.1D \
# -csim_pthr 0.010 \
# -csim_alpha "0.05"`
#echo "++ The final cluster volume threshold is: $$clust_thrvol"

# Obtaining cluster-forming threshold
voxstat_thr=`p2dsetstat -quiet \
Expand All @@ -57,7 +57,7 @@ echo "++ The voxelwise stat value threshold is: $$voxstat_thr"
-1Dformat -nosum -1tindex 1 -1dindex 0 \
-2thresh -1e+09 $$voxstat_thr -dxyz=1 \
-savemask perm_Positive_clust_mask.nii.gz \
1.01 752 perm_ttest++_Clustsim_result_t_stat_masked_4d.nii.gz
1.01 506 perm_ttest++_Clustsim_result_t_stat_masked_4d.nii.gz

# Binarizing
3dcalc \
Expand All @@ -72,7 +72,7 @@ echo "++ The voxelwise stat value threshold is: $$voxstat_thr"
-1Dformat -nosum -1tindex 1 -1dindex 0 \
-2thresh -$$voxstat_thr 1e+09 -dxyz=1 \
-savemask perm_Negative_clust_mask.nii.gz \
1.01 752 perm_ttest++_Clustsim_result_t_stat_masked_4d.nii.gz
1.01 506 perm_ttest++_Clustsim_result_t_stat_masked_4d.nii.gz

# Binarizing
3dcalc \
Expand Down
4 changes: 2 additions & 2 deletions scripts/lib/template_ds109_AFNI_perm_test_AMENDED
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ echo "++ The voxelwise stat value threshold is: $$voxstat_thr"
-1Dformat -nosum -1tindex 1 -1dindex 0 \
-2thresh -1e+09 $$voxstat_thr -dxyz=1 \
-savemask perm_Positive_clust_mask.nii.gz \
1.01 892 perm_ttest++_Clustsim_result_t_stat_masked_4d.nii.gz
1.01 $$clust_thrvol perm_ttest++_Clustsim_result_t_stat_masked_4d.nii.gz

# Binarizing
3dcalc \
Expand All @@ -77,7 +77,7 @@ echo "++ The voxelwise stat value threshold is: $$voxstat_thr"
-1Dformat -nosum -1tindex 1 -1dindex 0 \
-2thresh -$$voxstat_thr 1e+09 -dxyz=1 \
-savemask perm_Negative_clust_mask.nii.gz \
1.01 892 perm_ttest++_Clustsim_result_t_stat_masked_4d.nii.gz
1.01 $$clust_thrvol perm_ttest++_Clustsim_result_t_stat_masked_4d.nii.gz

# Binarizing
3dcalc \
Expand Down

0 comments on commit a16d73d

Please sign in to comment.