├── README.md ├── globalvars ├── grp └── GLM │ ├── FS_stats │ ├── designs │ ├── doss_tps │ │ ├── doss_anova.fsgd │ │ ├── doss_global-effect.mtx │ │ ├── doss_mean.mtx │ │ ├── doss_tp1-vs-tp2.mtx │ │ ├── doss_tp1-vs-tp3.mtx │ │ └── doss_tp2-vs-tp3.mtx │ └── getlist.cmd │ ├── alff │ ├── dualreg │ ├── designs │ ├── flexfact_func │ │ ├── design(copy).grp │ │ ├── design.con │ │ ├── design.fsf │ │ ├── design.grp │ │ ├── design.mat │ │ ├── design.png │ │ ├── design.ppm │ │ ├── design_cov.png │ │ └── design_cov.ppm │ ├── get_GlmsPng.cmd │ ├── get_allGlmsPng.cmd │ ├── getlist.cmd │ └── quintuple_func │ │ ├── design(copy).grp │ │ ├── design.con │ │ ├── design.fsf │ │ ├── design.grp │ │ ├── design.mat │ │ ├── design.png │ │ ├── design.ppm │ │ ├── design_cov.png │ │ └── design_cov.ppm │ ├── fslnets │ ├── tbss │ ├── designs │ ├── flexfact_struc │ │ ├── design(copy).grp │ │ ├── design.con │ │ ├── design.fsf │ │ ├── design.grp │ │ ├── design.mat │ │ ├── design.png │ │ ├── design.ppm │ │ ├── design.txt │ │ ├── design_cov.png │ │ └── design_cov.ppm │ ├── get_GlmsPng.cmd │ ├── get_allGlmsPng.cmd │ ├── getlist.cmd │ ├── quintuple_struc │ │ ├── design(copy).grp │ │ ├── design.con │ │ ├── design.fsf │ │ ├── design.grp │ │ ├── design.mat │ │ ├── design.png │ │ ├── design.ppm │ │ ├── design_cov.png │ │ └── design_cov.ppm │ └── vbm_template_list │ └── vbm ├── rsc ├── 01_install_sync.sh ├── 02_install_checkCompatibility.sh ├── 03_install_update.sh ├── 04_install_nautilus-scripts.sh ├── afni │ ├── 3dDespike_32 │ ├── 3dDespike_64 │ ├── 3dDetrend_32 │ ├── 3dDetrend_64 │ ├── 3dTcat_32 │ ├── 3dTcat_64 │ ├── 3dTstat_32 │ ├── 3dTstat_64 │ ├── 3dcalc_32 │ └── 3dcalc_64 ├── fs │ └── trac-all ├── fsl │ ├── fsl4 │ │ ├── featlib_v4.tcl │ │ ├── fsl_sub_v4 │ │ ├── slices_summary │ │ ├── tbss_x │ │ │ ├── swap_subjectwise_32 │ │ │ ├── swap_subjectwise_64 │ │ │ ├── swap_voxelwise_32 │ │ │ ├── swap_voxelwise_64 │ │ │ ├── tbss_x │ │ │ └── tbss_x_index.html │ │ └── topup │ │ │ ├── applytopup_32 │ │ │ ├── applytopup_64 │ │ │ ├── b02b0.cnf │ │ │ ├── topup_32 │ │ │ └── topup_64 │ ├── fsl5 │ │ ├── FSLNets │ │ │ ├── nets_glm.m │ │ │ └── nets_load.m │ │ ├── fsl_sub_patched │ │ ├── fsl_sub_v5.6 │ │ ├── fsl_sub_v5.6_patched │ │ ├── fsl_sub_v5.6_patched_NOPOSIXLY │ │ ├── fsl_sub_v5.8 │ │ ├── fsl_sub_v5.8_patched │ │ ├── fsl_sub_v5.8_patched_NOPOSIXLY │ │ ├── fslmaths5_32 │ │ └── fslmaths5_64 │ ├── orig │ │ ├── dual_regression │ │ ├── fslvbm_1_bet │ │ ├── fslvbm_2_template │ │ ├── fslvbm_3_proc │ │ ├── tbss_1_preproc │ │ ├── tbss_2_reg │ │ ├── tbss_3_postreg │ │ ├── tbss_4_prestats │ │ └── tbss_x │ └── templates │ │ ├── MNI152_T1_3mm.nii.gz │ │ ├── MNI152_T1_3mm_brain.nii.gz │ │ ├── MNI152_T1_4mm.nii.gz │ │ ├── MNI152_T1_4mm_brain.nii.gz │ │ ├── avg152T1_brain_bin.nii.gz │ │ ├── avg152T1_csf_bin.nii.gz │ │ ├── avg152T1_white_bin.nii.gz │ │ ├── rsn10_2mm.nii.gz │ │ ├── rsn10_3mm.nii.gz │ │ ├── rsn10_4mm.nii.gz │ │ ├── rsn10_CSFWM_2mm.nii.gz │ │ ├── rsn10_CSFWM_3mm.nii.gz │ │ ├── rsn10_CSFWM_4mm.nii.gz │ │ ├── rsn10_CSFWM_labels.txt │ │ ├── rsn10_labels.txt │ │ ├── rsn14_2mm.nii.gz │ │ ├── rsn14_3mm.nii.gz │ │ ├── rsn14_4mm.nii.gz │ │ ├── rsn14_CSFWM_2mm.nii.gz │ │ ├── rsn14_CSFWM_3mm.nii.gz │ │ ├── rsn14_CSFWM_4mm.nii.gz │ │ ├── rsn14_CSFWM_labels.txt │ │ ├── rsn14_labels.txt │ │ ├── rsn8_2mm.nii.gz │ │ ├── rsn8_3mm.nii.gz │ │ ├── rsn8_4mm.nii.gz │ │ ├── rsn8_CSFWM_2mm.nii.gz │ │ ├── rsn8_CSFWM_3mm.nii.gz │ │ ├── rsn8_CSFWM_4mm.nii.gz │ │ ├── rsn8_CSFWM_labels.txt │ │ ├── rsn8_labels.txt │ │ └── rsn_labels.xls ├── readme └── scripts │ ├── ICAcleanup.m │ ├── LIA_to_LAS_conformed.mat │ ├── PlotPow.sh │ ├── _check_progs.sh │ ├── _mask_softtissue.sh │ ├── annotquery_label.m │ ├── annotquery_sig.m │ ├── apply_mc+reg2MNI.sh │ ├── apply_mc+unwarp+reg2MNI.sh │ ├── apply_mc+unwarp.sh │ ├── apply_mc.sh │ ├── apply_unwarp.sh │ ├── bin │ ├── FSLNets │ │ ├── L1precision │ │ │ ├── L1precisionBCD.m │ │ │ ├── LassoShooting.m │ │ │ ├── drawGraph.m │ │ │ ├── example_L1precision.m │ │ │ ├── mysetdiff.m │ │ │ └── process_options.m │ │ ├── README │ │ ├── netjs │ │ │ ├── index.html │ │ │ └── js │ │ │ │ ├── lib │ │ │ │ ├── LICENSE.d3.js │ │ │ │ ├── d3.js │ │ │ │ ├── mustache.js │ │ │ │ ├── queue.js │ │ │ │ └── require.js │ │ │ │ ├── main.js │ │ │ │ ├── main.jsOLD │ │ │ │ ├── netctrl.html │ │ │ │ ├── netctrl.js │ │ │ │ ├── netdata.js │ │ │ │ ├── netjs.js │ │ │ │ ├── netvis.js │ │ │ │ ├── netvis_dynamics.js │ │ │ │ └── test.js │ │ ├── nets_boxplots.m │ │ ├── nets_class_vectomat.m │ │ ├── nets_demean.m │ │ ├── nets_edgepics.m │ │ ├── nets_examples.m │ │ ├── nets_glm.m │ │ ├── nets_groupmean.m │ │ ├── nets_hierarchy.m │ │ ├── nets_lda.m │ │ ├── nets_load.m │ │ ├── nets_netmats.m │ │ ├── nets_netweb.m │ │ ├── nets_nodepartial.m │ │ ├── nets_nodepics.m │ │ ├── nets_normalise.m │ │ ├── nets_outliers.m │ │ ├── nets_spectra.m │ │ ├── nets_stats.m │ │ ├── nets_svds.m │ │ ├── nets_tangentv.m │ │ ├── nets_tsclean.m │ │ ├── orig_nets_glm.m │ │ ├── orig_nets_load.m │ │ └── pwling │ │ │ ├── mentappr.m │ │ │ └── pwling.m │ ├── sort8_32 │ └── sort8_64 │ ├── calcT2.sh │ ├── checks.cmd │ ├── circshift4D.sh │ ├── collectvols.sh │ ├── convert_regs.sh │ ├── createALFF.sh │ ├── create_plots.sh │ ├── cycler.sh │ ├── dcm2niigz.sh │ ├── delbrokenlinks.sh │ ├── denoise4D.sh │ ├── dualreg.sh │ ├── dummy_bvalbvec.sh │ ├── eddy_correct.sh │ ├── eddy_correct_parallel.sh │ ├── eddy_correct_plot.sh │ ├── eddy_topup.sh │ ├── estdeform.sh │ ├── extract.sh │ ├── extract_dreg.sh │ ├── extract_z.sh │ ├── extract_z_precision.sh │ ├── extractmask.sh │ ├── extractmask_z.sh │ ├── extractmerge.sh │ ├── extractmerge_parallel.sh │ ├── feat_T1_2_MNI.sh │ ├── feat_hpf.sh │ ├── feat_mask.sh │ ├── feat_scale.sh │ ├── feat_smooth.sh │ ├── feat_unwarp.sh │ ├── feat_writeMNI.sh │ ├── fs_annotquery.sh │ ├── fs_convert.sh │ ├── fs_create_masks.sh │ ├── fs_label2label.sh │ ├── fs_label2vol.sh │ ├── fs_log10.sh │ ├── fs_roiextract.sh │ ├── fs_stats.sh │ ├── fs_vol2surf.sh │ ├── fs_vol4D2vol4D.sh │ ├── fsl_sub_NOPOSIXLY.sh │ ├── fslcc.sh │ ├── fslcc_mean.sh │ ├── fslmeants.sh │ ├── fslreorient2std.sh │ ├── fvm.sh │ ├── getSusanCmd.sh │ ├── getsliceorderSIEMENS_interleaved.sh │ ├── grepclusters.sh │ ├── greperror.sh │ ├── grepstats_tracula.sh │ ├── hpf_movpar.sh │ ├── ica.sh │ ├── ident.reg │ ├── longt_fslvbm_2_template.sh │ ├── longt_tbss_2_reg.sh │ ├── lssubj.sh │ ├── macros │ └── fv_dreg.sh │ ├── main(reconall-i).sh │ ├── main.sh │ ├── make_ecclog.sh │ ├── make_fmap.sh │ ├── melodic.sh │ ├── metaICA.sh │ ├── mkniigz.sh │ ├── mni152-vol_2_fsaverage-surf.register.dat │ ├── mni152-vol_2_mni152-surf.register.dat │ ├── nautilus-scripts │ ├── FREESURFER_freeview │ ├── FREESURFER_freeview-register │ ├── FREESURFER_freeview_checkSubject │ ├── FREESURFER_freeview_fsaverage │ ├── FREESURFER_mri_info │ ├── FREESURFER_mri_probedicom │ ├── FREESURFER_tkregister2 │ ├── FREESURFER_tkregister2_checkTalairach │ ├── FREESURFER_tksurfer │ ├── FREESURFER_tksurfer_fsaverage │ ├── FREESURFER_tksurfer_fsaverage_FLAT │ ├── FREESURFER_tksurfer_mni152.fnirt │ ├── FREESURFER_tksurfer_mni152.fnirt_FLAT │ ├── FSL_Feat │ ├── FSL_Glm │ ├── FSL_TBSScheck │ ├── FSL_VBMcheck │ ├── FSL_fslhd │ ├── FSL_fslmaths │ ├── FSL_fslmaths_-add │ ├── FSL_fslmerge │ ├── FSL_fslview │ ├── FSL_fslview_checkFeatdir │ ├── env_vars │ ├── greperror_log │ └── tail_-f.sh │ ├── normalize4D.sh │ ├── plot_ec.sh │ ├── project_denoise.sh │ ├── project_trim.sh │ ├── qdel.sh │ ├── qdelall.sh │ ├── qstatloop.sh │ ├── reformat_ts.sh │ ├── regress_out.m │ ├── rem_noise.sh │ ├── replace_val.sh │ ├── repvol.sh │ ├── resample.sh │ ├── robustfov.sh │ ├── seg_mask.sh │ ├── show_bvecs.m │ ├── slicesdir.sh │ ├── split4D.sh │ ├── splittxt.sh │ ├── start_FSLNets.sh │ ├── templates │ ├── template_fslcc.m │ ├── template_fslccmean.m │ ├── template_gICA.fsf │ ├── template_makeXfmMatrix.m │ ├── template_nets_examples.m │ ├── template_preprocBOLD.fsf │ └── template_tracula.rc │ ├── textcalc.sh │ ├── thres_z.sh │ ├── tksurfer.sh │ ├── tksurfer_mklabel │ ├── tksurfer_mklabel.label │ ├── topup.sh │ ├── transptxt.sh │ ├── trim4D.sh │ └── unwarp4D.sh ├── run_script.sh └── subj ├── config_acqparams_bold ├── config_acqparams_dwi ├── config_bet_lowb ├── config_bet_magn ├── config_bet_struc0 ├── config_bet_struc1 ├── config_func2highres.reg ├── config_unwarp_bold └── config_unwarp_dwi /globalvars: -------------------------------------------------------------------------------- 1 | ./rsc/scripts/_globalvars -------------------------------------------------------------------------------- /grp/GLM/FS_stats/designs: -------------------------------------------------------------------------------- 1 | doss_tps 2 | -------------------------------------------------------------------------------- /grp/GLM/FS_stats/doss_tps/doss_anova.fsgd: -------------------------------------------------------------------------------- 1 | GroupDescriptorFile 1 2 | Class Subject1 3 | Class Subject2 4 | Class Subject3 5 | Class Subject4 6 | Class Subject5 7 | Class Subject6 8 | Class Subject7 9 | Class Subject8 10 | Class Subject9 11 | Class Subject10 12 | Variables TP1-vs-TP2 TP1-vs-TP3 13 | Input 01a.long.01 Subject1 1 1 14 | Input 01c.long.01 Subject1 -1 0 15 | Input 01e.long.01 Subject1 0 -1 16 | Input 02a.long.02 Subject2 1 1 17 | Input 02c.long.02 Subject2 -1 0 18 | Input 02e.long.02 Subject2 0 -1 19 | Input 03a.long.03 Subject3 1 1 20 | Input 03c.long.03 Subject3 -1 0 21 | Input 03e.long.03 Subject3 0 -1 22 | Input 04a.long.04 Subject4 1 1 23 | Input 04c.long.04 Subject4 -1 0 24 | Input 04e.long.04 Subject4 0 -1 25 | Input 05a.long.05 Subject5 1 1 26 | Input 05c.long.05 Subject5 -1 0 27 | Input 05e.long.05 Subject5 0 -1 28 | Input 06a.long.06 Subject6 1 1 29 | Input 06c.long.06 Subject6 -1 0 30 | Input 06e.long.06 Subject6 0 -1 31 | Input 07a.long.07 Subject7 1 1 32 | Input 07c.long.07 Subject7 -1 0 33 | Input 07e.long.07 Subject7 0 -1 34 | Input 08a.long.08 Subject8 1 1 35 | Input 08c.long.08 Subject8 -1 0 36 | Input 08e.long.08 Subject8 0 -1 37 | Input 09a.long.09 Subject9 1 1 38 | Input 09c.long.09 Subject9 -1 0 39 | Input 09e.long.09 Subject9 0 -1 40 | Input 10a.long.10 Subject10 1 1 41 | Input 10c.long.10 Subject10 -1 0 42 | Input 10e.long.10 Subject10 0 -1 43 | -------------------------------------------------------------------------------- /grp/GLM/FS_stats/doss_tps/doss_global-effect.mtx: -------------------------------------------------------------------------------- 1 | 0 0 0 0 0 0 0 0 0 0 1 0 2 | 0 0 0 0 0 0 0 0 0 0 0 1 3 | -------------------------------------------------------------------------------- /grp/GLM/FS_stats/doss_tps/doss_mean.mtx: -------------------------------------------------------------------------------- 1 | 1 1 1 1 1 1 1 1 1 1 0 0 2 | -------------------------------------------------------------------------------- /grp/GLM/FS_stats/doss_tps/doss_tp1-vs-tp2.mtx: -------------------------------------------------------------------------------- 1 | 0 0 0 0 0 0 0 0 0 0 1 0 2 | -------------------------------------------------------------------------------- /grp/GLM/FS_stats/doss_tps/doss_tp1-vs-tp3.mtx: -------------------------------------------------------------------------------- 1 | 0 0 0 0 0 0 0 0 0 0 0 1 2 | -------------------------------------------------------------------------------- /grp/GLM/FS_stats/doss_tps/doss_tp2-vs-tp3.mtx: -------------------------------------------------------------------------------- 1 | 0 0 0 0 0 0 0 0 0 0 -1 1 2 | -------------------------------------------------------------------------------- /grp/GLM/FS_stats/getlist.cmd: -------------------------------------------------------------------------------- 1 | find ./?* -maxdepth 1 -type d | sort | cut -d / -f 2 | sort > designs 2 | 3 | -------------------------------------------------------------------------------- /grp/GLM/alff: -------------------------------------------------------------------------------- 1 | dualreg/ -------------------------------------------------------------------------------- /grp/GLM/dualreg/designs: -------------------------------------------------------------------------------- 1 | flexfact_func 2 | quintuple_func 3 | -------------------------------------------------------------------------------- /grp/GLM/dualreg/flexfact_func/design(copy).grp: -------------------------------------------------------------------------------- 1 | /NumWaves 1 2 | /NumPoints 50 3 | 4 | /Matrix 5 | 1 6 | 1 7 | 1 8 | 1 9 | 1 10 | 2 11 | 2 12 | 2 13 | 2 14 | 2 15 | 3 16 | 3 17 | 3 18 | 3 19 | 3 20 | 4 21 | 4 22 | 4 23 | 4 24 | 4 25 | 5 26 | 5 27 | 5 28 | 5 29 | 5 30 | 6 31 | 6 32 | 6 33 | 6 34 | 6 35 | 7 36 | 7 37 | 7 38 | 7 39 | 7 40 | 8 41 | 8 42 | 8 43 | 8 44 | 8 45 | 9 46 | 9 47 | 9 48 | 9 49 | 9 50 | 10 51 | 10 52 | 10 53 | 10 54 | 10 55 | -------------------------------------------------------------------------------- /grp/GLM/dualreg/flexfact_func/design.grp: -------------------------------------------------------------------------------- 1 | /NumWaves 1 2 | /NumPoints 50 3 | 4 | /Matrix 5 | 1 6 | 1 7 | 1 8 | 1 9 | 1 10 | 2 11 | 2 12 | 2 13 | 2 14 | 2 15 | 3 16 | 3 17 | 3 18 | 3 19 | 3 20 | 4 21 | 4 22 | 4 23 | 4 24 | 4 25 | 5 26 | 5 27 | 5 28 | 5 29 | 5 30 | 6 31 | 6 32 | 6 33 | 6 34 | 6 35 | 7 36 | 7 37 | 7 38 | 7 39 | 7 40 | 8 41 | 8 42 | 8 43 | 8 44 | 8 45 | 9 46 | 9 47 | 9 48 | 9 49 | 9 50 | 10 51 | 10 52 | 10 53 | 10 54 | 10 55 | -------------------------------------------------------------------------------- /grp/GLM/dualreg/flexfact_func/design.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/grp/GLM/dualreg/flexfact_func/design.png -------------------------------------------------------------------------------- /grp/GLM/dualreg/flexfact_func/design.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/grp/GLM/dualreg/flexfact_func/design.ppm -------------------------------------------------------------------------------- /grp/GLM/dualreg/flexfact_func/design_cov.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/grp/GLM/dualreg/flexfact_func/design_cov.png -------------------------------------------------------------------------------- /grp/GLM/dualreg/flexfact_func/design_cov.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/grp/GLM/dualreg/flexfact_func/design_cov.ppm -------------------------------------------------------------------------------- /grp/GLM/dualreg/get_GlmsPng.cmd: -------------------------------------------------------------------------------- 1 | files=`find ./ -name design.png | sort` 2 | for i in $files ; do echo $i ; done 3 | n=1 4 | montage -tile 1x${n} -mode Concatenate $(find ./ -name design.png | sort) glm.png 5 | 6 | -------------------------------------------------------------------------------- /grp/GLM/dualreg/get_allGlmsPng.cmd: -------------------------------------------------------------------------------- 1 | files=`find ./ -name design.png | sort` 2 | n=`echo $files | wc -w` 3 | n=`echo "$n / 2" | bc -l` 4 | for i in $files ; do echo $i ; done 5 | 6 | montage -tile 1x${n} -mode Concatenate $(find ./ -name design.png | sort) glm_all.png 7 | 8 | -------------------------------------------------------------------------------- /grp/GLM/dualreg/getlist.cmd: -------------------------------------------------------------------------------- 1 | find ./?* -maxdepth 1 -type d | sort | cut -d / -f 2 | sort > designs 2 | 3 | -------------------------------------------------------------------------------- /grp/GLM/dualreg/quintuple_func/design(copy).grp: -------------------------------------------------------------------------------- 1 | /NumWaves 1 2 | /NumPoints 50 3 | 4 | /Matrix 5 | 1 6 | 1 7 | 1 8 | 1 9 | 1 10 | 2 11 | 2 12 | 2 13 | 2 14 | 2 15 | 3 16 | 3 17 | 3 18 | 3 19 | 3 20 | 4 21 | 4 22 | 4 23 | 4 24 | 4 25 | 5 26 | 5 27 | 5 28 | 5 29 | 5 30 | 6 31 | 6 32 | 6 33 | 6 34 | 6 35 | 7 36 | 7 37 | 7 38 | 7 39 | 7 40 | 8 41 | 8 42 | 8 43 | 8 44 | 8 45 | 9 46 | 9 47 | 9 48 | 9 49 | 9 50 | 10 51 | 10 52 | 10 53 | 10 54 | 10 55 | -------------------------------------------------------------------------------- /grp/GLM/dualreg/quintuple_func/design.grp: -------------------------------------------------------------------------------- 1 | /NumWaves 1 2 | /NumPoints 50 3 | 4 | /Matrix 5 | 1 6 | 1 7 | 1 8 | 1 9 | 1 10 | 2 11 | 2 12 | 2 13 | 2 14 | 2 15 | 3 16 | 3 17 | 3 18 | 3 19 | 3 20 | 4 21 | 4 22 | 4 23 | 4 24 | 4 25 | 5 26 | 5 27 | 5 28 | 5 29 | 5 30 | 6 31 | 6 32 | 6 33 | 6 34 | 6 35 | 7 36 | 7 37 | 7 38 | 7 39 | 7 40 | 8 41 | 8 42 | 8 43 | 8 44 | 8 45 | 9 46 | 9 47 | 9 48 | 9 49 | 9 50 | 10 51 | 10 52 | 10 53 | 10 54 | 10 55 | -------------------------------------------------------------------------------- /grp/GLM/dualreg/quintuple_func/design.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/grp/GLM/dualreg/quintuple_func/design.png -------------------------------------------------------------------------------- /grp/GLM/dualreg/quintuple_func/design.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/grp/GLM/dualreg/quintuple_func/design.ppm -------------------------------------------------------------------------------- /grp/GLM/dualreg/quintuple_func/design_cov.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/grp/GLM/dualreg/quintuple_func/design_cov.png -------------------------------------------------------------------------------- /grp/GLM/dualreg/quintuple_func/design_cov.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/grp/GLM/dualreg/quintuple_func/design_cov.ppm -------------------------------------------------------------------------------- /grp/GLM/fslnets: -------------------------------------------------------------------------------- 1 | dualreg/ -------------------------------------------------------------------------------- /grp/GLM/tbss/designs: -------------------------------------------------------------------------------- 1 | flexfact_struc 2 | quintuple_struc 3 | -------------------------------------------------------------------------------- /grp/GLM/tbss/flexfact_struc/design(copy).grp: -------------------------------------------------------------------------------- 1 | /NumWaves 1 2 | /NumPoints 30 3 | 4 | /Matrix 5 | 1 6 | 1 7 | 1 8 | 2 9 | 2 10 | 2 11 | 3 12 | 3 13 | 3 14 | 4 15 | 4 16 | 4 17 | 5 18 | 5 19 | 5 20 | 6 21 | 6 22 | 6 23 | 7 24 | 7 25 | 7 26 | 8 27 | 8 28 | 8 29 | 9 30 | 9 31 | 9 32 | 10 33 | 10 34 | 10 35 | -------------------------------------------------------------------------------- /grp/GLM/tbss/flexfact_struc/design.con: -------------------------------------------------------------------------------- 1 | /ContrastName1 "Adaptation" 2 | /ContrastName2 "Regeneration" 3 | /ContrastName3 "Residual" 4 | /ContrastName4 "-Adaptation" 5 | /ContrastName5 "-Regeneration" 6 | /ContrastName6 "-Residual" 7 | /NumWaves 13 8 | /NumContrasts 6 9 | /PPheights 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 10 | /RequiredEffect 2.566 2.566 2.566 2.566 2.566 2.566 11 | 12 | /Matrix 13 | -1.000000e+00 1.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 14 | 0.000000e+00 -1.000000e+00 1.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 15 | -1.000000e+00 0.000000e+00 1.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 16 | 1.000000e+00 -1.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 17 | 0.000000e+00 1.000000e+00 -1.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 18 | 1.000000e+00 0.000000e+00 -1.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 19 | -------------------------------------------------------------------------------- /grp/GLM/tbss/flexfact_struc/design.grp: -------------------------------------------------------------------------------- 1 | /NumWaves 1 2 | /NumPoints 30 3 | 4 | /Matrix 5 | 1 6 | 1 7 | 1 8 | 2 9 | 2 10 | 2 11 | 3 12 | 3 13 | 3 14 | 4 15 | 4 16 | 4 17 | 5 18 | 5 19 | 5 20 | 6 21 | 6 22 | 6 23 | 7 24 | 7 25 | 7 26 | 8 27 | 8 28 | 8 29 | 9 30 | 9 31 | 9 32 | 10 33 | 10 34 | 10 35 | -------------------------------------------------------------------------------- /grp/GLM/tbss/flexfact_struc/design.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/grp/GLM/tbss/flexfact_struc/design.png -------------------------------------------------------------------------------- /grp/GLM/tbss/flexfact_struc/design.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/grp/GLM/tbss/flexfact_struc/design.ppm -------------------------------------------------------------------------------- /grp/GLM/tbss/flexfact_struc/design.txt: -------------------------------------------------------------------------------- 1 | flexfact_struc.grp -------------------------------------------------------------------------------- /grp/GLM/tbss/flexfact_struc/design_cov.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/grp/GLM/tbss/flexfact_struc/design_cov.png -------------------------------------------------------------------------------- /grp/GLM/tbss/flexfact_struc/design_cov.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/grp/GLM/tbss/flexfact_struc/design_cov.ppm -------------------------------------------------------------------------------- /grp/GLM/tbss/get_GlmsPng.cmd: -------------------------------------------------------------------------------- 1 | files=`find ./ -name design.png | sort` 2 | for i in $files ; do echo $i ; done 3 | n=1 4 | montage -tile 1x${n} -mode Concatenate $(find ./ -name design.png | sort) glm.png 5 | 6 | -------------------------------------------------------------------------------- /grp/GLM/tbss/get_allGlmsPng.cmd: -------------------------------------------------------------------------------- 1 | files=`find ./ -name design.png | sort` 2 | n=`echo $files | wc -w` 3 | n=`echo "$n / 2" | bc -l` 4 | for i in $files ; do echo $i ; done 5 | 6 | montage -tile 1x${n} -mode Concatenate $(find ./ -name design.png | sort) glm_all.png 7 | 8 | -------------------------------------------------------------------------------- /grp/GLM/tbss/getlist.cmd: -------------------------------------------------------------------------------- 1 | find ./?* -maxdepth 1 -type d | sort | cut -d / -f 2 | sort > designs 2 | 3 | -------------------------------------------------------------------------------- /grp/GLM/tbss/quintuple_struc/design(copy).grp: -------------------------------------------------------------------------------- 1 | /NumWaves 1 2 | /NumPoints 30 3 | 4 | /Matrix 5 | 1 6 | 1 7 | 1 8 | 2 9 | 2 10 | 2 11 | 3 12 | 3 13 | 3 14 | 4 15 | 4 16 | 4 17 | 5 18 | 5 19 | 5 20 | 6 21 | 6 22 | 6 23 | 7 24 | 7 25 | 7 26 | 8 27 | 8 28 | 8 29 | 9 30 | 9 31 | 9 32 | 10 33 | 10 34 | 10 35 | -------------------------------------------------------------------------------- /grp/GLM/tbss/quintuple_struc/design.con: -------------------------------------------------------------------------------- 1 | /ContrastName1 "Adaptation" 2 | /ContrastName2 "Regeneration" 3 | /ContrastName3 "Residual" 4 | /ContrastName4 "-Adaptation" 5 | /ContrastName5 "-Regeneration" 6 | /ContrastName6 "-Residual" 7 | /NumWaves 12 8 | /NumContrasts 6 9 | /PPheights 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 1.000000e+00 10 | /RequiredEffect 2.487 2.487 2.487 2.487 2.487 2.487 11 | 12 | /Matrix 13 | -2.000000e+00 -1.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 14 | 1.000000e+00 -1.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 15 | -1.000000e+00 -2.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 16 | 2.000000e+00 1.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 17 | -1.000000e+00 1.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 18 | 1.000000e+00 2.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 19 | -------------------------------------------------------------------------------- /grp/GLM/tbss/quintuple_struc/design.grp: -------------------------------------------------------------------------------- 1 | /NumWaves 1 2 | /NumPoints 30 3 | 4 | /Matrix 5 | 1 6 | 1 7 | 1 8 | 2 9 | 2 10 | 2 11 | 3 12 | 3 13 | 3 14 | 4 15 | 4 16 | 4 17 | 5 18 | 5 19 | 5 20 | 6 21 | 6 22 | 6 23 | 7 24 | 7 25 | 7 26 | 8 27 | 8 28 | 8 29 | 9 30 | 9 31 | 9 32 | 10 33 | 10 34 | 10 35 | -------------------------------------------------------------------------------- /grp/GLM/tbss/quintuple_struc/design.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/grp/GLM/tbss/quintuple_struc/design.png -------------------------------------------------------------------------------- /grp/GLM/tbss/quintuple_struc/design.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/grp/GLM/tbss/quintuple_struc/design.ppm -------------------------------------------------------------------------------- /grp/GLM/tbss/quintuple_struc/design_cov.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/grp/GLM/tbss/quintuple_struc/design_cov.png -------------------------------------------------------------------------------- /grp/GLM/tbss/quintuple_struc/design_cov.ppm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/grp/GLM/tbss/quintuple_struc/design_cov.ppm -------------------------------------------------------------------------------- /grp/GLM/tbss/vbm_template_list: -------------------------------------------------------------------------------- 1 | D02 2 | D06 3 | D07 4 | D12 5 | D14 6 | D18 7 | D20 8 | D21 9 | D23 10 | D25 11 | D26 12 | D27 13 | D28 14 | D31 15 | D32 16 | D33 17 | D50 18 | B01 19 | B02 20 | B03 21 | B04 22 | B05 23 | B06 24 | B07 25 | B08 26 | B09 27 | B10 28 | B11 29 | B12 30 | B13 31 | B14 32 | B15 33 | B16 34 | B17 35 | P02 36 | P03 37 | P04 38 | P05 39 | P06 40 | P07 41 | P08 42 | P10 43 | P11 44 | P13 45 | P14 46 | P15 47 | P16 48 | P17 49 | P18 50 | P19 51 | P36 52 | 53 | -------------------------------------------------------------------------------- /grp/GLM/vbm: -------------------------------------------------------------------------------- 1 | tbss/ -------------------------------------------------------------------------------- /rsc/01_install_sync.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Synchronizes installation (default ~/FSL-scripts) with zipped download from git-hub. 3 | 4 | # Written by Andreas Heckel 5 | # University of Heidelberg 6 | # heckelandreas@googlemail.com 7 | # https://github.com/ahheckel 8 | # 25/03/2014 9 | 10 | trap 'echo "$0 : An ERROR has occured."' ERR 11 | 12 | set -e 13 | 14 | Usage() { 15 | echo "" 16 | echo "Usage: `basename $0` " 17 | echo "Example: `basename $0` Downloads/FSL-scripts-from-github.zip ~/FSL-scripts" 18 | echo " `basename $0` -1 ~/FSL-scripts" 19 | echo "" 20 | exit 1 21 | } 22 | 23 | [ "$1" = "" ] && Usage 24 | 25 | if [ $(echo "$1" | grep \( | wc -l) -gt 0 ] ; then # remove parentheses if present 26 | zipfile=$(dirname "$1")/$(echo $(basename "$1") | sed "s|(.)||g") 27 | mv -i "$1" $zipfile 28 | else 29 | zipfile="$1" 30 | fi 31 | destdir="$2" 32 | if [ x"$destdir" = "x" ] ; then destdir="~/FSL-scripts" ; fi 33 | wd=`pwd` 34 | 35 | # create working dir. 36 | tmpdir=$(mktemp -d -t $(basename $0)_XXXXXXXXXX) # create unique dir. for temporary files 37 | 38 | # define exit trap 39 | trap "rm -f $tmpdir/* ; rmdir $tmpdir ; exit" EXIT 40 | 41 | # check 42 | if [ $(dirname $0 | grep ^\\. | wc -l) -eq 1 ] ; then 43 | echo "$(basename $0): ERROR: Please call with absolute filepath. Note that this script should not be executed within the directory-tree of the framework. Exiting..." 44 | exit 1 45 | fi 46 | 47 | # download github zipball 48 | if [ "$zipfile" = "-1" ] ; then 49 | zipfile="FSL-scripts-github.zip" 50 | wget -O $zipfile https://github.com/ahheckel/FSL-scripts/zipball/master 51 | fi 52 | 53 | # check 54 | if [ ! -f "$zipfile" ] ; then 55 | echo "$(basename $0): ERROR: File '$zipfile' does not exist! Exiting..." 56 | exit 1 57 | fi 58 | 59 | # unzip 60 | cd $(dirname $zipfile) 61 | #folder=${zipfile%.zip} 62 | folder=$(unzip -l $zipfile | awk '{print $4}' | cut -d / -f 1 | sort -u | grep heck) 63 | if [ -d "$folder" ] ; then 64 | read -p "$(basename $0): Press key to delete directory '`pwd`/$folder'..." 65 | rm -r "$folder" 66 | fi 67 | unzip $(basename $zipfile) 68 | cd "$wd" 69 | 70 | # display rsync command 71 | if [ ! -d "$folder" ] ; then 72 | echo "$(basename $0): ERROR: Folder '$folder' does not exist! Exiting..." ; exit 1 73 | else 74 | echo "$(basename $0): Execute:" 75 | echo "rsync -avzb --delete --backup-dir=backup/$(basename $destdir) $folder/ $destdir/" 76 | fi 77 | -------------------------------------------------------------------------------- /rsc/04_install_nautilus-scripts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Written by Andreas Heckel 4 | # University of Heidelberg 5 | # heckelandreas@googlemail.com 6 | # https://github.com/ahheckel 7 | # 03/01/2013 8 | 9 | trap 'echo "$0 : An ERROR has occured."' ERR 10 | 11 | set -e 12 | 13 | Usage() { 14 | echo "" 15 | echo "Usage: `basename $0` " 16 | echo "Example: `basename $0` MRI" 17 | echo " `basename $0` ." 18 | echo "" 19 | exit 1 20 | } 21 | 22 | [ "$1" = "" ] && Usage 23 | 24 | subdir="$1" 25 | cd $(dirname $0) 26 | installdirs="$HOME/.gnome2/nautilus-scripts/$subdir $HOME/.local/share/nautilus/scripts/$subdir" # for old and newer (ubuntu >=14.04, gnome3) nautilus versions 27 | for installdir in $installdirs ; do 28 | mkdir -p $installdir 29 | #cp -sf `pwd`/scripts/nautilus-scripts/* $installdir ; rm $installdir/env_vars # symlinks may not be recognized by some nautilus versions 30 | cp -f `pwd`/scripts/nautilus-scripts/* $installdir ; rm $installdir/env_vars ; chmod u+x $installdir/* 31 | cp `pwd`/scripts/nautilus-scripts/env_vars $installdir 32 | sed -i "s|PATH=.*|PATH=${PATH}|g" $installdir/env_vars 33 | sed -i "s|FSL_DIR=.*|FSL_DIR=${FSLDIR}|g" $installdir/env_vars 34 | sed -i "s|FREESURFER_HOME=.*|FREESURFER_HOME=${FREESURFER_HOME}|g" $installdir/env_vars 35 | sed -i "s|scriptdir=.*|scriptdir=`pwd`/scripts|g" $installdir/env_vars 36 | echo "$(basename $0): scripts installed in '$installdir' - done." 37 | done 38 | 39 | echo "$(basename $0): file 'env_vars' created in installation directory with following content:" 40 | echo "--------------------------------" 41 | cat $installdir/env_vars 42 | echo "--------------------------------" 43 | -------------------------------------------------------------------------------- /rsc/afni/3dDespike_32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/afni/3dDespike_32 -------------------------------------------------------------------------------- /rsc/afni/3dDespike_64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/afni/3dDespike_64 -------------------------------------------------------------------------------- /rsc/afni/3dDetrend_32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/afni/3dDetrend_32 -------------------------------------------------------------------------------- /rsc/afni/3dDetrend_64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/afni/3dDetrend_64 -------------------------------------------------------------------------------- /rsc/afni/3dTcat_32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/afni/3dTcat_32 -------------------------------------------------------------------------------- /rsc/afni/3dTcat_64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/afni/3dTcat_64 -------------------------------------------------------------------------------- /rsc/afni/3dTstat_32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/afni/3dTstat_32 -------------------------------------------------------------------------------- /rsc/afni/3dTstat_64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/afni/3dTstat_64 -------------------------------------------------------------------------------- /rsc/afni/3dcalc_32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/afni/3dcalc_32 -------------------------------------------------------------------------------- /rsc/afni/3dcalc_64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/afni/3dcalc_64 -------------------------------------------------------------------------------- /rsc/fsl/fsl4/tbss_x/swap_subjectwise_32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/fsl4/tbss_x/swap_subjectwise_32 -------------------------------------------------------------------------------- /rsc/fsl/fsl4/tbss_x/swap_subjectwise_64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/fsl4/tbss_x/swap_subjectwise_64 -------------------------------------------------------------------------------- /rsc/fsl/fsl4/tbss_x/swap_voxelwise_32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/fsl4/tbss_x/swap_voxelwise_32 -------------------------------------------------------------------------------- /rsc/fsl/fsl4/tbss_x/swap_voxelwise_64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/fsl4/tbss_x/swap_voxelwise_64 -------------------------------------------------------------------------------- /rsc/fsl/fsl4/topup/applytopup_32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/fsl4/topup/applytopup_32 -------------------------------------------------------------------------------- /rsc/fsl/fsl4/topup/applytopup_64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/fsl4/topup/applytopup_64 -------------------------------------------------------------------------------- /rsc/fsl/fsl4/topup/b02b0.cnf: -------------------------------------------------------------------------------- 1 | # Resolution (knot-spacing) of warps in mm 2 | --warpres=20,16,14,12,10,6,4,4,4 3 | # Subsampling level (a value of 2 indicates that a 2x2x2 neighbourhood is collapsed to 1 voxel) 4 | --subsamp=2,2,2,2,2,1,1,1,1 5 | # FWHM of gaussian smoothing 6 | --fwhm=8,6,4,3,3,2,1,0,0 7 | # Maximum number of iterations 8 | --miter=5,5,5,5,5,10,10,20,20 9 | # Relative weight of regularisation 10 | --lambda=0.005,0.001,0.0001,0.000015,0.000005,0.0000005,0.00000005,0.0000000005,0.00000000001 11 | # If set to 1 lambda is multiplied by the current average squared difference 12 | --ssqlambda=1 13 | # Regularisation model 14 | --regmod=bending_energy 15 | # If set to 1 movements are estimated along with the field 16 | --estmov=1,1,1,1,1,0,0,0,0 17 | # 0=Levenberg-Marquardt, 1=Scaled Conjugate Gradient 18 | --minmet=0,0,0,0,0,1,1,1,1 19 | # Quadratic or cubic splines 20 | --splineorder=3 21 | # Precision for calculation and storage of Hessian 22 | --numprec=double 23 | # Linear or spline interpolation 24 | --interp=spline 25 | # If set to 1 the images are individually scaled to a common mean intensity 26 | --scale=1 -------------------------------------------------------------------------------- /rsc/fsl/fsl4/topup/topup_32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/fsl4/topup/topup_32 -------------------------------------------------------------------------------- /rsc/fsl/fsl4/topup/topup_64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/fsl4/topup/topup_64 -------------------------------------------------------------------------------- /rsc/fsl/fsl5/FSLNets/nets_glm.m: -------------------------------------------------------------------------------- 1 | ../../../scripts/bin/FSLNets/nets_glm.m -------------------------------------------------------------------------------- /rsc/fsl/fsl5/FSLNets/nets_load.m: -------------------------------------------------------------------------------- 1 | ../../../scripts/bin/FSLNets/nets_load.m -------------------------------------------------------------------------------- /rsc/fsl/fsl5/fsl_sub_patched: -------------------------------------------------------------------------------- 1 | fsl_sub_v5.8_patched -------------------------------------------------------------------------------- /rsc/fsl/fsl5/fslmaths5_32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/fsl5/fslmaths5_32 -------------------------------------------------------------------------------- /rsc/fsl/fsl5/fslmaths5_64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/fsl5/fslmaths5_64 -------------------------------------------------------------------------------- /rsc/fsl/templates/MNI152_T1_3mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/MNI152_T1_3mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/MNI152_T1_3mm_brain.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/MNI152_T1_3mm_brain.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/MNI152_T1_4mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/MNI152_T1_4mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/MNI152_T1_4mm_brain.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/MNI152_T1_4mm_brain.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/avg152T1_brain_bin.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/avg152T1_brain_bin.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/avg152T1_csf_bin.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/avg152T1_csf_bin.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/avg152T1_white_bin.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/avg152T1_white_bin.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn10_2mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn10_2mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn10_3mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn10_3mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn10_4mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn10_4mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn10_CSFWM_2mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn10_CSFWM_2mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn10_CSFWM_3mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn10_CSFWM_3mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn10_CSFWM_4mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn10_CSFWM_4mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn10_CSFWM_labels.txt: -------------------------------------------------------------------------------- 1 | MedVisArea 2 | OccipitPole 3 | latVisArea 4 | DMN 5 | Cerebellum 6 | sensomotoric 7 | auditive 8 | executive 9 | rightAttent 10 | leftAttent 11 | CSF 12 | WM 13 | -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn10_labels.txt: -------------------------------------------------------------------------------- 1 | MedVisArea 2 | OccipitPole 3 | latVisArea 4 | DMN 5 | Cerebellum 6 | sensomotoric 7 | auditive 8 | executive 9 | rightAttent 10 | leftAttent 11 | -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn14_2mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn14_2mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn14_3mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn14_3mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn14_4mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn14_4mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn14_CSFWM_2mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn14_CSFWM_2mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn14_CSFWM_3mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn14_CSFWM_3mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn14_CSFWM_4mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn14_CSFWM_4mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn14_CSFWM_labels.txt: -------------------------------------------------------------------------------- 1 | anterior_Salience 2 | Auditory 3 | Basal_Ganglia 4 | dDMN 5 | high_Visual 6 | Language 7 | LECN 8 | post_Salience 9 | Precuneus 10 | prim_Visual 11 | RECN 12 | Sensorimotor 13 | vDMN 14 | Visuospatial 15 | CSF 16 | WM 17 | -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn14_labels.txt: -------------------------------------------------------------------------------- 1 | anterior_Salience 2 | Auditory 3 | Basal_Ganglia 4 | dDMN 5 | high_Visual 6 | Language 7 | LECN 8 | post_Salience 9 | Precuneus 10 | prim_Visual 11 | RECN 12 | Sensorimotor 13 | vDMN 14 | Visuospatial 15 | -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn8_2mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn8_2mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn8_3mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn8_3mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn8_4mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn8_4mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn8_CSFWM_2mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn8_CSFWM_2mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn8_CSFWM_3mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn8_CSFWM_3mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn8_CSFWM_4mm.nii.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn8_CSFWM_4mm.nii.gz -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn8_CSFWM_labels.txt: -------------------------------------------------------------------------------- 1 | MedVisArea 2 | OccipitPole 3 | auditive 4 | sensomotoric 5 | DMN 6 | executive 7 | rightAttent 8 | leftAttent 9 | CSF 10 | WM 11 | -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn8_labels.txt: -------------------------------------------------------------------------------- 1 | MedVisArea 2 | OccipitPole 3 | auditive 4 | sensomotoric 5 | DMN 6 | executive 7 | rightAttent 8 | leftAttent 9 | -------------------------------------------------------------------------------- /rsc/fsl/templates/rsn_labels.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/fsl/templates/rsn_labels.xls -------------------------------------------------------------------------------- /rsc/readme: -------------------------------------------------------------------------------- 1 | Modifications of original FSL / Freesurfer files. 2 | 3 | All modifications are indicated in the respective files (HKL). 4 | 5 | 6 | fsl/fsl4/featlib_v4.tcl 7 | ----------------------- 8 | Cross-modal affine registrations use mutualinfo (rather than corratio) as cost-function. 9 | Unwarping: +/- y unwarp example files are created. 10 | Only for use with FSL 4.9.1. 11 | 12 | 13 | fsl/fsl5/fsl_sub_v5_patched 14 | --------------------------- 15 | RAM limit added & JOB-IDs are written to file for better job control. 16 | 17 | 18 | fsl/fsl5/fslmaths5 19 | --------------------- 20 | Allows for filling holes in binary Freesurfer masks (32/64bit). 21 | 22 | 23 | fsl/FSLNets/nets_glm.m 24 | fsl/FSLNets/nets_load.m 25 | ----------------------- 26 | Adapted to work with FSL 4.9.1 and this framework. 27 | 28 | 29 | fsl/templates 30 | ------------- 31 | Added multi-resolution MNI152 templates, the Smith & Beckmann templates and CSF & WM masks. 32 | 33 | 34 | scripts/fsl_sub_NOPOSIXLY.sh 35 | ---------------------------- 36 | Adapted to run with Freesurfer. 37 | 38 | 39 | scripts/dualreg.sh 40 | ------------------ 41 | i) sections (mask / dualreg / randomise) can be called separately. 42 | ii) insert exchangeability block file in randomise call & voxel-wise stats. 43 | iii) naming of randomise results based on the name of the design used. 44 | iv) delete ${LOGDIR}/dr[ABCD] cmd-file to avoid accumulation on re-run. 45 | v) high-pass filtered motion parameters can be used for dr_stage2. 46 | vi) randomise_parallel or randomise can be used. 47 | vii) f-tests are considered. 48 | 49 | 50 | scripts/longt_tbss_2_reg.sh 51 | --------------------------- 52 | FLIRT is initialised with transform b0->T1->MNI, where T1 is the unbiased template of the Freesurfer longit. stream, 53 | and b0->T1 is done via Freesurfer's bbregister. 54 | 55 | 56 | scripts/bin/sort8 57 | ----------------- 58 | Allows for natural sort of (version) numbers within text (32/64bit). 59 | 60 | ----- 61 | Notes. 62 | The FSL-scripts folder must be exportet and mounted on all nodes. 63 | "recon-all -use-mritotal" may give better talairach registrations in some cases. 64 | -------------------------------------------------------------------------------- /rsc/scripts/ICAcleanup.m: -------------------------------------------------------------------------------- 1 | % Written by Andreas Heckel 2 | % University of Heidelberg 3 | % heckelandreas@googlemail.com 4 | % https://github.com/ahheckel 5 | % 02/20/2014 6 | 7 | RSN_idx=1:14; 8 | CSF_idx=15; 9 | GM_idx=16; 10 | WM_idx=17; 11 | MT_idx=18; 12 | mask='./mask'; 13 | melodic_IC='./melodic_IC_3mm.nii.gz'; 14 | melodic_mix='./melodic_mix'; 15 | movpar='./movpar'; 16 | template='/usr/share/fsl/5.0/data/standard/rsn14_CSFGMWMMN_3mm.nii.gz'; 17 | funcIN='../test'; 18 | funcOut='../filtered_func_data_ICAdn'; 19 | 20 | system(sprintf('fslcc -m %s %s %s > /tmp/cc', mask, template, melodic_IC)) 21 | [a,b]=system(sprintf('fslnvols %s',melodic_IC)) 22 | nvols=str2num(b); 23 | 24 | table=load('/tmp/cc'); 25 | mix=load(melodic_mix); 26 | mc=load(movpar); 27 | RR=table(:,3).^2; 28 | ic=table(:,2); 29 | icT=table(:,1); 30 | 31 | RSN=[]; 32 | CSF=[]; 33 | WM=[]; 34 | noGM=[]; 35 | MT=[]; 36 | motion=[]; 37 | 38 | for i=1:nvols 39 | idx=(ic==i); 40 | if max(RR(idx))>0.02 41 | RSN=[RSN, i]; 42 | end 43 | end 44 | 45 | for i=CSF_idx 46 | idx=(icT==i); 47 | if max(RR(idx))>0.05 48 | CSF=[CSF, i]; 49 | end 50 | end 51 | 52 | for i=WM_idx 53 | idx=(icT==i); 54 | if max(RR(idx))>0.02 55 | WM=[WM, i]; 56 | end 57 | end 58 | 59 | for i=GM_idx 60 | idx=(icT==i); 61 | if min(RR(idx))<0.001 62 | noGM=[noGM, i]; 63 | end 64 | end 65 | 66 | for i=MT_idx 67 | idx=(icT==i); 68 | if min(RR(idx))>0.01 69 | MT=[MT, i]; 70 | end 71 | end 72 | 73 | for i=1:nvols 74 | for j=1:length(size(mc,2)) 75 | [r,p]=corr(mc(:,j),mix(:,i)) 76 | if p<0.01 77 | motion=[motion, i]; 78 | break 79 | end 80 | end 81 | end 82 | 83 | good=[]; 84 | bad=[]; 85 | for i=1:nvols 86 | if sum(RSN(RSN==i)) > 0 87 | good=[good,i]; 88 | elseif sum(CSF(CSF==i)) > 0 89 | bad=[bad,i]; 90 | elseif sum(WM(WM==i)) > 0 91 | bad=[bad,i]; 92 | elseif sum(noGM(noGM==i)) > 0 93 | bad=[bad,i]; 94 | elseif sum(motion(motion==i)) > 0 95 | bad=[bad,i]; 96 | elseif sum(MT(MT==i)) > 0 97 | bad=[bad,i]; 98 | else 99 | good=[good,i]; 100 | end 101 | end 102 | 103 | disp('CSF:') 104 | disp(CSF) 105 | disp('noGM:') 106 | disp(noGM) 107 | disp('WM:') 108 | disp(WM) 109 | disp('MT:') 110 | disp(MT) 111 | disp('good:') 112 | disp(good) 113 | disp('bad:') 114 | disp(bad) 115 | 116 | bad_str=''; 117 | for i=bad 118 | bad_str=[bad_str, ',', num2str(i)]; 119 | end 120 | bad_str=bad_str(2:end); 121 | 122 | system(sprintf('fsl_regfilt -i %s -d %s -f %s -o %s',funcIN, melodic_mix, bad_str, funcOut)) 123 | 124 | system('rm -f /tmp/cc') 125 | 126 | -------------------------------------------------------------------------------- /rsc/scripts/LIA_to_LAS_conformed.mat: -------------------------------------------------------------------------------- 1 | 1 0 0 -37 2 | 0 0 1 -19 3 | 0 -1 0 219 4 | 0 0 0 1 5 | -------------------------------------------------------------------------------- /rsc/scripts/_check_progs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # For internal use only. 3 | 4 | # are all required progs / files installed ? 5 | echo "`basename $0` : checking for required progs..." 6 | progs="$FSLDIR/bin/tbss_x $FSLDIR/bin/swap_voxelwise $FSLDIR/bin/swap_subjectwise $FREESURFER_HOME/bin/trac-all $FSLDIR/etc/flirtsch/b02b0.cnf $FSLDIR/bin/topup $FSLDIR/bin/applytopup $FSLDIR/data/standard/avg152T1_white_bin.nii.gz $FSLDIR/data/standard/avg152T1_csf_bin.nii.gz" 7 | for prog in $progs ; do 8 | if [ ! -f $prog ] ; then echo "`basename $0` : ERROR : '$prog' is not installed. Exiting." ; exit 1 ; fi 9 | done 10 | for prog in xterm octave mktemp dos2unix paste sed awk diff touch tar ; do 11 | if [ x$(which $prog) = "x" ] ; then echo "`basename $0` : ERROR : '$prog' does not seem to be installed on your system ! Exiting..." ; exit 1 ; fi 12 | done 13 | 14 | # is sh linked to bash ? 15 | if [ ! -z $(which sh) ] ; then 16 | if [ $(basename $(readlink `which sh`)) != "bash" ] ; then read -p "WARNING : 'sh' is linked to $(readlink `which sh`), but should be linked to 'bash' for fsl compatibility. Press key to continue or abort with CTRL-C." ; fi 17 | fi 18 | 19 | # done. 20 | echo "`basename $0` : ...done." 21 | -------------------------------------------------------------------------------- /rsc/scripts/_mask_softtissue.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | trap 'echo "$0 : An ERROR has occured." ; exit 1' ERR 4 | 5 | set -e 6 | 7 | Usage() { 8 | echo "" 9 | echo "Usage: `basename $0` " 10 | echo "Example: `basename $0` b0 nerve-mask soft-mask" 11 | echo "" 12 | exit 1 13 | } 14 | 15 | [ "$3" = "" ] && Usage 16 | 17 | b0="$(remove_ext $1)" 18 | mask="$(remove_ext $2)" 19 | softmask="$3" 20 | 21 | # fsl ver. 22 | fslversion=$(cat $FSLDIR/etc/fslversion) 23 | 24 | 25 | # display info 26 | echo "---------------------------" 27 | echo "`basename $0` : fsl V.: $fslversion" 28 | echo "`basename $0` : input: $b0" 29 | echo "`basename $0` : nerve-mask: $mask" 30 | echo "`basename $0` : soft-mask: $softmask" 31 | echo "---------------------------" 32 | 33 | # create working dir. 34 | tmpdir=$(mktemp -d -t $(basename $0)_XXXXXXXXXX) # create unique dir. for temporary files 35 | 36 | # define exit trap 37 | trap "rm -f $tmpdir/* ; rmdir $tmpdir ; exit" EXIT 38 | 39 | # make soft tissue mask (outside nerve) 40 | imcp $b0 $tmpdir/ 41 | bet $tmpdir/$(basename $b0) $tmpdir/b0_bet -f 0.1 -m 42 | fslmaths $tmpdir/b0_bet_mask -sub $mask -thr 0 $softmask 43 | 44 | echo "`basename $0` : done." 45 | -------------------------------------------------------------------------------- /rsc/scripts/annotquery_label.m: -------------------------------------------------------------------------------- 1 | function f = annotquery_label(labelfiles, annotfile, out) 2 | 3 | % Written by Andreas Heckel 4 | % University of Freiburg 5 | % heckelandreas@googlemail.com 6 | % https://github.com/ahheckel 7 | % 05/18/2015 8 | 9 | %% commented variables below are replaced by shell-script 10 | % labelfiles=LABELS; 11 | % annotfile=ANNOT; 12 | % out=OUT; 13 | 14 | % 15 | % if(nargin ~= 3) 16 | % fprintf('l = annotquery_label(labelfiles, annotfile, out)\n'); 17 | % return; 18 | % end 19 | 20 | % delete existing output file 21 | system(sprintf('rm -f %s', out)); 22 | 23 | % open output file 24 | fid=fopen(out, 'a'); 25 | 26 | % read annotation 27 | [v,l,c]=read_annotation(annotfile,0); 28 | 29 | % write headings 30 | fprintf(fid,'input\t anat\t n_input/n_anat*100\t n_anat/n_input*100\n'); 31 | 32 | % for each labelfile... 33 | for k=1:length(labelfiles) 34 | labelfile=labelfiles{k}; 35 | 36 | % read label 37 | v_l=readlabel(labelfile); % Freesurfer's read_label.m was adapted by HKL to accept filepath as argument 38 | 39 | % 0-based -> 1-based indices 40 | v_l=v_l(:,1)+1; 41 | idx_l=zeros(length(v),1); 42 | idx_l(v_l)=1; 43 | 44 | % cycle through anatomical labels 45 | j=0; 46 | for i=1:c.numEntries 47 | struct_id=c.table(i,5); 48 | idx_s=l==struct_id; 49 | idx=idx_l & idx_s; 50 | prop(i)=sum(idx)/sum(idx_l); 51 | propinv(i)=sum(idx)/sum(idx_s); 52 | if prop(i) > 0 53 | j=j+1; 54 | lfiles{j}=labelfile; 55 | props(j)=prop(i); 56 | propinvs(j)=propinv(i); 57 | annots{j}=c.struct_names{i}; 58 | end 59 | end 60 | 61 | % sort (highest percentage first) 62 | [props, idx]=sort(props, 'descend'); 63 | propinvs=propinvs(idx); 64 | lfiles=lfiles(idx); 65 | annots=annots(idx); 66 | 67 | % output 68 | for i=1:j 69 | fprintf(fid,'%s: %s: %5.1f %5.1f\n', lfiles{i}, annots{i}, props(i)*100, propinvs(i)*100); 70 | end 71 | fprintf(fid,'%s: undefined: %5.1f\n', lfiles{i}, 100-sum(props)*100); 72 | end 73 | 74 | % display output 75 | system(sprintf('cat %s', out)); 76 | 77 | % close output file 78 | fclose(fid); 79 | 80 | % EXIT; 81 | end 82 | 83 | function l = readlabel(lname) 84 | 85 | l = [] ; 86 | fname = sprintf('%s', lname) ; 87 | 88 | fid = fopen(fname, 'r') ; 89 | if(fid == -1) 90 | fprintf('ERROR: could not open %s\n',fname); 91 | return; 92 | end 93 | 94 | fgets(fid) ; 95 | 96 | if(fid == -1) 97 | fprintf('ERROR: could not open %s\n',fname); 98 | return; 99 | end 100 | 101 | line = fgets(fid) ; 102 | nv = sscanf(line, '%d') ; 103 | l = fscanf(fid, '%d %f %f %f %f\n') ; 104 | l = reshape(l, 5, nv) ; 105 | l = l' ; 106 | 107 | fclose(fid) ; 108 | end 109 | -------------------------------------------------------------------------------- /rsc/scripts/annotquery_sig.m: -------------------------------------------------------------------------------- 1 | function f = annotquery_sig(sigfiles, annotfile, tval, out) 2 | 3 | % Written by Andreas Heckel 4 | % University of Freiburg 5 | % heckelandreas@googlemail.com 6 | % https://github.com/ahheckel 7 | % 05/20/2015 8 | 9 | %% commented variables below are replaced by shell-script 10 | % sigfiles=SIGFILES; 11 | % annotfile=ANNOT; 12 | % out=OUT; 13 | % tval=TVAL; 14 | 15 | % sigfiles={'/home/andi/projects/biller/testsig.mgh','/home/andi/projects/biller/testsig.mgh'}; 16 | % annotfile='/usr/local/freesurfer/subjects/fsaverage/label/lh.aparc.a2009s.annot'; 17 | % out='test.txt'; 18 | % tval=-1.5 ; 19 | 20 | 21 | % if(nargin ~= 4) 22 | % fprintf('l = annotquery_sig(sigfiles, annotfile, val, out)\n'); 23 | % return; 24 | % end 25 | 26 | % delete existing output file 27 | system(sprintf('rm -f %s', out)); 28 | 29 | % open output file 30 | fid=fopen(out, 'a'); 31 | 32 | % read annotation 33 | [v,l,c]=read_annotation(annotfile,0); 34 | 35 | % write headings 36 | fprintf(fid,'input\t anat\t n_input/n_anat*100\t n_anat/n_input*100\t tval \t\n'); 37 | 38 | % for each sigfile... 39 | for k=1:length(sigfiles) 40 | sigfile=sigfiles{k}; 41 | 42 | %read label 43 | v_l=load_mgh(sigfile); 44 | 45 | % create index vector 46 | if sign(tval)>=0 47 | idx_l=v_l>=tval; 48 | elseif sign(tval)<0 49 | idx_l=v_l<=tval; 50 | end 51 | 52 | % cycle through anatomical labels 53 | j=0; 54 | for i=1:c.numEntries 55 | struct_id=c.table(i,5); 56 | idx_s=l==struct_id; 57 | idx=idx_l & idx_s; 58 | prop(i)=sum(idx)/sum(idx_l); 59 | propinv(i)=sum(idx)/sum(idx_s); 60 | if prop(i) > 0 61 | j=j+1; 62 | lfiles{j}=sigfile; 63 | props(j)=prop(i); 64 | propinvs(j)=propinv(i); 65 | annots{j}=c.struct_names{i}; 66 | end 67 | end 68 | 69 | % sort (highest percentage first) 70 | [props, idx]=sort(props, 'descend'); 71 | propinvs=propinvs(idx); 72 | lfiles=lfiles(idx); 73 | annots=annots(idx); 74 | 75 | % output 76 | for i=1:j 77 | fprintf(fid,'%s: %s: %5.1f %5.1f %6.2f\n', lfiles{i}, annots{i}, props(i)*100, propinvs(i)*100, tval); 78 | end 79 | fprintf(fid,'%s: undefined: %5.1f\n', sigfile, 100-sum(props)*100); 80 | end 81 | 82 | % display output 83 | system(sprintf('cat %s', out)); 84 | 85 | % close output file 86 | fclose(fid); 87 | 88 | % EXIT; 89 | end 90 | -------------------------------------------------------------------------------- /rsc/scripts/apply_mc+reg2MNI.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Applies motion-correction and stereotactic registration to 4D. 3 | 4 | # Written by Andreas Heckel 5 | # University of Heidelberg 6 | # heckelandreas@googlemail.com 7 | # https://github.com/ahheckel 8 | # 12/25/2012 9 | 10 | trap 'echo "$0 : An ERROR has occured."' ERR 11 | 12 | set -e 13 | 14 | Usage() { 15 | echo "" 16 | echo "Usage: `basename $0` [] []" 17 | echo "" 18 | echo "Example: `basename $0` bold mni_bold ./mc/prefiltered_func_data_mcf.mat/ ./reg/example_func2highres.mat ./reg/highres2standard_warp.nii.gz" 19 | echo " `basename $0` diff mni_diff ./diff.ecclog none ./reg/highres2standard_warp.nii.gz nn" 20 | echo " `basename $0` diff mni_diff ./matrix.mat none ./reg/highres2standard_warp.nii.gz spline" 21 | echo " `basename $0` diff mni_diff none ./reg/example_func2highres.mat ./reg/highres2standard_warp.nii.gz spline" 22 | echo " `basename $0` bold mni_bold ./mc/prefiltered_func_data_mcf.mat/ ./reg/example_func2highres.mat ./reg/highres2standard_warp.nii.gz trilinear" 23 | echo " `basename $0` bold T1_bold ./mc/prefiltered_func_data_mcf.mat/ none ./reg/func2highres_warp.nii.gz spline reg/highres.nii.gz" 24 | echo "" 25 | exit 1 26 | } 27 | 28 | [ "$5" = "" ] && Usage 29 | 30 | # define vars 31 | input=`remove_ext "$1"` 32 | output=`remove_ext "$2"` 33 | mcdir="$3" 34 | f2t1_mat="$4" 35 | f2mni_warp=`remove_ext "$5"` 36 | interp="$6" 37 | if [ x"$interp" = "x" ] ; then interp="trilinear" ; fi 38 | ref=`remove_ext "$7"` 39 | if [ x"$ref" = "x" ] ; then ref="${FSLDIR}/data/standard/MNI152_T1_2mm_brain" ; fi 40 | 41 | # calling function 42 | cmd="$(dirname $0)/apply_mc+unwarp+reg2MNI.sh $input $output $mcdir none 00 $f2t1_mat $f2mni_warp $interp $ref" 43 | 44 | # display info 45 | echo "`basename $0` : executing:" 46 | echo " $cmd" 47 | $cmd 48 | 49 | echo "`basename $0` : done." 50 | -------------------------------------------------------------------------------- /rsc/scripts/apply_mc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Applies motion-correction to 4D. 3 | 4 | # Written by Andreas Heckel 5 | # University of Heidelberg 6 | # heckelandreas@googlemail.com 7 | # https://github.com/ahheckel 8 | # 12/25/2012 9 | 10 | trap 'echo "$0 : An ERROR has occured."' ERR 11 | 12 | set -e 13 | 14 | Usage() { 15 | echo "" 16 | echo "Usage: `basename $0` []" 17 | echo "" 18 | echo "Example: `basename $0` bold mc_bold ./mc/prefiltered_func_data_mcf.mat/ spline" 19 | echo " `basename $0` bold mc_bold ./matrix.mat sinc" 20 | echo " `basename $0` diff mc_diff ./diff.ecclog trilinear" 21 | echo "" 22 | exit 1 23 | } 24 | 25 | [ "$3" = "" ] && Usage 26 | 27 | # define vars 28 | input=`remove_ext "$1"` 29 | output=`remove_ext "$2"` 30 | mcdir="$3" 31 | interp="$4" 32 | if [ x"$interp" = "x" ] ; then interp="trilinear" ; fi 33 | 34 | # calling function 35 | cmd="$(dirname $0)/apply_mc+unwarp.sh $input $output $mcdir none 00 $interp" 36 | 37 | # display info 38 | echo "`basename $0` : executing:" 39 | echo " $cmd" 40 | $cmd 41 | 42 | echo "`basename $0` : done." 43 | -------------------------------------------------------------------------------- /rsc/scripts/apply_unwarp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Applies unwarp-shiftmap to 4D. 3 | 4 | # Written by Andreas Heckel 5 | # University of Heidelberg 6 | # heckelandreas@googlemail.com 7 | # https://github.com/ahheckel 8 | # 11/18/2012 9 | 10 | trap 'echo "$0 : An ERROR has occured."' ERR 11 | 12 | set -e 13 | 14 | Usage() { 15 | echo "" 16 | echo "Usage: `basename $0` []" 17 | echo "Example: `basename $0` bold uw_bold ./unwarp/EF_UD_shift.nii.gz y spline" 18 | echo "" 19 | exit 1 20 | } 21 | 22 | [ "$4" = "" ] && Usage 23 | 24 | input=`remove_ext "$1"` 25 | output=`remove_ext "$2"` 26 | shiftmap=`remove_ext "$3"` 27 | uwdir="$4" 28 | interp="$5" 29 | if [ x"$interp" = "x" ] ; then interp="trilinear" ; fi 30 | 31 | echo "`basename $0` : applying shiftmap..." 32 | 33 | nvol=`fslinfo $input | grep ^dim4 | awk '{print $2}'` 34 | mid=$(echo "scale=0 ; $nvol / 2" | bc) 35 | fslroi $input ${output}_example_func $mid 1 36 | 37 | cmd="convertwarp --ref=${output}_example_func --shiftmap=${shiftmap} --shiftdir=${uwdir} --out=${output}_WARP1 --relout" 38 | echo $cmd 39 | $cmd 40 | 41 | cmd="applywarp --ref=${output}_example_func --in=${input} --warp=${output}_WARP1 --rel --out=${output} --interp=${interp}" 42 | echo $cmd 43 | $cmd 44 | 45 | imrm ${output}_example_func 46 | imrm ${output}_WARP1 47 | 48 | echo "`basename $0` : done." 49 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/L1precision/L1precisionBCD.m: -------------------------------------------------------------------------------- 1 | function [X] = L1precisionBCD(sigma_emp,lambda) 2 | 3 | if nargin < 3 4 | useQP = 1; 5 | end 6 | 7 | verbose = 1; 8 | optTol = 0.00001; 9 | S = sigma_emp; 10 | p = size(S,1); 11 | row = lambda; 12 | maxIter = 10; 13 | A = [eye(p-1,p-1);-eye(p-1,p-1)]; 14 | f = zeros(p-1,1); 15 | 16 | % Initial W 17 | W = S + row*eye(p,p); 18 | 19 | % Check for qp mex file 20 | if exist('qpas') == 3 21 | useQP = 1; 22 | qpSolver = @qpas; 23 | qpArgs = {[],[],[],[]}; 24 | elseif 1 25 | useQP = 0; 26 | else 27 | useQP = 1; 28 | qpSolver = @quadprog; 29 | options = optimset('LargeScale','off','Display','none'); 30 | qpArgs = {[],[],[],[],[],options}; 31 | end 32 | 33 | for iter = 1:maxIter 34 | 35 | % Check Primal-Dual gap 36 | X = W^-1; % W should be PD 37 | gap = trace(S*X) + row*sum(sum(abs(X))) - p; 38 | fprintf('Iter = %d, OptCond = %.5f\n',iter,gap); 39 | if gap < optTol 40 | fprintf('Solution Found\n'); 41 | break; 42 | end 43 | 44 | for i = 1:p 45 | 46 | if verbose 47 | X = W^-1; % W should be PD 48 | gap = trace(S*X) + row*sum(sum(abs(X))) - p; 49 | fprintf('Column = %d, OptCond = %.5f\n',i,gap); 50 | if gap < optTol 51 | fprintf('Solution Found\n'); 52 | break; 53 | end 54 | end 55 | 56 | % Compute Needed Partitions of W and S 57 | s_12 = S(mysetdiff(1:p,i),i); 58 | 59 | if useQP 60 | % Solve as QP 61 | H = 2*W(mysetdiff(1:p,i),mysetdiff(1:p,i))^-1; 62 | b = row*ones(2*(p-1),1) + [s_12;-s_12]; 63 | w = qpSolver((H+H')/2,f,A,b,qpArgs{:}); 64 | else 65 | % Solve with Shooting 66 | W_11 = W(mysetdiff(1:p,i),mysetdiff(1:p,i)); 67 | Xsub = sqrtm(W_11); 68 | ysub = Xsub\s_12; 69 | w = W_11*LassoShooting(Xsub,ysub,2*row,'verbose',0); 70 | end 71 | 72 | % Un-Permute 73 | W(mysetdiff(1:p,i),i) = w; 74 | W(i,mysetdiff(1:p,i)) = w'; 75 | end 76 | %drawnow 77 | end -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/L1precision/LassoShooting.m: -------------------------------------------------------------------------------- 1 | function [w,wp,m] = LassoShooting(X, y, lambda,varargin) 2 | % This function computes the Least Squares parameters 3 | % with a penalty on the L1-norm of the parameters 4 | % 5 | % Method used: 6 | % The Shooting method of [Fu, 1998] 7 | % 8 | % Modifications: 9 | % We precompute the Hessian diagonals, since they do not 10 | % change between iterations 11 | [maxIter,verbose,optTol,zeroThreshold] = process_options(varargin,'maxIter',10000,'verbose',2,'optTol',1e-5,'zeroThreshold',1e-4); 12 | [n p] = size(X); 13 | 14 | % Start from the Least Squares solution 15 | beta = (X'*X + lambda*eye(p))\(X'*y); 16 | % Start the log 17 | if verbose==2 18 | w_old = beta; 19 | fprintf('%10s %10s %15s %15s %15s\n','iter','shoots','n(w)','n(step)','f(w)'); 20 | k=1; 21 | wp = beta; 22 | end 23 | 24 | m = 0; 25 | 26 | XX2 = X'*X*2; 27 | Xy2 = X'*y*2; 28 | while m < maxIter 29 | 30 | 31 | 32 | beta_old = beta; 33 | for j = 1:p 34 | 35 | % Compute the Shoot and Update the variable 36 | S0 = sum(XX2(j,:)*beta) - XX2(j,j)*beta(j) - Xy2(j); 37 | if S0 > lambda 38 | beta(j,1) = (lambda - S0)/XX2(j,j); 39 | elseif S0 < -lambda 40 | beta(j,1) = (-lambda - S0)/XX2(j,j); 41 | elseif abs(S0) <= lambda 42 | beta(j,1) = 0; 43 | end 44 | 45 | end 46 | 47 | m = m + 1; 48 | 49 | % Update the log 50 | if verbose==2 51 | fprintf('%10d %10d %15.2e %15.2e %15.2e\n',m,m*p,sum(abs(beta)),sum(abs(beta-w_old)),... 52 | sum((X*beta-y).^2)+lambda*sum(abs(beta))); 53 | w_old = beta; 54 | k=k+1; 55 | wp(:,k) = beta; 56 | end 57 | % Check termination 58 | if sum(abs(beta-beta_old)) < optTol 59 | break; 60 | end 61 | 62 | 63 | end 64 | if verbose 65 | fprintf('Number of iterations: %d\nTotal Shoots: %d\n',m,m*p); 66 | end 67 | w = beta; 68 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/L1precision/example_L1precision.m: -------------------------------------------------------------------------------- 1 | load 20news_w100 2 | docs = double(documents); 3 | sigma = full(docs*docs');%/16242; 4 | AM = L1precisionBCD(sigma,1); 5 | AM(abs(AM) < 1e-4) = 0; 6 | AM2 = sign(AM); 7 | drawGraph(abs(AM2),'labels',wordlist); -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/L1precision/mysetdiff.m: -------------------------------------------------------------------------------- 1 | function C = mysetdiff(A,B) 2 | % MYSETDIFF Set difference of two sets of positive integers (much faster than built-in setdiff) 3 | % C = mysetdiff(A,B) 4 | % C = A \ B = { things in A that are not in B } 5 | % 6 | % Original by Kevin Murphy, modified by Leon Peshkin 7 | 8 | if isempty(A) 9 | C = []; 10 | return; 11 | elseif isempty(B) 12 | C = A; 13 | return; 14 | else % both non-empty 15 | bits = zeros(1, max(max(A), max(B))); 16 | bits(A) = 1; 17 | bits(B) = 0; 18 | C = A(logical(bits(A))); 19 | end 20 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/README: -------------------------------------------------------------------------------- 1 | 2 | %%% FSLNets v0.6.2 3 | %%% FMRIB Analysis Group 4 | %%% Copyright (C) 2012-2014 University of Oxford 5 | %%% Licence is same as FSL licence 6 | %%% See documentation at http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FSLNets 7 | 8 | %%%%%%%%%% list of backwards incompatibilities from v0.4 to v0.5 9 | nets_pics renamed to nets_nodepics 10 | nets_consistency renamed to nets_groupmean 11 | nets_makemats and nets_r2z/nets_r2z_icov have all been merged to form a new function nets_netmats 12 | 13 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/netjs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | FSLNets interactive netmat visualisation - Paul McCarthy, FMRIB 4 | 5 | 6 | ... back to main index          7 | FSLNets interactive netmat visualisation

8 | 9 |

10 |
11 |
12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/netjs/js/lib/LICENSE.d3.js: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2014, Michael Bostock 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * The name Michael Bostock may not be used to endorse or promote products 15 | derived from this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT, 21 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 22 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/netjs/js/lib/queue.js: -------------------------------------------------------------------------------- 1 | !function(){function n(n){function e(){for(;i=ap;){var u=a++,e=c[u],o=t.call(e,1);o.push(l(u)),++p,e[0].apply(null,o)}}function l(n){return function(u,t){--p,null==s&&(null!=u?(s=u,a=d=0/0,o()):(c[n]=t,--d?i||e():o()))}}function o(){null!=s?m(s):f?m(s,c):m.apply(null,[s].concat(c))}var r,i,f,c=[],a=0,p=0,d=0,s=null,m=u;return n||(n=1/0),r={defer:function(){return s||(c.push(arguments),++d,e()),r},await:function(n){return m=n,f=!1,d||o(),r},awaitAll:function(n){return m=n,f=!0,d||o(),r}}}function u(){}var t=[].slice;n.version="1.0.7","function"==typeof define&&define.amd?define(function(){return n}):"object"==typeof module&&module.exports?module.exports=n:this.queue=n}(); -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/netjs/js/main.js: -------------------------------------------------------------------------------- 1 | require(["netjs", "lib/d3"], function(netjs, d3) { 2 | 3 | function thresholdMatrix(matrix, args) { 4 | 5 | var thresPerc = args[0]; 6 | 7 | var thresMatrix = []; 8 | var nodeThress = []; 9 | 10 | for (var i = 0; i < matrix.length; i++) { 11 | absVals = matrix[i].map(function(val) {return Math.abs(val);}); 12 | nodeThress.push(d3.max(absVals) * thresPerc); 13 | } 14 | 15 | for (var i = 0; i < matrix.length; i++) { 16 | 17 | thresMatrix.push([]); 18 | 19 | for (var j = 0; j < matrix[i].length; j++) { 20 | 21 | if (Math.abs(matrix[i][j]) < nodeThress[i] || 22 | Math.abs(matrix[i][j]) < nodeThress[j]) 23 | 24 | thresMatrix[i].push(Number.NaN); 25 | else 26 | thresMatrix[i].push(matrix[i][j]); 27 | } 28 | } 29 | 30 | return thresMatrix; 31 | } 32 | 33 | var args = {}; 34 | args.matrices = ["data/dataset1/Znet1.txt", "data/dataset1/Znet2.txt"]; 35 | args.matrixLabels = ["Full Correlation", "Partial"]; 36 | args.nodeData = ["data/dataset1/clusters.txt"]; 37 | args.nodeDataLabels = ["Cluster number"]; 38 | args.linkage = "data/dataset1/linkages.txt"; 39 | args.thumbnails = "data/dataset1/melodic_IC_sum.sum"; 40 | args.thresFunc = thresholdMatrix; 41 | args.thresVals = [0.75]; 42 | args.thresLabels = ["Threshold percentage"]; 43 | args.thresholdIdx = 0; 44 | args.numClusters = 10; 45 | 46 | // args.matrices = ["data/dummy/corr1.txt", "data/dummy/corr2.txt"]; 47 | // args.matrixLabels = ["Corr1", "Corr2"]; 48 | // args.nodeData = ["data/dummy/clusters.txt"]; 49 | // args.nodeDataLabels = ["Cluster number"]; 50 | // args.linkage = "data/dummy/linkages.txt"; 51 | // args.thumbnails = "data/dummy/thumbnails"; 52 | // args.thresFunc = thresholdMatrix; 53 | // args.thresVals = [0.75]; 54 | // args.thresLabels = ["Thres perc"]; 55 | 56 | netjs.loadNetwork(args, function(net) { 57 | 58 | var w = window.innerWidth - 250; 59 | var h = window.innerHeight - 50; 60 | var sz = Math.min(w/2.0, h); 61 | 62 | netjs.displayNetwork( 63 | net, 64 | "#fullNetwork", 65 | "#subNetwork", 66 | "#networkCtrl", 67 | sz,sz,sz,sz); 68 | }); 69 | }); 70 | 71 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/netjs/js/main.jsOLD: -------------------------------------------------------------------------------- 1 | require(["netjs", "lib/d3"], function(netjs, d3) { 2 | 3 | function thresholdMatrix(matrix, args) { 4 | 5 | var thresPerc = args[0]; 6 | 7 | var thresMatrix = []; 8 | var nodeThress = []; 9 | 10 | for (var i = 0; i < matrix.length; i++) { 11 | absVals = matrix[i].map(function(val) {return Math.abs(val);}); 12 | nodeThress.push(d3.max(absVals) * thresPerc); 13 | } 14 | 15 | for (var i = 0; i < matrix.length; i++) { 16 | 17 | thresMatrix.push([]); 18 | 19 | for (var j = 0; j < matrix[i].length; j++) { 20 | 21 | if (Math.abs(matrix[i][j]) < nodeThress[i] || 22 | Math.abs(matrix[i][j]) < nodeThress[j]) 23 | 24 | thresMatrix[i].push(Number.NaN); 25 | else 26 | thresMatrix[i].push(matrix[i][j]); 27 | } 28 | } 29 | 30 | return thresMatrix; 31 | } 32 | 33 | var args = {}; 34 | args.matrices = ["data/dataset2/Znet1.txt", "data/dataset2/Znet2.txt"]; 35 | args.matrixLabels = ["Corr1", "Corr2"]; 36 | args.nodeData = ["data/dataset2/clusters.txt"]; 37 | args.nodeDataLabels = ["Cluster number"]; 38 | args.linkage = "data/dataset2/linkages.txt"; 39 | args.thumbnails = "data/dataset2/melodic_IC_sum.sum"; 40 | args.thresFunc = thresholdMatrix; 41 | args.thresVals = [0.75]; 42 | args.thresLabels = ["Thres perc"]; 43 | args.thresholdIdx = 0; 44 | args.numClusters = 10; 45 | 46 | netjs.loadNetwork(args, function(net) { 47 | 48 | var w = window.innerWidth - 200; 49 | var h = window.innerHeight - 50; 50 | var sz = Math.min(w/2.0, h); 51 | 52 | netjs.displayNetwork( 53 | net, 54 | "#fullNetwork", 55 | "#subNetwork", 56 | "#networkCtrl", 57 | sz,sz,sz,sz); 58 | }); 59 | }); 60 | 61 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/netjs/js/netctrl.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | 6 | {{#thresholdValues}} 7 |
8 | 01
9 |
10 | {{/thresholdValues}} 11 | 12 |
13 | 125
14 |
15 | 16 |
17 |
18 | 19 |
20 | 21 |
22 |
23 | 24 |
25 | 26 |
27 |

28 |
29 | 30 |
31 | 32 |
33 | 34 |
35 | 36 |
37 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/netjs/js/netjs.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Application interface for the netjs library. Exposes two functions: 3 | * 4 | * - loadNetwork: Given a bunch of URLs and metadata, loads 5 | * the data at the URLs and creates a network. 6 | * from it. 7 | * - displayNetwork: Displays a network on a div. 8 | * 9 | * Author: Paul McCarthy 10 | */ 11 | define( 12 | ["netvis", "netdata", "netctrl", "netvis_dynamics"], 13 | function(netvis, netdata, netctrl, dynamics) { 14 | 15 | function displayNetwork( 16 | network, 17 | networkDiv, 18 | subNetDiv, 19 | controlDiv, 20 | networkWidth, 21 | networkHeight, 22 | subNetWidth, 23 | subNetHeight) { 24 | 25 | netvis.displayNetwork(network, networkDiv, networkWidth, networkHeight); 26 | dynamics.configDynamics(network); 27 | 28 | netctrl.createNetworkControls( 29 | network, controlDiv, subNetDiv, subNetWidth, subNetHeight); 30 | } 31 | 32 | var netjs = {}; 33 | netjs.loadNetwork = netdata.loadNetwork; 34 | netjs.displayNetwork = displayNetwork; 35 | 36 | return netjs; 37 | }); 38 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/nets_boxplots.m: -------------------------------------------------------------------------------- 1 | % 2 | % nets_boxplots(ts,netmat,IC1,IC2,Ngroup1); 3 | % Steve Smith - 2013-2014 4 | % 5 | % show cross-subject boxplots, for a given "netmat" element (IC1,IC2), assuming there are two groups of subjects 6 | % 7 | % NGroup1 is the number of subjects in the first group; set to -1 for paired groups 8 | % 9 | 10 | function nets_boxplots(ts,netmat,IC1,IC2,Ngroup1); 11 | 12 | ispaired=0; 13 | if Ngroup1<0 14 | ispaired=1; 15 | Ngroup1=ts.Nsubjects/2; 16 | end 17 | 18 | sprintf('nodes (%d,%d) correspond to original components (%d,%d) (counting starting at 0)',IC1,IC2,ts.DD(IC1)-1,ts.DD(IC2)-1) 19 | 20 | figure('position',[100 100 150 200]); 21 | 22 | i=(IC1-1)*ts.Nnodes + IC2; 23 | 24 | % get values for boxplots, padding with NaN for unequal groups (otherwise boxplot doesn't work) 25 | grot1=netmat(1:Ngroup1,i); grot2=netmat(Ngroup1+1:end,i); 26 | grotl=max(length(grot1),length(grot2)); 27 | grot1=[grot1;nan(grotl-length(grot1),1)]; grot2=[grot2;nan(grotl-length(grot2),1)]; 28 | 29 | %%% use the following line if the groups are paired 30 | if ispaired 31 | plot([grot1 grot2]','Color',[0.5 1 0.5]); 32 | end 33 | 34 | hold on; boxplot([grot1 grot2]); 35 | set(gcf,'PaperPositionMode','auto'); 36 | set(gca,'XTick',[1 2],'XTickLabel',['A' ; 'B']); 37 | 38 | %print('-depsc',sprintf('boxplot-%d-%d.eps',IC1,IC2)); 39 | 40 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/nets_class_vectomat.m: -------------------------------------------------------------------------------- 1 | % goes from a Nx1 vector of q different classes (Y) 2 | % to a Nxq matrix of dummy variables encoding the same 3 | function Ym = nets_class_vectomat(Y) 4 | N = length(Y); uY = unique(Y); q = length(uY); 5 | Ym = zeros(N,q); 6 | for j=1:q, Ym(Y==uY(j),j) = 1; end 7 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/nets_demean.m: -------------------------------------------------------------------------------- 1 | function x=nets_demean(x,dim) 2 | 3 | % nets_demean(X) 4 | % Removes the Average or mean value. 5 | % 6 | % nets_demean(X,DIM) 7 | % Removes the mean along the dimension DIM of X. 8 | 9 | if(nargin==1), 10 | dim = 1; 11 | if(size(x,1) > 1) 12 | dim = 1; 13 | elseif(size(x,2) > 1) 14 | dim = 2; 15 | end; 16 | end; 17 | 18 | dims = size(x); 19 | dimsize = size(x,dim); 20 | dimrep = ones(1,length(dims)); 21 | dimrep(dim) = dimsize; 22 | 23 | x = x - repmat(mean(x,dim),dimrep); 24 | 25 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/nets_groupmean.m: -------------------------------------------------------------------------------- 1 | % 2 | % nets_groupmean - estimate group mean/one-group-t-test and consistency of netmats across runs/subjects 3 | % Steve Smith, 2012-2014 4 | % 5 | % [Znet] = nets_groupmean(netmats,make_figure); 6 | % [Znet,Mnet] = nets_groupmean(netmats,make_figure); 7 | % 8 | % [Znet] = nets_groupmean(netmats,make_figure,Nsubgroup); 9 | % [Znet,Mnet] = nets_groupmean(netmats,make_figure,Nsubgroup); 10 | % 11 | % make_figure (0 or 1) controls whether to display the one-group-t-test group-level netmat and consistency figure 12 | % 13 | % Nsubgroup says that sets of Nsubgroup runs are from the same subject and should be averaged before cross-subject consistency estimation 14 | % 15 | % Znet is Z-stat from one-group t-test across subjects 16 | % Mnet is mean netmat across subjects 17 | % 18 | 19 | function [Znet,Mnet]=nets_groupmean(netmats,gofigure,varargin); 20 | 21 | Nsubgroup=1; 22 | if nargin==3 23 | Nsubgroup=varargin{1}; 24 | end 25 | 26 | Nf=sqrt(size(netmats,2)); N=round(Nf); Nsub=size(netmats,1); 27 | 28 | % one-group t-test 29 | grot=netmats; DoF=Nsub-1; 30 | if Nsubgroup>1 31 | clear grot; 32 | for i=1:Nsub/Nsubgroup 33 | grot(i,:)=mean(netmats((i-1)*Nsubgroup+1:i*Nsubgroup,:)); 34 | end 35 | DoF=i-1; 36 | end 37 | 38 | %[grotH,grotP,grotCI,grotSTATS]=ttest(grot,0); Tnet=grotSTATS.tstat; Tnet(isfinite(Tnet)==0)=0; 39 | Tnet = sqrt(size(grot,1)) * mean(grot) ./ std(grot); 40 | 41 | Mnet=mean(grot); 42 | 43 | % Znet=sign(Tnet).*(2^0.5).*erfinv(1-2.*(betainc(DoF./(DoF+abs(Tnet).^2),DoF/2,1/2)/2)); 44 | % Znet(isinf(Znet)==1)=20*sign(Znet(isinf(Znet)==1)); % very large t values would otherwise be called infinite 45 | Znet = zeros(size(Tnet)); 46 | Znet(Tnet>0) = -norminv(tcdf(-Tnet(Tnet>0),DoF)); 47 | Znet(Tnet<0) = norminv(tcdf(Tnet(Tnet<0),DoF)); 48 | 49 | Znetd=Znet; 50 | if N==Nf % is netmat square.... 51 | Znet=reshape(Znet,N,N); 52 | Mnet=reshape(Mnet,N,N); 53 | end 54 | 55 | if gofigure>0 56 | figure('position',[100 100 1100 400]); 57 | subplot(1,2,1); 58 | plot(Znetd); 59 | if N==Nf % is netmat square.... 60 | Znetd=reshape(Znetd,N,N); 61 | if sum(sum(abs(Znetd)-abs(Znetd')))<0.00000001 % .....and symmetric 62 | imagesc(Znetd,[-10 10]); colormap('jet'); colorbar; 63 | end 64 | end 65 | title('z-stat from one-group t-test'); 66 | 67 | % scatter plot of each session's netmat vs the mean netmat 68 | subplot(1,2,2); 69 | grot=repmat(mean(netmats),Nsub,1); 70 | scatter(netmats(:),grot(:)); 71 | title('scatter of each session''s netmat vs mean netmat'); 72 | end 73 | 74 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/nets_netweb.m: -------------------------------------------------------------------------------- 1 | % 2 | % nets_netweb - create interactive web-page netmat viewer 3 | % Paul McCarthy & Steve Smith, 2014 4 | % 5 | % THIS DOES NOT WORK IN OCTAVE BECAUSE THE OCTAVE statistics PACKAGE IS MISSING THE cluster FUNCTION 6 | % 7 | % nets_netweb(netF,netP,DD,sumpics,netwebdir) 8 | % netF is typically the full-correlation group netmat (e.g. Znet1 or Mnet1) 9 | % netP is typically the partial-correlation group netmat (e.g. Znet2 or Mnet2) 10 | % DD is the list of good nodes (e.g. ts.DD - needed to map the current set of nodes back to originals) 11 | % sumpics is the name of the directory containing summary pictures for each component, without the .sum suffix 12 | % netwebdir is the name of the output folder created to contain the netweb web pages 13 | % 14 | % e.g.: nets_netweb(Znet1,Znet2,ts.DD,'groupICA_d60/melodic_IC','my_netweb') 15 | % 16 | 17 | function nets_netweb(netF,netP,DD,sumpics,netwebdir); 18 | 19 | % replicate functionality from nets_hierarchy 20 | grot=prctile(abs(netF(:)),99); netmatL=netF/grot; netmatH=netP/grot; 21 | usenet=netmatL; usenet(usenet<0)=0; 22 | N=size(netmatL,1); grot=prctile(abs(usenet(:)),99); usenet=max(min(usenet/grot,1),-1)/2; 23 | for J = 1:N, for I = 1:J-1, y((I-1)*(N-I/2)+J-I) = 0.5 - usenet(I,J); end; end; 24 | linkages=linkage(y,'ward'); 25 | set(0,'DefaultFigureVisible','off');figure;[~,~,hier]=dendrogram(linkages,0,'colorthreshold',0.75);close;set(0,'DefaultFigureVisible','on'); 26 | clusters=cluster(linkages,'maxclust',10)'; 27 | 28 | % copy javascript stuff into place 29 | system(sprintf('mkdir -p %s; (cd %s/netjs; tar cf - *) | (cd %s; tar xf -)',netwebdir,fileparts(which('nets_netweb')),netwebdir)); 30 | NP=sprintf('%s/data/dataset1',netwebdir); 31 | save(sprintf('%s/Znet1.txt',NP),'netF','-ascii'); 32 | save(sprintf('%s/Znet2.txt',NP),'netP','-ascii'); 33 | save(sprintf('%s/hier.txt',NP),'hier','-ascii'); 34 | save(sprintf('%s/linkages.txt',NP),'linkages','-ascii'); 35 | save(sprintf('%s/clusters.txt',NP),'clusters','-ascii'); 36 | mkdir(sprintf('%s/melodic_IC_sum.sum',NP)); 37 | for i=1:length(DD) 38 | system(sprintf('/bin/cp %s.sum/%.4d.png %s/melodic_IC_sum.sum/%.4d.png',sumpics,DD(i)-1,NP,i-1)); 39 | end 40 | 41 | sprintf('now you can open the following in a web browser: %s/index.html',netwebdir) 42 | 43 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/nets_nodepartial.m: -------------------------------------------------------------------------------- 1 | % 2 | % nets_nodepartial - replace node timeseries with node partial timeseries 3 | % Steve Smith, 2013 4 | % 5 | % [new_ts] = nets_nodepartial(ts); 6 | % 7 | 8 | function [newts] = nets_nodepartial(ts); 9 | 10 | newts=ts; newts.ts=[]; 11 | 12 | for s=1:ts.Nsubjects 13 | grot=ts.ts((s-1)*ts.NtimepointsPerSubject+1:s*ts.NtimepointsPerSubject,:); % all comp 14 | for i=1:size(grot,2) 15 | TSi=nets_demean(grot(:,i)); 16 | TSr=nets_demean(grot(:,setdiff(1:size(grot,2),i))); 17 | grot2(:,i)= TSi - TSr*(pinv(TSr)*TSi); 18 | end 19 | newts.ts=[newts.ts;grot2]; 20 | end 21 | 22 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/nets_nodepics.m: -------------------------------------------------------------------------------- 1 | % 2 | % nets_nodepics - view thumbnail summary images of kept and (separately) discarded nodes 3 | % Steve Smith, 2013-2014 4 | % 5 | % nets_nodepics(ts,group_maps); 6 | % 7 | % ts: data structure containing information about nodes, timeseries and discarded nodes 8 | % group_maps: string pointing at folder containing thumbnails (without the .sum at the end) 9 | % 10 | 11 | function [netmat] = nets_nodepics(ts,group_maps); 12 | 13 | grot=tempname; 14 | 15 | system(sprintf('slices_summary %s.sum %s.png %s',group_maps,grot,num2str(ts.DD-1))); 16 | pic=imread(sprintf('%s.png',grot)); 17 | figure('Position',[10 10 3*size(pic,2) 3*size(pic,1)]); subplot('Position',[0 0 1 0.9]); imagesc(pic); axis off; axis equal; title('good components'); 18 | 19 | if ts.NnodesOrig~=ts.Nnodes 20 | system(sprintf('slices_summary %s.sum %s.png %s',group_maps,grot,num2str(setdiff(1:ts.NnodesOrig,ts.DD)-1))); 21 | pic=imread(sprintf('%s.png',grot)); 22 | figure('Position',[10 100+3*size(pic,1) 3*size(pic,2) 3*size(pic,1)]); subplot('Position',[0 0 1 0.9]); imagesc(pic); axis off; axis equal; title('bad components'); 23 | end 24 | 25 | system(sprintf('/bin/rm %s*',grot)); 26 | 27 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/nets_normalise.m: -------------------------------------------------------------------------------- 1 | function x=nets_normalise(x,dim) 2 | 3 | % nets_normalise(X) 4 | % Removes the Average or mean value and makes the std=1 5 | % 6 | % nets_normalise(X,DIM) 7 | % Removes the mean and makes the std=1 along the dimension DIM of X. 8 | 9 | if(nargin==1), 10 | dim = 1; 11 | if(size(x,1) > 1) 12 | dim = 1; 13 | elseif(size(x,2) > 1) 14 | dim = 2; 15 | end; 16 | end; 17 | 18 | dims = size(x); 19 | dimsize = size(x,dim); 20 | dimrep = ones(1,length(dims)); 21 | dimrep(dim) = dimsize; 22 | 23 | x = x - repmat(mean(x,dim),dimrep); 24 | x = x./repmat(std(x,0,dim),dimrep); 25 | 26 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/nets_outliers.m: -------------------------------------------------------------------------------- 1 | % 2 | % nets_outliers - identify potential outlier nodes and subjects 3 | % Steve Smith, 2013 4 | % 5 | % [outlier_nodes,outlier_subjects] = nets_outliers(ts); 6 | % [outlier_nodes,outlier_subjects] = nets_outliers(ts,Nsubgroup); 7 | % 8 | % Nsubgroup says that sets of Nsubgroup runs are from the same subject and should be combined before cross-subject consistency estimation 9 | % 10 | 11 | function [outlier_nodes,outlier_subjects,amplitudes]=nets_outliers(ts,varargin); 12 | 13 | Nsubgroup=1; 14 | if nargin==2 15 | Nsubgroup=varargin{1}; 16 | end 17 | 18 | ts.NtimepointsPerSubject=ts.NtimepointsPerSubject*Nsubgroup; 19 | ts.Nsubjects=ts.Nsubjects/Nsubgroup; 20 | 21 | for s=1:ts.Nsubjects 22 | amplitudes(s,:)=std(ts.ts((s-1)*ts.NtimepointsPerSubject+1:s*ts.NtimepointsPerSubject,:)); 23 | end 24 | 25 | amps=amplitudes./repmat(median(amplitudes),ts.Nsubjects,1); outlier_nodes=max(amps)>5; 26 | amps=amplitudes./repmat(median(amplitudes,2),1,ts.Nnodes); outlier_subjects=max(amps,[],2)>4; 27 | 28 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/nets_spectra.m: -------------------------------------------------------------------------------- 1 | % 2 | % nets_spectra - calculate and display spectrum for each node, averaged across subjects 3 | % Steve Smith and Ludo Griffanti, 2013-2014 4 | % 5 | % [ts_spectra] = nets_spectra(ts); 6 | % [ts_spectra] = nets_spectra(ts,node_list); 7 | % [ts_spectra] = nets_spectra(ts,node_list,tailnorm); 8 | % 9 | % node_list is optional, and is a vector listing the nodes to include 10 | % 11 | % tailnorm changes spectrum estimation to pwelch and scales spectra according to size of right-hand tail 12 | % - if using tailnorm and not node_list, use nets_spectra(ts,[],tailnorm) 13 | % 14 | 15 | function [ts_spectra] = nets_spectra(ts,varargin); % produce subject-averaged spectra 16 | 17 | N=ts.Nnodes; 18 | nodelist=1:N; 19 | if nargin>1 && length(varargin{1})>0 20 | nodelist=varargin{1}; 21 | N=length(nodelist); 22 | end 23 | 24 | tailnorm=0; 25 | if nargin==3 26 | tailnorm=varargin{2}; 27 | end 28 | 29 | ts_spectra=[]; 30 | 31 | for s=1:ts.Nsubjects 32 | grot=ts.ts((s-1)*ts.NtimepointsPerSubject+1:s*ts.NtimepointsPerSubject,nodelist); 33 | for ii=1:N 34 | if tailnorm==0 35 | blah=abs(fft(nets_demean(grot(:,ii)))); ts_spectra(:,ii,s)=blah(1:round(size(blah,1)/2)); 36 | else 37 | blah=pwelch(grot(:,ii)); ts_spectra(:,ii,s)=blah(1:end-1,:); 38 | end 39 | %ts_spectra(:,ii,s)=smooth( pwelch(grot(:,ii)) ,10,'lowess'); 40 | end 41 | end 42 | 43 | ts_spectra=mean(ts_spectra,3); 44 | 45 | if tailnorm==1 46 | for i=1:N 47 | F_end=mean(ts_spectra(end-9:end,i)); 48 | ts_spectra(:,i)=ts_spectra(:,i)/F_end; 49 | end 50 | end 51 | 52 | figure('Position',[10 10 1600 900]); 53 | 54 | if tailnorm==0 55 | grot=ts_spectra ./ repmat(max(ts_spectra),size(ts_spectra,1),1); 56 | grotm=median(grot,2); 57 | else 58 | grot=ts_spectra / max(ts_spectra(:)); 59 | grotm=median(grot,2); grotm=grotm/max(grotm); 60 | end 61 | 62 | II=3; I=ceil(N/II); gap=0.03; xw=(1-gap*(II+2))/(II+2); yh=1-(2*gap); iii=1; 63 | for i=1:II 64 | subplot('position', [ gap*i+xw*(i-1) gap xw yh*min( (N-iii+1)/I, 1) ]); 65 | splurghy=repmat(iii:min(iii+I-1,N),size(grot,1),1); 66 | plot(splurghy,'color',[0.8 0.8 0.8]); hold on; 67 | plot(splurghy+repmat(grotm,1,size(splurghy,2)),'color',[0.6 0.6 0.6]); hold on; 68 | clear grotx; 69 | for ii=1:I 70 | if iii<=N 71 | grotx(:,ii)=grot(:,iii)+iii; 72 | end 73 | iii=iii+1; 74 | end 75 | plot(grotx); % grid on; 76 | end 77 | 78 | subplot('position', [ gap*(II+1)+xw*II gap 2*xw yh ]); 79 | plot(grot); hold on; 80 | plot(grotm,'k','LineWidth',3); 81 | 82 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/nets_stats.m: -------------------------------------------------------------------------------- 1 | % 2 | % nets_stats - calculate various timeseries stats 3 | % Steve Smith, 2013-2014 4 | % 5 | % [ts_stats] = nets_stats(ts); 6 | % 7 | % estimates mean and stddev (across subjects) for temporal stats: stddev skewness kurtosis 8 | % 9 | 10 | function [ts_stats] = nets_stats(ts); 11 | 12 | all_stats.std=[]; all_stats.skewness=[]; all_stats.kurtosis=[]; 13 | for s=1:ts.Nsubjects 14 | grot=ts.ts((s-1)*ts.NtimepointsPerSubject+1:s*ts.NtimepointsPerSubject,:); 15 | all_stats.std = [all_stats.std; std(grot)]; 16 | all_stats.skewness = [all_stats.skewness; skewness(grot)]; 17 | all_stats.kurtosis = [all_stats.kurtosis; kurtosis(grot)]; 18 | end 19 | 20 | ts_stats.std.mean = mean(all_stats.std); 21 | ts_stats.std.std = std(all_stats.std); 22 | ts_stats.skewness.mean = mean(all_stats.skewness); 23 | ts_stats.skewness.std = std(all_stats.skewness); 24 | ts_stats.kurtosis.mean = mean(all_stats.kurtosis); 25 | ts_stats.kurtosis.std = std(all_stats.kurtosis); 26 | 27 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/nets_svds.m: -------------------------------------------------------------------------------- 1 | % 2 | % nets_svds - SVD: RAM/time-efficient wrapper for eig/eigs 3 | % Steve Smith 2013-2014 4 | % 5 | % [u,s,v]=nets_svds(x,n); 6 | % 7 | % x is any 2D matrix, which will be approximated by: x = u s v' 8 | % n is the number of components to estimate 9 | % If n<=0 then we will estimate rank-abs(n) components 10 | % 11 | % Note: no demeaning of x takes place within this function 12 | % 13 | 14 | function [u,s,v]=nets_svds(x,n); 15 | 16 | if n<1 17 | n = max( min(size(x))+n , 1); 18 | end 19 | 20 | if size(x,1) < size(x,2) 21 | 22 | if n < size(x,1) 23 | [u,d] = eigs(x*x',n); 24 | else 25 | [u,d] = eig(x*x'); u=fliplr(u); d=flipud(fliplr(d)); 26 | end 27 | s = sqrt(abs(d)); 28 | v = x' * (u * diag((1./diag(s)))); 29 | 30 | else 31 | 32 | if n < size(x,2) 33 | [v,d] = eigs(x'*x,n); 34 | else 35 | [v,d] = eig(x'*x); v=fliplr(v); d=flipud(fliplr(d)); 36 | end 37 | s = sqrt(abs(d)); 38 | u = x * (v * diag((1./diag(s)))); 39 | 40 | end 41 | 42 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/nets_tangentv.m: -------------------------------------------------------------------------------- 1 | % 2 | % nets_tangentv - vectorise the covariance matrices by tangent space mapping 3 | % Diego Vidaurre 4 | % FMRIB Oxford, 2013-2014 5 | % 6 | % X = nets_tangentv(C,TCref); 7 | % X = nets_tangentv(C); 8 | % 9 | % INPUTS 10 | % C - array NxNxM, where N is the number of nodes and M is the number of covariance matrices 11 | % TCref - what type of reference matrix we use for computing the mapping 12 | % + 1: geometric mean of the covariance matrices, in Riemannian space (default) 13 | % + 2: arithmetic mean of the covariance matrices 14 | % + 3: identity 15 | % 16 | % OUTPUTS 17 | % X - M x (N * (N-1) /2) matrix of stacked vectorised matrices 18 | 19 | function X = nets_tangentv(C,TCref) 20 | 21 | if nargin<2, TCref = 1; end 22 | 23 | [N,~,M] = size(C); 24 | 25 | if TCref == 1 26 | Cref = C(:,:,1); 27 | for i=2:M, 28 | isqCref = Cref^-0.5; 29 | sqCref = Cref^0.5; 30 | Cref = sqCref*((isqCref*C(:,:,i)*isqCref)^(1/i))*sqCref; 31 | end 32 | elseif TCref == 2 33 | Cref = mean(C,3); 34 | else 35 | Cref = eye(N); 36 | end 37 | 38 | isqCref = Cref^-0.5; 39 | sqCref = Cref^0.5; 40 | 41 | X = zeros(M,N * (N+1) /2); 42 | for i=1:M 43 | S = sqCref * logm(isqCref * C(:,:,i) * isqCref) * sqCref; 44 | X(i,:)=S(triu(ones(N),0)==1); 45 | end; 46 | 47 | end 48 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/nets_tsclean.m: -------------------------------------------------------------------------------- 1 | % 2 | % nets_tsclean - remove bad nodes, optionally regressing those out of the good (for further cleanup) 3 | % Steve Smith and Ludo Griffanti, 2013-2014 4 | % 5 | % [ts] = nets_tsclean(ts,aggressive); 6 | % 7 | % aggressive=0: "soft" - just deletes the bad and the unknown components 8 | % aggressive=1: regresses the bad timeseries (not in DD or UNK) out of the good, and deletes the bad & unknown components 9 | % 10 | % ts.DD = list of good components 11 | % ts.UNK = list of unknown components (gets deleted but never regressed out of good). Can be empty. 12 | % 13 | 14 | function [ts] = nets_tsclean(ts,aggressive); 15 | 16 | ts.NnodesOrig=ts.Nnodes; 17 | 18 | nongood=setdiff(1:ts.Nnodes,ts.DD); % bad or unknown components 19 | bad=setdiff(nongood,ts.UNK); % only bad components 20 | 21 | newts=[]; 22 | for s=1:ts.Nsubjects 23 | grot=ts.ts((s-1)*ts.NtimepointsPerSubject+1:s*ts.NtimepointsPerSubject,:); % all comp 24 | goodTS=grot(:,ts.DD); %good comp 25 | badTS=grot(:,bad); % bad components 26 | if aggressive == 1 27 | newts=[newts;goodTS-badTS*(pinv(badTS)*goodTS)]; 28 | else 29 | newts=[newts;goodTS]; 30 | end 31 | end 32 | ts.ts=newts; 33 | ts.Nnodes=size(ts.ts,2); 34 | 35 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/orig_nets_load.m: -------------------------------------------------------------------------------- 1 | % 2 | % nets_load - load a folder full of individual runs'/subjects' node-timeseries files 3 | % Steve Smith and Ludo Griffanti, 2013-2014 4 | % 5 | % ts = nets_load(indir,tr,varnorm); 6 | % ts = nets_load(indir,tr,varnorm,Nruns); 7 | % 8 | % indir: string, naming a folder that contains multiple timeseries files (e.g. as output by dual_regression) 9 | % tr: float containing TR (temporal resolution, in seconds) 10 | % varnorm: temporal variance normalisation to apply: 11 | % 0 = none 12 | % 1 = normalise overall stddev for each run (normally one run/subject per timeseries file) 13 | % 2 = normalise separately each separate timeseries from each run 14 | % Nruns (optional, default=1): specify how many sub-runs per subject-file 15 | % (i.e., if sub-runs had previously been combined into single timeseries files) 16 | % 17 | % nets_load loads data from a dual regression output directory, whatever the name 18 | % of the file (dr_stage1_subject*.txt or other). Files are loaded in 19 | % alphabetical order. 20 | % If you used dual regression standard command line, the subject order will 21 | % be the same as .filelist, and design.mat/design.con supplied to dual_regression can be used. 22 | % 23 | % Otherwise, make sure the file order will be the same of the 24 | % and you will call later. 25 | % In this case you will make later analysis easier if you name the .txt 26 | % files in a logical order, for example so that all controls are listed 27 | % before all patients: 28 | % CON_N00300_TS.txt 29 | % CON_N00302_TS.txt 30 | % CON_N00499_TS.txt 31 | % PAT_N00373_TS.txt 32 | % PAT_N00422_TS.txt 33 | % PAT_N03600_TS.txt 34 | % 35 | 36 | function [ts] = nets_load(indir,tr,varnorm,varargin); 37 | 38 | Nruns=1; 39 | if nargin>3 40 | Nruns=varargin{1}; 41 | end 42 | 43 | startdir=pwd; 44 | cd(indir); 45 | 46 | d=dir('*.txt'); 47 | Nsubjects=size(d,1); 48 | TS=[]; 49 | for i=1:Nsubjects 50 | grotALL=load(d(i).name); gn=size(grotALL,1); 51 | 52 | if i==1 53 | ts.NtimepointsPerSubject=gn; 54 | elseif gn ~= ts.NtimepointsPerSubject 55 | disp('Error: not all subjects have the same number of timepoints!'); 56 | end 57 | gn=gn/Nruns; 58 | 59 | for ii=1:Nruns 60 | grot=grotALL((ii-1)*gn+1:ii*gn,:); 61 | grot=grot-repmat(mean(grot),size(grot,1),1); % demean 62 | if varnorm==1 63 | grot=grot/std(grot(:)); % normalise whole subject stddev 64 | elseif varnorm==2 65 | grot=grot ./ repmat(std(grot),size(grot,1),1); % normalise each separate timeseries from each subject 66 | end 67 | TS=[TS; grot]; 68 | end 69 | end 70 | 71 | ts.ts=TS; 72 | ts.tr=tr; 73 | ts.Nsubjects=Nsubjects*Nruns; 74 | ts.Nnodes=size(TS,2); 75 | ts.NnodesOrig=ts.Nnodes; 76 | ts.Ntimepoints=size(TS,1); 77 | ts.NtimepointsPerSubject=ts.NtimepointsPerSubject/Nruns; 78 | ts.DD=1:ts.Nnodes; 79 | ts.UNK=[]; 80 | 81 | cd(startdir); 82 | 83 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/pwling/mentappr.m: -------------------------------------------------------------------------------- 1 | %MENTAPPR: Compute MaxEnt approximation of negentropy and differential entropy 2 | %Aapo Hyvarinen, May 2012 3 | %Based on NIPS*97 paper, www.cs.helsinki.fi/u/ahyvarin/papers/NIPS97.pdf 4 | % but using a new nonlinearity 5 | %Input: sample of continous-valued random variable as a vector. 6 | % For matrices, entropy computed for each column 7 | %Output: (differential) entropy and, optionally, negentropy 8 | 9 | function [entropy,negentropy]=mentappr(x) 10 | 11 | %standardize 12 | x=x-mean(x); 13 | xstd=std(x); 14 | x=x/xstd; 15 | 16 | %Constants we need 17 | k1=36/(8*sqrt(3)-9); 18 | gamma=0.37457; 19 | k2=79.047; 20 | gaussianEntropy=log(2*pi)/2+1/2; 21 | 22 | %This is negentropy 23 | negentropy = k2*(mean(log(cosh(x)))-gamma)^2+k1*mean(x.*exp(-x.^2/2))^2; 24 | 25 | %This is entropy 26 | entropy = gaussianEntropy - negentropy + log(xstd); 27 | 28 | -------------------------------------------------------------------------------- /rsc/scripts/bin/FSLNets/pwling/pwling.m: -------------------------------------------------------------------------------- 1 | %PWLING: pairwise causality measures in linear non-Gaussian model 2 | %Version 1.2, Aapo Hyvarinen, Feb 2013 3 | %Input: Data matrix with variables as rows, and index of method [1...5] 4 | %Output: Matrix LR with likelihood ratios 5 | % If entry (i,j) in that matrix is positive, 6 | % estimate of causal direction is i -> j 7 | %Methods 1...5 are as follows: 8 | % 1: General entropy-based method, for variables of any distribution 9 | % 2: First-order approximation of LR by tanh, for sparse variables 10 | % 3: Basic skewness measure, for skewed variables 11 | % 4: New skewness-based measure, robust to outliers 12 | % 5: Dodge-Rousson measure, for skewed variables 13 | % If you want to use method 3 or 4 without skewness correction, 14 | % input -3 or -4 as the method. 15 | %See http://www.cs.helsinki.fi/u/ahyvarin/code/pwcausal/ for more information 16 | 17 | function LR=pwling(X,method) 18 | 19 | 20 | %Get size parameters 21 | [n,T]=size(X); 22 | 23 | %Standardize each variable 24 | X=X-mean(X')'*ones(1,T); 25 | X=X./((std(X')+eps)'*ones(1,T)); 26 | 27 | %If using skewness measures with skewness correction, make skewnesses positive 28 | if method==3 | method==4 29 | for i=1:n; X(i,:)=X(i,:)*sign(skewness(X(i,:))); end 30 | end 31 | 32 | 33 | %Compute covariance matrix 34 | C=cov(X'); 35 | 36 | 37 | %Compute causality measures 38 | %%%%%%%%%%%%%%%%%%%%%%%%%%% 39 | 40 | switch abs(method) %negative method numbers are used as options 41 | 42 | case 1, %General entropy-based method, for variables of any distribution 43 | %Initialize output matrix 44 | LR=zeros(n); 45 | %Loop throgh pairs 46 | for i=1:n 47 | for j=1:n 48 | if i~=j 49 | res1=(X(j,:)-C(j,i)*X(i,:)); 50 | res2=(X(i,:)-C(i,j)*X(j,:)); 51 | LR(i,j)=mentappr(X(j,:))-mentappr(X(i,:))... 52 | -mentappr(res1)+mentappr(res2); 53 | end 54 | end 55 | end 56 | 57 | case 2, %first-order approximation of LR by tanh, for sparse variables 58 | LR=C.*(X*tanh(X')-tanh(X)*X')/T; 59 | 60 | case 3, %basic skewness measure, for skewed variables 61 | LR=C.*(-X*(X'.^2)+X.^2*X')/T; 62 | 63 | case 4, %New skewed measure, robust to outliers 64 | gX=log(cosh(max(X,0))); 65 | LR= C.*(-(X*gX'/T)+(gX*X'/T)); 66 | 67 | case 5, %Dodge-Rousson measure, for skewed variables 68 | LR=(-(X*(X'.^2)).^2+(X.^2*X').^2)/T; 69 | 70 | end -------------------------------------------------------------------------------- /rsc/scripts/bin/sort8_32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/scripts/bin/sort8_32 -------------------------------------------------------------------------------- /rsc/scripts/bin/sort8_64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ahheckel/FSL-scripts/e55996809ea212f2bb2688efc938888ddb9a1501/rsc/scripts/bin/sort8_64 -------------------------------------------------------------------------------- /rsc/scripts/calcT2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Computes T2 relaxation time from 4D multi-echo. 3 | 4 | # Written by Andreas Heckel 5 | # University of Heidelberg 6 | # heckelandreas@googlemail.com 7 | # https://github.com/ahheckel 8 | # 09/07/2014 9 | 10 | trap 'echo "$0 : An ERROR has occured."' ERR 11 | 12 | set -e 13 | 14 | Usage() { 15 | echo "" 16 | echo "Usage: `basename $0` " 17 | echo "" 18 | exit 1 19 | } 20 | 21 | [ "$3" = "" ] && Usage 22 | 23 | # define vars 24 | input=`remove_ext "$1"` 25 | TE="$2" ; TE="$(echo "$TE" | sed 's|,| |g')" 26 | output=`remove_ext "$3"` 27 | 28 | # create working dir. 29 | tmpdir=$(mktemp -d -t $(basename $0)_XXXXXXXXXX) # create unique dir. for temporary files 30 | 31 | # define exit trap 32 | trap "rm -f $tmpdir/* ; rmdir $tmpdir ; exit" EXIT 33 | 34 | # check 35 | n_echo=$(fslnvols $input) 36 | if [ $n_echo -lt 2 ] ; then 37 | echo "`basename $0` : ERROR: '$input' needs to contain at least 2 volumes (echoes) - exiting..." ; exit 1 38 | fi 39 | if [ $n_echo -ne $(echo $TE | wc -w) ] ; then 40 | echo "`basename $0` : ERROR: number of volumes in '$input' ($n_echo) and number of provided echo-times ($(echo $TE | wc -w)) do not match - exiting..." ; exit 1 41 | fi 42 | 43 | if [ $n_echo -gt 2 ] ; then 44 | # create design matrix 45 | for i in $TE ; do 46 | echo -${i} 1 47 | done > $tmpdir/design 48 | # execute 49 | echo "`basename $0` : fitting exponential ($n_echo echoes)..." 50 | cmd="fslmaths $input -log $tmpdir/input" 51 | echo " $cmd" ; $cmd 52 | cmd="fsl_glm -i $tmpdir/input -d $tmpdir/design -o $tmpdir/out --out_res=$tmpdir/res" 53 | echo " $cmd" ; $cmd 54 | cmd="fslroi $tmpdir/out $tmpdir/T2 0 1" 55 | echo " $cmd" ; $cmd 56 | cmd="fslroi $tmpdir/out $tmpdir/S0 1 1" 57 | echo " $cmd" ; $cmd 58 | cmd="fslmaths $tmpdir/T2 -recip ${output}_T2" 59 | echo " $cmd" ; $cmd 60 | cmd="fslmaths $tmpdir/S0 -exp ${output}_S0" 61 | echo " $cmd" ; $cmd 62 | #cmd="fslmaths $tmpdir/res ${output}_res" 63 | #echo " $cmd" ; $cmd 64 | elif [ $n_echo -eq 2 ] ; then 65 | dTE="$(echo "$TE" | sed 's| |-|g')" 66 | dTE=$(echo "($dTE) * -1"| bc -l) 67 | # execute 68 | echo "`basename $0` : calculating T2 (dTE=${dTE}ms, $n_echo echoes)..." 69 | cmd="fslroi $input $tmpdir/0 0 1" 70 | echo " $cmd" ; $cmd 71 | cmd="fslroi $input $tmpdir/1 1 1" 72 | echo " $cmd" ; $cmd 73 | cmd="fslmaths $tmpdir/0 -div $tmpdir/1 $tmpdir/div" 74 | echo " $cmd" ; $cmd 75 | cmd="fslmaths $tmpdir/div -log -recip -mul $dTE ${output}_T2" 76 | echo " $cmd" ; $cmd 77 | fi 78 | 79 | # done 80 | echo "`basename $0` : done." 81 | -------------------------------------------------------------------------------- /rsc/scripts/collectvols.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Collects and merges volumes from the directory tree. 3 | 4 | # Written by Andreas Heckel 5 | # University of Heidelberg 6 | # heckelandreas@googlemail.com 7 | # https://github.com/ahheckel 8 | # 11/18/2012 9 | 10 | set -e 11 | 12 | trap 'echo "$0 : An ERROR has occured."' ERR 13 | 14 | wdir=`pwd`/.collectvols$$ ; mkdir -p $wdir 15 | trap "echo -e \"\ncleanup: erasing '$wdir'\" ; rm -f $wdir/* ; rmdir $wdir ; exit" EXIT 16 | 17 | Usage() { 18 | echo "" 19 | echo "Usage: `basename $0` [ -m|-e [idx] ] <4doutput> <\"subdir/filename\"> <\"01 02 ...\"|-> <\"sessa sessb ...\">" 20 | echo "" 21 | exit 1 22 | } 23 | 24 | [ "$5" = "" ] && Usage 25 | domean=0 ; doextr=0 26 | if [ $1 = "-m" ] ; then 27 | domean=1 28 | shift 29 | elif [ $1 = "-e" ] ; then 30 | doextr=1 31 | idx=$2 32 | shift 2 33 | fi 34 | out=`remove_ext "$1"` 35 | file="$2" 36 | subjdir="$3" 37 | if [ "$4" = "-" ] ; then 38 | subj=$(find $subjdir -mindepth 1 -maxdepth 1 -type d | grep -v FS_ | sort) 39 | else 40 | subj="$4" 41 | _subj="" 42 | for i in $subj ; do 43 | _subj=$_subj" "$subjdir/$i 44 | done 45 | subj="$_subj" 46 | fi 47 | sess="$5" 48 | 49 | 50 | c=1 ; for i in $subj ; do 51 | for j in $sess ; do 52 | if [ -f $i/$j/$file ] ; then 53 | echo "$(zeropad $c 3) found: $i/$j/$file" 54 | c=$[$c+1] 55 | else 56 | echo " not found: $i/$j/$file" 57 | fi 58 | done 59 | done ; c=0 60 | 61 | set +e 62 | read -p "Press key..." 63 | set -e 64 | 65 | mkdir -p $(dirname $out) 66 | files="" 67 | rm -f $wdir/* 68 | rm -f ${out}.list 69 | c=1 ; for i in $subj ; do 70 | for j in $sess ; do 71 | if [ -f $i/$j/$file ] ; then 72 | if [ $doextr -eq 1 ] ; then 73 | echo "$(zeropad $c 3) found: $i/$j/$file - extracting at pos. $idx..." | tee -a ${out}.list 74 | _file=$(zeropad $c 3)_extracted_${idx} 75 | fslroi $i/$j/$file $wdir/$_file $idx 1 76 | files=$files" "$wdir/$_file 77 | elif [ $domean -eq 1 ] ; then 78 | echo "$(zeropad $c 3) found: $i/$j/$file - creating mean..." | tee -a ${out}.list 79 | _file=$(zeropad $c 3)_mean 80 | fslmaths $i/$j/$file -Tmean $wdir/$_file 81 | files=$files" "$wdir/$_file 82 | else 83 | echo "$(zeropad $c 3) found: $i/$j/$file" >> ${out}.list 84 | files=$files" "$i/$j/$file 85 | fi 86 | c=$[$c+1] 87 | else 88 | echo " not found: $i/$j/$file" >> ${out}.list 89 | fi 90 | done 91 | done ; c=0 92 | 93 | echo "merging..." 94 | cmd="fslmerge -t ${out} $files" 95 | echo $cmd ; $cmd 96 | 97 | #cmd="fslview ${out}" 98 | #echo $cmd | tee ${out}.cmd ; chmod +x ${out}.cmd ; $cmd 99 | 100 | 101 | echo "`basename $0`: done." 102 | -------------------------------------------------------------------------------- /rsc/scripts/convert_regs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Converts between affine matrix formats. 3 | 4 | # Written by Andreas Heckel 5 | # University of Heidelberg 6 | # heckelandreas@googlemail.com 7 | # https://github.com/ahheckel 8 | # 11/18/2012 9 | 10 | trap 'echo "$0 : An ERROR has occured."' ERR 11 | 12 | set -e 13 | 14 | Usage() { 15 | echo "" 16 | echo "Usage: `basename $0` " 17 | echo "Note: vox2vox ascii (.txt): targ->mov, not mov->targ" 18 | echo "" 19 | exit 1 20 | } 21 | 22 | [ "$4" = "" ] && Usage 23 | 24 | mov="$1" 25 | targ="$2" 26 | inmat="$3" 27 | outmat="$4" 28 | 29 | out_ext=${outmat##*.} 30 | in_ext=${inmat##*.} 31 | 32 | if [ "$in_ext" = "$out_ext" ] ; then echo "`basename $0` : ERROR : file extension of input and output matrices are the same (*.$out_ext)" ; exit 1 ; fi 33 | 34 | # create working dir. 35 | tmpdir=$(mktemp -d -t $(basename $0)_XXXXXXXXXX) # create unique dir. for temporary files 36 | 37 | # define exit trap 38 | trap "rm -f $tmpdir/* ; rmdir $tmpdir ; exit" EXIT 39 | 40 | # copy input matrix to temporary dir. (it gets overwritten otherwise) 41 | cp $inmat $tmpdir/inmat.${in_ext} 42 | _inmat=$tmpdir/inmat.${in_ext} 43 | 44 | regswitch=0 45 | if [ "$in_ext" = "dat" ] ; then regin="--reg $_inmat" ; regswitch=1 ; fi 46 | if [ "$in_ext" = "reg" ] ; then regin="--reg $_inmat" ; regswitch=1 ; fi 47 | if [ "$in_ext" = "xfm" ] ; then regin="--xfm $_inmat" ; fi 48 | if [ "$in_ext" = "mat" ] ; then regin="--fsl $_inmat" ; fi 49 | if [ "$in_ext" = "lta" ] ; then regin="--lta $_inmat" ; fi 50 | if [ "$in_ext" = "txt" ] ; then regin="--vox2vox $_inmat" ; fi 51 | 52 | if [ "$out_ext" = "dat" ] ; then regout="--reg $outmat" ; regswitch=1 ; fi 53 | if [ "$out_ext" = "reg" ] ; then regout="--reg $outmat" ; regswitch=1 ; fi 54 | if [ "$out_ext" = "xfm" ] ; then regout="--xfmout $outmat" ; fi 55 | if [ "$out_ext" = "mat" ] ; then regout="--fslregout $outmat" ; fi 56 | if [ "$out_ext" = "lta" ] ; then regout="--ltaout $outmat" ; fi 57 | 58 | #if [ "$in_ext" != "dat" -a "$out_ext" != "dat" ] ; then delme="--reg $tmpdir/deleteme.reg.dat" ; else delme="" ; fi 59 | if [ $regswitch -eq 0 ] ; then delme="--reg $tmpdir/deleteme.reg.dat" ; else delme="" ; fi 60 | 61 | cmd="tkregister2 --noedit --mov $mov --targ $targ $regin $regout $delme" 62 | echo $cmd ; $cmd 63 | 64 | # cleanup 65 | rm -f $tmpdir/deleteme.reg.dat 66 | rm -f $_inmat 67 | 68 | # done 69 | echo "`basename $0` : done." 70 | -------------------------------------------------------------------------------- /rsc/scripts/cycler.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Cycler. 3 | 4 | # Written by Andreas Heckel 5 | # University of Heidelberg 6 | # heckelandreas@googlemail.com 7 | # https://github.com/ahheckel 8 | # 11/18/2012 9 | 10 | trap 'echo "$0 : An ERROR has occured."' ERR 11 | 12 | set -e 13 | 14 | Usage() { 15 | echo "" 16 | echo "Usage: `basename $0` <'cmd'> <'01 02 03...'> <'A B C...'> <'a b c...'>" 17 | echo "Example: `basename $0` 'ls @^/@^^' '01 02 03' 'a b c'" 18 | echo "" 19 | exit 1 20 | } 21 | 22 | [ "$2" = "" ] && Usage 23 | 24 | cmd="$1" ; shift 25 | 26 | nlev=$# 27 | if [ $nlev -gt 4 ] ; then echo "`basename $0` : Sorry, `basename $0` does not support more than 4 levels." ; exit 1 ; fi 28 | 29 | a1="$1" 30 | a2="$2" 31 | a3="$3" 32 | a4="$4" 33 | 34 | if [ "$a2" = "" ] ; then a2="1" ; fi 35 | if [ "$a3" = "" ] ; then a3="1" ; fi 36 | if [ "$a4" = "" ] ; then a4="1" ; fi 37 | 38 | 39 | cmd=`echo $cmd | sed 's|@^^^^|\${LLL}|g'` 40 | cmd=`echo $cmd | sed 's|@^^^|\${KKK}|g'` 41 | cmd=`echo $cmd | sed 's|@^^|\${JJJ}|g'` 42 | cmd=`echo $cmd | sed 's|@^|\${III}|g'` 43 | 44 | export III JJJ KKK LLL 45 | 46 | for III in $a1 ; do 47 | for JJJ in $a2 ; do 48 | for KKK in $a3 ; do 49 | for LLL in $a4 ; do 50 | 51 | sh -c "echo $cmd" 52 | 53 | done 54 | done 55 | done 56 | done 57 | 58 | unset III JJJ KKK LLL 59 | 60 | -------------------------------------------------------------------------------- /rsc/scripts/dcm2niigz.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Converts DICOMS to compressed nifti using dcm2nii (Chris Rorden) 3 | 4 | # Written by Andreas Heckel 5 | # University of Heidelberg 6 | # heckelandreas@googlemail.com 7 | # https://github.com/ahheckel 8 | # 03/30/2013 9 | 10 | trap 'echo "$0 : An ERROR has occured."' ERR 11 | 12 | set -e 13 | 14 | Usage() { 15 | echo "" 16 | echo "`basename $0` will recursively parse for DICOMS, which will be converted to nii.gz files in ." 17 | echo "Usage: `basename $0` " 18 | echo "Example: `basename $0` dcm-dir out-dir" 19 | echo "" 20 | exit 1 21 | } 22 | 23 | [ "$2" = "" ] && Usage 24 | indir="$1" 25 | outdir="$2" 26 | 27 | # remove superfluous slashes 28 | indir=$(echo $indir | sed "s|/\./|/|g" | sed "s|/\+|/|g") 29 | indir=${indir%/} 30 | outdir=$(echo $outdir | sed "s|/\./|/|g" | sed "s|/\+|/|g") 31 | outdir=${outdir%/} 32 | 33 | # dcm2nii idiosyncrasy 34 | if [ $indir = "." ] ; then indir=$(pwd) ; fi 35 | 36 | # make outdir 37 | mkdir -p $outdir 38 | 39 | ## delete nii.gz files in outdir 40 | #for i in $(ls $outdir/*.nii.gz 2>/dev/null) ; do 41 | #rm -i $i 42 | #done 43 | #for i in $(ls $outdir/*.nii 2>/dev/null) ; do 44 | #rm -i $i 45 | #done 46 | 47 | # execute 48 | cmd="dcm2nii -d n -e y -g n -i y -p y -n y -r n -x n -o $outdir $indir/*" 49 | echo " $cmd" ; $cmd 50 | 51 | # compress 52 | for i in $(ls $outdir/*.nii) ; do 53 | cmd="gzip $i" 54 | echo " $cmd" ; $cmd 55 | done 56 | 57 | # done 58 | echo "`basename $0`: done." 59 | -------------------------------------------------------------------------------- /rsc/scripts/delbrokenlinks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Recursively removes broken symlinks. 3 | 4 | # Written by Andreas Heckel 5 | # University of Heidelberg 6 | # heckelandreas@googlemail.com 7 | # https://github.com/ahheckel 8 | # 11/18/2012 9 | 10 | trap 'echo "$0 : An ERROR has occured."' ERR 11 | 12 | set -e 13 | 14 | Usage() { 15 | echo "Recursively removes broken symlinks." 16 | echo "Usage: `basename $0` " 17 | echo "Examples: `basename $0` ./ 0" 18 | echo " ...removes all broken symlinks in whole dir-tree." 19 | echo " `basename $0` ./ 2" 20 | echo " ...removes all broken symlinks up to dir-level 2." 21 | echo " `basename $0` ./ 2 1" 22 | echo " ...reports all broken symlinks up to dir-level 2 (no deletions)." 23 | echo "" 24 | exit 1 25 | } 26 | 27 | 28 | [ "$2" = "" ] && Usage 29 | 30 | dir="$1" 31 | depth="$2" 32 | reportonly="$3" 33 | if [ x"$3" = "x" ] ; then 34 | reportonly=0 35 | fi 36 | 37 | if [ $reportonly -eq 1 ] ; then 38 | echo -n "`basename $0`: reporting all broken symlinks under '$dir' ... " 39 | else 40 | echo -n "`basename $0`: removing all broken symlinks under '$dir' ... " 41 | fi 42 | 43 | if [ ! -d $dir ] ; then echo "`basename $0`: '$dir' does not exist." ; exit 1 ; fi 44 | if [ $depth -gt 0 ] ; then 45 | maxdepth="-maxdepth $depth" 46 | echo "up to level $depth." 47 | elif [ $depth -eq 0 ] ; then 48 | maxdepth="" 49 | echo "" 50 | fi 51 | 52 | if [ $reportonly -eq 1 ] ; then 53 | find $dir -mindepth 1 $maxdepth -type l ! -exec test -e {} \; -exec echo {} \; 54 | else 55 | find $dir -mindepth 1 $maxdepth -type l ! -exec test -e {} \; -exec echo deleting {} \; -exec rm {} \; 56 | fi 57 | 58 | echo "`basename $0`: done." 59 | 60 | -------------------------------------------------------------------------------- /rsc/scripts/dummy_bvalbvec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Creates pseudo bval/bvec files. 3 | 4 | # Written by Andreas Heckel 5 | # University of Heidelberg 6 | # heckelandreas@googlemail.com 7 | # https://github.com/ahheckel 8 | # 11/20/2012 9 | 10 | set -e 11 | 12 | trap 'echo "$0 : An ERROR has occured."' ERR 13 | 14 | Usage() { 15 | echo "" 16 | echo "Usage: `basename $0` <4Dinput> " 17 | echo "" 18 | exit 1 19 | } 20 | 21 | [ "$1" = "" ] && Usage 22 | file=`remove_ext "$1"` 23 | if [ x"$2" = "x" ] ; then n_b0=4 ; else n_b0=$2 ; fi 24 | 25 | nvols=`fslinfo $file | grep ^dim4 | awk '{print $2}'` 26 | intb0=$(scale=0; echo "$nvols / $n_b0" | bc) 27 | 28 | vals="" 29 | vecs="" 30 | for i in `seq 1 $nvols` ; do 31 | if [ $i -eq 1 -a $n_b0 -gt 0 ] ; then 32 | vals=0 33 | vecs=0.5 34 | elif [ $i -le $n_b0 ] ; then 35 | vals=$vals" "0 36 | vecs=$vecs" "0.5 37 | else 38 | vals=$vals" "1000 39 | vecs=$vecs" "0.5 40 | fi 41 | done 42 | 43 | echo "`basename $0`: '${file}_bvals':" 44 | echo $vals | tee ${file}_bvals 45 | echo "`basename $0`: '${file}_bvecs':" 46 | echo $vecs 47 | echo $vecs 48 | echo $vecs 49 | echo $vecs > ${file}_bvecs 50 | echo $vecs >> ${file}_bvecs 51 | echo $vecs >> ${file}_bvecs 52 | 53 | echo "`basename $0`: done." 54 | -------------------------------------------------------------------------------- /rsc/scripts/eddy_correct_plot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ $# -lt 1 ] ; then 4 | echo "Usage: `basename $0` " 5 | exit 1; 6 | fi 7 | 8 | logfile=$1; 9 | subj=$2 # added by HKL 10 | basenm=`basename $logfile .ecclog`; 11 | 12 | nums=`grep -n 'Final' $logfile | sed 's/:.*//'`; 13 | 14 | touch grot_ts.txt 15 | touch grot.mat 16 | 17 | firsttime=yes; 18 | m=1; 19 | for n in $nums ; do 20 | echo "Timepoint $m" 21 | n1=`echo $n + 1 | bc` ; 22 | n2=`echo $n + 5 | bc` ; 23 | sed -n "$n1,${n2}p" $logfile > grot.mat ; 24 | if [ $firsttime = yes ] ; then firsttime=no; cp grot.mat grot.refmat ; cp grot.mat grot.oldmat ; fi 25 | absval=`$FSLDIR/bin/rmsdiff grot.mat grot.refmat $basenm`; 26 | relval=`$FSLDIR/bin/rmsdiff grot.mat grot.oldmat $basenm`; 27 | cp grot.mat grot.oldmat 28 | echo $absval $relval >> ec_disp.txt ; 29 | $FSLDIR/bin/avscale --allparams grot.mat $basenm | grep 'Rotation Angles' | sed 's/.* = //' >> ec_rot.txt ; 30 | $FSLDIR/bin/avscale --allparams grot.mat $basenm | grep 'Translations' | sed 's/.* = //' >> ec_trans.txt ; 31 | m=`echo $m + 1 | bc`; 32 | done 33 | 34 | echo "absolute" > grot_labels.txt 35 | echo "relative" >> grot_labels.txt 36 | 37 | $FSLDIR/bin/fsl_tsplot -i ec_disp.txt -t "Subj. $subj - Eddy Current estimated mean displacement (mm)" -l grot_labels.txt -o ec_disp.png 38 | 39 | echo "x" > grot_labels.txt 40 | echo "y" >> grot_labels.txt 41 | echo "z" >> grot_labels.txt 42 | 43 | $FSLDIR/bin/fsl_tsplot -i ec_rot.txt -t "Subj. $subj - Eddy Current estimated rotations (radians)" -l grot_labels.txt -o ec_rot.png 44 | $FSLDIR/bin/fsl_tsplot -i ec_trans.txt -t "Subj. $subj - Eddy Current estimated translations (mm)" -l grot_labels.txt -o ec_trans.png 45 | 46 | # clean up temp files 47 | /bin/rm grot_labels.txt grot.oldmat grot.refmat grot.mat grot_ts.txt 48 | -------------------------------------------------------------------------------- /rsc/scripts/estdeform.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Estimates the deformation (mean and median) of a fnirt warpfield to have a goodness of fit measure of the preceding affine registration. 3 | 4 | # Based on FSL's fsl_reg (v. 4.1.9). 5 | # Adapted by Andreas Heckel 6 | # University of Heidelberg 7 | # heckelandreas@googlemail.com 8 | # https://github.com/ahheckel 9 | # 11/18/2012 10 | 11 | set -e 12 | 13 | trap 'echo "$0 : An ERROR has occured."' ERR 14 | 15 | Usage() { 16 | echo "" 17 | echo "Usage: `basename $0` " 18 | echo "Example: `basename $0` t1_2_mni_warp.nii.gz" 19 | echo "" 20 | exit 1 21 | } 22 | 23 | [ "$1" = "" ] && Usage 24 | 25 | wf=$(remove_ext "$1") 26 | 27 | # estimate the mean deformation 28 | fslmaths ${wf} -sqr -Tmean ${wf}_tmp 29 | result=$(fslstats ${wf}_tmp -M -P 50) 30 | imrm ${wf}_tmp 31 | 32 | echo "`basename $0`: mean/median deformation of '$wf' : $result" 33 | #echo "`basename $0`: done." 34 | -------------------------------------------------------------------------------- /rsc/scripts/extract.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Extracts images from 4D volume. 3 | 4 | # Written by Andreas Heckel 5 | # University of Heidelberg 6 | # heckelandreas@googlemail.com 7 | # https://github.com/ahheckel 8 | # 04/29/2013 9 | 10 | set -e 11 | 12 | trap 'echo "$0 : An ERROR has occured."' ERR 13 | 14 | Usage() { 15 | echo "" 16 | echo "Usage: `basename $0` " 17 | echo "Example: `basename $0` melodic_IC.nii.gz ./test/melodic 0,1,2,3" 18 | echo " `basename $0` \"\$files\" -1 beg,mid,end" 19 | echo "Note: -1 : creates extraction in directory of input file." 20 | echo "" 21 | exit 1 22 | } 23 | 24 | [ "$3" = "" ] && Usage 25 | 26 | inputs="$1" 27 | _pref="$2" 28 | idxs="$(echo "$3" | sed 's|,| |g')" 29 | 30 | if [ $(echo $inputs | wc -w) -gt 1 -a "$_pref" != "-1" ] ; then echo "`basename $0`: ERROR: multiple inputs require option '-1' - exiting..." ; exit 1 ; fi 31 | 32 | for input in $inputs ; do 33 | 34 | input=$(remove_ext "$input") 35 | 36 | if [ "$_pref" = "-1" ] ; then 37 | pref=$(dirname $input)/$(basename $input) 38 | else 39 | pref=$_pref 40 | mkdir -p $(dirname $pref) 41 | fi 42 | 43 | total_volumes=`fslnvols $input 2> /dev/null` 44 | 45 | for idx in $idxs ; do 46 | #echo "`basename $0`: extracting volume at pos. $idx from '$input'..." 47 | if [ $idx = "beg" ] ; then 48 | idx=0 49 | echo "`basename $0`: start-position: $idx" 50 | fi 51 | if [ $idx = "mid" ] ; then 52 | idx=$(echo "$total_volumes / 2" | bc) 53 | echo "`basename $0`: mid-position: $idx" 54 | fi 55 | if [ $idx = "end" ] ; then 56 | idx=$(echo "$total_volumes - 1" | bc) 57 | echo "`basename $0`: end-position: $idx" 58 | fi 59 | cmd="fslroi $input ${pref}_$(zeropad $idx 4) $idx 1" 60 | echo " $cmd" ; $cmd 61 | done 62 | 63 | done 64 | 65 | echo "`basename $0`: done." 66 | -------------------------------------------------------------------------------- /rsc/scripts/extractmerge.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | SGE_ROOT="" 3 | . $(dirname $0)/extractmerge_parallel.sh "$@" 4 | -------------------------------------------------------------------------------- /rsc/scripts/feat_T1_2_MNI.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The FEAT way of T1->MNI registration. 3 | 4 | # Based on FSL's featlib.tcl (v. 4.1.9). 5 | # Adapted by Andreas Heckel 6 | # University of Heidelberg 7 | # heckelandreas@googlemail.com 8 | # https://github.com/ahheckel 9 | # 11/18/2012 10 | 11 | trap 'echo "$0 : An ERROR has occured."' ERR 12 | 13 | set -e 14 | 15 | Usage() { 16 | echo "" 17 | echo "Usage: `basename $0` [ ] " 18 | echo "" 19 | exit 1 20 | } 21 | 22 | [ "$4" = "" ] && Usage 23 | 24 | T1head=$(remove_ext $1) 25 | T1=$(remove_ext $2) 26 | out=$(remove_ext $3) 27 | aff=$4 28 | if [ $aff = "none" ] ; then 29 | if [ x$5 = "x" ] ; then 30 | costf="corratio" 31 | else 32 | costf="$5" 33 | shift 34 | fi 35 | if [ x$5 = "x" ] ; then 36 | initmat="" 37 | else 38 | initmat="-init $5" 39 | shift 40 | fi 41 | fi 42 | if [ x$5 = "x" ] ; then 43 | MNIhead=$FSLDIR/data/standard/MNI152_T1_2mm.nii.gz 44 | MNI=$FSLDIR/data/standard/MNI152_T1_2mm_brain.nii.gz 45 | MNI_mask=$FSLDIR/data/standard/MNI152_T1_2mm_brain_mask_dil.nii.gz 46 | else 47 | MNIhead=$(remove_ext $5) 48 | MNI=$(remove_ext $6) 49 | MNI_mask=$(remove_ext $7) 50 | fi 51 | subj="$8" # optional 52 | sess="$9" # optional 53 | 54 | outdir=$(dirname $out) 55 | 56 | 57 | if [ $aff = "none" ] ; then 58 | echo "`basename $0`: subj $subj , sess $sess : flirting brain '${T1}' -> '${MNI}'..." 59 | cmd="flirt -ref ${MNI} -in $T1 -out $outdir/$(basename $T1)2$(basename $MNI) $initmat -omat $outdir/$(basename $T1)2$(basename $MNI).mat -cost $costf -dof 12 -searchrx -90 90 -searchry -90 90 -searchrz -90 90 -interp trilinear" #-usesqform" 60 | echo $cmd ; $cmd 61 | aff=${outdir}/$(basename $T1)2$(basename $MNI).mat 62 | fi 63 | 64 | echo "`basename $0`: subj $subj , sess $sess : fnirting head '${T1head}' -> '${MNIhead}'..." 65 | cmd="fnirt --in=${T1head} --aff=${aff} --cout=${out}_warp --iout=${out} --jout=${out}_jac --config=T1_2_MNI152_2mm --ref=${MNIhead} --refmask=${MNI_mask} --warpres=10,10,10" 66 | echo $cmd ; $cmd 67 | 68 | echo "`basename $0`: subj $subj , sess $sess : '${out}' created." 69 | echo "`basename $0`: subj $subj , sess $sess : done." 70 | -------------------------------------------------------------------------------- /rsc/scripts/feat_hpf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The FEAT way of high-pass filtering. 3 | 4 | # Based on FSL's featlib.tcl (v. 4.1.9). 5 | # Adapted by Andreas Heckel 6 | # University of Heidelberg 7 | # heckelandreas@googlemail.com 8 | # https://github.com/ahheckel 9 | # 11/18/2012 10 | 11 | trap 'echo "$0 : An ERROR has occured."' ERR 12 | 13 | set -e 14 | 15 | Usage() { 16 | echo "" 17 | echo "Usage: `basename $0` <4dinput> " 18 | echo "" 19 | exit 1 20 | } 21 | 22 | [ "$4" = "" ] && Usage 23 | data=`remove_ext "$1"` 24 | out=`remove_ext "$2"` 25 | hpf="$3" 26 | TR="$4" 27 | subj="$5" # optional 28 | sess="$6" # optional 29 | 30 | if [ $hpf = "inf" -o $hpf = "Inf" ] ; then 31 | fslmaths $data ${out} 32 | else 33 | cmdaddmean="" 34 | version=$(cat $FSLDIR/etc/fslversion) 35 | if [ $( echo $version | cut -d . -f1) -ge 6 -o $( echo $version | cut -d . -f1) -ge 5 -a $( echo $version | cut -d . -f2) -ge 1 -o $( echo $version | cut -d . -f1) -eq 5 -a $( echo $version | cut -d . -f2) -eq 0 -a $( echo $version | cut -d . -f3) -ge 7 ] ; then 36 | fslmaths ${data} -Tmean ${out}_tmpmean 37 | cmdaddmean="-add ${out}_tmpmean" # need to add back mean in fsl >= 5.0.7 38 | echo "`basename $0`: subj $subj , sess $sess : highpass temporal filtering of ${data}: FSL >= 5.0.7 detected -> need to add back mean." 39 | fi 40 | hp_sigma_sec=$(echo "scale=9; $hpf / 2.0" | bc -l) 41 | hp_sigma_vol=$(echo "scale=9; $hp_sigma_sec / $TR" | bc -l) 42 | echo "`basename $0`: subj $subj , sess $sess : highpass temporal filtering of ${data} (Gaussian-weighted least-squares straight line fitting, with sigma=${hp_sigma_sec}s)..." 43 | cmd="fslmaths $data -bptf $hp_sigma_vol -1 $cmdaddmean ${out}" ; echo " $cmd" 44 | $cmd 45 | fi 46 | # cleanup 47 | if [ $(imtest ${out}_tmpmean) -eq 1 ] ; then imrm ${out}_tmpmean ; fi 48 | 49 | # done 50 | echo "`basename $0`: subj $subj , sess $sess : done." 51 | -------------------------------------------------------------------------------- /rsc/scripts/feat_mask.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The FEAT way of making the mask. 3 | 4 | # Based on FSL's featlib.tcl (v. 4.1.9). 5 | # Adapted by Andreas Heckel 6 | # University of Heidelberg 7 | # heckelandreas@googlemail.com 8 | # https://github.com/ahheckel 9 | # 11/18/2012 10 | 11 | trap 'echo "$0 : An ERROR has occured."' ERR 12 | 13 | set -e 14 | 15 | Usage() { 16 | echo "" 17 | echo "Usage: `basename $0` <4dinput> " 18 | echo "" 19 | exit 1 20 | } 21 | 22 | [ "$2" = "" ] && Usage 23 | data=`remove_ext "$1"` 24 | out=`remove_ext "$2"` 25 | subj="$3" # optional 26 | sess="$4" # optional 27 | 28 | echo "`basename $0`: subj $subj , sess $sess : generating mask for $data -> $out..." 29 | 30 | echo "`basename $0`: subj $subj , sess $sess : generating `basename ${out}_mean_func`..." 31 | fslmaths ${data} -Tmean ${out}_mean_func 32 | 33 | echo "`basename $0`: subj $subj , sess $sess : betting `basename ${out}_mean_func` -> `basename ${out}`..." 34 | bet2 ${out}_mean_func ${out} -f 0.3 -n -m ; immv ${out}_mask ${out} 35 | 36 | echo "`basename $0`: subj $subj , sess $sess : masking `basename ${data}` -> `basename ${out}_bet`..." 37 | fslmaths ${data} -mas ${out} ${out}_bet 38 | range=`fslstats ${out}_bet -p 2 -p 98` 39 | int2=$(echo $range | cut -d " " -f 1) 40 | int98=$(echo $range | cut -d " " -f 2) 41 | brain_thres=10 42 | intensity_threshold=$(echo "scale=10; $int2 + ( ( $int98 - $int2 ) / 100.0 * $brain_thres )" | bc -l) 43 | echo "`basename $0`: subj $subj , sess $sess : -> p2: $int2" 44 | echo "`basename $0`: subj $subj , sess $sess : -> p98: $int98" 45 | echo "`basename $0`: subj $subj , sess $sess : -> intensity threshold: $intensity_threshold" 46 | 47 | echo "`basename $0`: subj $subj , sess $sess : thresholding `basename ${out}_bet` with $intensity_threshold -> `basename ${out}`..." 48 | fslmaths ${out}_bet -thr $intensity_threshold -Tmin -bin ${out} -odt char 49 | median_intensity=`fslstats ${data} -k ${out} -p 50` 50 | susan_int=$(echo "scale=10; ($median_intensity - $int2) * 0.75" | bc -l ) 51 | echo "`basename $0`: subj $subj , sess $sess : -> median: $median_intensity" 52 | echo "`basename $0`: subj $subj , sess $sess : -> brightness threshold (susan_int): $susan_int" 53 | 54 | echo "`basename $0`: subj $subj , sess $sess : dilating `basename ${out}`..." 55 | fslmaths ${out} -dilF ${out} 56 | 57 | # cleanup 58 | echo "`basename $0`: subj $subj , sess $sess : cleanup..." 59 | imrm ${out}_bet ${out}_mean_func 60 | 61 | # save stats 62 | echo "$int2 $int98 $intensity_threshold $median_intensity $susan_int" > ${out}_vals 63 | 64 | echo "`basename $0`: subj $subj , sess $sess : done." 65 | -------------------------------------------------------------------------------- /rsc/scripts/feat_scale.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # The FEAT way of scaling. 3 | 4 | # Based on FSL's featlib.tcl (v. 4.1.9). 5 | # Adapted by Andreas Heckel 6 | # University of Heidelberg 7 | # heckelandreas@googlemail.com 8 | # https://github.com/ahheckel 9 | # 11/18/2012 10 | 11 | set -e 12 | 13 | trap 'echo "$0 : An ERROR has occured."' ERR 14 | 15 | Usage() { 16 | echo "" 17 | echo "Usage: `basename $0` <4dinput> <'global'|'prop'> " 18 | echo "" 19 | exit 1 20 | } 21 | 22 | [ "$4" = "" ] && Usage 23 | data=`remove_ext "$1"` 24 | out=`remove_ext "$2"` 25 | mode="$3" 26 | normmean="$4" 27 | median_intensity="$5" 28 | subj="$6" # optional 29 | sess="$7" # optional 30 | 31 | if [ $mode = "global" ] ; then 32 | if [ x"$median_intensity" = x ] ; then Usage ; fi 33 | scaling=$(echo "scale=10; $normmean / $median_intensity" | bc -l) 34 | echo "`basename $0`: subj $subj , sess $sess : global-mean scaling of ${data} with factor $scaling..." 35 | fslmaths ${data} -mul $scaling ${out} 36 | elif [ $mode = "prop" ] ; then 37 | echo "`basename $0`: subj $subj , sess $sess : multiplicative mean intensity normalization of ${data} at each timepoint..." 38 | fslmaths ${data} -inm $normmean ${out} 39 | else 40 | echo "`basename $0`: subj $subj , sess $sess : ERROR : mode '$mode' not recognised..." 41 | exit 1 42 | fi 43 | 44 | echo "`basename $0`: subj $subj , sess $sess : done." 45 | -------------------------------------------------------------------------------- /rsc/scripts/feat_writeMNI.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Writes input to MNI space according to given transforms. For internal use only. 3 | 4 | # Based on FSL's featlib.tcl (v. 4.1.9). 5 | # Adapted by Andreas Heckel 6 | # University of Heidelberg 7 | # heckelandreas@googlemail.com 8 | # https://github.com/ahheckel 9 | # 11/18/2012 10 | 11 | trap 'echo "$0 : An ERROR has occured."' ERR 12 | 13 | set -e 14 | 15 | Usage() { 16 | echo "" 17 | echo "Usage: `basename $0` T1> MNI> " 18 | echo "" 19 | exit 1 20 | } 21 | 22 | [ "$7" = "" ] && Usage 23 | input=$(remove_ext "$1") 24 | MNI=$(remove_ext "$2") 25 | output=$(remove_ext "$3") 26 | mni_res=$4 27 | affine=$5 28 | warp=$6 29 | interp="$7" 30 | subj="$8" # optional 31 | sess="${9}" # optional 32 | 33 | outdir=$(dirname $output) 34 | _mni_res=$(echo $mni_res | sed "s|\.||g") # remove '.' 35 | 36 | # create working dir. 37 | tmpdir=$(mktemp -d -t $(basename $0)_XXXXXXXXXX) # create unique dir. for temporary files 38 | 39 | # define exit trap 40 | trap "rm -f $tmpdir/* ; rmdir $tmpdir ; exit" EXIT 41 | 42 | echo "`basename $0`: subj $subj , sess $sess : output directory: '$outdir'" 43 | 44 | echo "`basename $0`: subj $subj , sess $sess : write Input->MNI ('$input' -> '$output')..." 45 | 46 | imrm ${tmpdir}/$(basename $output)_tmp_????.* 47 | fslsplit $input ${tmpdir}/$(basename $output)_tmp_ 48 | full_list=`imglob ${tmpdir}/$(basename $output)_tmp_????.*` 49 | for i in $full_list ; do 50 | echo "processing $i" 51 | cmd="applywarp --ref=$outdir/$(basename $MNI)_${_mni_res} --in=$i --out=$i --warp=${warp} --premat=${affine} --interp=${interp}" 52 | #echo $cmd 53 | $cmd 54 | done 55 | echo "`basename $0`: subj $subj , sess $sess : merge outputs...." 56 | fslmerge -t $output $full_list 57 | imrm $full_list 58 | 59 | echo "`basename $0`: subj $subj , sess $sess : done." 60 | -------------------------------------------------------------------------------- /rsc/scripts/fs_annotquery.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Written by Andreas Heckel 4 | # University of Freiburg 5 | # heckelandreas@googlemail.com 6 | # https://github.com/ahheckel 7 | # 05/20/2015 8 | 9 | trap 'echo "$0 : An ERROR has occured."' ERR 10 | 11 | set -e 12 | 13 | Usage() { 14 | echo "" 15 | echo "Usage: `basename $0` " 16 | echo "Example: `basename $0` out.txt 1.5 /usr/local/freesurfer/subjects/fsaverage/label/lh.aparc.a2009s.annot sig.mgh (mgh files must be non-concatenated)" 17 | echo " `basename $0` out.txt na /usr/local/freesurfer/subjects/fsaverage/label/lh.aparc.a2009s.annot *.label" 18 | echo "" 19 | exit 1 20 | } 21 | 22 | [ "$4" = "" ] && Usage 23 | 24 | # create working dir. 25 | tmpdir=$(mktemp -d -t $(basename $0)_XXXXXXXXXX) # create unique dir. for temporary files 26 | 27 | # define exit trap 28 | trap "rm -f $tmpdir/* ; rmdir $tmpdir ; exit" EXIT 29 | 30 | # define vars 31 | out="$1" ; shift 32 | tval=$1 ; shift 33 | annot="$1" ; shift 34 | labelfiles="" ; 35 | while [ _$1 != _ ] ; do 36 | cp "$1" $tmpdir # copy inputs to tmpdir 37 | labels=$labels,\'$(basename $1)\' 38 | shift 39 | done 40 | labels="{$labels}" 41 | labels=$(echo $labels | sed "s|{,'|{'|g") # create matlab cell array 42 | wd=`pwd` 43 | 44 | # copy other files to tmpdir 45 | cp $(which annotquery_label.m) $tmpdir 46 | cp $(which annotquery_sig.m) $tmpdir 47 | cp $annot $tmpdir 48 | 49 | # adapt .m files 50 | sed -i "s|% labelfiles=LABELS|labelfiles=$labels|g" $tmpdir/annotquery_label.m 51 | sed -i "s|% annotfile=ANNOT|annotfile=\'$(basename $annot)\'|g" $tmpdir/annotquery_label.m 52 | sed -i "s|% out=OUT|out=\'$(basename $out)\'|g" $tmpdir/annotquery_label.m 53 | sed -i "s|% EXIT|exit|g" $tmpdir/annotquery_label.m 54 | # -------------- 55 | sed -i "s|% sigfiles=SIGFILES|sigfiles=$labels|g" $tmpdir/annotquery_sig.m 56 | sed -i "s|% annotfile=ANNOT|annotfile=\'$(basename $annot)\'|g" $tmpdir/annotquery_sig.m 57 | sed -i "s|% out=OUT|out=\'$(basename $out)\'|g" $tmpdir/annotquery_sig.m 58 | sed -i "s|% tval=TVAL|tval=$tval|g" $tmpdir/annotquery_sig.m 59 | sed -i "s|% EXIT|exit|g" $tmpdir/annotquery_sig.m 60 | 61 | # execute 62 | cd $tmpdir 63 | if [ $tval = "na" ] ; then 64 | xterm -e "matlab -nodesktop -nosplash -r annotquery_label" 65 | else 66 | xterm -e "matlab -nodesktop -nosplash -r annotquery_sig" 67 | fi 68 | cd $wd 69 | 70 | # copy results file 71 | cp $tmpdir/$(basename $out) $out 72 | 73 | # display result 74 | cat $out 75 | -------------------------------------------------------------------------------- /rsc/scripts/fs_convert.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Converts Freesurfer-format to FSL-format / normalizes WM-intensity and conforms to 256^3 at 1mm (or another isotropic resolution) if requested. 3 | 4 | # Written by Andreas Heckel 5 | # University of Heidelberg 6 | # heckelandreas@googlemail.com 7 | # https://github.com/ahheckel 8 | # 10/04/2013 9 | 10 | trap 'echo "$0 : An ERROR has occured."' ERR 11 | 12 | set -e 13 | 14 | Usage() { 15 | echo "" 16 | echo "Usage: `basename $0` [-n] [] []" 17 | echo "Options: -n normalize output" 18 | echo "" 19 | echo "Example: `basename $0` -n T1.mgz T1.nii.gz 1 2 \"-odt float -c -rt cubic\"" 20 | echo "" 21 | exit 1 22 | } 23 | 24 | if [ "$1" = "-n" ] ; then 25 | normalize=1 26 | shift 27 | else 28 | normalize=0 29 | fi 30 | 31 | [ "$3" = "" ] && Usage 32 | 33 | input=$1 34 | out=$2 35 | reor=$3 36 | res=$4 37 | opts="$5" 38 | 39 | if [ x"$res" = "x" ] ; then 40 | resopt="" 41 | else 42 | resopt="-applyisoxfm $res" 43 | fi 44 | if [ x"$opts" = "x" ] ; then 45 | opts="-odt float" 46 | fi 47 | 48 | if [ $normalize -eq 1 ] ; then 49 | mri_convert $input ${input%%.*}.mnc -odt float 50 | nu_correct -clobber ${input%%.*}.mnc ${input%%.*}_nu.mnc 51 | mri_normalize ${input%%.*}_nu.mnc ${input%%.*}_nu_norm.mnc 52 | mri_convert ${input%%.*}_nu_norm.mnc $out $opts 53 | rm -f ${input%%.*}.mnc ${input%%.*}_nu.mnc ${input%%.*}_nu_norm.mnc ${input%%.*}_nu.imp 54 | else 55 | cmd="mri_convert $input $out $opts" 56 | echo "`basename $0`: executing '$cmd'" 57 | $cmd 1>/dev/null 58 | fi 59 | 60 | if [ $reor -eq 1 ] ; then 61 | echo "`basename $0`: applying fslreorient2std..." 62 | fslreorient2std $out $out 63 | fi 64 | 65 | if [ x"$resopt" != "x" ] ; then 66 | echo "`basename $0`: resampling to resolution '$resopt'..." 67 | flirt -in $out -ref $out $resopt -out ${out} 68 | fi 69 | 70 | echo "`basename $0`: done." 71 | -------------------------------------------------------------------------------- /rsc/scripts/fs_label2vol.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Converts Freesurfer label files to NIFTI. 3 | 4 | # Written by Andreas Heckel 5 | # University of Heidelberg 6 | # heckelandreas@googlemail.com 7 | # https://github.com/ahheckel 8 | # 07/03/2014 9 | 10 | trap 'echo "$0 : An ERROR has occured."' ERR 11 | 12 | set -e 13 | 14 | Usage() { 15 | echo "" 16 | echo "Usage: `basename $0`