├── .gitattributes ├── .gitignore ├── .gitmodules ├── .zenodo.json ├── LICENSE ├── README.md ├── analysis ├── fmri │ ├── README.txt │ ├── active-task │ │ ├── Act_Package │ │ │ ├── EA_Act.m │ │ │ ├── EA_ShowResults.m │ │ │ ├── enrico_classical_preprocess.m │ │ │ ├── enrico_classical_preprocess_norm.m │ │ │ └── enrico_classical_stat.m │ │ ├── MRI_ActiveTaskParadigm_CHU-Coma-Science-Group_130313_english.doc │ │ ├── tennis-test-cosmo_2level-analysis_scripts │ │ │ ├── spm_2nd-level_paired-t-test_cosmo_navigation.mat │ │ │ └── spm_2nd-level_paired-t-test_cosmo_tennis.mat │ │ └── tennis-test-cosmo_3level-analysis_scripts │ │ │ ├── ImCalc_job_csf.m │ │ │ ├── ImCalc_job_grey.m │ │ │ ├── ImCalc_job_navigation.m │ │ │ ├── ImCalc_job_navigation_followuppost.m │ │ │ ├── ImCalc_job_navigation_followuppre.m │ │ │ ├── ImCalc_job_tennis.m │ │ │ ├── ImCalc_job_tennis_followuppost.m │ │ │ ├── ImCalc_job_tennis_followuppre.m │ │ │ ├── ImCalc_job_white.m │ │ │ ├── exp2_stats_navigation_tfce.mat │ │ │ ├── exp2_stats_tennis_tfce.mat │ │ │ ├── exp3_stats_navigation_snpm.mat │ │ │ ├── exp3_stats_tennis_snpm.mat │ │ │ ├── exp_csf_group.mat │ │ │ ├── exp_grey_group.mat │ │ │ ├── exp_navigation_group.mat │ │ │ ├── exp_navigation_group_2024.mat │ │ │ ├── exp_navigation_group_followup-post.mat │ │ │ ├── exp_navigation_group_followup-pre.mat │ │ │ ├── exp_tennis_group.mat │ │ │ ├── exp_tennis_group_2024.mat │ │ │ ├── exp_tennis_group_followup-post.mat │ │ │ ├── exp_tennis_group_followup-pre.mat │ │ │ ├── exp_white_group.mat │ │ │ ├── readme.txt │ │ │ └── version.txt │ ├── conn_subjects_loader │ │ └── conn_subjects_loader.m │ └── various │ │ ├── callPython.m │ │ ├── conn_1stlevel_ttest.m │ │ ├── conn_3dvis.m │ │ ├── movvis.m │ │ ├── run_spm_jobs.m │ │ └── threshold_fdr.m └── smri │ └── single-subject-longitudinal │ ├── control-1-gm-smoothed.nii │ ├── control-2-gm-smoothed.nii │ ├── control-etc...gm-smoothed.nii │ ├── patient-post-scan-gm-smoothed.nii │ ├── patient-pre-scan-gm-smoothed.nii │ └── vbm_singlesubject_longitudinal_stattest_spm12.mat ├── external ├── cat12-csg-install.txt ├── cat12_latest.zip └── spm12.zip ├── how to update submodules.txt ├── preprocessing ├── dwi │ ├── Conv_track.py │ ├── DTIValueAfter.txt │ ├── DTIValueBefore.txt │ ├── EA_masking.m │ ├── FAQ.pdf │ ├── NIfTI_tools.pdf │ ├── New_Patients_Prep_Multishell.sh │ ├── New_Patients_Prep_SingleshellACT.sh │ ├── New_Patients_Prep_SingleshellACT_step1.sh │ ├── New_Patients_Prep_SingleshellACT_step2.sh │ ├── New_Patients_Prep_SingleshellACT_step3.sh │ ├── New_Patients_Prep_SingleshellNoACT.sh │ ├── README.txt │ ├── Resample_im.m │ ├── UseANALYZE.pdf │ ├── _version.py │ ├── acqp.txt │ ├── affine.m │ ├── bipolar.m │ ├── bresenham_line3d.m │ ├── clip_nii.m │ ├── collapse_nii_scan.m │ ├── docs │ │ ├── How-to-configure-Neurodebian8-for-DTI-analysis.txt │ │ └── MRI-printout-DWI-3shells-ComaScienceGroup.pdf │ ├── dti-template-multishell.png │ ├── dti-template.png │ ├── dti-template.xcf │ ├── dti_gen_final_image │ │ ├── README.txt │ │ ├── _version.py │ │ ├── arialbold.ttf │ │ ├── dti-template-blank-multishellnoact.png │ │ ├── dti-template-blank-old.png │ │ ├── dti-template-blank-singleshellact.png │ │ ├── dti_gen_final_image.ipynb │ │ └── dti_gen_final_image.py │ ├── dti_pipeline.py │ ├── examples.txt │ ├── expand_nii_scan.m │ ├── extra_nii_hdr.m │ ├── flip_lr.m │ ├── get_nii_frame.m │ ├── index.txt │ ├── license.txt │ ├── load_nii.m │ ├── load_nii_ext.m │ ├── load_nii_hdr.m │ ├── load_nii_img.m │ ├── load_untouch0_nii_hdr.m │ ├── load_untouch_header_only.m │ ├── load_untouch_nii.m │ ├── load_untouch_nii_hdr.m │ ├── load_untouch_nii_img.m │ ├── make_ana.m │ ├── make_nii.m │ ├── mat_into_hdr.m │ ├── pad_nii.m │ ├── process_spm_coreg_and_exit.m │ ├── reslice_nii.m │ ├── rri_file_menu.m │ ├── rri_orient.m │ ├── rri_orient_ui.m │ ├── rri_select_file.m │ ├── rri_xhair.m │ ├── rri_zoom_menu.m │ ├── save_nii.m │ ├── save_nii_ext.m │ ├── save_nii_hdr.m │ ├── save_untouch0_nii_hdr.m │ ├── save_untouch_header_only.m │ ├── save_untouch_nii.m │ ├── save_untouch_nii_hdr.m │ ├── save_untouch_slice.m │ ├── unxform_nii.m │ ├── verify_nii_ext.m │ ├── view_nii.m │ ├── view_nii_menu.m │ └── xform_nii.m ├── fmri-conn │ ├── README.txt │ ├── conn-csg-pipeline-noreslice-maskedsmoothing.mat │ ├── conn-csg-pipeline-noreslice.info │ ├── conn-csg-pipeline-noreslice.mat │ ├── conn-csg-pipeline-reslice.info │ ├── conn-csg-pipeline-reslice.mat │ ├── conn-csg-pipeline-unwarp-maskedsmoothing.mat │ ├── conn-csg-pipeline-unwarp.info │ └── conn-csg-pipeline-unwarp.mat ├── fmri │ ├── README.txt │ ├── autodetect_sliceorder.m │ ├── batch_preproc_spm12_CAT12Dartel_2024.mat │ ├── batch_preproc_spm12_CAT12Dartel_2024_unwarp.mat │ ├── batch_preproc_spm12_CAT12Dartel_old2019.mat │ ├── batch_preproc_spm12_CAT12Dartel_old2019_expand.mat │ ├── batch_preproc_spm12_CAT12Dartel_old2019_unwarp.mat │ ├── batch_preproc_spm12_oldseg.mat │ ├── batch_preproc_spm12_oldseg_expand.mat │ ├── batch_preproc_spm12_oldseg_unwarp.mat │ ├── batch_preproc_spm12_uniseg.mat │ ├── batch_preproc_spm12_uniseg_unwarp.mat │ ├── batch_preproc_spm8_vbm8dartel_midtemplate_defbiascorrected.mat │ ├── batch_preproc_spm8_vbm8dartel_midtemplate_defbiascorrected_expand.mat │ ├── dirPlus.m │ ├── gen_microtime_onset.m │ ├── gen_slice_order.m │ ├── jsonlab │ │ ├── .gitignore │ │ ├── AUTHORS.txt │ │ ├── ChangeLog.txt │ │ ├── LICENSE_BSD.txt │ │ ├── LICENSE_GPLv3.txt │ │ ├── README.rst │ │ ├── README.txt │ │ ├── examples │ │ │ ├── demo_jsonlab_basic.m │ │ │ ├── demo_ubjson_basic.m │ │ │ ├── example1.json │ │ │ ├── example2.json │ │ │ ├── example3.json │ │ │ ├── example4.json │ │ │ ├── jsonlab_basictest.matlab │ │ │ ├── jsonlab_selftest.m │ │ │ ├── jsonlab_selftest.matlab │ │ │ └── jsonlab_speedtest.m │ │ ├── jsonopt.m │ │ ├── loadjson.m │ │ ├── loadubjson.m │ │ ├── mergestruct.m │ │ ├── package.json │ │ ├── savejson.m │ │ ├── saveubjson.m │ │ ├── struct2jdata.m │ │ └── varargin2struct.m │ ├── nifti_3dto4d_convert_recursive.m │ ├── nifti_4dto3d_convert_recursive.m │ ├── regex_files.m │ ├── resize_img.m │ └── script_preproc_fmri_csg.m ├── smri │ ├── INSTRUCTIONS_HOWTO_VBM_ANALYSIS_CSG.txt │ ├── README.txt │ ├── callPython.m │ ├── vbm_gen_final_image.exe │ ├── vbm_gen_final_image.ipynb │ ├── vbm_gen_final_image.py │ ├── vbm_results.m │ ├── vbm_script_preproc_csg.m │ └── vbm_script_preproc_csg_relativepaths.m └── utils │ ├── nifti_convert_recursive │ ├── LICENSE │ ├── dirPlus.m │ ├── nifti_3dto4d_convert_recursive.m │ └── nifti_4dto3d_convert_recursive.m │ └── slice_order │ ├── autodetect_sliceorder.m │ ├── gen_microtime_onset.m │ ├── gen_slice_order.m │ └── jsonlab │ ├── .gitignore │ ├── AUTHORS.txt │ ├── ChangeLog.txt │ ├── LICENSE_BSD.txt │ ├── LICENSE_GPLv3.txt │ ├── README.rst │ ├── README.txt │ ├── examples │ ├── demo_jsonlab_basic.m │ ├── demo_ubjson_basic.m │ ├── example1.json │ ├── example2.json │ ├── example3.json │ ├── example4.json │ ├── jsonlab_basictest.matlab │ ├── jsonlab_selftest.m │ ├── jsonlab_selftest.matlab │ └── jsonlab_speedtest.m │ ├── jsonopt.m │ ├── loadjson.m │ ├── loadubjson.m │ ├── mergestruct.m │ ├── package.json │ ├── savejson.m │ ├── saveubjson.m │ ├── struct2jdata.m │ └── varargin2struct.m └── utils ├── README.md ├── asciirename ├── asciirename.py └── unidecode │ ├── __init__.py │ ├── util.py │ ├── x000.py │ ├── x001.py │ ├── x002.py │ ├── x003.py │ ├── x004.py │ ├── x005.py │ ├── x006.py │ ├── x007.py │ ├── x009.py │ ├── x00a.py │ ├── x00b.py │ ├── x00c.py │ ├── x00d.py │ ├── x00e.py │ ├── x00f.py │ ├── x010.py │ ├── x011.py │ ├── x012.py │ ├── x013.py │ ├── x014.py │ ├── x015.py │ ├── x016.py │ ├── x017.py │ ├── x018.py │ ├── x01d.py │ ├── x01e.py │ ├── x01f.py │ ├── x020.py │ ├── x021.py │ ├── x022.py │ ├── x023.py │ ├── x024.py │ ├── x025.py │ ├── x026.py │ ├── x027.py │ ├── x028.py │ ├── x029.py │ ├── x02a.py │ ├── x02c.py │ ├── x02e.py │ ├── x02f.py │ ├── x030.py │ ├── x031.py │ ├── x032.py │ ├── x033.py │ ├── x04d.py │ ├── x04e.py │ ├── x04f.py │ ├── x050.py │ ├── x051.py │ ├── x052.py │ ├── x053.py │ ├── x054.py │ ├── x055.py │ ├── x056.py │ ├── x057.py │ ├── x058.py │ ├── x059.py │ ├── x05a.py │ ├── x05b.py │ ├── x05c.py │ ├── x05d.py │ ├── x05e.py │ ├── x05f.py │ ├── x060.py │ ├── x061.py │ ├── x062.py │ ├── x063.py │ ├── x064.py │ ├── x065.py │ ├── x066.py │ ├── x067.py │ ├── x068.py │ ├── x069.py │ ├── x06a.py │ ├── x06b.py │ ├── x06c.py │ ├── x06d.py │ ├── x06e.py │ ├── x06f.py │ ├── x070.py │ ├── x071.py │ ├── x072.py │ ├── x073.py │ ├── x074.py │ ├── x075.py │ ├── x076.py │ ├── x077.py │ ├── x078.py │ ├── x079.py │ ├── x07a.py │ ├── x07b.py │ ├── x07c.py │ ├── x07d.py │ ├── x07e.py │ ├── x07f.py │ ├── x080.py │ ├── x081.py │ ├── x082.py │ ├── x083.py │ ├── x084.py │ ├── x085.py │ ├── x086.py │ ├── x087.py │ ├── x088.py │ ├── x089.py │ ├── x08a.py │ ├── x08b.py │ ├── x08c.py │ ├── x08d.py │ ├── x08e.py │ ├── x08f.py │ ├── x090.py │ ├── x091.py │ ├── x092.py │ ├── x093.py │ ├── x094.py │ ├── x095.py │ ├── x096.py │ ├── x097.py │ ├── x098.py │ ├── x099.py │ ├── x09a.py │ ├── x09b.py │ ├── x09c.py │ ├── x09d.py │ ├── x09e.py │ ├── x09f.py │ ├── x0a0.py │ ├── x0a1.py │ ├── x0a2.py │ ├── x0a3.py │ ├── x0a4.py │ ├── x0ac.py │ ├── x0ad.py │ ├── x0ae.py │ ├── x0af.py │ ├── x0b0.py │ ├── x0b1.py │ ├── x0b2.py │ ├── x0b3.py │ ├── x0b4.py │ ├── x0b5.py │ ├── x0b6.py │ ├── x0b7.py │ ├── x0b8.py │ ├── x0b9.py │ ├── x0ba.py │ ├── x0bb.py │ ├── x0bc.py │ ├── x0bd.py │ ├── x0be.py │ ├── x0bf.py │ ├── x0c0.py │ ├── x0c1.py │ ├── x0c2.py │ ├── x0c3.py │ ├── x0c4.py │ ├── x0c5.py │ ├── x0c6.py │ ├── x0c7.py │ ├── x0c8.py │ ├── x0c9.py │ ├── x0ca.py │ ├── x0cb.py │ ├── x0cc.py │ ├── x0cd.py │ ├── x0ce.py │ ├── x0cf.py │ ├── x0d0.py │ ├── x0d1.py │ ├── x0d2.py │ ├── x0d3.py │ ├── x0d4.py │ ├── x0d5.py │ ├── x0d6.py │ ├── x0d7.py │ ├── x0f9.py │ ├── x0fa.py │ ├── x0fb.py │ ├── x0fc.py │ ├── x0fd.py │ ├── x0fe.py │ ├── x0ff.py │ ├── x1d4.py │ ├── x1d5.py │ ├── x1d6.py │ ├── x1d7.py │ └── x1f1.py ├── python-various └── datediff.py └── study-specific ├── helper_scripts ├── addcalccommands.m ├── addpath_conn17f.m ├── addpath_conn18b.m ├── addpath_spm12.m ├── addpath_spm12_fdr.m ├── addpath_spm8.m └── get_totals.m └── sleep ├── regex_files.m └── sleepvolslist.ipynb /.gitattributes: -------------------------------------------------------------------------------- 1 | *.zip filter=lfs diff=lfs merge=lfs -text 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | #*.manifest 31 | #*.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | 55 | # Sphinx documentation 56 | docs/_build/ 57 | 58 | # PyBuilder 59 | target/ 60 | 61 | #Ipython Notebook 62 | .ipynb_checkpoints 63 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "utils/pathmatcher"] 2 | path = utils/pathmatcher 3 | url = https://github.com/lrq3000/pathmatcher.git 4 | -------------------------------------------------------------------------------- /.zenodo.json: -------------------------------------------------------------------------------- 1 | { 2 | "creators": [ 3 | { 4 | "affiliation": "Coma Science Group (GIGA-Consciousness, ULg) & Centre du Cerveau² (CHU)", 5 | "name": "Larroque, Stephen Karl", 6 | "orcid": "0000-0002-6248-0957" 7 | } 8 | ], 9 | "keywords": [ 10 | "Magnetic Resonance Imagery", 11 | "MRI", 12 | "analysis", 13 | "pipeline", 14 | "functional MRI", 15 | "fMRI", 16 | "diffusion MRI", 17 | "dMRI", 18 | "structural MRI", 19 | "sMRI", 20 | "VBM", 21 | "CAT12", 22 | "SPM12", 23 | "SPM8" 24 | ], 25 | "license": "MIT", 26 | "upload_type": "software" 27 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-2020 Stephen Karl Larroque 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /analysis/fmri/README.txt: -------------------------------------------------------------------------------- 1 | * Active-task folder contains active task paradigm designs, such as tennis and navigation imagination tasks. It's an activity analysis. 2 | * conn_subjects_loader folder contains a script to ease data loading and design setup in CONN, to perform functional connectivity analyses. Active task paradigm can also be done in CONN by using gPPI. 3 | -------------------------------------------------------------------------------- /analysis/fmri/active-task/Act_Package/EA_ShowResults.m: -------------------------------------------------------------------------------- 1 | function EA_ShowResults() 2 | % Setup SPM results gui 3 | load(fullfile(rootpath, 'SPM.mat')); 4 | connum = 1; 5 | thresh = 0.05; 6 | threshdesc = 'FDR'; 7 | k = 0; 8 | job = struct('swd', SPM.swd, ... 9 | 'Ic', connum, ... 10 | 'u', thresh, ... 11 | 'Im', [], ... 12 | 'thresDesc', threshdesc, ... 13 | 'title', SPM.xCon(connum).name, ... 14 | 'k', k); 15 | 16 | % Set modality (FMRI) 17 | spm('defaults', 'FMRI') 18 | % Load the SPM results 19 | [hReg, xSPM, SPM] = spm_results_ui('setup', job); 20 | 21 | % Section visu 22 | spm_sections(xSPM,hReg,fullfile(rootpath, ['wmr' T1name '.nii'])); 23 | end % end script -------------------------------------------------------------------------------- /analysis/fmri/active-task/MRI_ActiveTaskParadigm_CHU-Coma-Science-Group_130313_english.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/MRI_ActiveTaskParadigm_CHU-Coma-Science-Group_130313_english.doc -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_2level-analysis_scripts/spm_2nd-level_paired-t-test_cosmo_navigation.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/tennis-test-cosmo_2level-analysis_scripts/spm_2nd-level_paired-t-test_cosmo_navigation.mat -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_2level-analysis_scripts/spm_2nd-level_paired-t-test_cosmo_tennis.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/tennis-test-cosmo_2level-analysis_scripts/spm_2nd-level_paired-t-test_cosmo_tennis.mat -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp2_stats_navigation_tfce.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp2_stats_navigation_tfce.mat -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp2_stats_tennis_tfce.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp2_stats_tennis_tfce.mat -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp3_stats_navigation_snpm.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp3_stats_navigation_snpm.mat -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp3_stats_tennis_snpm.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp3_stats_tennis_snpm.mat -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_csf_group.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_csf_group.mat -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_grey_group.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_grey_group.mat -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_navigation_group.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_navigation_group.mat -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_navigation_group_2024.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_navigation_group_2024.mat -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_navigation_group_followup-post.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_navigation_group_followup-post.mat -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_navigation_group_followup-pre.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_navigation_group_followup-pre.mat -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_tennis_group.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_tennis_group.mat -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_tennis_group_2024.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_tennis_group_2024.mat -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_tennis_group_followup-post.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_tennis_group_followup-post.mat -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_tennis_group_followup-pre.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_tennis_group_followup-pre.mat -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_white_group.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/exp_white_group.mat -------------------------------------------------------------------------------- /analysis/fmri/active-task/tennis-test-cosmo_3level-analysis_scripts/version.txt: -------------------------------------------------------------------------------- 1 | v0.5.1 2 | -------------------------------------------------------------------------------- /analysis/fmri/various/callPython.m: -------------------------------------------------------------------------------- 1 | function callPython(scriptpath, arguments) 2 | % Call a Python script with given arguments 3 | commandStr = ['python ' scriptpath ' ' arguments]; 4 | [status, commandOut] = system(commandStr); 5 | if status==1 6 | fprintf('ERROR: Python call probably failed, return code is %d and error message:\n%s\n',int2str(status),commandOut); 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /analysis/fmri/various/conn_3dvis.m: -------------------------------------------------------------------------------- 1 | function h = conn_3dvis(imfilepath, vismode) 2 | % conn_3dvis(imfilepath, mode) 3 | % Load CONN 3D brain visualization on any given nifti map. 4 | % You need CONN in the path in MATLAB to use this script. 5 | % If no argument is given, a SPM (minimal) GUI will open to ask for the required parameters. 6 | % 7 | % Inputs: 8 | % imfilepath : can be any neuroimage, but generally you want to use the unthresholded maps, also called the T maps, in other words in SPM the contrast maps which are named spmT_XXXX.nii, where XXXX is the position of the contrast in the contrast manager (first, second, etc). 9 | % vismode : type of visualization to use, can be either 'surface' or 'volume'. 10 | % 11 | % Outputs: 12 | % h : GUI handler 13 | % 14 | % 15 | % By Stephen Larroque, Coma Science Group, GIGA-Consciousness, University and Hospital of Liege 16 | % Created on 2019-06-18 17 | % License: MIT 18 | % 19 | % v0.1.1 20 | % 21 | % TODO: 22 | % * Nothing 23 | % 24 | 25 | if ~exist('imfilepath', 'var') | isempty(imfilepath) 26 | imfilepath = spm_select(1,'image','Select NIfTI image'); 27 | end 28 | if ~exist('vismode', 'var') | isempty(mode) 29 | vismode = spm_input('Visualization mode','+1','b','surface|volume',[],1); 30 | end 31 | 32 | if strcmpi(vismode, 'surface') 33 | h = conn_mesh_display(imfilepath); 34 | elseif strcmpi(vismode, 'volume') 35 | h = conn_mesh_display('' ,imfilepath, [],[],[],[],0.5); 36 | else 37 | error('Invalid vismode!\n') 38 | end 39 | 40 | end % endfunction 41 | -------------------------------------------------------------------------------- /analysis/fmri/various/run_spm_jobs.m: -------------------------------------------------------------------------------- 1 | function run_spm_jobs(matlabbatchall, parallel_processing, matlabbatchall_infos, pathtoset) 2 | % run_spm_jobs(matlabbatchall, parallel_processing, matlabbatchall_infos) 3 | % run in SPM a cell array of batch jobs, sequentially or in parallel 4 | % matlabbatchall_infos is optional, it is a cell array of strings 5 | % containing additional info to print for each job 6 | % pathtoset is optional and allows to provide a path to set inside the 7 | % parfor loop before running the jobs 8 | if exist('matlabbatchall_infos','var') % check if variable was provided, for parfor transparency we need to check existence before 9 | minfos_flag = true; 10 | else 11 | minfos_flag = false; 12 | end 13 | 14 | if parallel_processing 15 | fprintf(1, 'PARALLEL PROCESSING MODE\n'); 16 | if exist('pathtoset', 'var') % not transparent, can't check variable existence in parfor loop 17 | pathtoset_flag = true; 18 | else 19 | pathtoset_flag = false; 20 | end 21 | parfor jobcounter = 1:numel(matlabbatchall) 22 | %parfor jobcounter = 1:1 % test on 1 job 23 | if minfos_flag 24 | fprintf(1, '\n---- PROCESSING JOB %i/%i FOR %s ----\n', jobcounter, numel(matlabbatchall), matlabbatchall_infos{jobcounter}); 25 | else 26 | fprintf(1, '\n---- PROCESSING JOB %i/%i ----\n', jobcounter, numel(matlabbatchall)); 27 | end 28 | % Set the path if provided, since in the parfor loop the 29 | % default path is restored. No need to backup because no need 30 | % to restore at the end of the thread, it will be destroyed 31 | if pathtoset_flag 32 | path(pathtoset) 33 | end 34 | % Init the SPM jobman inside the parfor loop 35 | spm_jobman('initcfg'); 36 | % Load the batch for this iteration 37 | matlabbatch = matlabbatchall{jobcounter}; 38 | % Run the preprocessing pipeline for current subject! 39 | spm_jobman('run', matlabbatch) 40 | %spm_jobman('serial',artbatchall{matlabbatchall_counter}); %serial and remove spm defaults 41 | % Close all windows 42 | fclose all; 43 | close all; 44 | end 45 | else 46 | fprintf(1, 'SEQUENTIAL PROCESSING MODE\n'); 47 | % Set the path if provided 48 | if exist('pathtoset', 'var') 49 | bakpath = path; % backup the current path variable 50 | restoredefaultpath(); matlabpath(strrep(matlabpath, userpath, '')); % clean up the path 51 | path(pathtoset); 52 | end 53 | % Initialize the SPM jobman 54 | spm_jobman('initcfg'); 55 | % Run the jobs sequentially 56 | for jobcounter = 1:numel(matlabbatchall) 57 | %for jobcounter = 1:1 % test on 1 job 58 | if minfos_flag 59 | fprintf(1, '\n---- PROCESSING JOB %i/%i FOR %s ----\n', jobcounter, numel(matlabbatchall), matlabbatchall_infos{jobcounter}); 60 | else 61 | fprintf(1, '\n---- PROCESSING JOB %i/%i ----\n', jobcounter, numel(matlabbatchall)); 62 | end 63 | matlabbatch = matlabbatchall{jobcounter}; 64 | % Run the preprocessing pipeline for current subject! 65 | spm_jobman('run', matlabbatch) 66 | %spm_jobman('serial',artbatchall{matlabbatchall_counter}); %serial and remove spm defaults 67 | % Close all windows 68 | fclose all; 69 | close all; 70 | end 71 | % Restore the path 72 | path(bakpath); 73 | end 74 | end %endfunction 75 | -------------------------------------------------------------------------------- /analysis/smri/single-subject-longitudinal/control-1-gm-smoothed.nii: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/smri/single-subject-longitudinal/control-1-gm-smoothed.nii -------------------------------------------------------------------------------- /analysis/smri/single-subject-longitudinal/control-2-gm-smoothed.nii: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/smri/single-subject-longitudinal/control-2-gm-smoothed.nii -------------------------------------------------------------------------------- /analysis/smri/single-subject-longitudinal/control-etc...gm-smoothed.nii: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/smri/single-subject-longitudinal/control-etc...gm-smoothed.nii -------------------------------------------------------------------------------- /analysis/smri/single-subject-longitudinal/patient-post-scan-gm-smoothed.nii: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/smri/single-subject-longitudinal/patient-post-scan-gm-smoothed.nii -------------------------------------------------------------------------------- /analysis/smri/single-subject-longitudinal/patient-pre-scan-gm-smoothed.nii: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/smri/single-subject-longitudinal/patient-pre-scan-gm-smoothed.nii -------------------------------------------------------------------------------- /analysis/smri/single-subject-longitudinal/vbm_singlesubject_longitudinal_stattest_spm12.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/analysis/smri/single-subject-longitudinal/vbm_singlesubject_longitudinal_stattest_spm12.mat -------------------------------------------------------------------------------- /external/cat12-csg-install.txt: -------------------------------------------------------------------------------- 1 | After placing cat12 folder in your spm12/toolbox folder, please also enable expert gui mode by opening cat_defaults.m and setting cat.extopts.expertgui = 1; 2 | This will allow you to open the CAT12 batch files and see all the parameters. 3 | If SPM was already launched at least once in the current MATLAB session, please close and reopen a new MATLAB window (and not just SPM) to get the expert options to display (in particular, White Matter Hyperintensities Correction WMHC). 4 | -------------------------------------------------------------------------------- /external/cat12_latest.zip: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0c5153b161909cfd138e37854ba1e21542dca917575f41845c46ec9ee1028092 3 | size 181770315 4 | -------------------------------------------------------------------------------- /external/spm12.zip: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:0dc847eb065ccfcefbaefafdc12201dd20a22b9ee9b33a6b1973d07690a21914 3 | size 101594261 4 | -------------------------------------------------------------------------------- /how to update submodules.txt: -------------------------------------------------------------------------------- 1 | git submodule update --remote --merge 2 | 3 | https://stackoverflow.com/questions/5828324/update-git-submodule-to-latest-commit-on-origin 4 | -------------------------------------------------------------------------------- /preprocessing/dwi/Conv_track.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import nipype.interfaces.mrtrix as mrt 3 | tck2trk = mrt.MRTrix2TrackVis() 4 | tck2trk.inputs.in_file = 'Allbrain.tck' 5 | tck2trk.inputs.out_filename = 'Allbrain.trk' 6 | tck2trk.inputs.image_file = 'dwicorr.nii' 7 | tck2trk.run() 8 | quit() 9 | -------------------------------------------------------------------------------- /preprocessing/dwi/DTIValueAfter.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/dwi/DTIValueAfter.txt -------------------------------------------------------------------------------- /preprocessing/dwi/DTIValueBefore.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/dwi/DTIValueBefore.txt -------------------------------------------------------------------------------- /preprocessing/dwi/EA_masking.m: -------------------------------------------------------------------------------- 1 | function EA_masking(Mask,Im,New_Im) 2 | %%% Mask the Image using Mask (all non zero voxel outside will be put to zero) 3 | %% Mask and Im should have the same size 4 | I=spm_vol(Im); 5 | M=spm_vol(Mask); 6 | Maskmat=spm_read_vols(M); 7 | MaskIm=spm_read_vols(I); 8 | MaskIm=MaskIm(:); 9 | Maskmat=Maskmat(:); 10 | tmp=MaskIm; 11 | for i=1:length(MaskIm) 12 | if(Maskmat(i)==0 && MaskIm(i)~=0) 13 | tmp(i)=0; 14 | end 15 | end 16 | 17 | I.fname = New_Im; 18 | I.dt=[16,0]; 19 | tmp = reshape(tmp,I.dim); 20 | spm_write_vol(I,tmp); 21 | 22 | return; 23 | -------------------------------------------------------------------------------- /preprocessing/dwi/FAQ.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/dwi/FAQ.pdf -------------------------------------------------------------------------------- /preprocessing/dwi/NIfTI_tools.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/dwi/NIfTI_tools.pdf -------------------------------------------------------------------------------- /preprocessing/dwi/New_Patients_Prep_SingleshellACT_step1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Get argument 4 | gradients_count=$1 # Get the gradients dimensions count as an argument 5 | 6 | # Get working dir 7 | WORKDIR=$(pwd) 8 | # Absolute path to this script, e.g. /home/user/bin/foo.sh 9 | SCRIPT=$(readlink -f "$0") 10 | # Absolute path this script is in, thus /home/user/bin 11 | SCRIPTPATH=$(dirname "$SCRIPT") 12 | 13 | echo "Working from directory: $WORKDIR" 14 | echo $nb_dti_grad_dim 15 | 16 | rm -f index.txt nodif.nii nodif.nii.gz mask.nii mask.nii.gz 17 | rm -f dwicorr.nii 18 | rm -f dwicorr.nii.gz tensor.nii fa.nii fathr.nii fathr.nii.gz 19 | rm -f t1_bet.nii t1_bet.nii.gz t1_bet_pve_* 20 | 21 | sed -i 's/nan/0/g' grad.* 22 | # TODO: autodetect number of volumes (using mrinfo?) 23 | for (( i=1;i<=$gradients_count;i++)); do printf "%i " 1 >> index.txt; done 24 | fslroi dwi.nii nodif 0 1 25 | gunzip nodif.nii.gz 26 | bet nodif mask -f 0.4 -g 0.15 -c 62 63 26 -n -m 27 | mv mask_mask.nii.gz mask.nii.gz 28 | gunzip mask.nii.gz 29 | # TODO: Only run for old acquisition protocol, (if voxel dimension is a non-int like 1.8) 30 | #mrconvert -datatype UInt16 -vox 2,2,2 mask.nii mask2.nii 31 | #mrconvert -datatype UInt16 -vox 2,2,2 dwi.nii dwi2.nii 32 | # motion correction for diffusion imaging 33 | # acqp.txt is a fixed file for all patients = acquisition parameters for the scan for the CHU (for another scanner you need to change) 34 | # TODO: auto set path of acqp.txt (in the same folder as current script) + check if exists at the start of this script 35 | # TODO: blocking commands (convert to Python?): if a command fail, stop everything 36 | # TODO: check if each file exists before using, and force scripts to overwrite files! Do not ask! 37 | # TODO: add status messages and progress bar? for example when eddy is launched, say that it is currently processing (and check CPU activity of eddy process?) 38 | # TODO: auto overwrite all files (can input --force to this script) without asking first 39 | # TODO: write a copy of console output to a log file, for all softwares called! 40 | echo "Motion correction using fsl eddy, this can take a while..." 41 | eddy --very_verbose --imain=dwi.nii --mask=mask.nii --index=index.txt --acqp=$SCRIPTPATH/acqp.txt --bvecs=grad.bvecs --bvals=grad.bvals --out=dwicorr.nii # can also do --very_verbose 42 | 43 | # Tensor directions estimation 44 | echo "Tensor directions estimation, this can also take a while..." 45 | gunzip dwicorr.nii.gz 46 | dwi2tensor -force -grad grad.txt -mask mask.nii dwicorr.nii tensor.nii 47 | tensor2metric -force -mask mask.nii tensor.nii -adc adc.nii -fa fa.nii -vector RGB_fa.nii 48 | fslmaths fa.nii -thr 0.20 fathr.nii 49 | gunzip fathr.nii.gz 50 | # fa.nii = fractional anistotropy estimation 51 | 52 | #Segmentation with fast and registration to native space (t1 and aal) 53 | #### T1 registration to mni, GM and WM mask creation (pve 2 WM, 1 GM, 0 CSF) 54 | echo "Segmentation using BET..." 55 | bet T1.nii t1_bet -m -f .4 -v 56 | gunzip t1_bet.nii.gz 57 | echo "Coregistration using FAST..." 58 | fast -v t1_bet.nii 59 | gunzip t1_bet_pve_* 60 | 61 | # Quality Assurance: Check segmentation using mricron (display white and grey matter segmentation over skull extracted brain) 62 | mricron t1_bet.nii -o t1_bet_pve_2.nii -o t1_bet_pve_1.nii -b 50 -t 50 & 63 | 64 | # Extra (registration, stuff) 65 | #flirt -in mask2.nii -ref t1_bet_pve_2.nii -out mask_t1.nii 66 | #fslmaths mask_t1.nii -mul t1_bet_pve_2.nii WM.nii 67 | #fslmaths mask_t1.nii -mul t1_bet_pve_1.nii GM.nii 68 | ## segmentation might fail, in patients is important to add this extra step (change EA_coreg.py accordingly!!!) 69 | #cp /usr/share/fsl/data/standard/MNI152_T1_1mm_brain.nii.gz MNI152_T1_1mm_brain.nii.gz 70 | #cp /usr/share/fsl/data/standard/MNI152_T1_2mm_brain.nii.gz MNI152_T1_2mm_brain.nii.gz 71 | #gunzip MNI152_T1_1mm_brain.nii.gz 72 | #gunzip MNI152_T1_2mm_brain.nii.gz 73 | ##### run EA_coreg.py then EA_coreg.sh then DtiTMS2.sh 74 | # run first ipython /home/enrico/Dropbox/Ulg/My_fun/DTI/EA_modules/EA_coreg.py and extract Transform_t1_bet_pve_2_flirt_flirt.mat and t1_bet_pve_2_flirt_flirt.nii.gz then launch New_patients_Prep2.sh WARNING! U should be in the structurefunction folder on dropbox when launching AND don't forget to copy aal.nii into the patient folder 75 | -------------------------------------------------------------------------------- /preprocessing/dwi/New_Patients_Prep_SingleshellACT_step2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | WORKDIR=$(pwd) 4 | # Absolute path to this script, e.g. /home/user/bin/foo.sh 5 | SCRIPT=$(readlink -f "$0") 6 | # Absolute path this script is in, thus /home/user/bin 7 | SCRIPTPATH=$(dirname "$SCRIPT") 8 | echo "Working from directory: $WORKDIR" 9 | 10 | forcewhite="" 11 | if [ $# -ge 1 ]; then 12 | forcewhite="$1" 13 | fi 14 | 15 | #run first ipython /home/brain/Downloads/FromEnri/DTI/EA_modules/EA_coreg.py and extract #Transform_t1_bet_pve_2_flirt_flirt.mat and t1_bet_pve_2_flirt_flirt.nii.gz then launch #New_patients_Prep2.sh 16 | #flirt -in t1_bet_pve_1.nii -ref t1_bet_pve_2_flirt_flirt.nii -out GMdiffusion.nii -init Transform_t1_bet_pve_2_flirt_flirt.mat -applyxfm 17 | #mv t1_bet_pve_2_flirt_flirt.nii WMdiffusion.nii 18 | #fslmaths GMdiffusion.nii.gz -add WMdiffusion.nii.gz GM_WM_diffusion.nii 19 | #gunzip GM_WM_diffusion.nii.gz 20 | 21 | # Cleanup before beginning (if we already launched the analysis before) 22 | rm -f WM.nii GM.nii 23 | rm -f fathr015.nii DTIValueBefore.txt DTIValueAfter.txt 24 | cp t1_bet_pve_2.nii WM.nii 25 | cp t1_bet_pve_1.nii GM.nii 26 | 27 | # If forcewhite is provided, then use that and don't ask any question 28 | if [ -n "$forcewhite" ]; then 29 | choice_wmgm="$forcewhite" 30 | else 31 | echo "Please check the White Matter (WM.nii) and Grey Matter (GM.nii)" 32 | mrview GM.nii & 33 | mrview WM.nii & 34 | echo "Use only the white matter (y) or use white+grey (n) ?:" 35 | read choice_wmgm 36 | fi 37 | # Use white+grey if user wants 38 | if [ "$choice_wmgm" == "n" ]; then 39 | echo "Merging Grey and White matter, please wait..." 40 | rm -f WM.nii.gz 41 | fslmaths WM.nii -add GM.nii WM.nii.gz # fslmaths always save as 4D nifti, even if you just output "WM.nii", it will be named "WM.nii.gz" 42 | gunzip -f WM.nii.gz 43 | rm -f WM.nii.gz 44 | fi 45 | 46 | echo "Launching SPM coregistration and resampling, please wait..." 47 | matlab -nodesktop -nosplash -r "addpath(genpath('$SCRIPTPATH'));process_spm_coreg_and_exit('fathr.nii', 'WM.nii', 'WMdiff.nii', 'WM.nii', 'GMdiff.nii', 'GM.nii');quit();" 48 | matlab -nodesktop -nosplash -r "addpath(genpath('$SCRIPTPATH'));process_spm_coreg_and_exit('fathr.nii', 'WM.nii', 'T1diff.nii', 'T1.nii');quit();" 49 | 50 | matlab -nodesktop -nosplash -r "addpath(genpath('$SCRIPTPATH'));Resample_im('mask.nii','WMdiff.nii','mask3.nii');quit();" 51 | 52 | 53 | matlab -nodesktop -nosplash -r "addpath(genpath('$SCRIPTPATH'));EA_masking('mask3.nii','WMdiff.nii','WMdiff_masked.nii');quit();" 54 | 55 | matlab -nodesktop -nosplash -r "addpath(genpath('$SCRIPTPATH'));Resample_im('WMdiff_masked.nii','mask.nii','WMdiff_masked2.nii');quit();" 56 | 57 | # Quality Assurance: check if the WM mask is not cutting too much (and it eases interpretation) 58 | mricron WMdiff.nii -o mask3.nii -b 50 -t 50 & 59 | 60 | 61 | #Pacho number 62 | fslmaths fa.nii -thr 0.15 fathr015.nii 63 | fslstats fa.nii -M -S -V > DTIValueBefore.txt 64 | fslstats fathr015.nii -M -V > DTIValueAfter.txt 65 | -------------------------------------------------------------------------------- /preprocessing/dwi/New_Patients_Prep_SingleshellACT_step3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | WORKDIR=$(pwd) 4 | # Absolute path to this script, e.g. /home/user/bin/foo.sh 5 | SCRIPT=$(readlink -f "$0") 6 | # Absolute path this script is in, thus /home/user/bin 7 | SCRIPTPATH=$(dirname "$SCRIPT") 8 | 9 | # Path to MRTRIX3 install folder 10 | MRTRIX3=$1 11 | 12 | echo "Working from directory: $WORKDIR" 13 | 14 | # Please check T1 registration with the dwi before tractography 15 | # tractography 16 | 17 | # Probabilistic tractography (mrtrix) 18 | echo "Probabilistic tractography using mrtrix3..." 19 | # 300000 is the number of seeds (but not ROI seeds but starting seeds to explore via viterbi-like exploration) 20 | dwi2response tournier -force dwicorr.nii -mask WMdiff_masked2.nii -grad grad.txt -lmax 6 response.txt 21 | dwi2fod csd -force dwicorr.nii response.txt -lmax 6 -mask mask.nii ODF.nii -grad grad.txt 22 | #tckgen -force -seed_image WMdiffusion.nii -mask GM_WM_diffusion.nii -number 300000 -maxnum 300000 ODF.nii Allbrain.tck 23 | tckgen -force -seed_image WMdiff_masked.nii -mask WMdiff_masked.nii -select 300000 -seeds 300000 ODF.nii Allbrain.tck 24 | 25 | #tckgen -force -seed_image mask2.nii -mask mask2.nii -number 300000 -maxnum 300000 ODF.nii Allbrain.tck 26 | 27 | # Convert from .tck to .trk (to open with Trackvis) 28 | echo "Convert .tck to .trk (trackvis compatibility)..." 29 | python $SCRIPTPATH/Conv_track.py 30 | 31 | ### connectome 32 | #tck2connectome -info -force Allbrain.tck aalnative.nii Connectome.csv -zero_diagonal 33 | 34 | #erode -dilate -npass 3 mask2.nii mask_dil.nii dilate mask? 35 | ##erode a mask or image by zeroing non-zero voxels when zero voxels found in kernel 36 | ############################################################################################## 37 | #fslmaths 'mask.nii.gz' -kernel box 5x5x5 -ero 'output_image.nii.gz' 38 | #tckgen -force -seed_image WM_native.nii -mask GM_WM_native.nii -number 50000000 -maxnum 50000000 ODF.nii AllbrainBefore.tck 39 | #tcksift -force AllbrainBefore.tck ODF.nii Allbrain.tck 40 | #rm AllbrainBefore.tck 41 | -------------------------------------------------------------------------------- /preprocessing/dwi/README.txt: -------------------------------------------------------------------------------- 1 | DWI (diffusion MRI) preprocessing script up to tractography of the Coma Science Group. It does not do fieldmap correction (topup), but it does every other possible corrections (motion correction, multi-band correction, etc.) 2 | 3 | You need to have the latest MRTRIX3, FSL, ANTS and dipy (Python, use Anaconda distribution, easier to install) installed on your system to run these scripts. 4 | 5 | In addition, for the Single-Shell with ACT (anatomical constraints) pipeline, you need to have MATLAB with SPM installed, and you need to copy the templates from Freesurfer. 6 | 7 | Here are the entry points: 8 | * New_Patients_Prep_Multishell.sh for multi-shell DWI analysis (latest pipeline). This does not use ACT. 9 | * New_Patients_Prep_SingleshellNoACT.sh for single-shell DWI analysis without ACT. It's basically the same, with same parameters, as the Multishell pipeline but using only a single shell. 10 | * New_Patients_Prep_SingleshellACT.sh for single-shell DWI analysis with ACT. This requires MATLAB with SPM and Freesurfer templates. 11 | 12 | Read the comments or help messages for these scripts to get more information on their usage. 13 | -------------------------------------------------------------------------------- /preprocessing/dwi/Resample_im.m: -------------------------------------------------------------------------------- 1 | function Resample_im(Im,Target,Output) 2 | %%% Resample Im to the same dimensions as the Target image (needed to flirt the T1 without resampling) 3 | %Fa=['./' 'fathr.nii' ',1']; 4 | %Wm=['./' 'WM.nii' ',1']; 5 | %Output='fa_res.nii'; 6 | 7 | matlabbatch{1}.spm.util.imcalc.input = { 8 | Target 9 | Im 10 | 11 | }; 12 | matlabbatch{1}.spm.util.imcalc.output = Output; 13 | matlabbatch{1}.spm.util.imcalc.outdir = {''}; 14 | matlabbatch{1}.spm.util.imcalc.expression = 'i2'; 15 | matlabbatch{1}.spm.util.imcalc.options.dmtx = 0; 16 | matlabbatch{1}.spm.util.imcalc.options.mask = 0; 17 | matlabbatch{1}.spm.util.imcalc.options.interp = 1; 18 | matlabbatch{1}.spm.util.imcalc.options.dtype = 4; 19 | spm_jobman('serial',matlabbatch); 20 | 21 | -------------------------------------------------------------------------------- /preprocessing/dwi/UseANALYZE.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/dwi/UseANALYZE.pdf -------------------------------------------------------------------------------- /preprocessing/dwi/_version.py: -------------------------------------------------------------------------------- 1 | version = '1.3.0.3' -------------------------------------------------------------------------------- /preprocessing/dwi/acqp.txt: -------------------------------------------------------------------------------- 1 | 0 -1 0 0.062 2 | -------------------------------------------------------------------------------- /preprocessing/dwi/bipolar.m: -------------------------------------------------------------------------------- 1 | %BIPOLAR returns an M-by-3 matrix containing a blue-red colormap, in 2 | % in which red stands for positive, blue stands for negative, 3 | % and white stands for 0. 4 | % 5 | % Usage: cmap = bipolar(M, lo, hi, contrast); or cmap = bipolar; 6 | % 7 | % cmap: output M-by-3 matrix for BIPOLAR colormap. 8 | % M: number of shades in the colormap. By default, it is the 9 | % same length as the current colormap. 10 | % lo: the lowest value to represent. 11 | % hi: the highest value to represent. 12 | % 13 | % Inspired from the LORETA PASCAL program: 14 | % http://www.unizh.ch/keyinst/NewLORETA 15 | % 16 | % jimmy@rotman-baycrest.on.ca 17 | % 18 | %---------------------------------------------------------------- 19 | function cmap = bipolar(M, lo, hi, contrast) 20 | 21 | if ~exist('contrast','var') 22 | contrast = 128; 23 | end 24 | 25 | if ~exist('lo','var') 26 | lo = -1; 27 | end 28 | 29 | if ~exist('hi','var') 30 | hi = 1; 31 | end 32 | 33 | if ~exist('M','var') 34 | cmap = colormap; 35 | M = size(cmap,1); 36 | end 37 | 38 | steepness = 10 ^ (1 - (contrast-1)/127); 39 | pos_infs = 1e-99; 40 | neg_infs = -1e-99; 41 | 42 | doubleredc = []; 43 | doublebluec = []; 44 | 45 | if lo >= 0 % all positive 46 | 47 | if lo == 0 48 | lo = pos_infs; 49 | end 50 | 51 | for i=linspace(hi/M, hi, M) 52 | t = exp(log(i/hi)*steepness); 53 | doubleredc = [doubleredc; [(1-t)+t,(1-t)+0,(1-t)+0]]; 54 | end 55 | 56 | cmap = doubleredc; 57 | 58 | elseif hi <= 0 % all negative 59 | 60 | if hi == 0 61 | hi = neg_infs; 62 | end 63 | 64 | for i=linspace(abs(lo)/M, abs(lo), M) 65 | t = exp(log(i/abs(lo))*steepness); 66 | doublebluec = [doublebluec; [(1-t)+0,(1-t)+0,(1-t)+t]]; 67 | end 68 | 69 | cmap = flipud(doublebluec); 70 | 71 | else 72 | 73 | if hi > abs(lo) 74 | maxc = hi; 75 | else 76 | maxc = abs(lo); 77 | end 78 | 79 | for i=linspace(maxc/M, hi, round(M*hi/(hi-lo))) 80 | t = exp(log(i/maxc)*steepness); 81 | doubleredc = [doubleredc; [(1-t)+t,(1-t)+0,(1-t)+0]]; 82 | end 83 | 84 | for i=linspace(maxc/M, abs(lo), round(M*abs(lo)/(hi-lo))) 85 | t = exp(log(i/maxc)*steepness); 86 | doublebluec = [doublebluec; [(1-t)+0,(1-t)+0,(1-t)+t]]; 87 | end 88 | 89 | cmap = [flipud(doublebluec); doubleredc]; 90 | 91 | end 92 | 93 | return; % bipolar 94 | 95 | -------------------------------------------------------------------------------- /preprocessing/dwi/clip_nii.m: -------------------------------------------------------------------------------- 1 | % CLIP_NII: Clip the NIfTI volume from any of the 6 sides 2 | % 3 | % Usage: nii = clip_nii(nii, [option]) 4 | % 5 | % Inputs: 6 | % 7 | % nii - NIfTI volume. 8 | % 9 | % option - struct instructing how many voxel to be cut from which side. 10 | % 11 | % option.cut_from_L = ( number of voxel ) 12 | % option.cut_from_R = ( number of voxel ) 13 | % option.cut_from_P = ( number of voxel ) 14 | % option.cut_from_A = ( number of voxel ) 15 | % option.cut_from_I = ( number of voxel ) 16 | % option.cut_from_S = ( number of voxel ) 17 | % 18 | % Options description in detail: 19 | % ============================== 20 | % 21 | % cut_from_L: Number of voxels from Left side will be clipped. 22 | % 23 | % cut_from_R: Number of voxels from Right side will be clipped. 24 | % 25 | % cut_from_P: Number of voxels from Posterior side will be clipped. 26 | % 27 | % cut_from_A: Number of voxels from Anterior side will be clipped. 28 | % 29 | % cut_from_I: Number of voxels from Inferior side will be clipped. 30 | % 31 | % cut_from_S: Number of voxels from Superior side will be clipped. 32 | % 33 | % NIfTI data format can be found on: http://nifti.nimh.nih.gov 34 | % 35 | % - Jimmy Shen (jimmy@rotman-baycrest.on.ca) 36 | % 37 | function nii = clip_nii(nii, opt) 38 | 39 | dims = abs(nii.hdr.dime.dim(2:4)); 40 | origin = abs(nii.hdr.hist.originator(1:3)); 41 | 42 | if isempty(origin) | all(origin == 0) % according to SPM 43 | origin = round((dims+1)/2); 44 | end 45 | 46 | cut_from_L = 0; 47 | cut_from_R = 0; 48 | cut_from_P = 0; 49 | cut_from_A = 0; 50 | cut_from_I = 0; 51 | cut_from_S = 0; 52 | 53 | if nargin > 1 & ~isempty(opt) 54 | if ~isstruct(opt) 55 | error('option argument should be a struct'); 56 | end 57 | 58 | if isfield(opt,'cut_from_L') 59 | cut_from_L = round(opt.cut_from_L); 60 | 61 | if cut_from_L >= origin(1) | cut_from_L < 0 62 | error('cut_from_L cannot be negative or cut beyond originator'); 63 | end 64 | end 65 | 66 | if isfield(opt,'cut_from_P') 67 | cut_from_P = round(opt.cut_from_P); 68 | 69 | if cut_from_P >= origin(2) | cut_from_P < 0 70 | error('cut_from_P cannot be negative or cut beyond originator'); 71 | end 72 | end 73 | 74 | if isfield(opt,'cut_from_I') 75 | cut_from_I = round(opt.cut_from_I); 76 | 77 | if cut_from_I >= origin(3) | cut_from_I < 0 78 | error('cut_from_I cannot be negative or cut beyond originator'); 79 | end 80 | end 81 | 82 | if isfield(opt,'cut_from_R') 83 | cut_from_R = round(opt.cut_from_R); 84 | 85 | if cut_from_R > dims(1)-origin(1) | cut_from_R < 0 86 | error('cut_from_R cannot be negative or cut beyond originator'); 87 | end 88 | end 89 | 90 | if isfield(opt,'cut_from_A') 91 | cut_from_A = round(opt.cut_from_A); 92 | 93 | if cut_from_A > dims(2)-origin(2) | cut_from_A < 0 94 | error('cut_from_A cannot be negative or cut beyond originator'); 95 | end 96 | end 97 | 98 | if isfield(opt,'cut_from_S') 99 | cut_from_S = round(opt.cut_from_S); 100 | 101 | if cut_from_S > dims(3)-origin(3) | cut_from_S < 0 102 | error('cut_from_S cannot be negative or cut beyond originator'); 103 | end 104 | end 105 | end 106 | 107 | nii = make_nii(nii.img( (cut_from_L+1) : (dims(1)-cut_from_R), ... 108 | (cut_from_P+1) : (dims(2)-cut_from_A), ... 109 | (cut_from_I+1) : (dims(3)-cut_from_S), ... 110 | :,:,:,:,:), nii.hdr.dime.pixdim(2:4), ... 111 | [origin(1)-cut_from_L origin(2)-cut_from_P origin(3)-cut_from_I], ... 112 | nii.hdr.dime.datatype, nii.hdr.hist.descrip); 113 | 114 | return; 115 | 116 | -------------------------------------------------------------------------------- /preprocessing/dwi/docs/How-to-configure-Neurodebian8-for-DTI-analysis.txt: -------------------------------------------------------------------------------- 1 | How to configure Neurodebian 8 for DTI analysis (in a Virtual Machine such as VirtualBox) 2 | Written on 2018-11-12 by Stephen Karl Larroque 3 | 4 | Enable Virtualization Technology in your BIOS (and optionally VT-x) 5 | Launch the virtual machine (or create it after downloading the appliance on Neurodebian website) 6 | sudo apt-get remove python-cryptography 7 | sudo apt-get remove python 8 | install anaconda2 (Python 2) - do NOT use the standard python bundled with Debian! 9 | python fsl.py 10 | then add variables of FSL in .bashrc 11 | sudo apt-get install ants 12 | sudo find / -name "N4BiasFieldCorrection" 13 | export PATH="/usr/lib/ants:$PATH" 14 | pip install nipype 15 | pip install dipy 16 | install MRTRIX3 as per the documentation (from the github) (make sure your VM is configured with at least 4096 GB, it's necessary to complete the ./build command of MRTRIX3, else it will run indefinitely). 17 | Then you can run the scripts! 18 | In Trackvis, open Allbrain.trk and use Threshold 95% and uncheck y slice filter. Then put Trackvis in fullscreen, zoom in as much as possible while stil seeing the full brain (use ALT + left click to move the brain around) and then save pictures on different angles (front, left, right, top, back). Use CTRL + Left click to rotate, and CTRL+R to reset the view (but might not be correctly oriented). 19 | Optional: sudo apt-get install gimp, to adjust generated images 20 | -------------------------------------------------------------------------------- /preprocessing/dwi/docs/MRI-printout-DWI-3shells-ComaScienceGroup.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/dwi/docs/MRI-printout-DWI-3shells-ComaScienceGroup.pdf -------------------------------------------------------------------------------- /preprocessing/dwi/dti-template-multishell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/dwi/dti-template-multishell.png -------------------------------------------------------------------------------- /preprocessing/dwi/dti-template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/dwi/dti-template.png -------------------------------------------------------------------------------- /preprocessing/dwi/dti-template.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/dwi/dti-template.xcf -------------------------------------------------------------------------------- /preprocessing/dwi/dti_gen_final_image/README.txt: -------------------------------------------------------------------------------- 1 | This python script is just an utility to stitch together multiple images of different orientation of the DWI tracts, for a nice presentation to patients families. 2 | 3 | This is not necessary but is an example of further automatization. 4 | 5 | To use it, it expects 5 images in the same folder as the script and named "top.png", "front.png", "back.png", "left.png" and "right.png". 6 | -------------------------------------------------------------------------------- /preprocessing/dwi/dti_gen_final_image/_version.py: -------------------------------------------------------------------------------- 1 | version = '0.2.2' -------------------------------------------------------------------------------- /preprocessing/dwi/dti_gen_final_image/arialbold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/dwi/dti_gen_final_image/arialbold.ttf -------------------------------------------------------------------------------- /preprocessing/dwi/dti_gen_final_image/dti-template-blank-multishellnoact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/dwi/dti_gen_final_image/dti-template-blank-multishellnoact.png -------------------------------------------------------------------------------- /preprocessing/dwi/dti_gen_final_image/dti-template-blank-old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/dwi/dti_gen_final_image/dti-template-blank-old.png -------------------------------------------------------------------------------- /preprocessing/dwi/dti_gen_final_image/dti-template-blank-singleshellact.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/dwi/dti_gen_final_image/dti-template-blank-singleshellact.png -------------------------------------------------------------------------------- /preprocessing/dwi/dti_gen_final_image/dti_gen_final_image.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": false 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "from __future__ import division\n", 12 | "from PIL import Image, ImageChops, ImageDraw, ImageFont\n", 13 | "\n", 14 | "def trim(im):\n", 15 | " bg = Image.new(im.mode, im.size, im.getpixel((0,0)))\n", 16 | " diff = ImageChops.difference(im, bg)\n", 17 | " diff = ImageChops.add(diff, diff, 2.0, -100)\n", 18 | " bbox = diff.getbbox()\n", 19 | " if bbox:\n", 20 | " return im.crop(bbox)\n", 21 | "\n", 22 | "def resize_height(img, baseheight):\n", 23 | " baseheight = int(baseheight)\n", 24 | " hpercent = (baseheight/float(img.size[1]))\n", 25 | " wsize = int((float(img.size[0])*float(hpercent)))\n", 26 | " return img.resize((wsize, baseheight), Image.ANTIALIAS)\n", 27 | "\n", 28 | "def resize_width(img, basewidth):\n", 29 | " basewidth = int(basewidth)\n", 30 | " wpercent = (basewidth/float(img.size[0]))\n", 31 | " hsize = int((float(img.size[1])*float(wpercent)))\n", 32 | " return img.resize((basewidth, hsize), Image.ANTIALIAS)\n", 33 | "\n", 34 | "im_width = im_height = 1000\n" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": null, 40 | "metadata": { 41 | "collapsed": true 42 | }, 43 | "outputs": [], 44 | "source": [ 45 | "im_front = Image.open(\"front.png\")\n", 46 | "im_left = Image.open(\"left.png\")\n", 47 | "im_right = Image.open(\"right.png\")\n", 48 | "im_top = Image.open(\"top.png\")\n", 49 | "im_dti_template = Image.open(\"dti-template-blank.png\")" 50 | ] 51 | }, 52 | { 53 | "cell_type": "code", 54 | "execution_count": null, 55 | "metadata": { 56 | "collapsed": false 57 | }, 58 | "outputs": [], 59 | "source": [ 60 | "im_front" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": null, 66 | "metadata": { 67 | "collapsed": false 68 | }, 69 | "outputs": [], 70 | "source": [ 71 | "im_parts = []\n", 72 | "for img in (im_front, im_left, im_right, im_top):\n", 73 | " draw = ImageDraw.Draw(img)\n", 74 | " draw.rectangle((img.size[0]*0.9, img.size[1]*0.9, img.size[0], img.size[1]), fill='black')\n", 75 | " im_parts.append(resize_height(trim(img), 410))" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": null, 81 | "metadata": { 82 | "collapsed": false, 83 | "scrolled": true 84 | }, 85 | "outputs": [], 86 | "source": [ 87 | "im_parts[3]" 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "execution_count": null, 93 | "metadata": { 94 | "collapsed": false 95 | }, 96 | "outputs": [], 97 | "source": [ 98 | "#im1_trimmed = trim(im1_crop)\n", 99 | "\n", 100 | "#im_parts_top = [resize_height(img, im_height/2) for img in (im1_trimmed, im2_new)]\n", 101 | "#im_parts_bottom = [resize_width(img, (im_width/2)*0.9) for img in (im3_trimmed, im4_trimmed)]\n", 102 | "\n", 103 | "im_dti_template.paste(im_parts[0], (305-int(im_parts[0].size[0]/2),840))\n", 104 | "im_dti_template.paste(im_parts[1], (954-int(im_parts[1].size[0]/2),840))\n", 105 | "im_dti_template.paste(im_parts[2], (1650-int(im_parts[2].size[0]/2),840))\n", 106 | "im_dti_template.paste(im_parts[3], (2364-int(im_parts[3].size[0]/2),840))\n", 107 | "\n", 108 | "center_pos = 1300\n", 109 | "patient_name = 'NAME'\n", 110 | "d = ImageDraw.Draw(im_dti_template)\n", 111 | "fnt = ImageFont.truetype('arialbold.ttf', 64)\n", 112 | "# Write control\n", 113 | "tw, th = d.textsize('CONTROL'.upper(), font=fnt) # calculate text size to center position\n", 114 | "d.text((int(center_pos - tw/2),66), 'CONTROL'.upper(), font=fnt, fill=(255, 255, 255, 0))\n", 115 | "# Write patient name\n", 116 | "tw, th = d.textsize(patient_name.upper(), font=fnt) # calculate text size to center position\n", 117 | "d.text((int(center_pos - tw/2),705), patient_name.upper(), font=fnt, fill=(255, 255, 255, 0))\n", 118 | "\n", 119 | "im_dti_template" 120 | ] 121 | }, 122 | { 123 | "cell_type": "code", 124 | "execution_count": null, 125 | "metadata": { 126 | "collapsed": true 127 | }, 128 | "outputs": [], 129 | "source": [] 130 | } 131 | ], 132 | "metadata": { 133 | "kernelspec": { 134 | "display_name": "Python [default]", 135 | "language": "python", 136 | "name": "python2" 137 | }, 138 | "language_info": { 139 | "codemirror_mode": { 140 | "name": "ipython", 141 | "version": 2 142 | }, 143 | "file_extension": ".py", 144 | "mimetype": "text/x-python", 145 | "name": "python", 146 | "nbconvert_exporter": "python", 147 | "pygments_lexer": "ipython2", 148 | "version": "2.7.12" 149 | } 150 | }, 151 | "nbformat": 4, 152 | "nbformat_minor": 0 153 | } 154 | -------------------------------------------------------------------------------- /preprocessing/dwi/dti_gen_final_image/dti_gen_final_image.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | # DTI final image generator, by Stephen Larroque 3 | # v0.2.2 4 | # 5 | # Usage: you need to use Trackvis to save screenshots of each view (front.png, left.png, right.png and top.png), and then place this script and the dependencies in the same folder as these images, and call it. You will then just need to input the patient's name, and the final image will be generated. 6 | # 7 | 8 | from __future__ import division 9 | from PIL import Image, ImageChops, ImageDraw, ImageFont 10 | 11 | def trim(im): 12 | bg = Image.new(im.mode, im.size, im.getpixel((0,0))) 13 | diff = ImageChops.difference(im, bg) 14 | diff = ImageChops.add(diff, diff, 2.0, -100) 15 | bbox = diff.getbbox() 16 | if bbox: 17 | return im.crop(bbox) 18 | 19 | def resize_height(img, baseheight): 20 | baseheight = int(baseheight) 21 | hpercent = (baseheight/float(img.size[1])) 22 | wsize = int((float(img.size[0])*float(hpercent))) 23 | return img.resize((wsize, baseheight), Image.ANTIALIAS) 24 | 25 | def resize_width(img, basewidth): 26 | basewidth = int(basewidth) 27 | wpercent = (basewidth/float(img.size[0])) 28 | hsize = int((float(img.size[1])*float(wpercent))) 29 | return img.resize((basewidth, hsize), Image.ANTIALIAS) 30 | 31 | def paste_align(im, paste, posx, posy, align='center'): 32 | if align == 'left': 33 | return im.paste(paste, (posx,posy)) 34 | elif align == 'right': 35 | return im.paste(paste, (posx-int(paste.size[0]),posy)) 36 | else: 37 | return im.paste(paste, (posx-int(paste.size[0]/2),posy)) 38 | 39 | controlsheight = 490 # controls images height (to resize patient images to the same size) 40 | print("This script expects to find 4 or 5 images in the same folder as this script and named: front.png, left.png, right.png, top.png and optionally for multi-shell back.png") 41 | patient_name = raw_input("Please enter patient's name: ") 42 | shell_mode = raw_input("Single-shell with ACT (s) or Multi-shell without ACT (m) mode? (s/m): ") 43 | 44 | # Loading images 45 | im_in = [] 46 | im_in.append(Image.open("front.png")) 47 | im_in.append(Image.open("left.png")) 48 | im_in.append(Image.open("right.png")) 49 | im_in.append(Image.open("top.png")) 50 | if shell_mode == 'm': 51 | im_in.append(Image.open("back.png")) 52 | 53 | if shell_mode == 'm': 54 | im_dti_template = Image.open("dti-template-blank-multishellnoact.png") 55 | else: 56 | im_dti_template = Image.open("dti-template-blank-singleshellact.png") 57 | center_pos = int(im_dti_template.size[0]/2) 58 | 59 | # Preprocessing all images parts 60 | im_parts = [] 61 | for i, img in enumerate(im_in): 62 | # Hide rotation cube in bottom right corner by cutting 63 | draw = ImageDraw.Draw(img) 64 | draw.rectangle((img.size[0]*0.9, img.size[1]*0.9, img.size[0], img.size[1]), fill='black') 65 | # Trim black borders and resize to the height of control's images 66 | if i == 3: 67 | # For top view, we need to reduce the size a bit 68 | im_parts.append(resize_height(trim(img), controlsheight*0.9)) 69 | else: 70 | im_parts.append(resize_height(trim(img), controlsheight)) 71 | 72 | # == Final image generation 73 | 74 | # Place all image parts of patient into the right position (below corresponding control's image) 75 | if shell_mode == 's': 76 | paste_align(im_dti_template, im_parts[0], 305, 800, 'center') 77 | paste_align(im_dti_template, im_parts[1], 954, 800, 'center') 78 | paste_align(im_dti_template, im_parts[2], 1620, 800, 'center') 79 | paste_align(im_dti_template, im_parts[3], 2334, 800, 'center') 80 | elif shell_mode == 'm': 81 | paste_align(im_dti_template, im_parts[0], 255, 750, 'center') 82 | paste_align(im_dti_template, im_parts[1], 854, 750, 'center') 83 | paste_align(im_dti_template, im_parts[2], 1580, 750, 'center') 84 | paste_align(im_dti_template, im_parts[3], 2284, 750, 'center') 85 | paste_align(im_dti_template, im_parts[4], 2896, 750, 'center') 86 | 87 | # Draw text for control and patient name 88 | d = ImageDraw.Draw(im_dti_template) 89 | fnt = ImageFont.truetype('arialbold.ttf', 64) 90 | # Write control 91 | tw, th = d.textsize('CONTROL'.upper(), font=fnt) # calculate text size to center position 92 | d.text((int(center_pos - tw/2),40), 'CONTROL'.upper(), font=fnt, fill=(255, 255, 255, 255)) 93 | # Write patient name 94 | tw, th = d.textsize(patient_name.upper(), font=fnt) # calculate text size to center position 95 | d.text((int(center_pos - tw/2),650), patient_name.upper(), font=fnt, fill=(255, 255, 255, 255)) 96 | 97 | # Save! 98 | im_dti_template.save('dti-%s.png' % patient_name) 99 | -------------------------------------------------------------------------------- /preprocessing/dwi/dti_pipeline.py: -------------------------------------------------------------------------------- 1 | # Originally made by Enrico Amico for the Coma Science Group 2 | # Modified to fit in a pipeline by Stephen Larroque 3 | 4 | from __future__ import print_function 5 | 6 | import os 7 | import subprocess 8 | 9 | rootfolder = "/home/brain/neuro-csg-pipelines/enrico-scripts-allinone/Patient_Name_2016/" 10 | 11 | def run_command(command): 12 | p = subprocess.Popen(command, 13 | stdout=subprocess.PIPE, 14 | stderr=subprocess.STDOUT) 15 | return iter(p.stdout.readline, b'') 16 | 17 | def run_command_full(command): 18 | if os.name == 'nt': 19 | p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 20 | elif os.name == 'posix': 21 | # Run the command supporting .bashrc 22 | subprocess.call([os.getenv('SHELL'), '-i', '-c', command], stdout=subprocess.PIPE, stderr=subprocess.PIPE) 23 | # Retrieve the terminal 24 | os.tcsetpgrp(0,os.getpgrp()) 25 | out, err = p.communicate() 26 | return out, err 27 | 28 | out, err = run_command_full(r'mrinfo "' + rootfolder + r'" -force -export_grad_mrtrix grad.txt -export_grad_fsl grad.bvecs grad.bvals') 29 | -------------------------------------------------------------------------------- /preprocessing/dwi/examples.txt: -------------------------------------------------------------------------------- 1 | 2 | - Examples to load, make and save a nii struct: 3 | 4 | To load Analyze data or NIFTI data to a structure: 5 | 6 | nii = load_nii(NIFTI_file_name, [img_idx], [old_RGB24]); 7 | 8 | img_idx is a numerical array of image indices along the temporal 9 | axis, which is only available in NIFTI data. After you specify 10 | img_idx, only those images indexed by img_idx will be loaded. If 11 | there is no img_idx or img_idx is empty, all available images 12 | will be loaded. 13 | 14 | For RGB image, most people use RGB triple sequentially for each 15 | voxel, like [R1 G1 B1 R2 G2 B2 ...]. However, some program like 16 | Analyze 6.0 developed by AnalyzeDirect uses old RGB24, in a way 17 | like [R1 R2 ... G1 G2 ... B1 B2 ...] for each slices. In this 18 | case, you can set old_RGB24 flag to 1 and load data correctly: 19 | 20 | nii = load_nii(NIFTI_file_name, [], 1); 21 | 22 | To get a total number of images along the temporal axis: 23 | 24 | num_scan = get_nii_frame(NIFTI_file_name); 25 | 26 | You can also load the header extension if it exists: 27 | 28 | nii.ext = load_nii_ext(NIFTI_file_name); 29 | 30 | You can just load the Analyze or NIFTI header: 31 | (header contains: hk, dime, and hist) 32 | 33 | hdr = load_nii_hdr(NIFTI_file_name); 34 | 35 | You can also save the structure to a new file: 36 | (header extension will be saved if there is nii.ext structure) 37 | 38 | save_nii(nii, NIFTI_file_name); 39 | 40 | To make the structure from any 3D (or 4D) data: 41 | 42 | img = rand(91,109,91); or 43 | img = rand(64,64,21,18); 44 | nii = make_nii(img [, voxel_size, origin, datatype] ); 45 | 46 | Use "help load_nii", "help save_nii", "help make_nii" etc. 47 | to get more detail information. 48 | 49 | 50 | - Examples to plot a nii struct: 51 | (More detail descriptions are available on top of "view_nii.m") 52 | 53 | Simple way to plot a nii struct: 54 | 55 | view_nii(nii); 56 | 57 | The default colormap will use the Gray if all data values are 58 | non-negative; otherwise, the default colormap will use BiPolar. 59 | You can choose other colormap, including customized colormap 60 | from panel. 61 | 62 | To imbed the plot into your existing figure: 63 | 64 | h = gcf; 65 | opt.command = 'init'; 66 | opt.setarea = [0.3 0.1 0.6 0.8]; 67 | view_nii(h, nii, opt); 68 | 69 | To add a colorbar: 70 | 71 | opt.usecolorbar = 1; 72 | view_nii(gcf, opt); 73 | 74 | Here, opt.command is implicitly set to 'update'. 75 | 76 | To display in real aspect ratio: 77 | 78 | opt.usestretch = 0; 79 | view_nii(gcf, opt); 80 | 81 | If you want the data value to be directly used as the index 82 | of colormap, instead of scale to the whole colormap: 83 | 84 | opt.useimagesc = 0; 85 | view_nii(gcf, opt); 86 | 87 | If you modified the data value without changing the dimension, 88 | voxel_size, and origin, you can update the display by: 89 | 90 | opt.command = 'updateimg'; 91 | view_nii(gcf, nii.img, opt); 92 | 93 | If the data is completely different, display can be updated by: 94 | 95 | opt.command = 'updatenii'; 96 | view_nii(gcf, nii, opt); 97 | 98 | This is an example to plot EEG source imaging on top of T1 background: 99 | 1. download overlay.zip and unzip it from: 100 | http://www.rotman-baycrest.on.ca/~jimmy/NIFTI/overlay.zip 101 | 2. T1 = load_nii('T1.nii'); 102 | 3. EEG = load_nii('EEG.nii'); 103 | 4. option.setvalue.idx = find(EEG.img); 104 | 5. option.setvalue.val = EEG.img(option.setvalue.idx); 105 | 6. option.useinterp = 1; 106 | 7. option.setviewpoint = [62 48 46]; 107 | 8. view_nii(T1, option); 108 | 109 | 110 | - Contrast and Brightness are available under Gray and Bipolar colormap: 111 | 112 | Increase contrast in Gray colormap will make high end values 113 | more distinguishable by sacrificing the low end values; The 114 | minimum contrast (default) will display the whole range. 115 | 116 | Increase or decrease contrast in BiPolar colormap will shift 117 | the distinguishable position for both positive and negative 118 | values. 119 | 120 | Increase or decrease brightness in Gray colormap will shift 121 | the distinguishable position. 122 | 123 | Increase or decrease brightness in BiPolar colormap will make 124 | both positive and negative values more distinguishable. 125 | 126 | 127 | - Required files: 128 | 129 | All files in this package. 130 | 131 | -------------------------------------------------------------------------------- /preprocessing/dwi/expand_nii_scan.m: -------------------------------------------------------------------------------- 1 | % Expand a multiple-scan NIFTI file into multiple single-scan NIFTI files 2 | % 3 | % Usage: expand_nii_scan(multi_scan_filename, [img_idx], [path_to_save]) 4 | % 5 | % NIFTI data format can be found on: http://nifti.nimh.nih.gov 6 | % 7 | % - Jimmy Shen (jimmy@rotman-baycrest.on.ca) 8 | % 9 | function expand_nii_scan(filename, img_idx, newpath) 10 | 11 | v = version; 12 | 13 | % Check file extension. If .gz, unpack it into temp folder 14 | % 15 | if length(filename) > 2 & strcmp(filename(end-2:end), '.gz') 16 | 17 | if ~strcmp(filename(end-6:end), '.img.gz') & ... 18 | ~strcmp(filename(end-6:end), '.hdr.gz') & ... 19 | ~strcmp(filename(end-6:end), '.nii.gz') 20 | 21 | error('Please check filename.'); 22 | end 23 | 24 | if str2num(v(1:3)) < 7.1 | ~usejava('jvm') 25 | error('Please use MATLAB 7.1 (with java) and above, or run gunzip outside MATLAB.'); 26 | else 27 | gzFile = 1; 28 | end 29 | end 30 | 31 | if ~exist('newpath','var') | isempty(newpath), newpath = pwd; end 32 | if ~exist('img_idx','var') | isempty(img_idx), img_idx = 1:get_nii_frame(filename); end 33 | 34 | for i=img_idx 35 | nii_i = load_untouch_nii(filename, i); 36 | 37 | fn = [nii_i.fileprefix '_' sprintf('%04d',i)]; 38 | pnfn = fullfile(newpath, fn); 39 | 40 | if exist('gzFile', 'var') 41 | pnfn = [pnfn '.nii.gz']; 42 | end 43 | 44 | save_untouch_nii(nii_i, pnfn); 45 | end 46 | 47 | return; % expand_nii_scan 48 | 49 | -------------------------------------------------------------------------------- /preprocessing/dwi/flip_lr.m: -------------------------------------------------------------------------------- 1 | % When you load any ANALYZE or NIfTI file with 'load_nii.m', and view 2 | % it with 'view_nii.m', you may find that the image is L-R flipped. 3 | % This is because of the confusion of radiological and neurological 4 | % convention in the medical image before NIfTI format is adopted. You 5 | % can find more details from: 6 | % 7 | % http://www.rotman-baycrest.on.ca/~jimmy/UseANALYZE.htm 8 | % 9 | % Sometime, people even want to convert RAS (standard orientation) back 10 | % to LAS orientation to satisfy the legend programs or processes. This 11 | % program is only written for those purpose. So PLEASE BE VERY CAUTIOUS 12 | % WHEN USING THIS 'FLIP_LR.M' PROGRAM. 13 | % 14 | % With 'flip_lr.m', you can convert any ANALYZE or NIfTI (no matter 15 | % 3D or 4D) file to a flipped NIfTI file. This is implemented simply 16 | % by flipping the affine matrix in the NIfTI header. Since the L-R 17 | % orientation is determined there, so the image will be flipped. 18 | % 19 | % Usage: flip_lr(original_fn, flipped_fn, [old_RGB],[tolerance],[preferredForm]) 20 | % 21 | % original_fn - filename of the original ANALYZE or NIfTI (3D or 4D) file 22 | % 23 | % flipped_fn - filename of the L-R flipped NIfTI file 24 | % 25 | % old_RGB (optional) - a scale number to tell difference of new RGB24 26 | % from old RGB24. New RGB24 uses RGB triple sequentially for each 27 | % voxel, like [R1 G1 B1 R2 G2 B2 ...]. Analyze 6.0 from AnalyzeDirect 28 | % uses old RGB24, in a way like [R1 R2 ... G1 G2 ... B1 B2 ...] for 29 | % each slices. If the image that you view is garbled, try to set 30 | % old_RGB variable to 1 and try again, because it could be in 31 | % old RGB24. It will be set to 0, if it is default or empty. 32 | % 33 | % tolerance (optional) - distortion allowed for non-orthogonal rotation 34 | % or shearing in NIfTI affine matrix. It will be set to 0.1 (10%), 35 | % if it is default or empty. 36 | % 37 | % preferredForm (optional) - selects which transformation from voxels 38 | % to RAS coordinates; values are s,q,S,Q. Lower case s,q indicate 39 | % "prefer sform or qform, but use others if preferred not present". 40 | % Upper case indicate the program is forced to use the specificied 41 | % tranform or fail loading. 'preferredForm' will be 's', if it is 42 | % default or empty. - Jeff Gunter 43 | % 44 | % Example: flip_lr('avg152T1_LR_nifti.nii', 'flipped_lr.nii'); 45 | % flip_lr('avg152T1_RL_nifti.nii', 'flipped_rl.nii'); 46 | % 47 | % You will find that 'avg152T1_LR_nifti.nii' and 'avg152T1_RL_nifti.nii' 48 | % are the same, and 'flipped_lr.nii' and 'flipped_rl.nii' are also the 49 | % the same, but they are L-R flipped from 'avg152T1_*'. 50 | % 51 | % NIFTI data format can be found on: http://nifti.nimh.nih.gov 52 | % 53 | % - Jimmy Shen (jimmy@rotman-baycrest.on.ca) 54 | % 55 | function flip_lr(original_fn, flipped_fn, old_RGB, tolerance, preferredForm) 56 | 57 | if ~exist('original_fn','var') | ~exist('flipped_fn','var') 58 | error('Usage: flip_lr(original_fn, flipped_fn, [old_RGB],[tolerance])'); 59 | end 60 | 61 | if ~exist('old_RGB','var') | isempty(old_RGB) 62 | old_RGB = 0; 63 | end 64 | 65 | if ~exist('tolerance','var') | isempty(tolerance) 66 | tolerance = 0.1; 67 | end 68 | 69 | if ~exist('preferredForm','var') | isempty(preferredForm) 70 | preferredForm= 's'; % Jeff 71 | end 72 | 73 | nii = load_nii(original_fn, [], [], [], [], old_RGB, tolerance, preferredForm); 74 | M = diag(nii.hdr.dime.pixdim(2:5)); 75 | M(1:3,4) = -M(1:3,1:3)*(nii.hdr.hist.originator(1:3)-1)'; 76 | M(1,:) = -1*M(1,:); 77 | nii.hdr.hist.sform_code = 1; 78 | nii.hdr.hist.srow_x = M(1,:); 79 | nii.hdr.hist.srow_y = M(2,:); 80 | nii.hdr.hist.srow_z = M(3,:); 81 | save_nii(nii, flipped_fn); 82 | 83 | return; % flip_lr 84 | 85 | -------------------------------------------------------------------------------- /preprocessing/dwi/index.txt: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /preprocessing/dwi/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Jimmy Shen 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 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /preprocessing/dwi/mat_into_hdr.m: -------------------------------------------------------------------------------- 1 | %MAT_INTO_HDR The old versions of SPM (any version before SPM5) store 2 | % an affine matrix of the SPM Reoriented image into a matlab file 3 | % (.mat extension). The file name of this SPM matlab file is the 4 | % same as the SPM Reoriented image file (.img/.hdr extension). 5 | % 6 | % This program will convert the ANALYZE 7.5 SPM Reoriented image 7 | % file into NIfTI format, and integrate the affine matrix in the 8 | % SPM matlab file into its header file (.hdr extension). 9 | % 10 | % WARNING: Before you run this program, please save the header 11 | % file (.hdr extension) into another file name or into another 12 | % folder location, because all header files (.hdr extension) 13 | % will be overwritten after they are converted into NIfTI 14 | % format. 15 | % 16 | % Usage: mat_into_hdr(filename); 17 | % 18 | % filename: file name(s) with .hdr or .mat file extension, like: 19 | % '*.hdr', or '*.mat', or a single .hdr or .mat file. 20 | % e.g. mat_into_hdr('T1.hdr') 21 | % mat_into_hdr('*.mat') 22 | % 23 | 24 | % - Jimmy Shen (jimmy@rotman-baycrest.on.ca) 25 | % 26 | %------------------------------------------------------------------------- 27 | function mat_into_hdr(files) 28 | 29 | pn = fileparts(files); 30 | file_lst = dir(files); 31 | file_lst = {file_lst.name}; 32 | file1 = file_lst{1}; 33 | [p n e]= fileparts(file1); 34 | 35 | for i=1:length(file_lst) 36 | [p n e]= fileparts(file_lst{i}); 37 | disp(['working on file ', num2str(i) ,' of ', num2str(length(file_lst)), ': ', n,e]); 38 | process=1; 39 | 40 | if isequal(e,'.hdr') 41 | mat=fullfile(pn, [n,'.mat']); 42 | hdr=fullfile(pn, file_lst{i}); 43 | 44 | if ~exist(mat,'file') 45 | warning(['Cannot find file "',mat , '". File "', n, e, '" will not be processed.']); 46 | process=0; 47 | end 48 | elseif isequal(e,'.mat') 49 | hdr=fullfile(pn, [n,'.hdr']); 50 | mat=fullfile(pn, file_lst{i}); 51 | 52 | if ~exist(hdr,'file') 53 | warning(['Can not find file "',hdr , '". File "', n, e, '" will not be processed.']); 54 | process=0; 55 | end 56 | else 57 | warning(['Input file must have .mat or .hdr extension. File "', n, e, '" will not be processed.']); 58 | process=0; 59 | end 60 | 61 | if process 62 | load(mat); 63 | R=M(1:3,1:3); 64 | T=M(1:3,4); 65 | T=R*ones(3,1)+T; 66 | M(1:3,4)=T; 67 | 68 | [h filetype fileprefix machine]=load_nii_hdr(hdr); 69 | h.hist.qform_code=0; 70 | h.hist.sform_code=1; 71 | h.hist.srow_x=M(1,:); 72 | h.hist.srow_y=M(2,:); 73 | h.hist.srow_z=M(3,:); 74 | h.hist.magic='ni1'; 75 | 76 | fid = fopen(hdr,'w',machine); 77 | save_nii_hdr(h,fid); 78 | fclose(fid); 79 | end 80 | end 81 | 82 | return; % mat_into_hdr 83 | 84 | -------------------------------------------------------------------------------- /preprocessing/dwi/pad_nii.m: -------------------------------------------------------------------------------- 1 | % PAD_NII: Pad the NIfTI volume from any of the 6 sides 2 | % 3 | % Usage: nii = pad_nii(nii, [option]) 4 | % 5 | % Inputs: 6 | % 7 | % nii - NIfTI volume. 8 | % 9 | % option - struct instructing how many voxel to be padded from which side. 10 | % 11 | % option.pad_from_L = ( number of voxel ) 12 | % option.pad_from_R = ( number of voxel ) 13 | % option.pad_from_P = ( number of voxel ) 14 | % option.pad_from_A = ( number of voxel ) 15 | % option.pad_from_I = ( number of voxel ) 16 | % option.pad_from_S = ( number of voxel ) 17 | % option.bg = [0] 18 | % 19 | % Options description in detail: 20 | % ============================== 21 | % 22 | % pad_from_L: Number of voxels from Left side will be padded. 23 | % 24 | % pad_from_R: Number of voxels from Right side will be padded. 25 | % 26 | % pad_from_P: Number of voxels from Posterior side will be padded. 27 | % 28 | % pad_from_A: Number of voxels from Anterior side will be padded. 29 | % 30 | % pad_from_I: Number of voxels from Inferior side will be padded. 31 | % 32 | % pad_from_S: Number of voxels from Superior side will be padded. 33 | % 34 | % bg: Background intensity, which is 0 by default. 35 | % 36 | % NIfTI data format can be found on: http://nifti.nimh.nih.gov 37 | % 38 | % - Jimmy Shen (jshen@research.baycrest.org) 39 | % 40 | function nii = pad_nii(nii, opt) 41 | 42 | dims = abs(nii.hdr.dime.dim(2:4)); 43 | origin = abs(nii.hdr.hist.originator(1:3)); 44 | 45 | if isempty(origin) | all(origin == 0) % according to SPM 46 | origin = round((dims+1)/2); 47 | end 48 | 49 | pad_from_L = 0; 50 | pad_from_R = 0; 51 | pad_from_P = 0; 52 | pad_from_A = 0; 53 | pad_from_I = 0; 54 | pad_from_S = 0; 55 | bg = 0; 56 | 57 | if nargin > 1 & ~isempty(opt) 58 | if ~isstruct(opt) 59 | error('option argument should be a struct'); 60 | end 61 | 62 | if isfield(opt,'pad_from_L') 63 | pad_from_L = round(opt.pad_from_L); 64 | 65 | if pad_from_L >= origin(1) | pad_from_L < 0 66 | error('pad_from_L cannot be negative'); 67 | end 68 | end 69 | 70 | if isfield(opt,'pad_from_P') 71 | pad_from_P = round(opt.pad_from_P); 72 | 73 | if pad_from_P >= origin(2) | pad_from_P < 0 74 | error('pad_from_P cannot be negative'); 75 | end 76 | end 77 | 78 | if isfield(opt,'pad_from_I') 79 | pad_from_I = round(opt.pad_from_I); 80 | 81 | if pad_from_I >= origin(3) | pad_from_I < 0 82 | error('pad_from_I cannot be negative'); 83 | end 84 | end 85 | 86 | if isfield(opt,'pad_from_R') 87 | pad_from_R = round(opt.pad_from_R); 88 | 89 | if pad_from_R > dims(1)-origin(1) | pad_from_R < 0 90 | error('pad_from_R cannot be negative'); 91 | end 92 | end 93 | 94 | if isfield(opt,'pad_from_A') 95 | pad_from_A = round(opt.pad_from_A); 96 | 97 | if pad_from_A > dims(2)-origin(2) | pad_from_A < 0 98 | error('pad_from_A cannot be negative'); 99 | end 100 | end 101 | 102 | if isfield(opt,'pad_from_S') 103 | pad_from_S = round(opt.pad_from_S); 104 | 105 | if pad_from_S > dims(3)-origin(3) | pad_from_S < 0 106 | error('pad_from_S cannot be negative'); 107 | end 108 | end 109 | 110 | if isfield(opt,'bg') 111 | bg = opt.bg; 112 | end 113 | end 114 | 115 | blk = bg * ones( pad_from_L, dims(2), dims(3) ); 116 | nii.img = cat(1, blk, nii.img); 117 | 118 | blk = bg * ones( pad_from_R, dims(2), dims(3) ); 119 | nii.img = cat(1, nii.img, blk); 120 | 121 | dims = size(nii.img); 122 | 123 | blk = bg * ones( dims(1), pad_from_P, dims(3) ); 124 | nii.img = cat(2, blk, nii.img); 125 | 126 | blk = bg * ones( dims(1), pad_from_A, dims(3) ); 127 | nii.img = cat(2, nii.img, blk); 128 | 129 | dims = size(nii.img); 130 | 131 | blk = bg * ones( dims(1), dims(2), pad_from_I ); 132 | nii.img = cat(3, blk, nii.img); 133 | 134 | blk = bg * ones( dims(1), dims(2), pad_from_S ); 135 | nii.img = cat(3, nii.img, blk); 136 | 137 | nii = make_nii(nii.img, nii.hdr.dime.pixdim(2:4), ... 138 | [origin(1)+pad_from_L origin(2)+pad_from_P origin(3)+pad_from_I], ... 139 | nii.hdr.dime.datatype, nii.hdr.hist.descrip); 140 | 141 | return; 142 | 143 | -------------------------------------------------------------------------------- /preprocessing/dwi/process_spm_coreg_and_exit.m: -------------------------------------------------------------------------------- 1 | function process_spm_coreg_and_exit(fileto, filefrom, fileout, filein, fileout2, filein2) 2 | 3 | % Usage: process_spm_coreg_and_exit(fileto, filefrom, fileout, filein, fileout2, filein2) 4 | % fileto filename of a reference image to coregister to (if file 5 | % contains several volumes, only the first is used) 6 | % filefrom filename of the source image to coregister to the reference 7 | % (if file contains several volumes, only the first is used) 8 | % fileout new filename (required) 9 | % filein optional input image which will be transformed using the 10 | % transform from filefrom->fileto and which needs to be in 11 | % the same space as the source image 12 | % fileout2 2nd new filename (optional) 13 | % filein2 2nd optional input image which will be transformed using 14 | % the transform from filefrom->fileto and which needs to be 15 | % in the same space as the source image 16 | % 17 | % (c) Timo Roine (timo.roine@uantwerpen.be) and Ben Jeurissen 18 | % (ben.jeurissen@uantwerpen.be), 2014 19 | 20 | if nargin<4 21 | filein=filefrom; 22 | end 23 | VG = spm_vol(fileto); 24 | VF = spm_vol(filefrom); 25 | x = spm_coreg(VG(1),VF(1)); 26 | mat = spm_matrix(x(:)'); 27 | 28 | nii = load_untouch_nii(filein); 29 | nii.hdr.hist.qform_code = 0; 30 | nii.hdr.hist.quatern_b = 0; 31 | nii.hdr.hist.qoffset_x = 0; 32 | nii.hdr.hist.qoffset_y = 0; 33 | nii.hdr.hist.qoffset_z = 0; 34 | tmp = mat\cat(1,nii.hdr.hist.srow_x,nii.hdr.hist.srow_y,nii.hdr.hist.srow_z,[0 0 0 1]); 35 | nii.hdr.hist.srow_x = tmp(1,:); nii.hdr.hist.srow_y = tmp(2,:); nii.hdr.hist.srow_z = tmp(3,:); 36 | save_untouch_nii(nii,fileout); 37 | 38 | if nargin>5 39 | nii = load_untouch_nii(filein2); 40 | nii.hdr.hist.qform_code = 0; 41 | nii.hdr.hist.quatern_b = 0; 42 | nii.hdr.hist.qoffset_x = 0; 43 | nii.hdr.hist.qoffset_y = 0; 44 | nii.hdr.hist.qoffset_z = 0; 45 | tmp = mat\cat(1,nii.hdr.hist.srow_x,nii.hdr.hist.srow_y,nii.hdr.hist.srow_z,[0 0 0 1]); 46 | nii.hdr.hist.srow_x = tmp(1,:); nii.hdr.hist.srow_y = tmp(2,:); nii.hdr.hist.srow_z = tmp(3,:); 47 | save_untouch_nii(nii,fileout2); 48 | end 49 | 50 | %exit -------------------------------------------------------------------------------- /preprocessing/dwi/rri_file_menu.m: -------------------------------------------------------------------------------- 1 | % Imbed a file menu to any figure. If file menu exist, it will append 2 | % to the existing file menu. This file menu includes: Copy to clipboard, 3 | % print, save, close etc. 4 | % 5 | % Usage: rri_file_menu(fig); 6 | % 7 | % rri_file_menu(fig,0) means no 'Close' menu. 8 | % 9 | % - Jimmy Shen (jimmy@rotman-baycrest.on.ca) 10 | % 11 | %-------------------------------------------------------------------- 12 | 13 | function rri_file_menu(action, varargin) 14 | 15 | if isnumeric(action) 16 | fig = action; 17 | action = 'init'; 18 | end 19 | 20 | % clear the message line, 21 | % 22 | h = findobj(gcf,'Tag','MessageLine'); 23 | set(h,'String',''); 24 | 25 | if ~strcmp(action, 'init') 26 | set(gcbf, 'InvertHardcopy','off'); 27 | % set(gcbf, 'PaperPositionMode','auto'); 28 | end 29 | 30 | switch action 31 | case {'init'} 32 | if nargin > 1 33 | init(fig, 1); % no 'close' menu 34 | else 35 | init(fig, 0); 36 | end 37 | case {'print_fig'} 38 | printdlg(gcbf); 39 | case {'copy_fig'} 40 | copy_fig; 41 | case {'export_fig'} 42 | export_fig; 43 | end 44 | 45 | return % rri_file_menu 46 | 47 | 48 | %------------------------------------------------ 49 | % 50 | % Create (or append) File menu 51 | % 52 | function init(fig, no_close) 53 | 54 | % search for file menu 55 | % 56 | h_file = []; 57 | menuitems = findobj(fig, 'type', 'uimenu'); 58 | 59 | for i=1:length(menuitems) 60 | filelabel = get(menuitems(i),'label'); 61 | 62 | if strcmpi(strrep(filelabel, '&', ''), 'file') 63 | h_file = menuitems(i); 64 | break; 65 | end 66 | end 67 | 68 | set(fig, 'menubar', 'none'); 69 | 70 | if isempty(h_file) 71 | if isempty(menuitems) 72 | h_file = uimenu('parent', fig, 'label', 'File'); 73 | else 74 | h_file = uimenu('parent', fig, 'label', 'Copy Figure'); 75 | end 76 | 77 | h1 = uimenu('parent', h_file, ... 78 | 'callback','rri_file_menu(''copy_fig'');', ... 79 | 'label','Copy to Clipboard'); 80 | else 81 | h1 = uimenu('parent', h_file, ... 82 | 'callback','rri_file_menu(''copy_fig'');', ... 83 | 'separator','on', ... 84 | 'label','Copy to Clipboard'); 85 | end 86 | 87 | h2 = uimenu(h_file, ... 88 | 'callback','pagesetupdlg(gcbf);', ... 89 | 'label','Page Setup...'); 90 | 91 | h2 = uimenu(h_file, ... 92 | 'callback','printpreview(gcbf);', ... 93 | 'label','Print Preview...'); 94 | 95 | h2 = uimenu('parent', h_file, ... 96 | 'callback','printdlg(gcbf);', ... 97 | 'label','Print Figure ...'); 98 | 99 | h2 = uimenu('parent', h_file, ... 100 | 'callback','rri_file_menu(''export_fig'');', ... 101 | 'label','Save Figure ...'); 102 | 103 | arch = computer; 104 | if ~strcmpi(arch(1:2),'PC') 105 | set(h1, 'enable', 'off'); 106 | end 107 | 108 | if ~no_close 109 | h1 = uimenu('parent', h_file, ... 110 | 'callback','close(gcbf);', ... 111 | 'separator','on', ... 112 | 'label','Close'); 113 | end 114 | 115 | return; % init 116 | 117 | 118 | %------------------------------------------------ 119 | % 120 | % Copy to clipboard 121 | % 122 | function copy_fig 123 | 124 | arch = computer; 125 | if(~strcmpi(arch(1:2),'PC')) 126 | error('copy to clipboard can only be used under MS Windows'); 127 | return; 128 | end 129 | 130 | print -noui -dbitmap; 131 | 132 | return % copy_fig 133 | 134 | 135 | %------------------------------------------------ 136 | % 137 | % Save as an image file 138 | % 139 | function export_fig 140 | 141 | curr = pwd; 142 | if isempty(curr) 143 | curr = filesep; 144 | end 145 | 146 | [selected_file, selected_path] = rri_select_file(curr,'Save As'); 147 | 148 | if isempty(selected_file) | isempty(selected_path) 149 | return; 150 | end 151 | 152 | filename = [selected_path selected_file]; 153 | 154 | if(exist(filename,'file')==2) % file exist 155 | 156 | dlg_title = 'Confirm File Overwrite'; 157 | msg = ['File ',filename,' exist. Are you sure you want to overwrite it?']; 158 | response = questdlg(msg,dlg_title,'Yes','No','Yes'); 159 | 160 | if(strcmp(response,'No')) 161 | return; 162 | end 163 | 164 | end 165 | 166 | old_pointer = get(gcbf,'pointer'); 167 | set(gcbf,'pointer','watch'); 168 | 169 | try 170 | saveas(gcbf,filename); 171 | catch 172 | msg = 'ERROR: Cannot save file'; 173 | set(findobj(gcf,'Tag','MessageLine'),'String',msg); 174 | end 175 | 176 | set(gcbf,'pointer',old_pointer); 177 | 178 | return; % export_fig 179 | 180 | -------------------------------------------------------------------------------- /preprocessing/dwi/rri_orient.m: -------------------------------------------------------------------------------- 1 | % Convert image of different orientations to standard Analyze orientation 2 | % 3 | % Usage: nii = rri_orient(nii); 4 | 5 | % Jimmy Shen (jimmy@rotman-baycrest.on.ca), 26-APR-04 6 | %___________________________________________________________________ 7 | 8 | function [nii, orient, pattern] = rri_orient(nii, varargin) 9 | 10 | if nargin > 1 11 | pattern = varargin{1}; 12 | else 13 | pattern = []; 14 | end 15 | 16 | if(nargin > 2) 17 | orient = varargin{2}; 18 | if(length(find(orient>6)) || length(find(orient<1))) %value checking 19 | orient=[1 2 3]; %set to default if bogus values set 20 | end 21 | else 22 | orient = [1 2 3]; 23 | end 24 | 25 | 26 | dim = double(nii.hdr.dime.dim([2:4])); 27 | 28 | if ~isempty(pattern) & ~isequal(length(pattern), prod(dim)) 29 | return; 30 | end 31 | 32 | % get orient of the current image 33 | % 34 | if isequal(orient, [1 2 3]) 35 | orient = rri_orient_ui; 36 | pause(.1); 37 | end 38 | 39 | % no need for conversion 40 | % 41 | if isequal(orient, [1 2 3]) 42 | return; 43 | end 44 | 45 | if isempty(pattern) 46 | pattern = 1:prod(dim); 47 | end 48 | 49 | pattern = reshape(pattern, dim); 50 | img = nii.img; 51 | 52 | % calculate after flip orient 53 | % 54 | rot_orient = mod(orient + 2, 3) + 1; 55 | 56 | % do flip: 57 | % 58 | flip_orient = orient - rot_orient; 59 | 60 | for i = 1:3 61 | if flip_orient(i) 62 | pattern = flipdim(pattern, i); 63 | img = flipdim(img, i); 64 | end 65 | end 66 | 67 | % get index of orient (do inverse) 68 | % 69 | [tmp rot_orient] = sort(rot_orient); 70 | 71 | % do rotation: 72 | % 73 | pattern = permute(pattern, rot_orient); 74 | img = permute(img, [rot_orient 4 5 6]); 75 | 76 | % rotate resolution, or 'dim' 77 | % 78 | new_dim = nii.hdr.dime.dim([2:4]); 79 | new_dim = new_dim(rot_orient); 80 | nii.hdr.dime.dim([2:4]) = new_dim; 81 | 82 | % rotate voxel_size, or 'pixdim' 83 | % 84 | tmp = nii.hdr.dime.pixdim([2:4]); 85 | tmp = tmp(rot_orient); 86 | nii.hdr.dime.pixdim([2:4]) = tmp; 87 | 88 | % re-calculate originator 89 | % 90 | tmp = nii.hdr.hist.originator([1:3]); 91 | tmp = tmp(rot_orient); 92 | flip_orient = flip_orient(rot_orient); 93 | 94 | for i = 1:3 95 | if flip_orient(i) & ~isequal(double(tmp(i)), 0) 96 | tmp(i) = int16(double(new_dim(i)) - double(tmp(i)) + 1); 97 | end 98 | end 99 | 100 | nii.hdr.hist.originator([1:3]) = tmp; 101 | 102 | nii.img = img; 103 | pattern = pattern(:); 104 | 105 | return; % rri_orient 106 | 107 | -------------------------------------------------------------------------------- /preprocessing/dwi/rri_xhair.m: -------------------------------------------------------------------------------- 1 | % rri_xhair: create a pair of full_cross_hair at point [x y] in 2 | % axes h_ax, and return xhair struct 3 | % 4 | % Usage: xhair = rri_xhair([x y], xhair, h_ax); 5 | % 6 | % If omit xhair, rri_xhair will create a pair of xhair; otherwise, 7 | % rri_xhair will update the xhair. If omit h_ax, current axes will 8 | % be used. 9 | % 10 | 11 | % 24-nov-2003 jimmy (jimmy@rotman-baycrest.on.ca) 12 | % 13 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 14 | 15 | function xhair = rri_xhair(varargin) 16 | 17 | if nargin == 0 18 | error('Please enter a point position as first argument'); 19 | return; 20 | end 21 | 22 | if nargin > 0 23 | p = varargin{1}; 24 | 25 | if ~isnumeric(p) | length(p) ~= 2 26 | error('Invalid point position'); 27 | return; 28 | else 29 | xhair = []; 30 | end 31 | end 32 | 33 | if nargin > 1 34 | xhair = varargin{2}; 35 | 36 | if ~isempty(xhair) 37 | if ~isstruct(xhair) 38 | error('Invalid xhair struct'); 39 | return; 40 | elseif ~isfield(xhair,'lx') | ~isfield(xhair,'ly') 41 | error('Invalid xhair struct'); 42 | return; 43 | elseif ~ishandle(xhair.lx) | ~ishandle(xhair.ly) 44 | error('Invalid xhair struct'); 45 | return; 46 | end 47 | 48 | lx = xhair.lx; 49 | ly = xhair.ly; 50 | else 51 | lx = []; 52 | ly = []; 53 | end 54 | end 55 | 56 | if nargin > 2 57 | h_ax = varargin{3}; 58 | 59 | if ~ishandle(h_ax) 60 | error('Invalid axes handle'); 61 | return; 62 | elseif ~strcmp(lower(get(h_ax,'type')), 'axes') 63 | error('Invalid axes handle'); 64 | return; 65 | end 66 | else 67 | h_ax = gca; 68 | end 69 | 70 | x_range = get(h_ax,'xlim'); 71 | y_range = get(h_ax,'ylim'); 72 | 73 | if ~isempty(xhair) 74 | set(lx, 'ydata', [p(2) p(2)]); 75 | set(ly, 'xdata', [p(1) p(1)]); 76 | set(h_ax, 'selected', 'on'); 77 | set(h_ax, 'selected', 'off'); 78 | else 79 | figure(get(h_ax,'parent')); 80 | axes(h_ax); 81 | 82 | xhair.lx = line('xdata', x_range, 'ydata', [p(2) p(2)], ... 83 | 'zdata', [11 11], 'color', [1 0 0], 'hittest', 'off'); 84 | xhair.ly = line('xdata', [p(1) p(1)], 'ydata', y_range, ... 85 | 'zdata', [11 11], 'color', [1 0 0], 'hittest', 'off'); 86 | end 87 | 88 | set(h_ax,'xlim',x_range); 89 | set(h_ax,'ylim',y_range); 90 | 91 | return; 92 | 93 | -------------------------------------------------------------------------------- /preprocessing/dwi/rri_zoom_menu.m: -------------------------------------------------------------------------------- 1 | % Imbed a zoom menu to any figure. 2 | % 3 | % Usage: rri_zoom_menu(fig); 4 | % 5 | 6 | % - Jimmy Shen (jimmy@rotman-baycrest.on.ca) 7 | % 8 | %-------------------------------------------------------------------- 9 | function menu_hdl = rri_zoom_menu(fig) 10 | 11 | if isnumeric(fig) 12 | menu_hdl = uimenu('Parent',fig, ... 13 | 'Label','Zoom on', ... 14 | 'Userdata', 1, ... 15 | 'Callback','rri_zoom_menu(''zoom'');'); 16 | 17 | return; 18 | end 19 | 20 | zoom_on_state = get(gcbo,'Userdata'); 21 | 22 | if (zoom_on_state == 1) 23 | zoom on; 24 | set(gcbo,'Userdata',0,'Label','Zoom off'); 25 | set(gcbf,'pointer','crosshair'); 26 | else 27 | zoom off; 28 | set(gcbo,'Userdata',1,'Label','Zoom on'); 29 | set(gcbf,'pointer','arrow'); 30 | end 31 | 32 | return % rri_zoom_menu 33 | 34 | -------------------------------------------------------------------------------- /preprocessing/dwi/save_nii_ext.m: -------------------------------------------------------------------------------- 1 | % Save NIFTI header extension. 2 | % 3 | % Usage: save_nii_ext(ext, fid) 4 | % 5 | % ext - struct with NIFTI header extension fields. 6 | % 7 | % NIFTI data format can be found on: http://nifti.nimh.nih.gov 8 | % 9 | % - Jimmy Shen (jimmy@rotman-baycrest.on.ca) 10 | % 11 | function save_nii_ext(ext, fid) 12 | 13 | if ~exist('ext','var') | ~exist('fid','var') 14 | error('Usage: save_nii_ext(ext, fid)'); 15 | end 16 | 17 | if ~isfield(ext,'extension') | ~isfield(ext,'section') | ~isfield(ext,'num_ext') 18 | error('Wrong header extension'); 19 | end 20 | 21 | write_ext(ext, fid); 22 | 23 | return; % save_nii_ext 24 | 25 | 26 | %--------------------------------------------------------------------- 27 | function write_ext(ext, fid) 28 | 29 | fwrite(fid, ext.extension, 'uchar'); 30 | 31 | for i=1:ext.num_ext 32 | fwrite(fid, ext.section(i).esize, 'int32'); 33 | fwrite(fid, ext.section(i).ecode, 'int32'); 34 | fwrite(fid, ext.section(i).edata, 'uchar'); 35 | end 36 | 37 | return; % write_ext 38 | 39 | -------------------------------------------------------------------------------- /preprocessing/dwi/save_untouch_header_only.m: -------------------------------------------------------------------------------- 1 | % This function is only used to save Analyze or NIfTI header that is 2 | % ended with .hdr and loaded by load_untouch_header_only.m. If you 3 | % have NIfTI file that is ended with .nii and you want to change its 4 | % header only, you can use load_untouch_nii / save_untouch_nii pair. 5 | % 6 | % Usage: save_untouch_header_only(hdr, new_header_file_name) 7 | % 8 | % hdr - struct with NIfTI / Analyze header fields, which is obtained from: 9 | % hdr = load_untouch_header_only(original_header_file_name) 10 | % 11 | % new_header_file_name - NIfTI / Analyze header name ended with .hdr. 12 | % You can either copy original.img(.gz) to new.img(.gz) manually, 13 | % or simply input original.hdr(.gz) in save_untouch_header_only.m 14 | % to overwrite the original header. 15 | % 16 | % - Jimmy Shen (jshen@research.baycrest.org) 17 | % 18 | function save_untouch_header_only(hdr, filename) 19 | 20 | if ~exist('hdr','var') | isempty(hdr) | ~exist('filename','var') | isempty(filename) 21 | error('Usage: save_untouch_header_only(hdr, filename)'); 22 | end 23 | 24 | v = version; 25 | 26 | % Check file extension. If .gz, unpack it into temp folder 27 | % 28 | if length(filename) > 2 & strcmp(filename(end-2:end), '.gz') 29 | 30 | if ~strcmp(filename(end-6:end), '.hdr.gz') 31 | error('Please check filename.'); 32 | end 33 | 34 | if str2num(v(1:3)) < 7.1 | ~usejava('jvm') 35 | error('Please use MATLAB 7.1 (with java) and above, or run gunzip outside MATLAB.'); 36 | else 37 | gzFile = 1; 38 | filename = filename(1:end-3); 39 | end 40 | end 41 | 42 | [p,f] = fileparts(filename); 43 | fileprefix = fullfile(p, f); 44 | 45 | write_hdr(hdr, fileprefix); 46 | 47 | % gzip output file if requested 48 | % 49 | if exist('gzFile', 'var') 50 | gzip([fileprefix, '.hdr']); 51 | delete([fileprefix, '.hdr']); 52 | end; 53 | 54 | return % save_untouch_header_only 55 | 56 | 57 | %----------------------------------------------------------------------------------- 58 | function write_hdr(hdr, fileprefix) 59 | 60 | fid = fopen(sprintf('%s.hdr',fileprefix),'w'); 61 | 62 | if isfield(hdr.hist,'magic') 63 | save_untouch_nii_hdr(hdr, fid); 64 | else 65 | save_untouch0_nii_hdr(hdr, fid); 66 | end 67 | 68 | fclose(fid); 69 | 70 | return % write_hdr 71 | 72 | -------------------------------------------------------------------------------- /preprocessing/dwi/unxform_nii.m: -------------------------------------------------------------------------------- 1 | % Undo the flipping and rotations performed by xform_nii; spit back only 2 | % the raw img data block. Initial cut will only deal with 3D volumes 3 | % strongly assume we have called xform_nii to write down the steps used 4 | % in xform_nii. 5 | % 6 | % Usage: a = load_nii('original_name'); 7 | % manipulate a.img to make array b; 8 | % 9 | % if you use unxform_nii to un-tranform the image (img) data 10 | % block, then nii.original.hdr is the corresponding header. 11 | % 12 | % nii.original.img = unxform_nii(a, b); 13 | % save_nii(nii.original,'newname'); 14 | % 15 | % Where, 'newname' is created with data in the same space as the 16 | % original_name data 17 | % 18 | % - Jeff Gunter, 26-JUN-06 19 | % 20 | function outblock = unxform_nii(nii, inblock) 21 | 22 | if isempty(nii.hdr.hist.rot_orient) 23 | outblock=inblock; 24 | else 25 | [dummy unrotate_orient] = sort(nii.hdr.hist.rot_orient); 26 | outblock = permute(inblock, unrotate_orient); 27 | end 28 | 29 | if ~isempty(nii.hdr.hist.flip_orient) 30 | flip_orient = nii.hdr.hist.flip_orient(unrotate_orient); 31 | 32 | for i = 1:3 33 | if flip_orient(i) 34 | outblock = flipdim(outblock, i); 35 | end 36 | end 37 | end; 38 | 39 | return; 40 | 41 | -------------------------------------------------------------------------------- /preprocessing/dwi/verify_nii_ext.m: -------------------------------------------------------------------------------- 1 | % Verify NIFTI header extension to make sure that each extension section 2 | % must be an integer multiple of 16 byte long that includes the first 8 3 | % bytes of esize and ecode. If the length of extension section is not the 4 | % above mentioned case, edata should be padded with all 0. 5 | % 6 | % Usage: [ext, esize_total] = verify_nii_ext(ext) 7 | % 8 | % ext - Structure of NIFTI header extension, which includes num_ext, 9 | % and all the extended header sections in the header extension. 10 | % Each extended header section will have its esize, ecode, and 11 | % edata, where edata can be plain text, xml, or any raw data 12 | % that was saved in the extended header section. 13 | % 14 | % esize_total - Sum of all esize variable in all header sections. 15 | % 16 | % NIFTI data format can be found on: http://nifti.nimh.nih.gov 17 | % 18 | % - Jimmy Shen (jimmy@rotman-baycrest.on.ca) 19 | % 20 | function [ext, esize_total] = verify_nii_ext(ext) 21 | 22 | if ~isfield(ext, 'section') 23 | error('Incorrect NIFTI header extension structure.'); 24 | elseif ~isfield(ext, 'num_ext') 25 | ext.num_ext = length(ext.section); 26 | elseif ~isfield(ext, 'extension') 27 | ext.extension = [1 0 0 0]; 28 | end 29 | 30 | esize_total = 0; 31 | 32 | for i=1:ext.num_ext 33 | if ~isfield(ext.section(i), 'ecode') | ~isfield(ext.section(i), 'edata') 34 | error('Incorrect NIFTI header extension structure.'); 35 | end 36 | 37 | ext.section(i).esize = ceil((length(ext.section(i).edata)+8)/16)*16; 38 | ext.section(i).edata = ... 39 | [ext.section(i).edata ... 40 | zeros(1,ext.section(i).esize-length(ext.section(i).edata)-8)]; 41 | esize_total = esize_total + ext.section(i).esize; 42 | end 43 | 44 | return % verify_nii_ext 45 | 46 | -------------------------------------------------------------------------------- /preprocessing/fmri-conn/README.txt: -------------------------------------------------------------------------------- 1 | These are preprocessing pipelines for the CONN 18b toolbox, by the Coma Science Group - GIGA-Consciousness, University of Liège, Belgium. 2 | 3 | It is advised to use either the unwarp or noreslice pipelines, but disadvised to use the reslice pipeline as it gives quite different results (and particularly diminished anti-correlations). Furthermore, for a maximal similarity to our custom SPM pipeline, when running the pipeline, the option "rtm" aka "realignment to mean image" should be selected during the realignment step. These pipelines are not totally equivalent to the script one (because CONN management of files is different, and particularly the functional is realigned/coregistered by reference to the first scan instead of mean image as in our script pipeline), but the results are close. 4 | 5 | Experimental pipelines using "Masked smoothing", which is to apply a gaussian smoothing only to the grey matter in order to avoid noise spillage from white matter and CSF, are also available. 6 | 7 | To use these pipelines, copy them in your CONN folder inside: conn\utils\preprocessingpipelines\ 8 | 9 | Author: Stephen Karl Larroque, 2018-2019 10 | -------------------------------------------------------------------------------- /preprocessing/fmri-conn/conn-csg-pipeline-noreslice-maskedsmoothing.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/fmri-conn/conn-csg-pipeline-noreslice-maskedsmoothing.mat -------------------------------------------------------------------------------- /preprocessing/fmri-conn/conn-csg-pipeline-noreslice.info: -------------------------------------------------------------------------------- 1 | Coma Science Group pipeline using indirect normalization, similar to the batch pipeline using SPM12 with unified segmentation mode, but using Realign (without Reslicing nor Unwarping so no interpolation of functional). If you have multiband BOLD data, please use this pipeline (and not the "reslice" one). For CONN 18a. By Stephen Karl Larroque, 2018. License: MIT. 2 | -------------------------------------------------------------------------------- /preprocessing/fmri-conn/conn-csg-pipeline-noreslice.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/fmri-conn/conn-csg-pipeline-noreslice.mat -------------------------------------------------------------------------------- /preprocessing/fmri-conn/conn-csg-pipeline-reslice.info: -------------------------------------------------------------------------------- 1 | Coma Science Group pipeline using indirect normalization, similar to the batch pipeline using SPM12 with unified segmentation mode, but using Realign and Reslice. Note this is incompatible with multiband BOLD, if you use this pipeline, the resulting BOLD will be cut in half. For CONN 18a. By Stephen Karl Larroque, 2018. License: MIT. 2 | -------------------------------------------------------------------------------- /preprocessing/fmri-conn/conn-csg-pipeline-reslice.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/fmri-conn/conn-csg-pipeline-reslice.mat -------------------------------------------------------------------------------- /preprocessing/fmri-conn/conn-csg-pipeline-unwarp-maskedsmoothing.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/fmri-conn/conn-csg-pipeline-unwarp-maskedsmoothing.mat -------------------------------------------------------------------------------- /preprocessing/fmri-conn/conn-csg-pipeline-unwarp.info: -------------------------------------------------------------------------------- 1 | Coma Science Group pipeline using indirect normalization, similar to the batch pipeline using SPM12 with unified segmentation mode, but using Realign and Unwarp. For CONN 18a. By Stephen Karl Larroque, 2018. License: MIT. 2 | -------------------------------------------------------------------------------- /preprocessing/fmri-conn/conn-csg-pipeline-unwarp.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/fmri-conn/conn-csg-pipeline-unwarp.mat -------------------------------------------------------------------------------- /preprocessing/fmri/README.txt: -------------------------------------------------------------------------------- 1 | script_preproc_fmri_csg.m is the entry point (main script), open it in a text editor to modify the parameters (and paths to toolboxes) and then run it. 2 | -------------------------------------------------------------------------------- /preprocessing/fmri/batch_preproc_spm12_CAT12Dartel_2024.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/fmri/batch_preproc_spm12_CAT12Dartel_2024.mat -------------------------------------------------------------------------------- /preprocessing/fmri/batch_preproc_spm12_CAT12Dartel_2024_unwarp.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/fmri/batch_preproc_spm12_CAT12Dartel_2024_unwarp.mat -------------------------------------------------------------------------------- /preprocessing/fmri/batch_preproc_spm12_CAT12Dartel_old2019.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/fmri/batch_preproc_spm12_CAT12Dartel_old2019.mat -------------------------------------------------------------------------------- /preprocessing/fmri/batch_preproc_spm12_CAT12Dartel_old2019_expand.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/fmri/batch_preproc_spm12_CAT12Dartel_old2019_expand.mat -------------------------------------------------------------------------------- /preprocessing/fmri/batch_preproc_spm12_CAT12Dartel_old2019_unwarp.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/fmri/batch_preproc_spm12_CAT12Dartel_old2019_unwarp.mat -------------------------------------------------------------------------------- /preprocessing/fmri/batch_preproc_spm12_oldseg.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/fmri/batch_preproc_spm12_oldseg.mat -------------------------------------------------------------------------------- /preprocessing/fmri/batch_preproc_spm12_oldseg_expand.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/fmri/batch_preproc_spm12_oldseg_expand.mat -------------------------------------------------------------------------------- /preprocessing/fmri/batch_preproc_spm12_oldseg_unwarp.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/fmri/batch_preproc_spm12_oldseg_unwarp.mat -------------------------------------------------------------------------------- /preprocessing/fmri/batch_preproc_spm12_uniseg.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/fmri/batch_preproc_spm12_uniseg.mat -------------------------------------------------------------------------------- /preprocessing/fmri/batch_preproc_spm12_uniseg_unwarp.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/fmri/batch_preproc_spm12_uniseg_unwarp.mat -------------------------------------------------------------------------------- /preprocessing/fmri/batch_preproc_spm8_vbm8dartel_midtemplate_defbiascorrected.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/fmri/batch_preproc_spm8_vbm8dartel_midtemplate_defbiascorrected.mat -------------------------------------------------------------------------------- /preprocessing/fmri/batch_preproc_spm8_vbm8dartel_midtemplate_defbiascorrected_expand.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/fmri/batch_preproc_spm8_vbm8dartel_midtemplate_defbiascorrected_expand.mat -------------------------------------------------------------------------------- /preprocessing/fmri/gen_microtime_onset.m: -------------------------------------------------------------------------------- 1 | function [microtime_onset, microtime_resolution, refslice] = gen_microtime_onset(slice_order, refslice, min_microtime_resolution, max_microtime_resolution) 2 | % [microtime_onset, microtime_resolution, refslice] = gen_microtime_onset(slice_order, refslice, min_microtime_resolution) 3 | % Calculates the appropriate microtime_onset for a statistical test in SPM given the slice_order, min_microtime_resolution and reference slice 4 | % input: slice_order is the slice order used for slice timing correction. 5 | % input: refslice is the spatial reference slice used in slice timing correction. Value can be either: 'first', 'middle', 'last' or any slice number or slice timing. 6 | % optional input: min_microtime_resolution: minimal microtime resolution you want, the script will return the smallest microtime resolution above this minimum that can perfectly align with this refslice (default in SPM12 = 16) 7 | % optional input: max_microtime_resolution: maximal microtime resolution you want, if the result need to have a higher microtime resolution to be precise, with this option the onset will be approximated to the nearest previous microtime block (default=0 disabled). 8 | % 9 | % by Stephen Larroque from the Coma Science Group, 2017 10 | % Licensed under MIT. 11 | % 12 | % v1.0 13 | % 14 | % Notices/Changelog: 15 | % * v1.0: first release 16 | % 17 | 18 | if ~exist('min_microtime_resolution', 'var') 19 | min_microtime_resolution = 16; % SPM12 default 20 | end 21 | if ~exist('max_microtime_resolution', 'var') 22 | max_microtime_resolution = 0; 23 | end 24 | 25 | % Helper condition for easy refslice setting 26 | if strcmpi(refslice, 'first') | refslice == slice_order(1) 27 | % special case, we do not need to compute anything 28 | refslice = slice_order(1); 29 | microtime_resolution = min_microtime_resolution; 30 | microtime_onset = 1; 31 | return; 32 | elseif strcmpi(refslice, 'middle') 33 | refslice = slice_order(ceil(numel(slice_order)/2)); 34 | elseif strcmpi(refslice, 'last') 35 | refslice = slice_order(end); 36 | %else refslice is an integer or a float, which is the slice spatial number we want to use as refslice 37 | end %endif 38 | 39 | % Convert refslice from spatial convention (number is slice position is space and position in array is position in time) to temporal convention (position in array is position in space and number is position in time) 40 | temporal_refslice = find(slice_order == refslice) - 1; % minus 1 because we want to set onset at the start of the slice, so in fact before this slice. Here this will give us the last microtime that belong to the previous slice. 41 | % Calculate the ratio compared to the number of slices (to get the relative position from the start of the array) 42 | microtime_onset_ratio = temporal_refslice / numel(slice_order); 43 | 44 | % Rescale to min_microtime_resolution 45 | [N, D] = rat(microtime_onset_ratio); 46 | if D < 16 47 | ratio_newT = ceil(min_microtime_resolution/D); 48 | microtime_resolution = D*ratio_newT; 49 | microtime_onset = N*ratio_newT + 1; % plus 1 because N is at the last microtime block of the previous slice, so if we do +1 we will be at the start microtime block of the next slice (the refslice) 50 | else 51 | microtime_resolution = D; 52 | microtime_onset = N + 1; % plus 1 for same reason, to move from last microtime block of previous slice to the start microtime block of the refslice 53 | end %endif 54 | 55 | % Approximate onset if resolution is above max_microtime_resolution 56 | if max_microtime_resolution > 0 & microtime_resolution > max_microtime_resolution 57 | microtime_onset = floor(microtime_onset/(microtime_resolution/max_microtime_resolution)); 58 | microtime_resolution = max_microtime_resolution; 59 | end %endif 60 | 61 | end 62 | -------------------------------------------------------------------------------- /preprocessing/fmri/jsonlab/.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | .idea 3 | .DS_store 4 | Thumbs.db 5 | logs 6 | *.log 7 | npm-debug.log* 8 | yarn-debug.log* 9 | yarn-error.log* 10 | pids 11 | *.pid 12 | *.seed 13 | *.pid.lock 14 | lib-cov 15 | coverage 16 | .nyc_output 17 | .grunt 18 | bower_components 19 | .lock-wscript 20 | build/Release 21 | node_modules/ 22 | jspm_packages/ 23 | typings/ 24 | .npm 25 | .eslintcache 26 | .node_repl_history 27 | *.tgz 28 | .yarn-integrity 29 | .env 30 | *.asv 31 | *.m~ 32 | *.mex* 33 | slprj/ 34 | octave-workspace 35 | .autosave 36 | -------------------------------------------------------------------------------- /preprocessing/fmri/jsonlab/AUTHORS.txt: -------------------------------------------------------------------------------- 1 | The author of "jsonlab" toolbox is Qianqian Fang. Qianqian 2 | is currently an Assistant Professor in the Department of Bioengineering, 3 | Northeastern University. 4 | 5 | Address: Qianqian Fang 6 | Department of Bioengineering 7 | Northeastern University 8 | 212A Lake Hall 9 | 360 Huntington Ave, Boston, MA 02115, USA 10 | Office: 503 Holmes Hall 11 | Phone[O]: 617-373-3829 12 | URL: http://fanglab.org 13 | Email: and 14 | 15 | 16 | The script loadjson.m was built upon previous works by 17 | 18 | - Nedialko Krouchev: http://www.mathworks.com/matlabcentral/fileexchange/25713 19 | date: 2009/11/02 20 | - François Glineur: http://www.mathworks.com/matlabcentral/fileexchange/23393 21 | date: 2009/03/22 22 | - Joel Feenstra: http://www.mathworks.com/matlabcentral/fileexchange/20565 23 | date: 2008/07/03 24 | 25 | 26 | This toolbox contains patches submitted by the following contributors: 27 | 28 | - Blake Johnson 29 | part of revision 341 30 | 31 | - Niclas Borlin 32 | various fixes in revision 394, including 33 | - loadjson crashes for all-zero sparse matrix. 34 | - loadjson crashes for empty sparse matrix. 35 | - Non-zero size of 0-by-N and N-by-0 empty matrices is lost after savejson/loadjson. 36 | - loadjson crashes for sparse real column vector. 37 | - loadjson crashes for sparse complex column vector. 38 | - Data is corrupted by savejson for sparse real row vector. 39 | - savejson crashes for sparse complex row vector. 40 | 41 | - Yul Kang 42 | patches for svn revision 415. 43 | - savejson saves an empty cell array as [] instead of null 44 | - loadjson differentiates an empty struct from an empty array 45 | 46 | - Mykhailo Bratukha 47 | (Pull#14) Bug fix: File path is wrongly inerpreted as JSON string 48 | 49 | - Insik Kim 50 | (Pull#12) Bug fix: Resolving bug that cell type is converted to json with transposed data 51 | 52 | - Sertan Senturk 53 | (Pull#10,#11) Feature: Added matlab object saving to savejson and saveubjson 54 | -------------------------------------------------------------------------------- /preprocessing/fmri/jsonlab/LICENSE_BSD.txt: -------------------------------------------------------------------------------- 1 | Copyright 2011-2017 Qianqian Fang neu.edu>. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are 4 | permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of 7 | conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list 10 | of conditions and the following disclaimer in the documentation and/or other materials 11 | provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY EXPRESS OR IMPLIED 14 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 15 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 16 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 17 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 18 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 19 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 20 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 21 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | 23 | The views and conclusions contained in the software and documentation are those of the 24 | authors and should not be interpreted as representing official policies, either expressed 25 | or implied, of the copyright holders. 26 | -------------------------------------------------------------------------------- /preprocessing/fmri/jsonlab/examples/example1.json: -------------------------------------------------------------------------------- 1 | { 2 | "firstName": "John", 3 | "lastName": "Smith", 4 | "age": 25, 5 | "address": 6 | { 7 | "streetAddress": "21 2nd Street", 8 | "city": "New York", 9 | "state": "NY", 10 | "postalCode": "10021" 11 | }, 12 | "phoneNumber": 13 | [ 14 | { 15 | "type": "home", 16 | "number": "212 555-1234" 17 | }, 18 | { 19 | "type": "fax", 20 | "number": "646 555-4567" 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /preprocessing/fmri/jsonlab/examples/example2.json: -------------------------------------------------------------------------------- 1 | { 2 | "glossary": { 3 | "title": "example glossary", 4 | "GlossDiv": { 5 | "title": "S", 6 | "GlossList": { 7 | "GlossEntry": { 8 | "ID": "SGML", 9 | "SortAs": "SGML", 10 | "GlossTerm": "Standard Generalized Markup Language", 11 | "Acronym": "SGML", 12 | "Abbrev": "ISO 8879:1986", 13 | "GlossDef": { 14 | "para": "A meta-markup language, used to create markup languages such as DocBook.", 15 | "GlossSeeAlso": ["GML", "XML"] 16 | }, 17 | "GlossSee": "markup" 18 | } 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /preprocessing/fmri/jsonlab/examples/example3.json: -------------------------------------------------------------------------------- 1 | {"menu": { 2 | "id": "file", 3 | "value": "_&File", 4 | "popup": { 5 | "menuitem": [ 6 | {"value": "_&New", "onclick": "CreateNewDoc(\"'\\\"Untitled\\\"'\")"}, 7 | {"value": "_&Open", "onclick": "OpenDoc()"}, 8 | {"value": "_&Close", "onclick": "CloseDoc()"} 9 | ] 10 | } 11 | }} 12 | -------------------------------------------------------------------------------- /preprocessing/fmri/jsonlab/examples/example4.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "sample" : { 4 | "rho" : 1 5 | } 6 | }, 7 | { 8 | "sample" : { 9 | "rho" : 2 10 | } 11 | }, 12 | [ 13 | { 14 | "_ArrayType_" : "double", 15 | "_ArraySize_" : [1,2], 16 | "_ArrayData_" : [1,0] 17 | }, 18 | { 19 | "_ArrayType_" : "double", 20 | "_ArraySize_" : [1,2], 21 | "_ArrayData_" : [1,1] 22 | }, 23 | { 24 | "_ArrayType_" : "double", 25 | "_ArraySize_" : [1,2], 26 | "_ArrayData_" : [1,2] 27 | } 28 | ], 29 | [ 30 | "Paper", 31 | "Scissors", 32 | "Stone" 33 | ], 34 | ["a", "b\\", "c\"","d\\\"","e\"[","f\\\"[","g[\\","h[\\\""] 35 | ] 36 | -------------------------------------------------------------------------------- /preprocessing/fmri/jsonlab/examples/jsonlab_selftest.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % Regression Test Unit of loadjson and savejson 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | 5 | for i=1:4 6 | fname=sprintf('example%d.json',i); 7 | if(exist(fname,'file')==0) break; end 8 | fprintf(1,'===============================================\n>> %s\n',fname); 9 | json=savejson('data',loadjson(fname)); 10 | fprintf(1,'%s\n',json); 11 | fprintf(1,'%s\n',savejson('data',loadjson(fname),'Compact',1)); 12 | data=loadjson(json); 13 | savejson('data',data,'selftest.json'); 14 | data=loadjson('selftest.json'); 15 | end 16 | 17 | for i=1:4 18 | fname=sprintf('example%d.json',i); 19 | if(exist(fname,'file')==0) break; end 20 | fprintf(1,'===============================================\n>> %s\n',fname); 21 | json=saveubjson('data',loadjson(fname)); 22 | fprintf(1,'%s\n',json); 23 | data=loadubjson(json); 24 | savejson('',data); 25 | saveubjson('data',data,'selftest.ubj'); 26 | data=loadubjson('selftest.ubj'); 27 | end 28 | -------------------------------------------------------------------------------- /preprocessing/fmri/jsonlab/examples/jsonlab_speedtest.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % Benchmarking processing speed of savejson and loadjson 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | 5 | datalen=[1e3 1e4 1e5 1e6]; 6 | len=length(datalen); 7 | tsave=zeros(len,1); 8 | tload=zeros(len,1); 9 | for i=1:len 10 | tic; 11 | json=savejson('data',struct('d1',rand(datalen(i),3),'d2',rand(datalen(i),3)>0.5)); 12 | tsave(i)=toc; 13 | data=loadjson(json); 14 | tload(i)=toc-tsave(i); 15 | fprintf(1,'matrix size: %d\n',datalen(i)); 16 | end 17 | 18 | loglog(datalen,tsave,'o-',datalen,tload,'r*-'); 19 | legend('savejson runtime (s)','loadjson runtime (s)'); 20 | xlabel('array size'); 21 | ylabel('running time (s)'); 22 | -------------------------------------------------------------------------------- /preprocessing/fmri/jsonlab/jsonopt.m: -------------------------------------------------------------------------------- 1 | function val=jsonopt(key,default,varargin) 2 | % 3 | % val=jsonopt(key,default,optstruct) 4 | % 5 | % setting options based on a struct. The struct can be produced 6 | % by varargin2struct from a list of 'param','value' pairs 7 | % 8 | % authors:Qianqian Fang (q.fang neu.edu) 9 | % 10 | % $Id: loadjson.m 371 2012-06-20 12:43:06Z fangq $ 11 | % 12 | % input: 13 | % key: a string with which one look up a value from a struct 14 | % default: if the key does not exist, return default 15 | % optstruct: a struct where each sub-field is a key 16 | % 17 | % output: 18 | % val: if key exists, val=optstruct.key; otherwise val=default 19 | % 20 | % license: 21 | % BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details 22 | % 23 | % -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab) 24 | % 25 | 26 | val=default; 27 | if(nargin<=2) return; end 28 | opt=varargin{1}; 29 | if(isstruct(opt)) 30 | if(isfield(opt,key)) 31 | val=getfield(opt,key); 32 | elseif(isfield(opt,lower(key))) 33 | val=getfield(opt,lower(key)); 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /preprocessing/fmri/jsonlab/mergestruct.m: -------------------------------------------------------------------------------- 1 | function s=mergestruct(s1,s2) 2 | % 3 | % s=mergestruct(s1,s2) 4 | % 5 | % merge two struct objects into one 6 | % 7 | % authors:Qianqian Fang (q.fang neu.edu) 8 | % date: 2012/12/22 9 | % 10 | % input: 11 | % s1,s2: a struct object, s1 and s2 can not be arrays 12 | % 13 | % output: 14 | % s: the merged struct object. fields in s1 and s2 will be combined in s. 15 | % 16 | % license: 17 | % BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details 18 | % 19 | % -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab) 20 | % 21 | 22 | if(~isstruct(s1) || ~isstruct(s2)) 23 | error('input parameters contain non-struct'); 24 | end 25 | if(length(s1)>1 || length(s2)>1) 26 | error('can not merge struct arrays'); 27 | end 28 | fn=fieldnames(s2); 29 | s=s1; 30 | for i=1:length(fn) 31 | s=setfield(s,fn{i},getfield(s2,fn{i})); 32 | end 33 | 34 | -------------------------------------------------------------------------------- /preprocessing/fmri/jsonlab/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jsonlab", 3 | "version": "1.5.0", 4 | "description": "An open-source MATLAB/Octave JSON encoder and decoder", 5 | "directories": { 6 | "example": "examples" 7 | }, 8 | "scripts": { 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/fangq/jsonlab.git" 14 | }, 15 | "author": "Qianqian Fang ", 16 | "license": "GPL-3.0", 17 | "bugs": { 18 | "url": "https://github.com/fangq/jsonlab/issues" 19 | }, 20 | "homepage": "https://github.com/fangq/jsonlab#readme" 21 | } 22 | -------------------------------------------------------------------------------- /preprocessing/fmri/jsonlab/struct2jdata.m: -------------------------------------------------------------------------------- 1 | function newdata=struct2jdata(data,varargin) 2 | % 3 | % newdata=struct2jdata(data,opt,...) 4 | % 5 | % convert a JData object (in the form of a struct array) into an array 6 | % 7 | % authors:Qianqian Fang (q.fang neu.edu) 8 | % 9 | % input: 10 | % data: a struct array. If data contains JData keywords in the first 11 | % level children, these fields are parsed and regrouped into a 12 | % data object (arrays, trees, graphs etc) based on JData 13 | % specification. The JData keywords are 14 | % "_ArrayType_", "_ArraySize_", "_ArrayData_" 15 | % "_ArrayIsSparse_", "_ArrayIsComplex_" 16 | % opt: (optional) a list of 'Param',value pairs for additional options 17 | % The supported options include 18 | % 'Recursive', if set to 1, will apply the conversion to 19 | % every child; 0 to disable 20 | % 21 | % output: 22 | % newdata: the covnerted data if the input data does contain a JData 23 | % structure; otherwise, the same as the input. 24 | % 25 | % examples: 26 | % obj=struct('_ArrayType_','double','_ArraySize_',[2 3], 27 | % '_ArrayIsSparse_',1 ,'_ArrayData_',null); 28 | % ubjdata=struct2jdata(obj); 29 | % 30 | % license: 31 | % BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details 32 | % 33 | % -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab) 34 | % 35 | 36 | fn=fieldnames(data); 37 | newdata=data; 38 | len=length(data); 39 | if(jsonopt('Recursive',0,varargin{:})==1) 40 | for i=1:length(fn) % depth-first 41 | for j=1:len 42 | if(isstruct(getfield(data(j),fn{i}))) 43 | newdata(j)=setfield(newdata(j),fn{i},jstruct2array(getfield(data(j),fn{i}))); 44 | end 45 | end 46 | end 47 | end 48 | if(~isempty(strmatch('x0x5F_ArrayType_',fn)) && ~isempty(strmatch('x0x5F_ArrayData_',fn))) 49 | newdata=cell(len,1); 50 | for j=1:len 51 | ndata=cast(data(j).x0x5F_ArrayData_,data(j).x0x5F_ArrayType_); 52 | iscpx=0; 53 | if(~isempty(strmatch('x0x5F_ArrayIsComplex_',fn))) 54 | if(data(j).x0x5F_ArrayIsComplex_) 55 | iscpx=1; 56 | end 57 | end 58 | if(~isempty(strmatch('x0x5F_ArrayIsSparse_',fn))) 59 | if(data(j).x0x5F_ArrayIsSparse_) 60 | if(~isempty(strmatch('x0x5F_ArraySize_',fn))) 61 | dim=double(data(j).x0x5F_ArraySize_); 62 | if(iscpx && size(ndata,2)==4-any(dim==1)) 63 | ndata(:,end-1)=complex(ndata(:,end-1),ndata(:,end)); 64 | end 65 | if isempty(ndata) 66 | % All-zeros sparse 67 | ndata=sparse(dim(1),prod(dim(2:end))); 68 | elseif dim(1)==1 69 | % Sparse row vector 70 | ndata=sparse(1,ndata(:,1),ndata(:,2),dim(1),prod(dim(2:end))); 71 | elseif dim(2)==1 72 | % Sparse column vector 73 | ndata=sparse(ndata(:,1),1,ndata(:,2),dim(1),prod(dim(2:end))); 74 | else 75 | % Generic sparse array. 76 | ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3),dim(1),prod(dim(2:end))); 77 | end 78 | else 79 | if(iscpx && size(ndata,2)==4) 80 | ndata(:,3)=complex(ndata(:,3),ndata(:,4)); 81 | end 82 | ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3)); 83 | end 84 | end 85 | elseif(~isempty(strmatch('x0x5F_ArraySize_',fn))) 86 | if(iscpx && size(ndata,2)==2) 87 | ndata=complex(ndata(:,1),ndata(:,2)); 88 | end 89 | ndata=reshape(ndata(:),data(j).x0x5F_ArraySize_); 90 | end 91 | newdata{j}=ndata; 92 | end 93 | if(len==1) 94 | newdata=newdata{1}; 95 | end 96 | end -------------------------------------------------------------------------------- /preprocessing/fmri/jsonlab/varargin2struct.m: -------------------------------------------------------------------------------- 1 | function opt=varargin2struct(varargin) 2 | % 3 | % opt=varargin2struct('param1',value1,'param2',value2,...) 4 | % or 5 | % opt=varargin2struct(...,optstruct,...) 6 | % 7 | % convert a series of input parameters into a structure 8 | % 9 | % authors:Qianqian Fang (q.fang neu.edu) 10 | % date: 2012/12/22 11 | % 12 | % input: 13 | % 'param', value: the input parameters should be pairs of a string and a value 14 | % optstruct: if a parameter is a struct, the fields will be merged to the output struct 15 | % 16 | % output: 17 | % opt: a struct where opt.param1=value1, opt.param2=value2 ... 18 | % 19 | % license: 20 | % BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details 21 | % 22 | % -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab) 23 | % 24 | 25 | len=length(varargin); 26 | opt=struct; 27 | if(len==0) return; end 28 | i=1; 29 | while(i<=len) 30 | if(isstruct(varargin{i})) 31 | opt=mergestruct(opt,varargin{i}); 32 | elseif(ischar(varargin{i}) && i 0 17 | filesList = cellfun(@(f) fullfile(dirpath, f), filesList, 'UniformOutput', false); 18 | end 19 | % Return directly the string instead of the cell array if there is only one file matched 20 | if length(filesList) == 1 21 | filesList = filesList{1}; 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /preprocessing/smri/INSTRUCTIONS_HOWTO_VBM_ANALYSIS_CSG.txt: -------------------------------------------------------------------------------- 1 | INSTRUCTIONS - HOW TO DO VBM/CAT12 STRUCTURAL MRI ANALYSIS FOR SINGLE SUBJECT COMA PATIENTS FOR THE COMA SCIENCE GROUP, HOSPITAL OF LIEGE 2 | ================================================================== 3 | 4 | 1. use MRIConvert or dcm2niix to convert DICOMs (files acquired from MRI machine) to nifti files. This will create a subfolder with FLAWS INV2 in the folder name, and inside a .nii file. 5 | 2. Open MATLAB 6 | 3. type in MATLAB: 7 | cd 'Z:\Research\CSG\Data\2-ANALYSES\MRI\vbm\pipeline\smri' 8 | vbm_script_preproc_csg_relativepaths 9 | 4. select the FLAWS INV2 nifti file you just converted from the patient DICOMs. If there are multiple such folders, select the last one (most bottom one). 10 | 5. wait for the script to complete 11 | 6. at the end, the script will ask for a control's structural of same sex and similar age. You can find one out of the 40 control images in the folder 'Z:\Research\CSG\Data\2-ANALYSES\MRI\vbm\pipeline\CTR_40sbj_meanage45.2_structonly', each folder has a name including 'M' for male, 'F' for female, and a 2 digits number for the age (some controls are missing some info, simply don't use them). 12 | 7. open the patient's nifti folder (the one you created when you converted from DICOMs at step 1), and inside the 'mri' subfolder, find the image 'img_type1_final.png', this is the final results image. 13 | 14 | Tip: to run analyses faster, you can copy the whole content of the 'Z:\Research\CSG\Data\2-ANALYSES\MRI\vbm\pipeline' folder onto your local hard disk (ie, on your computer), and run the script from there, without modifying anything, it should work fine (ie, it's using relative paths). 15 | 16 | Tip2: check if the reorientation was correct by opening the FLAWS INV2 nifti file, for example with MRIcroN 17 | 18 | Tip3: in the report subfolder (in the patient's nifti folder), you will find a pdf file with the GM/WM/CSF/WMH (lesions) volumes. 19 | 20 | Tip4: you can visually see the segmentation of GM/WM/CSF and WMH (lesions) in subject's space, by opening in the mri subfolder the file rp0*rigid.nii, and then loading as colored overlays the files rp1*rigid.nii (GM), rp2*rigid.nii (WM), rp3*rigid.nii (CSF) and rp7*rigid.nii (WMH = lesions). 21 | 22 | By Stephen Karl Larroque 23 | First written on 12/02/2020 24 | Further code development may become available online at https://github.com/lrq3000/csg_mri_pipelines 25 | -------------------------------------------------------------------------------- /preprocessing/smri/callPython.m: -------------------------------------------------------------------------------- 1 | function callPython(scriptpath, arguments) 2 | % Call a Python script with given arguments 3 | commandStr = ['python ' scriptpath ' ' arguments]; 4 | [status, commandOut] = system(commandStr); 5 | if status==1 6 | fprintf('ERROR: Python call probably failed, return code is %d and error message:\n%s\n',int2str(status),commandOut); 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /preprocessing/smri/vbm_gen_final_image.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lrq3000/csg_mri_pipelines/9156b25206a8efe487b1021db690ad0a7779276f/preprocessing/smri/vbm_gen_final_image.exe -------------------------------------------------------------------------------- /preprocessing/smri/vbm_gen_final_image.py: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | # VBM final image generator, by Stephen Karl Larroque, 2017-2019 3 | # v0.1.8 4 | # Note that you need to install PILLOW (not PIL) for this script to work 5 | 6 | from __future__ import division 7 | import os, sys 8 | from PIL import Image, ImageChops, ImageEnhance 9 | 10 | def trim(im): 11 | '''Trim borders of a picture automatically''' 12 | bg = Image.new(im.mode, im.size, im.getpixel((0,0))) 13 | diff = ImageChops.difference(im, bg) 14 | diff = ImageChops.add(diff, diff, 1.0, -100) 15 | bbox = diff.getbbox() 16 | if bbox: 17 | return im.crop(bbox) 18 | 19 | def resize_height(img, baseheight): 20 | '''Resize by height and keep width ratio''' 21 | baseheight = int(baseheight) 22 | hpercent = (baseheight/float(img.size[1])) 23 | wsize = int((float(img.size[0])*float(hpercent))) 24 | return img.resize((wsize, baseheight), Image.ANTIALIAS) 25 | 26 | def resize_width(img, basewidth): 27 | '''Resize by width and keep height ratio''' 28 | basewidth = int(basewidth) 29 | wpercent = (basewidth/float(img.size[0])) 30 | hsize = int((float(img.size[1])*float(wpercent))) 31 | return img.resize((basewidth, hsize), Image.ANTIALIAS) 32 | 33 | 34 | # Configuration parameters (edit me) 35 | im_width = im_height = 1000 # Final image height and width 36 | brightness = 2.0 # how much to raise brightness of the bottom images 37 | contrast = 1.5 38 | 39 | # Get arguments 40 | if len(sys.argv) < 4: 41 | raise ValueError('Not enough arguments supplied: need to specify 3 arguments: 1- the rootpath of the images, 2- the images prefix, 3- the script mode (0 or 1)') 42 | impath = sys.argv[1] 43 | imprefix = sys.argv[2] 44 | script_mode = int(sys.argv[3]) 45 | 46 | # Loading images 47 | im1 = Image.open(os.path.join(impath, imprefix+"1.png")) 48 | im2 = Image.open(os.path.join(impath, imprefix+"2.png")) 49 | im3 = Image.open(os.path.join(impath, imprefix+"3.png")) 50 | im4 = Image.open(os.path.join(impath, imprefix+"4.png")) 51 | 52 | # == Image 1: brain section with VBM damages correlations 53 | im1_crop = im1.crop((0, int(im1.size[1]/2), im1.size[0], im1.size[1])) 54 | im1_trimmed = trim(im1_crop) 55 | 56 | # == Image 2: brain rendering spm96 old in 3D sections 57 | im2_crop = im2.crop((0, int(im2.size[1]/2), im2.size[0], im2.size[1])) 58 | # Separate the 2 columns 59 | im2_col1 = im2_crop.crop((im2_crop.size[0]/8, 0, (im2_crop.size[0]/8) * 3, im2_crop.size[1])) 60 | im2_col2 = im2_crop.crop((im2_crop.size[0]/8 * 5, 0, (im2_crop.size[0]/8) * 7, im2_crop.size[1])) 61 | # Join them (they should be tighter now) 62 | im2_new = Image.new('RGB', (int(im2_col1.size[0] + im2_col2.size[0]), int(max(im2_col1.size[1], im2_col2.size[1])))) 63 | im2_new.paste(im2_col1, (0, 0)) 64 | im2_new.paste(im2_col2, (im2_col1.size[0], 0)) 65 | 66 | # == Images 3 and 4: patient's unnormalized T1 and age-sex-matched control 67 | if script_mode == 0: 68 | im3offset = 2.7 69 | im4offset = 2.8 70 | elif script_mode == 1: 71 | im3offset = im4offset = 3. 72 | im3_crop = im3.crop((0, 0, im3.size[0], int(im3.size[1]/5*im3offset))) 73 | im3_trimmed = trim(im3_crop) 74 | im4_crop = im4.crop((0, 0, im4.size[0], int(im4.size[1]/5*im4offset))) 75 | im4_trimmed = trim(im4_crop) 76 | # Raise brightness 77 | im3_enhancer_b = ImageEnhance.Brightness(im3_trimmed) 78 | im4_enhancer_b = ImageEnhance.Brightness(im4_trimmed) 79 | im3_trimmed = im3_enhancer_b.enhance(brightness) 80 | im4_trimmed = im4_enhancer_b.enhance(brightness) 81 | # Raise contrast 82 | im3_enhancer_c = ImageEnhance.Contrast(im3_trimmed) 83 | im4_enhancer_c = ImageEnhance.Contrast(im4_trimmed) 84 | im3_trimmed = im3_enhancer_c.enhance(contrast) 85 | im4_trimmed = im4_enhancer_c.enhance(contrast) 86 | 87 | # == Final image generation 88 | 89 | # Resize top images by height and bottom images by width 90 | im_parts_top = [resize_height(img, im_height/2) for img in (im1_trimmed, im2_new)] 91 | im_parts_bottom = [resize_width(img, (im_width/2)*0.9) for img in (im3_trimmed, im4_trimmed)] 92 | 93 | # Create final image and stitch image parts together (one in each corner) 94 | im_full = Image.new('RGB', size=(im_width, im_height), color=(0,0,0,0)) 95 | im_full.paste(im_parts_top[0], (0,0)) 96 | im_full.paste(im_parts_top[1], (im_width-im_parts_top[1].size[0],0)) 97 | im_full.paste(im_parts_bottom[0], (10,int((im_height/2)*1.1))) 98 | im_full.paste(im_parts_bottom[1], (im_width-im_parts_bottom[1].size[0]-10,int((im_height/2)*1.1))) 99 | # Last trim 100 | im_full = trim(im_full) 101 | 102 | # And save! 103 | im_full.save(os.path.join(impath, imprefix+"final.png")) 104 | 105 | sys.exit(0) 106 | -------------------------------------------------------------------------------- /preprocessing/smri/vbm_results.m: -------------------------------------------------------------------------------- 1 | function vbm_results(path_to_spm, rootpath, T1file, significance, normprefix, id) 2 | % vbm_results(path_to_spm, rootpath, T1file, significance) 3 | % Automagically print VBM analysis results onto png images. 4 | % Significance is either unc or fdr 5 | % Tested on SPM12 and SPM8 6 | % STEPHEN KARL LARROQUE 7 | % v0.2.1 8 | % 2017-2019 9 | % LICENSE: MIT 10 | 11 | % T1 normalized prefix 12 | if ~exist('normprefix', 'var') 13 | normprefix = 'wm'; 14 | end 15 | 16 | % Analysis id (just for filename, to generate multiple results for the same scan) 17 | if ~exist('id', 'var') 18 | id = 0; 19 | end 20 | 21 | % Build image filename prefix 22 | imprefix = ['img_type' int2str(id) '_']; 23 | 24 | % Split T1file into parts 25 | [T1pathstr,T1name,T1ext] = fileparts(T1file); 26 | 27 | % keep current folder in memory 28 | scriptfolder = cd; 29 | 30 | % Setup SPM results gui 31 | load(fullfile(rootpath, 'SPM.mat')); 32 | connum = 1; 33 | if strcmpi(significance, 'unc') 34 | thresh = 0.001; 35 | threshdesc = 'none'; 36 | else 37 | thresh = 0.05; 38 | threshdesc = 'FDR'; 39 | end 40 | k = 0; 41 | job = struct('swd', SPM.swd, ... 42 | 'Ic', connum, ... 43 | 'u', thresh, ... 44 | 'Im', [], ... 45 | 'thresDesc', threshdesc, ... 46 | 'title', SPM.xCon(connum).name, ... 47 | 'k', k); 48 | 49 | % Set modality (FMRI) 50 | spm('defaults', 'FMRI') 51 | % Load the SPM results 52 | [hReg, xSPM, SPM] = spm_results_ui('setup', job); 53 | 54 | % Section visu 55 | spm_sections(xSPM,hReg,fullfile(rootpath, [normprefix T1name '.nii'])); 56 | spmfigprint(fullfile(rootpath, [imprefix '1.png']), 'png', 'white'); 57 | 58 | % Rendered 3D brains visu 59 | rendfile = fullfile(path_to_spm, 'rend', 'render_spm96.mat'); 60 | brt = NaN; 61 | dat = struct( 'XYZ', xSPM.XYZ,... 62 | 't', xSPM.Z',... 63 | 'mat', xSPM.M,... 64 | 'dim', xSPM.DIM); 65 | % Workaround SPM8 bug: even if we provide rendfile argument, spm_render will still look for a prevrend.rendfile or else ask user. So we setup an artificial one to ensure batch. 66 | global prevrend 67 | prevrend = struct('rendfile',rendfile, 'brt',brt, 'col',[]); 68 | % Render and save! 69 | spm_render(dat,brt,rendfile); 70 | spmfigprint(fullfile(rootpath, [imprefix '2.png']), 'png', 'white'); 71 | %spm_figure('Print'); % Works but only in eps 72 | %spm_print('im2.png'); % Works but only in eps 73 | 74 | % Display patient's unnormalized brain 75 | spm_image('init', T1file); 76 | spm_image('display', T1file); 77 | spm_orthviews('Xhairs','off'); % hide crosshairs 78 | spm_orthviews('Reposition', [0, 0, 0]); % reposition to origin ([0 0 0] in mm space) 79 | spmfigprint(fullfile(rootpath, [imprefix '3.png']), 'png', 'black'); 80 | 81 | % Display a gender and age matched control's brain 82 | controlt1 = spm_select(1,'IMAGE','Select age/gender matched control T1 (unnormalized)'); 83 | spm_image('init', controlt1); 84 | spm_image('display', controlt1); 85 | spm_orthviews('Xhairs','off'); 86 | spmfigprint(fullfile(rootpath, [imprefix '4.png']), 'png', 'black'); 87 | 88 | % Close all SPM displays 89 | %spm_figure('Close'); 90 | %spm('Quit'); 91 | cd(scriptfolder); 92 | 93 | fprintf(1, 'All VBM results images printed!\n'); 94 | 95 | end % endfunction 96 | 97 | 98 | % ==== AUX FUNCTIONS ==== 99 | 100 | function spmfigprint(filename, type, background) 101 | % spmfigprint(filename, type, background) 102 | % save current SPM figure to a filename by simulating MATLAB's GUI File > Export 103 | style = hgexport('factorystyle'); 104 | style.Background = background; 105 | style.Format = type; 106 | hgexport(spm_figure('FindWin'), filename, style); 107 | end %endfunction 108 | -------------------------------------------------------------------------------- /preprocessing/utils/nifti_convert_recursive/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017, Kenneth Eaton 2 | Copyright (c) 2017, Stephen Larroque 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /preprocessing/utils/slice_order/gen_microtime_onset.m: -------------------------------------------------------------------------------- 1 | function [microtime_onset, microtime_resolution, refslice] = gen_microtime_onset(slice_order, refslice, min_microtime_resolution, max_microtime_resolution) 2 | % [microtime_onset, microtime_resolution, refslice] = gen_microtime_onset(slice_order, refslice, min_microtime_resolution) 3 | % Calculates the appropriate microtime_onset for a statistical test in SPM given the slice_order, min_microtime_resolution and reference slice 4 | % input: slice_order is the slice order used for slice timing correction. 5 | % input: refslice is the spatial reference slice used in slice timing correction. Value can be either: 'first', 'middle', 'last' or any slice number or slice timing. 6 | % optional input: min_microtime_resolution: minimal microtime resolution you want, the script will return the smallest microtime resolution above this minimum that can perfectly align with this refslice (default in SPM12 = 16) 7 | % optional input: max_microtime_resolution: maximal microtime resolution you want, if the result need to have a higher microtime resolution to be precise, with this option the onset will be approximated to the nearest previous microtime block (default=0 disabled). 8 | % 9 | % by Stephen Larroque from the Coma Science Group, 2017 10 | % Licensed under MIT. 11 | % 12 | % v1.0 13 | % 14 | % Notices/Changelog: 15 | % * v1.0: first release 16 | % 17 | 18 | if ~exist('min_microtime_resolution', 'var') 19 | min_microtime_resolution = 16; % SPM12 default 20 | end 21 | if ~exist('max_microtime_resolution', 'var') 22 | max_microtime_resolution = 0; 23 | end 24 | 25 | % Helper condition for easy refslice setting 26 | if strcmpi(refslice, 'first') | refslice == slice_order(1) 27 | % special case, we do not need to compute anything 28 | refslice = slice_order(1); 29 | microtime_resolution = min_microtime_resolution; 30 | microtime_onset = 1; 31 | return; 32 | elseif strcmpi(refslice, 'middle') 33 | refslice = slice_order(ceil(numel(slice_order)/2)); 34 | elseif strcmpi(refslice, 'last') 35 | refslice = slice_order(end); 36 | %else refslice is an integer or a float, which is the slice spatial number we want to use as refslice 37 | end %endif 38 | 39 | % Convert refslice from spatial convention (number is slice position is space and position in array is position in time) to temporal convention (position in array is position in space and number is position in time) 40 | temporal_refslice = find(slice_order == refslice) - 1; % minus 1 because we want to set onset at the start of the slice, so in fact before this slice. Here this will give us the last microtime that belong to the previous slice. 41 | % Calculate the ratio compared to the number of slices (to get the relative position from the start of the array) 42 | microtime_onset_ratio = temporal_refslice / numel(slice_order); 43 | 44 | % Rescale to min_microtime_resolution 45 | [N, D] = rat(microtime_onset_ratio); 46 | if D < 16 47 | ratio_newT = ceil(min_microtime_resolution/D); 48 | microtime_resolution = D*ratio_newT; 49 | microtime_onset = N*ratio_newT + 1; % plus 1 because N is at the last microtime block of the previous slice, so if we do +1 we will be at the start microtime block of the next slice (the refslice) 50 | else 51 | microtime_resolution = D; 52 | microtime_onset = N + 1; % plus 1 for same reason, to move from last microtime block of previous slice to the start microtime block of the refslice 53 | end %endif 54 | 55 | % Approximate onset if resolution is above max_microtime_resolution 56 | if max_microtime_resolution > 0 & microtime_resolution > max_microtime_resolution 57 | microtime_onset = floor(microtime_onset/(microtime_resolution/max_microtime_resolution)); 58 | microtime_resolution = max_microtime_resolution; 59 | end %endif 60 | 61 | end 62 | -------------------------------------------------------------------------------- /preprocessing/utils/slice_order/jsonlab/.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | .idea 3 | .DS_store 4 | Thumbs.db 5 | logs 6 | *.log 7 | npm-debug.log* 8 | yarn-debug.log* 9 | yarn-error.log* 10 | pids 11 | *.pid 12 | *.seed 13 | *.pid.lock 14 | lib-cov 15 | coverage 16 | .nyc_output 17 | .grunt 18 | bower_components 19 | .lock-wscript 20 | build/Release 21 | node_modules/ 22 | jspm_packages/ 23 | typings/ 24 | .npm 25 | .eslintcache 26 | .node_repl_history 27 | *.tgz 28 | .yarn-integrity 29 | .env 30 | *.asv 31 | *.m~ 32 | *.mex* 33 | slprj/ 34 | octave-workspace 35 | .autosave 36 | -------------------------------------------------------------------------------- /preprocessing/utils/slice_order/jsonlab/AUTHORS.txt: -------------------------------------------------------------------------------- 1 | The author of "jsonlab" toolbox is Qianqian Fang. Qianqian 2 | is currently an Assistant Professor in the Department of Bioengineering, 3 | Northeastern University. 4 | 5 | Address: Qianqian Fang 6 | Department of Bioengineering 7 | Northeastern University 8 | 212A Lake Hall 9 | 360 Huntington Ave, Boston, MA 02115, USA 10 | Office: 503 Holmes Hall 11 | Phone[O]: 617-373-3829 12 | URL: http://fanglab.org 13 | Email: and 14 | 15 | 16 | The script loadjson.m was built upon previous works by 17 | 18 | - Nedialko Krouchev: http://www.mathworks.com/matlabcentral/fileexchange/25713 19 | date: 2009/11/02 20 | - François Glineur: http://www.mathworks.com/matlabcentral/fileexchange/23393 21 | date: 2009/03/22 22 | - Joel Feenstra: http://www.mathworks.com/matlabcentral/fileexchange/20565 23 | date: 2008/07/03 24 | 25 | 26 | This toolbox contains patches submitted by the following contributors: 27 | 28 | - Blake Johnson 29 | part of revision 341 30 | 31 | - Niclas Borlin 32 | various fixes in revision 394, including 33 | - loadjson crashes for all-zero sparse matrix. 34 | - loadjson crashes for empty sparse matrix. 35 | - Non-zero size of 0-by-N and N-by-0 empty matrices is lost after savejson/loadjson. 36 | - loadjson crashes for sparse real column vector. 37 | - loadjson crashes for sparse complex column vector. 38 | - Data is corrupted by savejson for sparse real row vector. 39 | - savejson crashes for sparse complex row vector. 40 | 41 | - Yul Kang 42 | patches for svn revision 415. 43 | - savejson saves an empty cell array as [] instead of null 44 | - loadjson differentiates an empty struct from an empty array 45 | 46 | - Mykhailo Bratukha 47 | (Pull#14) Bug fix: File path is wrongly inerpreted as JSON string 48 | 49 | - Insik Kim 50 | (Pull#12) Bug fix: Resolving bug that cell type is converted to json with transposed data 51 | 52 | - Sertan Senturk 53 | (Pull#10,#11) Feature: Added matlab object saving to savejson and saveubjson 54 | -------------------------------------------------------------------------------- /preprocessing/utils/slice_order/jsonlab/LICENSE_BSD.txt: -------------------------------------------------------------------------------- 1 | Copyright 2011-2017 Qianqian Fang neu.edu>. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are 4 | permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of 7 | conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, this list 10 | of conditions and the following disclaimer in the documentation and/or other materials 11 | provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY EXPRESS OR IMPLIED 14 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 15 | FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 16 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 17 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 18 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 19 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 20 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 21 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 | 23 | The views and conclusions contained in the software and documentation are those of the 24 | authors and should not be interpreted as representing official policies, either expressed 25 | or implied, of the copyright holders. 26 | -------------------------------------------------------------------------------- /preprocessing/utils/slice_order/jsonlab/examples/example1.json: -------------------------------------------------------------------------------- 1 | { 2 | "firstName": "John", 3 | "lastName": "Smith", 4 | "age": 25, 5 | "address": 6 | { 7 | "streetAddress": "21 2nd Street", 8 | "city": "New York", 9 | "state": "NY", 10 | "postalCode": "10021" 11 | }, 12 | "phoneNumber": 13 | [ 14 | { 15 | "type": "home", 16 | "number": "212 555-1234" 17 | }, 18 | { 19 | "type": "fax", 20 | "number": "646 555-4567" 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /preprocessing/utils/slice_order/jsonlab/examples/example2.json: -------------------------------------------------------------------------------- 1 | { 2 | "glossary": { 3 | "title": "example glossary", 4 | "GlossDiv": { 5 | "title": "S", 6 | "GlossList": { 7 | "GlossEntry": { 8 | "ID": "SGML", 9 | "SortAs": "SGML", 10 | "GlossTerm": "Standard Generalized Markup Language", 11 | "Acronym": "SGML", 12 | "Abbrev": "ISO 8879:1986", 13 | "GlossDef": { 14 | "para": "A meta-markup language, used to create markup languages such as DocBook.", 15 | "GlossSeeAlso": ["GML", "XML"] 16 | }, 17 | "GlossSee": "markup" 18 | } 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /preprocessing/utils/slice_order/jsonlab/examples/example3.json: -------------------------------------------------------------------------------- 1 | {"menu": { 2 | "id": "file", 3 | "value": "_&File", 4 | "popup": { 5 | "menuitem": [ 6 | {"value": "_&New", "onclick": "CreateNewDoc(\"'\\\"Untitled\\\"'\")"}, 7 | {"value": "_&Open", "onclick": "OpenDoc()"}, 8 | {"value": "_&Close", "onclick": "CloseDoc()"} 9 | ] 10 | } 11 | }} 12 | -------------------------------------------------------------------------------- /preprocessing/utils/slice_order/jsonlab/examples/example4.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "sample" : { 4 | "rho" : 1 5 | } 6 | }, 7 | { 8 | "sample" : { 9 | "rho" : 2 10 | } 11 | }, 12 | [ 13 | { 14 | "_ArrayType_" : "double", 15 | "_ArraySize_" : [1,2], 16 | "_ArrayData_" : [1,0] 17 | }, 18 | { 19 | "_ArrayType_" : "double", 20 | "_ArraySize_" : [1,2], 21 | "_ArrayData_" : [1,1] 22 | }, 23 | { 24 | "_ArrayType_" : "double", 25 | "_ArraySize_" : [1,2], 26 | "_ArrayData_" : [1,2] 27 | } 28 | ], 29 | [ 30 | "Paper", 31 | "Scissors", 32 | "Stone" 33 | ], 34 | ["a", "b\\", "c\"","d\\\"","e\"[","f\\\"[","g[\\","h[\\\""] 35 | ] 36 | -------------------------------------------------------------------------------- /preprocessing/utils/slice_order/jsonlab/examples/jsonlab_selftest.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % Regression Test Unit of loadjson and savejson 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | 5 | for i=1:4 6 | fname=sprintf('example%d.json',i); 7 | if(exist(fname,'file')==0) break; end 8 | fprintf(1,'===============================================\n>> %s\n',fname); 9 | json=savejson('data',loadjson(fname)); 10 | fprintf(1,'%s\n',json); 11 | fprintf(1,'%s\n',savejson('data',loadjson(fname),'Compact',1)); 12 | data=loadjson(json); 13 | savejson('data',data,'selftest.json'); 14 | data=loadjson('selftest.json'); 15 | end 16 | 17 | for i=1:4 18 | fname=sprintf('example%d.json',i); 19 | if(exist(fname,'file')==0) break; end 20 | fprintf(1,'===============================================\n>> %s\n',fname); 21 | json=saveubjson('data',loadjson(fname)); 22 | fprintf(1,'%s\n',json); 23 | data=loadubjson(json); 24 | savejson('',data); 25 | saveubjson('data',data,'selftest.ubj'); 26 | data=loadubjson('selftest.ubj'); 27 | end 28 | -------------------------------------------------------------------------------- /preprocessing/utils/slice_order/jsonlab/examples/jsonlab_speedtest.m: -------------------------------------------------------------------------------- 1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2 | % Benchmarking processing speed of savejson and loadjson 3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4 | 5 | datalen=[1e3 1e4 1e5 1e6]; 6 | len=length(datalen); 7 | tsave=zeros(len,1); 8 | tload=zeros(len,1); 9 | for i=1:len 10 | tic; 11 | json=savejson('data',struct('d1',rand(datalen(i),3),'d2',rand(datalen(i),3)>0.5)); 12 | tsave(i)=toc; 13 | data=loadjson(json); 14 | tload(i)=toc-tsave(i); 15 | fprintf(1,'matrix size: %d\n',datalen(i)); 16 | end 17 | 18 | loglog(datalen,tsave,'o-',datalen,tload,'r*-'); 19 | legend('savejson runtime (s)','loadjson runtime (s)'); 20 | xlabel('array size'); 21 | ylabel('running time (s)'); 22 | -------------------------------------------------------------------------------- /preprocessing/utils/slice_order/jsonlab/jsonopt.m: -------------------------------------------------------------------------------- 1 | function val=jsonopt(key,default,varargin) 2 | % 3 | % val=jsonopt(key,default,optstruct) 4 | % 5 | % setting options based on a struct. The struct can be produced 6 | % by varargin2struct from a list of 'param','value' pairs 7 | % 8 | % authors:Qianqian Fang (q.fang neu.edu) 9 | % 10 | % $Id: loadjson.m 371 2012-06-20 12:43:06Z fangq $ 11 | % 12 | % input: 13 | % key: a string with which one look up a value from a struct 14 | % default: if the key does not exist, return default 15 | % optstruct: a struct where each sub-field is a key 16 | % 17 | % output: 18 | % val: if key exists, val=optstruct.key; otherwise val=default 19 | % 20 | % license: 21 | % BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details 22 | % 23 | % -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab) 24 | % 25 | 26 | val=default; 27 | if(nargin<=2) return; end 28 | opt=varargin{1}; 29 | if(isstruct(opt)) 30 | if(isfield(opt,key)) 31 | val=getfield(opt,key); 32 | elseif(isfield(opt,lower(key))) 33 | val=getfield(opt,lower(key)); 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /preprocessing/utils/slice_order/jsonlab/mergestruct.m: -------------------------------------------------------------------------------- 1 | function s=mergestruct(s1,s2) 2 | % 3 | % s=mergestruct(s1,s2) 4 | % 5 | % merge two struct objects into one 6 | % 7 | % authors:Qianqian Fang (q.fang neu.edu) 8 | % date: 2012/12/22 9 | % 10 | % input: 11 | % s1,s2: a struct object, s1 and s2 can not be arrays 12 | % 13 | % output: 14 | % s: the merged struct object. fields in s1 and s2 will be combined in s. 15 | % 16 | % license: 17 | % BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details 18 | % 19 | % -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab) 20 | % 21 | 22 | if(~isstruct(s1) || ~isstruct(s2)) 23 | error('input parameters contain non-struct'); 24 | end 25 | if(length(s1)>1 || length(s2)>1) 26 | error('can not merge struct arrays'); 27 | end 28 | fn=fieldnames(s2); 29 | s=s1; 30 | for i=1:length(fn) 31 | s=setfield(s,fn{i},getfield(s2,fn{i})); 32 | end 33 | 34 | -------------------------------------------------------------------------------- /preprocessing/utils/slice_order/jsonlab/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jsonlab", 3 | "version": "1.5.0", 4 | "description": "An open-source MATLAB/Octave JSON encoder and decoder", 5 | "directories": { 6 | "example": "examples" 7 | }, 8 | "scripts": { 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/fangq/jsonlab.git" 14 | }, 15 | "author": "Qianqian Fang ", 16 | "license": "GPL-3.0", 17 | "bugs": { 18 | "url": "https://github.com/fangq/jsonlab/issues" 19 | }, 20 | "homepage": "https://github.com/fangq/jsonlab#readme" 21 | } 22 | -------------------------------------------------------------------------------- /preprocessing/utils/slice_order/jsonlab/struct2jdata.m: -------------------------------------------------------------------------------- 1 | function newdata=struct2jdata(data,varargin) 2 | % 3 | % newdata=struct2jdata(data,opt,...) 4 | % 5 | % convert a JData object (in the form of a struct array) into an array 6 | % 7 | % authors:Qianqian Fang (q.fang neu.edu) 8 | % 9 | % input: 10 | % data: a struct array. If data contains JData keywords in the first 11 | % level children, these fields are parsed and regrouped into a 12 | % data object (arrays, trees, graphs etc) based on JData 13 | % specification. The JData keywords are 14 | % "_ArrayType_", "_ArraySize_", "_ArrayData_" 15 | % "_ArrayIsSparse_", "_ArrayIsComplex_" 16 | % opt: (optional) a list of 'Param',value pairs for additional options 17 | % The supported options include 18 | % 'Recursive', if set to 1, will apply the conversion to 19 | % every child; 0 to disable 20 | % 21 | % output: 22 | % newdata: the covnerted data if the input data does contain a JData 23 | % structure; otherwise, the same as the input. 24 | % 25 | % examples: 26 | % obj=struct('_ArrayType_','double','_ArraySize_',[2 3], 27 | % '_ArrayIsSparse_',1 ,'_ArrayData_',null); 28 | % ubjdata=struct2jdata(obj); 29 | % 30 | % license: 31 | % BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details 32 | % 33 | % -- this function is part of JSONLab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab) 34 | % 35 | 36 | fn=fieldnames(data); 37 | newdata=data; 38 | len=length(data); 39 | if(jsonopt('Recursive',0,varargin{:})==1) 40 | for i=1:length(fn) % depth-first 41 | for j=1:len 42 | if(isstruct(getfield(data(j),fn{i}))) 43 | newdata(j)=setfield(newdata(j),fn{i},jstruct2array(getfield(data(j),fn{i}))); 44 | end 45 | end 46 | end 47 | end 48 | if(~isempty(strmatch('x0x5F_ArrayType_',fn)) && ~isempty(strmatch('x0x5F_ArrayData_',fn))) 49 | newdata=cell(len,1); 50 | for j=1:len 51 | ndata=cast(data(j).x0x5F_ArrayData_,data(j).x0x5F_ArrayType_); 52 | iscpx=0; 53 | if(~isempty(strmatch('x0x5F_ArrayIsComplex_',fn))) 54 | if(data(j).x0x5F_ArrayIsComplex_) 55 | iscpx=1; 56 | end 57 | end 58 | if(~isempty(strmatch('x0x5F_ArrayIsSparse_',fn))) 59 | if(data(j).x0x5F_ArrayIsSparse_) 60 | if(~isempty(strmatch('x0x5F_ArraySize_',fn))) 61 | dim=double(data(j).x0x5F_ArraySize_); 62 | if(iscpx && size(ndata,2)==4-any(dim==1)) 63 | ndata(:,end-1)=complex(ndata(:,end-1),ndata(:,end)); 64 | end 65 | if isempty(ndata) 66 | % All-zeros sparse 67 | ndata=sparse(dim(1),prod(dim(2:end))); 68 | elseif dim(1)==1 69 | % Sparse row vector 70 | ndata=sparse(1,ndata(:,1),ndata(:,2),dim(1),prod(dim(2:end))); 71 | elseif dim(2)==1 72 | % Sparse column vector 73 | ndata=sparse(ndata(:,1),1,ndata(:,2),dim(1),prod(dim(2:end))); 74 | else 75 | % Generic sparse array. 76 | ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3),dim(1),prod(dim(2:end))); 77 | end 78 | else 79 | if(iscpx && size(ndata,2)==4) 80 | ndata(:,3)=complex(ndata(:,3),ndata(:,4)); 81 | end 82 | ndata=sparse(ndata(:,1),ndata(:,2),ndata(:,3)); 83 | end 84 | end 85 | elseif(~isempty(strmatch('x0x5F_ArraySize_',fn))) 86 | if(iscpx && size(ndata,2)==2) 87 | ndata=complex(ndata(:,1),ndata(:,2)); 88 | end 89 | ndata=reshape(ndata(:),data(j).x0x5F_ArraySize_); 90 | end 91 | newdata{j}=ndata; 92 | end 93 | if(len==1) 94 | newdata=newdata{1}; 95 | end 96 | end -------------------------------------------------------------------------------- /preprocessing/utils/slice_order/jsonlab/varargin2struct.m: -------------------------------------------------------------------------------- 1 | function opt=varargin2struct(varargin) 2 | % 3 | % opt=varargin2struct('param1',value1,'param2',value2,...) 4 | % or 5 | % opt=varargin2struct(...,optstruct,...) 6 | % 7 | % convert a series of input parameters into a structure 8 | % 9 | % authors:Qianqian Fang (q.fang neu.edu) 10 | % date: 2012/12/22 11 | % 12 | % input: 13 | % 'param', value: the input parameters should be pairs of a string and a value 14 | % optstruct: if a parameter is a struct, the fields will be merged to the output struct 15 | % 16 | % output: 17 | % opt: a struct where opt.param1=value1, opt.param2=value2 ... 18 | % 19 | % license: 20 | % BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details 21 | % 22 | % -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab) 23 | % 24 | 25 | len=length(varargin); 26 | opt=struct; 27 | if(len==0) return; end 28 | i=1; 29 | while(i<=len) 30 | if(isstruct(varargin{i})) 31 | opt=mergestruct(opt,varargin{i}); 32 | elseif(ischar(varargin{i}) && i>> from unidecode import unidecode: 7 | >>> unidecode(u"\u5317\u4EB0") 8 | "Bei Jing " 9 | 10 | The transliteration uses a straightforward map, and doesn't have alternatives 11 | for the same character based on language, position, or anything else. 12 | 13 | In Python 3, a standard string object will be returned. If you need bytes, use: 14 | >>> unidecode("Κνωσός").encode("ascii") 15 | b'Knosos' 16 | """ 17 | import warnings 18 | from sys import version_info 19 | 20 | Cache = {} 21 | 22 | 23 | def _warn_if_not_unicode(string): 24 | if version_info[0] < 3 and not isinstance(string, unicode): 25 | warnings.warn( "Argument %r is not an unicode object. " 26 | "Passing an encoded string will likely have " 27 | "unexpected results." % (type(string),), 28 | RuntimeWarning, 2) 29 | 30 | 31 | def unidecode_expect_ascii(string): 32 | """Transliterate an Unicode object into an ASCII string 33 | 34 | >>> unidecode(u"\u5317\u4EB0") 35 | "Bei Jing " 36 | 37 | This function first tries to convert the string using ASCII codec. 38 | If it fails (because of non-ASCII characters), it falls back to 39 | transliteration using the character tables. 40 | 41 | This is approx. five times faster if the string only contains ASCII 42 | characters, but slightly slower than using unidecode directly if non-ASCII 43 | chars are present. 44 | """ 45 | 46 | _warn_if_not_unicode(string) 47 | try: 48 | bytestring = string.encode('ASCII') 49 | except UnicodeEncodeError: 50 | return _unidecode(string) 51 | if version_info[0] >= 3: 52 | return string 53 | else: 54 | return bytestring 55 | 56 | def unidecode_expect_nonascii(string): 57 | """Transliterate an Unicode object into an ASCII string 58 | 59 | >>> unidecode(u"\u5317\u4EB0") 60 | "Bei Jing " 61 | """ 62 | 63 | _warn_if_not_unicode(string) 64 | return _unidecode(string) 65 | 66 | unidecode = unidecode_expect_ascii 67 | 68 | def _unidecode(string): 69 | retval = [] 70 | 71 | for char in string: 72 | codepoint = ord(char) 73 | 74 | if codepoint < 0x80: # Basic ASCII 75 | retval.append(str(char)) 76 | continue 77 | 78 | if codepoint > 0xeffff: 79 | continue # Characters in Private Use Area and above are ignored 80 | 81 | if 0xd800 <= codepoint <= 0xdfff: 82 | warnings.warn( "Surrogate character %r will be ignored. " 83 | "You might be using a narrow Python build." % (char,), 84 | RuntimeWarning, 2) 85 | 86 | section = codepoint >> 8 # Chop off the last two hex digits 87 | position = codepoint % 256 # Last two hex digits 88 | 89 | try: 90 | table = Cache[section] 91 | except KeyError: 92 | try: 93 | mod = __import__('unidecode.x%03x'%(section), globals(), locals(), ['data']) 94 | except ImportError: 95 | Cache[section] = None 96 | continue # No match: ignore this character and carry on. 97 | 98 | Cache[section] = table = mod.data 99 | 100 | if table and len(table) > position: 101 | retval.append( table[position] ) 102 | 103 | return ''.join(retval) 104 | -------------------------------------------------------------------------------- /utils/asciirename/unidecode/util.py: -------------------------------------------------------------------------------- 1 | # vim:ts=4 sw=4 expandtab softtabstop=4 2 | from __future__ import print_function, absolute_import 3 | import optparse 4 | import locale 5 | import os 6 | import sys 7 | import warnings 8 | 9 | from . import unidecode 10 | 11 | PY3 = sys.version_info[0] >= 3 12 | 13 | def fatal(msg): 14 | sys.stderr.write(msg + "\n") 15 | sys.exit(1) 16 | 17 | def main(): 18 | default_encoding = locale.getpreferredencoding() 19 | 20 | parser = optparse.OptionParser('%prog [options] [FILE]', 21 | description="Transliterate Unicode text into ASCII. FILE is path to file to transliterate. " 22 | "Standard input is used if FILE is omitted and -c is not specified.") 23 | parser.add_option('-e', '--encoding', metavar='ENCODING', default=default_encoding, 24 | help='Specify an encoding (default is %s)' % (default_encoding,)) 25 | parser.add_option('-c', metavar='TEXT', dest='text', 26 | help='Transliterate TEXT instead of FILE') 27 | 28 | options, args = parser.parse_args() 29 | 30 | encoding = options.encoding 31 | 32 | if args: 33 | if options.text: 34 | fatal("Can't use both FILE and -c option") 35 | else: 36 | with open(args[0], 'rb') as f: 37 | stream = f.read() 38 | elif options.text: 39 | if PY3: 40 | stream = os.fsencode(options.text) 41 | else: 42 | stream = options.text 43 | # add a newline to the string if it comes from the 44 | # command line so that the result is printed nicely 45 | # on the console. 46 | stream += '\n'.encode('ascii') 47 | else: 48 | if PY3: 49 | stream = sys.stdin.buffer.read() 50 | else: 51 | stream = sys.stdin.read() 52 | 53 | try: 54 | stream = stream.decode(encoding) 55 | except UnicodeDecodeError as e: 56 | fatal('Unable to decode input: %s, start: %d, end: %d' % (e.reason, e.start, e.end)) 57 | 58 | sys.stdout.write(unidecode(stream)) 59 | -------------------------------------------------------------------------------- /utils/asciirename/unidecode/x000.py: -------------------------------------------------------------------------------- 1 | data = ( 2 | # Code points u+007f and below are equivalent to ASCII and are handled by a 3 | # special case in the code. Hence they are not present in this table. 4 | '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 5 | '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 6 | '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 7 | '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 8 | '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 9 | '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 10 | '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 11 | '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 12 | 13 | '', # 0x80 14 | '', # 0x81 15 | '', # 0x82 16 | '', # 0x83 17 | '', # 0x84 18 | '', # 0x85 19 | '', # 0x86 20 | '', # 0x87 21 | '', # 0x88 22 | '', # 0x89 23 | '', # 0x8a 24 | '', # 0x8b 25 | '', # 0x8c 26 | '', # 0x8d 27 | '', # 0x8e 28 | '', # 0x8f 29 | '', # 0x90 30 | '', # 0x91 31 | '', # 0x92 32 | '', # 0x93 33 | '', # 0x94 34 | '', # 0x95 35 | '', # 0x96 36 | '', # 0x97 37 | '', # 0x98 38 | '', # 0x99 39 | '', # 0x9a 40 | '', # 0x9b 41 | '', # 0x9c 42 | '', # 0x9d 43 | '', # 0x9e 44 | '', # 0x9f 45 | ' ', # 0xa0 46 | '!', # 0xa1 47 | 'C/', # 0xa2 48 | 49 | # Not "GBP" - Pound Sign is used for more than just British Pounds. 50 | 'PS', # 0xa3 51 | 52 | '$?', # 0xa4 53 | 'Y=', # 0xa5 54 | '|', # 0xa6 55 | 'SS', # 0xa7 56 | '"', # 0xa8 57 | '(c)', # 0xa9 58 | 'a', # 0xaa 59 | '<<', # 0xab 60 | '!', # 0xac 61 | '', # 0xad 62 | '(r)', # 0xae 63 | '-', # 0xaf 64 | 'deg', # 0xb0 65 | '+-', # 0xb1 66 | 67 | # These might be combined with other superscript digits (u+2070 - u+2079) 68 | '2', # 0xb2 69 | '3', # 0xb3 70 | 71 | '\'', # 0xb4 72 | 'u', # 0xb5 73 | 'P', # 0xb6 74 | '*', # 0xb7 75 | ',', # 0xb8 76 | '1', # 0xb9 77 | 'o', # 0xba 78 | '>>', # 0xbb 79 | '1/4', # 0xbc 80 | '1/2', # 0xbd 81 | '3/4', # 0xbe 82 | '?', # 0xbf 83 | 'A', # 0xc0 84 | 'A', # 0xc1 85 | 'A', # 0xc2 86 | 'A', # 0xc3 87 | 88 | # Not "AE" - used in languages other than German 89 | 'A', # 0xc4 90 | 91 | 'A', # 0xc5 92 | 'AE', # 0xc6 93 | 'C', # 0xc7 94 | 'E', # 0xc8 95 | 'E', # 0xc9 96 | 'E', # 0xca 97 | 'E', # 0xcb 98 | 'I', # 0xcc 99 | 'I', # 0xcd 100 | 'I', # 0xce 101 | 'I', # 0xcf 102 | 'D', # 0xd0 103 | 'N', # 0xd1 104 | 'O', # 0xd2 105 | 'O', # 0xd3 106 | 'O', # 0xd4 107 | 'O', # 0xd5 108 | 109 | # Not "OE" - used in languages other than German 110 | 'O', # 0xd6 111 | 112 | 'x', # 0xd7 113 | 'O', # 0xd8 114 | 'U', # 0xd9 115 | 'U', # 0xda 116 | 'U', # 0xdb 117 | 118 | # Not "UE" - used in languages other than German 119 | 'U', # 0xdc 120 | 121 | 'Y', # 0xdd 122 | 'Th', # 0xde 123 | 'ss', # 0xdf 124 | 'a', # 0xe0 125 | 'a', # 0xe1 126 | 'a', # 0xe2 127 | 'a', # 0xe3 128 | 129 | # Not "ae" - used in languages other than German 130 | 'a', # 0xe4 131 | 132 | 'a', # 0xe5 133 | 'ae', # 0xe6 134 | 'c', # 0xe7 135 | 'e', # 0xe8 136 | 'e', # 0xe9 137 | 'e', # 0xea 138 | 'e', # 0xeb 139 | 'i', # 0xec 140 | 'i', # 0xed 141 | 'i', # 0xee 142 | 'i', # 0xef 143 | 'd', # 0xf0 144 | 'n', # 0xf1 145 | 'o', # 0xf2 146 | 'o', # 0xf3 147 | 'o', # 0xf4 148 | 'o', # 0xf5 149 | 150 | # Not "oe" - used in languages other than German 151 | 'o', # 0xf6 152 | 153 | '/', # 0xf7 154 | 'o', # 0xf8 155 | 'u', # 0xf9 156 | 'u', # 0xfa 157 | 'u', # 0xfb 158 | 159 | # Not "ue" - used in languages other than German 160 | 'u', # 0xfc 161 | 162 | 'y', # 0xfd 163 | 'th', # 0xfe 164 | 'y', # 0xff 165 | ) 166 | -------------------------------------------------------------------------------- /utils/asciirename/unidecode/x01d.py: -------------------------------------------------------------------------------- 1 | data = ( 2 | '', # 0x00 3 | '', # 0x01 4 | '', # 0x02 5 | '', # 0x03 6 | '', # 0x04 7 | '', # 0x05 8 | '', # 0x06 9 | '', # 0x07 10 | '', # 0x08 11 | '', # 0x09 12 | '', # 0x0a 13 | '', # 0x0b 14 | '', # 0x0c 15 | '', # 0x0d 16 | '', # 0x0e 17 | '', # 0x0f 18 | '', # 0x10 19 | '', # 0x11 20 | '', # 0x12 21 | '', # 0x13 22 | '', # 0x14 23 | '', # 0x15 24 | '', # 0x16 25 | '', # 0x17 26 | '', # 0x18 27 | '', # 0x19 28 | '', # 0x1a 29 | '', # 0x1b 30 | '', # 0x1c 31 | '', # 0x1d 32 | '', # 0x1e 33 | '', # 0x1f 34 | '', # 0x20 35 | '', # 0x21 36 | '', # 0x22 37 | '', # 0x23 38 | '', # 0x24 39 | '', # 0x25 40 | '', # 0x26 41 | '', # 0x27 42 | '', # 0x28 43 | '', # 0x29 44 | '', # 0x2a 45 | '', # 0x2b 46 | '', # 0x2c 47 | '', # 0x2d 48 | '', # 0x2e 49 | '', # 0x2f 50 | '', # 0x30 51 | '', # 0x31 52 | '', # 0x32 53 | '', # 0x33 54 | '', # 0x34 55 | '', # 0x35 56 | '', # 0x36 57 | '', # 0x37 58 | '', # 0x38 59 | '', # 0x39 60 | '', # 0x3a 61 | '', # 0x3b 62 | '', # 0x3c 63 | '', # 0x3d 64 | '', # 0x3e 65 | '', # 0x3f 66 | '', # 0x40 67 | '', # 0x41 68 | '', # 0x42 69 | '', # 0x43 70 | '', # 0x44 71 | '', # 0x45 72 | '', # 0x46 73 | '', # 0x47 74 | '', # 0x48 75 | '', # 0x49 76 | '', # 0x4a 77 | '', # 0x4b 78 | '', # 0x4c 79 | '', # 0x4d 80 | '', # 0x4e 81 | '', # 0x4f 82 | '', # 0x50 83 | '', # 0x51 84 | '', # 0x52 85 | '', # 0x53 86 | '', # 0x54 87 | '', # 0x55 88 | '', # 0x56 89 | '', # 0x57 90 | '', # 0x58 91 | '', # 0x59 92 | '', # 0x5a 93 | '', # 0x5b 94 | '', # 0x5c 95 | '', # 0x5d 96 | '', # 0x5e 97 | '', # 0x5f 98 | '', # 0x60 99 | '', # 0x61 100 | '', # 0x62 101 | '', # 0x63 102 | '', # 0x64 103 | '', # 0x65 104 | '', # 0x66 105 | '', # 0x67 106 | '', # 0x68 107 | '', # 0x69 108 | '', # 0x6a 109 | '', # 0x6b 110 | 'b', # 0x6c 111 | 'd', # 0x6d 112 | 'f', # 0x6e 113 | 'm', # 0x6f 114 | 'n', # 0x70 115 | 'p', # 0x71 116 | 'r', # 0x72 117 | 'r', # 0x73 118 | 's', # 0x74 119 | 't', # 0x75 120 | 'z', # 0x76 121 | 'g', # 0x77 122 | '', # 0x78 123 | '', # 0x79 124 | '', # 0x7a 125 | '', # 0x7b 126 | '', # 0x7c 127 | 'p', # 0x7d 128 | '', # 0x7e 129 | '', # 0x7f 130 | 'b', # 0x80 131 | 'd', # 0x81 132 | 'f', # 0x82 133 | 'g', # 0x83 134 | 'k', # 0x84 135 | 'l', # 0x85 136 | 'm', # 0x86 137 | 'n', # 0x87 138 | 'p', # 0x88 139 | 'r', # 0x89 140 | 's', # 0x8a 141 | '', # 0x8b 142 | 'v', # 0x8c 143 | 'x', # 0x8d 144 | 'z', # 0x8e 145 | '', # 0x8f 146 | '', # 0x90 147 | '', # 0x91 148 | '', # 0x92 149 | '', # 0x93 150 | '', # 0x94 151 | '', # 0x95 152 | '', # 0x96 153 | '', # 0x97 154 | '', # 0x98 155 | '', # 0x99 156 | '', # 0x9a 157 | '', # 0x9b 158 | '', # 0x9c 159 | '', # 0x9d 160 | '', # 0x9e 161 | '', # 0x9f 162 | '', # 0xa0 163 | '', # 0xa1 164 | '', # 0xa2 165 | '', # 0xa3 166 | '', # 0xa4 167 | '', # 0xa5 168 | '', # 0xa6 169 | '', # 0xa7 170 | '', # 0xa8 171 | '', # 0xa9 172 | '', # 0xaa 173 | '', # 0xab 174 | '', # 0xac 175 | '', # 0xad 176 | '', # 0xae 177 | '', # 0xaf 178 | '', # 0xb0 179 | '', # 0xb1 180 | '', # 0xb2 181 | '', # 0xb3 182 | '', # 0xb4 183 | '', # 0xb5 184 | '', # 0xb6 185 | '', # 0xb7 186 | '', # 0xb8 187 | '', # 0xb9 188 | '', # 0xba 189 | '', # 0xbb 190 | '', # 0xbc 191 | '', # 0xbd 192 | '', # 0xbe 193 | '', # 0xbf 194 | '', # 0xc0 195 | '', # 0xc1 196 | '', # 0xc2 197 | '', # 0xc3 198 | '', # 0xc4 199 | '', # 0xc5 200 | '', # 0xc6 201 | '', # 0xc7 202 | '', # 0xc8 203 | '', # 0xc9 204 | '', # 0xca 205 | '', # 0xcb 206 | '', # 0xcc 207 | '', # 0xcd 208 | '', # 0xce 209 | '', # 0xcf 210 | '', # 0xd0 211 | '', # 0xd1 212 | '', # 0xd2 213 | '', # 0xd3 214 | '', # 0xd4 215 | '', # 0xd5 216 | '', # 0xd6 217 | '', # 0xd7 218 | '', # 0xd8 219 | '', # 0xd9 220 | '', # 0xda 221 | '', # 0xdb 222 | '', # 0xdc 223 | '', # 0xdd 224 | '', # 0xde 225 | '', # 0xdf 226 | '', # 0xe0 227 | '', # 0xe1 228 | '', # 0xe2 229 | '', # 0xe3 230 | '', # 0xe4 231 | '', # 0xe5 232 | '', # 0xe6 233 | '', # 0xe7 234 | '', # 0xe8 235 | '', # 0xe9 236 | '', # 0xea 237 | '', # 0xeb 238 | '', # 0xec 239 | '', # 0xed 240 | '', # 0xee 241 | '', # 0xef 242 | '', # 0xf0 243 | '', # 0xf1 244 | '', # 0xf2 245 | '', # 0xf3 246 | '', # 0xf4 247 | '', # 0xf5 248 | '', # 0xf6 249 | '', # 0xf7 250 | '', # 0xf8 251 | '', # 0xf9 252 | '', # 0xfa 253 | '', # 0xfb 254 | '', # 0xfc 255 | '', # 0xfd 256 | '', # 0xfe 257 | ) 258 | -------------------------------------------------------------------------------- /utils/asciirename/unidecode/x029.py: -------------------------------------------------------------------------------- 1 | data = ( 2 | '', # 0x00 3 | '', # 0x01 4 | '', # 0x02 5 | '', # 0x03 6 | '', # 0x04 7 | '', # 0x05 8 | '', # 0x06 9 | '', # 0x07 10 | '', # 0x08 11 | '', # 0x09 12 | '', # 0x0a 13 | '', # 0x0b 14 | '', # 0x0c 15 | '', # 0x0d 16 | '', # 0x0e 17 | '', # 0x0f 18 | '', # 0x10 19 | '', # 0x11 20 | '', # 0x12 21 | '', # 0x13 22 | '', # 0x14 23 | '', # 0x15 24 | '', # 0x16 25 | '', # 0x17 26 | '', # 0x18 27 | '', # 0x19 28 | '', # 0x1a 29 | '', # 0x1b 30 | '', # 0x1c 31 | '', # 0x1d 32 | '', # 0x1e 33 | '', # 0x1f 34 | '', # 0x20 35 | '', # 0x21 36 | '', # 0x22 37 | '', # 0x23 38 | '', # 0x24 39 | '', # 0x25 40 | '', # 0x26 41 | '', # 0x27 42 | '', # 0x28 43 | '', # 0x29 44 | '', # 0x2a 45 | '', # 0x2b 46 | '', # 0x2c 47 | '', # 0x2d 48 | '', # 0x2e 49 | '', # 0x2f 50 | '', # 0x30 51 | '', # 0x31 52 | '', # 0x32 53 | '', # 0x33 54 | '', # 0x34 55 | '', # 0x35 56 | '', # 0x36 57 | '', # 0x37 58 | '', # 0x38 59 | '', # 0x39 60 | '', # 0x3a 61 | '', # 0x3b 62 | '', # 0x3c 63 | '', # 0x3d 64 | '', # 0x3e 65 | '', # 0x3f 66 | '', # 0x40 67 | '', # 0x41 68 | '', # 0x42 69 | '', # 0x43 70 | '', # 0x44 71 | '', # 0x45 72 | '', # 0x46 73 | '', # 0x47 74 | '', # 0x48 75 | '', # 0x49 76 | '', # 0x4a 77 | '', # 0x4b 78 | '', # 0x4c 79 | '', # 0x4d 80 | '', # 0x4e 81 | '', # 0x4f 82 | '', # 0x50 83 | '', # 0x51 84 | '', # 0x52 85 | '', # 0x53 86 | '', # 0x54 87 | '', # 0x55 88 | '', # 0x56 89 | '', # 0x57 90 | '', # 0x58 91 | '', # 0x59 92 | '', # 0x5a 93 | '', # 0x5b 94 | '', # 0x5c 95 | '', # 0x5d 96 | '', # 0x5e 97 | '', # 0x5f 98 | '', # 0x60 99 | '', # 0x61 100 | '', # 0x62 101 | '', # 0x63 102 | '', # 0x64 103 | '', # 0x65 104 | '', # 0x66 105 | '', # 0x67 106 | '', # 0x68 107 | '', # 0x69 108 | '', # 0x6a 109 | '', # 0x6b 110 | '', # 0x6c 111 | '', # 0x6d 112 | '', # 0x6e 113 | '', # 0x6f 114 | '', # 0x70 115 | '', # 0x71 116 | '', # 0x72 117 | '', # 0x73 118 | '', # 0x74 119 | '', # 0x75 120 | '', # 0x76 121 | '', # 0x77 122 | '', # 0x78 123 | '', # 0x79 124 | '', # 0x7a 125 | '', # 0x7b 126 | '', # 0x7c 127 | '', # 0x7d 128 | '', # 0x7e 129 | '', # 0x7f 130 | '', # 0x80 131 | '', # 0x81 132 | '', # 0x82 133 | '{', # 0x83 134 | '} ', # 0x84 135 | '', # 0x85 136 | '', # 0x86 137 | '', # 0x87 138 | '', # 0x88 139 | '', # 0x89 140 | '', # 0x8a 141 | '', # 0x8b 142 | '', # 0x8c 143 | '', # 0x8d 144 | '', # 0x8e 145 | '', # 0x8f 146 | '', # 0x90 147 | '', # 0x91 148 | '', # 0x92 149 | '', # 0x93 150 | '', # 0x94 151 | '', # 0x95 152 | '', # 0x96 153 | '', # 0x97 154 | '', # 0x98 155 | '', # 0x99 156 | '', # 0x9a 157 | '', # 0x9b 158 | '', # 0x9c 159 | '', # 0x9d 160 | '', # 0x9e 161 | '', # 0x9f 162 | '', # 0xa0 163 | '', # 0xa1 164 | '', # 0xa2 165 | '', # 0xa3 166 | '', # 0xa4 167 | '', # 0xa5 168 | '', # 0xa6 169 | '', # 0xa7 170 | '', # 0xa8 171 | '', # 0xa9 172 | '', # 0xaa 173 | '', # 0xab 174 | '', # 0xac 175 | '', # 0xad 176 | '', # 0xae 177 | '', # 0xaf 178 | '', # 0xb0 179 | '', # 0xb1 180 | '', # 0xb2 181 | '', # 0xb3 182 | '', # 0xb4 183 | '', # 0xb5 184 | '', # 0xb6 185 | '', # 0xb7 186 | '', # 0xb8 187 | '', # 0xb9 188 | '', # 0xba 189 | '', # 0xbb 190 | '', # 0xbc 191 | '', # 0xbd 192 | '', # 0xbe 193 | '', # 0xbf 194 | '', # 0xc0 195 | '', # 0xc1 196 | '', # 0xc2 197 | '', # 0xc3 198 | '', # 0xc4 199 | '', # 0xc5 200 | '', # 0xc6 201 | '', # 0xc7 202 | '', # 0xc8 203 | '', # 0xc9 204 | '', # 0xca 205 | '', # 0xcb 206 | '', # 0xcc 207 | '', # 0xcd 208 | '', # 0xce 209 | '', # 0xcf 210 | '', # 0xd0 211 | '', # 0xd1 212 | '', # 0xd2 213 | '', # 0xd3 214 | '', # 0xd4 215 | '', # 0xd5 216 | '', # 0xd6 217 | '', # 0xd7 218 | '', # 0xd8 219 | '', # 0xd9 220 | '', # 0xda 221 | '', # 0xdb 222 | '', # 0xdc 223 | '', # 0xdd 224 | '', # 0xde 225 | '', # 0xdf 226 | '', # 0xe0 227 | '', # 0xe1 228 | '', # 0xe2 229 | '', # 0xe3 230 | '', # 0xe4 231 | '', # 0xe5 232 | '', # 0xe6 233 | '', # 0xe7 234 | '', # 0xe8 235 | '', # 0xe9 236 | '', # 0xea 237 | '', # 0xeb 238 | '', # 0xec 239 | '', # 0xed 240 | '', # 0xee 241 | '', # 0xef 242 | '', # 0xf0 243 | '', # 0xf1 244 | '', # 0xf2 245 | '', # 0xf3 246 | '', # 0xf4 247 | '', # 0xf5 248 | '', # 0xf6 249 | '', # 0xf7 250 | '', # 0xf8 251 | '', # 0xf9 252 | '', # 0xfa 253 | '', # 0xfb 254 | '', # 0xfc 255 | '', # 0xfd 256 | '', # 0xfe 257 | ) 258 | -------------------------------------------------------------------------------- /utils/asciirename/unidecode/x02a.py: -------------------------------------------------------------------------------- 1 | data = ( 2 | '', # 0x00 3 | '', # 0x01 4 | '', # 0x02 5 | '', # 0x03 6 | '', # 0x04 7 | '', # 0x05 8 | '', # 0x06 9 | '', # 0x07 10 | '', # 0x08 11 | '', # 0x09 12 | '', # 0x0a 13 | '', # 0x0b 14 | '', # 0x0c 15 | '', # 0x0d 16 | '', # 0x0e 17 | '', # 0x0f 18 | '', # 0x10 19 | '', # 0x11 20 | '', # 0x12 21 | '', # 0x13 22 | '', # 0x14 23 | '', # 0x15 24 | '', # 0x16 25 | '', # 0x17 26 | '', # 0x18 27 | '', # 0x19 28 | '', # 0x1a 29 | '', # 0x1b 30 | '', # 0x1c 31 | '', # 0x1d 32 | '', # 0x1e 33 | '', # 0x1f 34 | '', # 0x20 35 | '', # 0x21 36 | '', # 0x22 37 | '', # 0x23 38 | '', # 0x24 39 | '', # 0x25 40 | '', # 0x26 41 | '', # 0x27 42 | '', # 0x28 43 | '', # 0x29 44 | '', # 0x2a 45 | '', # 0x2b 46 | '', # 0x2c 47 | '', # 0x2d 48 | '', # 0x2e 49 | '', # 0x2f 50 | '', # 0x30 51 | '', # 0x31 52 | '', # 0x32 53 | '', # 0x33 54 | '', # 0x34 55 | '', # 0x35 56 | '', # 0x36 57 | '', # 0x37 58 | '', # 0x38 59 | '', # 0x39 60 | '', # 0x3a 61 | '', # 0x3b 62 | '', # 0x3c 63 | '', # 0x3d 64 | '', # 0x3e 65 | '', # 0x3f 66 | '', # 0x40 67 | '', # 0x41 68 | '', # 0x42 69 | '', # 0x43 70 | '', # 0x44 71 | '', # 0x45 72 | '', # 0x46 73 | '', # 0x47 74 | '', # 0x48 75 | '', # 0x49 76 | '', # 0x4a 77 | '', # 0x4b 78 | '', # 0x4c 79 | '', # 0x4d 80 | '', # 0x4e 81 | '', # 0x4f 82 | '', # 0x50 83 | '', # 0x51 84 | '', # 0x52 85 | '', # 0x53 86 | '', # 0x54 87 | '', # 0x55 88 | '', # 0x56 89 | '', # 0x57 90 | '', # 0x58 91 | '', # 0x59 92 | '', # 0x5a 93 | '', # 0x5b 94 | '', # 0x5c 95 | '', # 0x5d 96 | '', # 0x5e 97 | '', # 0x5f 98 | '', # 0x60 99 | '', # 0x61 100 | '', # 0x62 101 | '', # 0x63 102 | '', # 0x64 103 | '', # 0x65 104 | '', # 0x66 105 | '', # 0x67 106 | '', # 0x68 107 | '', # 0x69 108 | '', # 0x6a 109 | '', # 0x6b 110 | '', # 0x6c 111 | '', # 0x6d 112 | '', # 0x6e 113 | '', # 0x6f 114 | '', # 0x70 115 | '', # 0x71 116 | '', # 0x72 117 | '', # 0x73 118 | '::=', # 0x74 119 | '==', # 0x75 120 | '===', # 0x76 121 | '', # 0x77 122 | '', # 0x78 123 | '', # 0x79 124 | '', # 0x7a 125 | '', # 0x7b 126 | '', # 0x7c 127 | '', # 0x7d 128 | '', # 0x7e 129 | '', # 0x7f 130 | '', # 0x80 131 | '', # 0x81 132 | '', # 0x82 133 | '', # 0x83 134 | '', # 0x84 135 | '', # 0x85 136 | '', # 0x86 137 | '', # 0x87 138 | '', # 0x88 139 | '', # 0x89 140 | '', # 0x8a 141 | '', # 0x8b 142 | '', # 0x8c 143 | '', # 0x8d 144 | '', # 0x8e 145 | '', # 0x8f 146 | '', # 0x90 147 | '', # 0x91 148 | '', # 0x92 149 | '', # 0x93 150 | '', # 0x94 151 | '', # 0x95 152 | '', # 0x96 153 | '', # 0x97 154 | '', # 0x98 155 | '', # 0x99 156 | '', # 0x9a 157 | '', # 0x9b 158 | '', # 0x9c 159 | '', # 0x9d 160 | '', # 0x9e 161 | '', # 0x9f 162 | '', # 0xa0 163 | '', # 0xa1 164 | '', # 0xa2 165 | '', # 0xa3 166 | '', # 0xa4 167 | '', # 0xa5 168 | '', # 0xa6 169 | '', # 0xa7 170 | '', # 0xa8 171 | '', # 0xa9 172 | '', # 0xaa 173 | '', # 0xab 174 | '', # 0xac 175 | '', # 0xad 176 | '', # 0xae 177 | '', # 0xaf 178 | '', # 0xb0 179 | '', # 0xb1 180 | '', # 0xb2 181 | '', # 0xb3 182 | '', # 0xb4 183 | '', # 0xb5 184 | '', # 0xb6 185 | '', # 0xb7 186 | '', # 0xb8 187 | '', # 0xb9 188 | '', # 0xba 189 | '', # 0xbb 190 | '', # 0xbc 191 | '', # 0xbd 192 | '', # 0xbe 193 | '', # 0xbf 194 | '', # 0xc0 195 | '', # 0xc1 196 | '', # 0xc2 197 | '', # 0xc3 198 | '', # 0xc4 199 | '', # 0xc5 200 | '', # 0xc6 201 | '', # 0xc7 202 | '', # 0xc8 203 | '', # 0xc9 204 | '', # 0xca 205 | '', # 0xcb 206 | '', # 0xcc 207 | '', # 0xcd 208 | '', # 0xce 209 | '', # 0xcf 210 | '', # 0xd0 211 | '', # 0xd1 212 | '', # 0xd2 213 | '', # 0xd3 214 | '', # 0xd4 215 | '', # 0xd5 216 | '', # 0xd6 217 | '', # 0xd7 218 | '', # 0xd8 219 | '', # 0xd9 220 | '', # 0xda 221 | '', # 0xdb 222 | '', # 0xdc 223 | '', # 0xdd 224 | '', # 0xde 225 | '', # 0xdf 226 | '', # 0xe0 227 | '', # 0xe1 228 | '', # 0xe2 229 | '', # 0xe3 230 | '', # 0xe4 231 | '', # 0xe5 232 | '', # 0xe6 233 | '', # 0xe7 234 | '', # 0xe8 235 | '', # 0xe9 236 | '', # 0xea 237 | '', # 0xeb 238 | '', # 0xec 239 | '', # 0xed 240 | '', # 0xee 241 | '', # 0xef 242 | '', # 0xf0 243 | '', # 0xf1 244 | '', # 0xf2 245 | '', # 0xf3 246 | '', # 0xf4 247 | '', # 0xf5 248 | '', # 0xf6 249 | '', # 0xf7 250 | '', # 0xf8 251 | '', # 0xf9 252 | '', # 0xfa 253 | '', # 0xfb 254 | '', # 0xfc 255 | '', # 0xfd 256 | '', # 0xfe 257 | ) 258 | -------------------------------------------------------------------------------- /utils/asciirename/unidecode/x02c.py: -------------------------------------------------------------------------------- 1 | data = ( 2 | '', # 0x00 3 | '', # 0x01 4 | '', # 0x02 5 | '', # 0x03 6 | '', # 0x04 7 | '', # 0x05 8 | '', # 0x06 9 | '', # 0x07 10 | '', # 0x08 11 | '', # 0x09 12 | '', # 0x0a 13 | '', # 0x0b 14 | '', # 0x0c 15 | '', # 0x0d 16 | '', # 0x0e 17 | '', # 0x0f 18 | '', # 0x10 19 | '', # 0x11 20 | '', # 0x12 21 | '', # 0x13 22 | '', # 0x14 23 | '', # 0x15 24 | '', # 0x16 25 | '', # 0x17 26 | '', # 0x18 27 | '', # 0x19 28 | '', # 0x1a 29 | '', # 0x1b 30 | '', # 0x1c 31 | '', # 0x1d 32 | '', # 0x1e 33 | '', # 0x1f 34 | '', # 0x20 35 | '', # 0x21 36 | '', # 0x22 37 | '', # 0x23 38 | '', # 0x24 39 | '', # 0x25 40 | '', # 0x26 41 | '', # 0x27 42 | '', # 0x28 43 | '', # 0x29 44 | '', # 0x2a 45 | '', # 0x2b 46 | '', # 0x2c 47 | '', # 0x2d 48 | '', # 0x2e 49 | '', # 0x2f 50 | '', # 0x30 51 | '', # 0x31 52 | '', # 0x32 53 | '', # 0x33 54 | '', # 0x34 55 | '', # 0x35 56 | '', # 0x36 57 | '', # 0x37 58 | '', # 0x38 59 | '', # 0x39 60 | '', # 0x3a 61 | '', # 0x3b 62 | '', # 0x3c 63 | '', # 0x3d 64 | '', # 0x3e 65 | '', # 0x3f 66 | '', # 0x40 67 | '', # 0x41 68 | '', # 0x42 69 | '', # 0x43 70 | '', # 0x44 71 | '', # 0x45 72 | '', # 0x46 73 | '', # 0x47 74 | '', # 0x48 75 | '', # 0x49 76 | '', # 0x4a 77 | '', # 0x4b 78 | '', # 0x4c 79 | '', # 0x4d 80 | '', # 0x4e 81 | '', # 0x4f 82 | '', # 0x50 83 | '', # 0x51 84 | '', # 0x52 85 | '', # 0x53 86 | '', # 0x54 87 | '', # 0x55 88 | '', # 0x56 89 | '', # 0x57 90 | '', # 0x58 91 | '', # 0x59 92 | '', # 0x5a 93 | '', # 0x5b 94 | '', # 0x5c 95 | '', # 0x5d 96 | '', # 0x5e 97 | '', # 0x5f 98 | 'L', # 0x60 99 | 'l', # 0x61 100 | 'L', # 0x62 101 | 'P', # 0x63 102 | 'R', # 0x64 103 | 'a', # 0x65 104 | 't', # 0x66 105 | 'H', # 0x67 106 | 'h', # 0x68 107 | 'K', # 0x69 108 | 'k', # 0x6a 109 | 'Z', # 0x6b 110 | 'z', # 0x6c 111 | '', # 0x6d 112 | 'M', # 0x6e 113 | 'A', # 0x6f 114 | '', # 0x70 115 | '', # 0x71 116 | '', # 0x72 117 | '', # 0x73 118 | '', # 0x74 119 | '', # 0x75 120 | '', # 0x76 121 | '', # 0x77 122 | '', # 0x78 123 | '', # 0x79 124 | '', # 0x7a 125 | '', # 0x7b 126 | '', # 0x7c 127 | '', # 0x7d 128 | '', # 0x7e 129 | '', # 0x7f 130 | '', # 0x80 131 | '', # 0x81 132 | '', # 0x82 133 | '', # 0x83 134 | '', # 0x84 135 | '', # 0x85 136 | '', # 0x86 137 | '', # 0x87 138 | '', # 0x88 139 | '', # 0x89 140 | '', # 0x8a 141 | '', # 0x8b 142 | '', # 0x8c 143 | '', # 0x8d 144 | '', # 0x8e 145 | '', # 0x8f 146 | '', # 0x90 147 | '', # 0x91 148 | '', # 0x92 149 | '', # 0x93 150 | '', # 0x94 151 | '', # 0x95 152 | '', # 0x96 153 | '', # 0x97 154 | '', # 0x98 155 | '', # 0x99 156 | '', # 0x9a 157 | '', # 0x9b 158 | '', # 0x9c 159 | '', # 0x9d 160 | '', # 0x9e 161 | '', # 0x9f 162 | '', # 0xa0 163 | '', # 0xa1 164 | '', # 0xa2 165 | '', # 0xa3 166 | '', # 0xa4 167 | '', # 0xa5 168 | '', # 0xa6 169 | '', # 0xa7 170 | '', # 0xa8 171 | '', # 0xa9 172 | '', # 0xaa 173 | '', # 0xab 174 | '', # 0xac 175 | '', # 0xad 176 | '', # 0xae 177 | '', # 0xaf 178 | '', # 0xb0 179 | '', # 0xb1 180 | '', # 0xb2 181 | '', # 0xb3 182 | '', # 0xb4 183 | '', # 0xb5 184 | '', # 0xb6 185 | '', # 0xb7 186 | '', # 0xb8 187 | '', # 0xb9 188 | '', # 0xba 189 | '', # 0xbb 190 | '', # 0xbc 191 | '', # 0xbd 192 | '', # 0xbe 193 | '', # 0xbf 194 | '', # 0xc0 195 | '', # 0xc1 196 | '', # 0xc2 197 | '', # 0xc3 198 | '', # 0xc4 199 | '', # 0xc5 200 | '', # 0xc6 201 | '', # 0xc7 202 | '', # 0xc8 203 | '', # 0xc9 204 | '', # 0xca 205 | '', # 0xcb 206 | '', # 0xcc 207 | '', # 0xcd 208 | '', # 0xce 209 | '', # 0xcf 210 | '', # 0xd0 211 | '', # 0xd1 212 | '', # 0xd2 213 | '', # 0xd3 214 | '', # 0xd4 215 | '', # 0xd5 216 | '', # 0xd6 217 | '', # 0xd7 218 | '', # 0xd8 219 | '', # 0xd9 220 | '', # 0xda 221 | '', # 0xdb 222 | '', # 0xdc 223 | '', # 0xdd 224 | '', # 0xde 225 | '', # 0xdf 226 | '', # 0xe0 227 | '', # 0xe1 228 | '', # 0xe2 229 | '', # 0xe3 230 | '', # 0xe4 231 | '', # 0xe5 232 | '', # 0xe6 233 | '', # 0xe7 234 | '', # 0xe8 235 | '', # 0xe9 236 | '', # 0xea 237 | '', # 0xeb 238 | '', # 0xec 239 | '', # 0xed 240 | '', # 0xee 241 | '', # 0xef 242 | '', # 0xf0 243 | '', # 0xf1 244 | '', # 0xf2 245 | '', # 0xf3 246 | '', # 0xf4 247 | '', # 0xf5 248 | '', # 0xf6 249 | '', # 0xf7 250 | '', # 0xf8 251 | '', # 0xf9 252 | '', # 0xfa 253 | '', # 0xfb 254 | '', # 0xfc 255 | '', # 0xfd 256 | '', # 0xfe 257 | ) 258 | -------------------------------------------------------------------------------- /utils/asciirename/unidecode/x0fc.py: -------------------------------------------------------------------------------- 1 | data = ( 2 | '', # 0x00 3 | '', # 0x01 4 | '', # 0x02 5 | '', # 0x03 6 | '', # 0x04 7 | '', # 0x05 8 | '', # 0x06 9 | '', # 0x07 10 | '', # 0x08 11 | '', # 0x09 12 | '', # 0x0a 13 | '', # 0x0b 14 | '', # 0x0c 15 | '', # 0x0d 16 | '', # 0x0e 17 | '', # 0x0f 18 | '', # 0x10 19 | '', # 0x11 20 | '', # 0x12 21 | '', # 0x13 22 | '', # 0x14 23 | '', # 0x15 24 | '', # 0x16 25 | '', # 0x17 26 | '', # 0x18 27 | '', # 0x19 28 | '', # 0x1a 29 | '', # 0x1b 30 | '', # 0x1c 31 | '', # 0x1d 32 | '', # 0x1e 33 | '', # 0x1f 34 | '', # 0x20 35 | '', # 0x21 36 | '', # 0x22 37 | '', # 0x23 38 | '', # 0x24 39 | '', # 0x25 40 | '', # 0x26 41 | '', # 0x27 42 | '', # 0x28 43 | '', # 0x29 44 | '', # 0x2a 45 | '', # 0x2b 46 | '', # 0x2c 47 | '', # 0x2d 48 | '', # 0x2e 49 | '', # 0x2f 50 | '', # 0x30 51 | '', # 0x31 52 | '', # 0x32 53 | '', # 0x33 54 | '', # 0x34 55 | '', # 0x35 56 | '', # 0x36 57 | '', # 0x37 58 | '', # 0x38 59 | '', # 0x39 60 | '', # 0x3a 61 | '', # 0x3b 62 | '', # 0x3c 63 | '', # 0x3d 64 | '', # 0x3e 65 | '', # 0x3f 66 | '', # 0x40 67 | '', # 0x41 68 | '', # 0x42 69 | '', # 0x43 70 | '', # 0x44 71 | '', # 0x45 72 | '', # 0x46 73 | '', # 0x47 74 | '', # 0x48 75 | '', # 0x49 76 | '', # 0x4a 77 | '', # 0x4b 78 | '', # 0x4c 79 | '', # 0x4d 80 | '', # 0x4e 81 | '', # 0x4f 82 | '', # 0x50 83 | '', # 0x51 84 | '', # 0x52 85 | '', # 0x53 86 | '', # 0x54 87 | '', # 0x55 88 | '', # 0x56 89 | '', # 0x57 90 | '', # 0x58 91 | '', # 0x59 92 | '', # 0x5a 93 | '', # 0x5b 94 | '', # 0x5c 95 | '', # 0x5d 96 | '', # 0x5e 97 | '', # 0x5f 98 | '', # 0x60 99 | '', # 0x61 100 | '', # 0x62 101 | '', # 0x63 102 | '', # 0x64 103 | '', # 0x65 104 | '', # 0x66 105 | '', # 0x67 106 | '', # 0x68 107 | '', # 0x69 108 | '', # 0x6a 109 | '', # 0x6b 110 | '', # 0x6c 111 | '', # 0x6d 112 | '', # 0x6e 113 | '', # 0x6f 114 | '', # 0x70 115 | '', # 0x71 116 | '', # 0x72 117 | '', # 0x73 118 | '', # 0x74 119 | '', # 0x75 120 | '', # 0x76 121 | '', # 0x77 122 | '', # 0x78 123 | '', # 0x79 124 | '', # 0x7a 125 | '', # 0x7b 126 | '', # 0x7c 127 | '', # 0x7d 128 | '', # 0x7e 129 | '', # 0x7f 130 | '', # 0x80 131 | '', # 0x81 132 | '', # 0x82 133 | '', # 0x83 134 | '', # 0x84 135 | '', # 0x85 136 | '', # 0x86 137 | '', # 0x87 138 | '', # 0x88 139 | '', # 0x89 140 | '', # 0x8a 141 | '', # 0x8b 142 | '', # 0x8c 143 | '', # 0x8d 144 | '', # 0x8e 145 | '', # 0x8f 146 | '', # 0x90 147 | '', # 0x91 148 | '', # 0x92 149 | '', # 0x93 150 | '', # 0x94 151 | '', # 0x95 152 | '', # 0x96 153 | '', # 0x97 154 | '', # 0x98 155 | '', # 0x99 156 | '', # 0x9a 157 | '', # 0x9b 158 | '', # 0x9c 159 | '', # 0x9d 160 | '', # 0x9e 161 | '', # 0x9f 162 | '', # 0xa0 163 | '', # 0xa1 164 | '', # 0xa2 165 | '', # 0xa3 166 | '', # 0xa4 167 | '', # 0xa5 168 | '', # 0xa6 169 | '', # 0xa7 170 | '', # 0xa8 171 | '', # 0xa9 172 | '', # 0xaa 173 | '', # 0xab 174 | '', # 0xac 175 | '', # 0xad 176 | '', # 0xae 177 | '', # 0xaf 178 | '', # 0xb0 179 | '', # 0xb1 180 | '', # 0xb2 181 | '', # 0xb3 182 | '', # 0xb4 183 | '', # 0xb5 184 | '', # 0xb6 185 | '', # 0xb7 186 | '', # 0xb8 187 | '', # 0xb9 188 | '', # 0xba 189 | '', # 0xbb 190 | '', # 0xbc 191 | '', # 0xbd 192 | '', # 0xbe 193 | '', # 0xbf 194 | '', # 0xc0 195 | '', # 0xc1 196 | '', # 0xc2 197 | '', # 0xc3 198 | '', # 0xc4 199 | '', # 0xc5 200 | '', # 0xc6 201 | '', # 0xc7 202 | '', # 0xc8 203 | '', # 0xc9 204 | '', # 0xca 205 | '', # 0xcb 206 | '', # 0xcc 207 | '', # 0xcd 208 | '', # 0xce 209 | '', # 0xcf 210 | '', # 0xd0 211 | '', # 0xd1 212 | '', # 0xd2 213 | '', # 0xd3 214 | '', # 0xd4 215 | '', # 0xd5 216 | '', # 0xd6 217 | '', # 0xd7 218 | '', # 0xd8 219 | '', # 0xd9 220 | '', # 0xda 221 | '', # 0xdb 222 | '', # 0xdc 223 | '', # 0xdd 224 | '', # 0xde 225 | '', # 0xdf 226 | '', # 0xe0 227 | '', # 0xe1 228 | '', # 0xe2 229 | '', # 0xe3 230 | '', # 0xe4 231 | '', # 0xe5 232 | '', # 0xe6 233 | '', # 0xe7 234 | '', # 0xe8 235 | '', # 0xe9 236 | '', # 0xea 237 | '', # 0xeb 238 | '', # 0xec 239 | '', # 0xed 240 | '', # 0xee 241 | '', # 0xef 242 | '', # 0xf0 243 | '', # 0xf1 244 | '', # 0xf2 245 | '', # 0xf3 246 | '', # 0xf4 247 | '', # 0xf5 248 | '', # 0xf6 249 | '', # 0xf7 250 | '', # 0xf8 251 | '', # 0xf9 252 | '', # 0xfa 253 | '', # 0xfb 254 | '', # 0xfc 255 | '', # 0xfd 256 | '', # 0xfe 257 | '', # 0xff 258 | ) 259 | -------------------------------------------------------------------------------- /utils/asciirename/unidecode/x0fd.py: -------------------------------------------------------------------------------- 1 | data = ( 2 | '', # 0x00 3 | '', # 0x01 4 | '', # 0x02 5 | '', # 0x03 6 | '', # 0x04 7 | '', # 0x05 8 | '', # 0x06 9 | '', # 0x07 10 | '', # 0x08 11 | '', # 0x09 12 | '', # 0x0a 13 | '', # 0x0b 14 | '', # 0x0c 15 | '', # 0x0d 16 | '', # 0x0e 17 | '', # 0x0f 18 | '', # 0x10 19 | '', # 0x11 20 | '', # 0x12 21 | '', # 0x13 22 | '', # 0x14 23 | '', # 0x15 24 | '', # 0x16 25 | '', # 0x17 26 | '', # 0x18 27 | '', # 0x19 28 | '', # 0x1a 29 | '', # 0x1b 30 | '', # 0x1c 31 | '', # 0x1d 32 | '', # 0x1e 33 | '', # 0x1f 34 | '', # 0x20 35 | '', # 0x21 36 | '', # 0x22 37 | '', # 0x23 38 | '', # 0x24 39 | '', # 0x25 40 | '', # 0x26 41 | '', # 0x27 42 | '', # 0x28 43 | '', # 0x29 44 | '', # 0x2a 45 | '', # 0x2b 46 | '', # 0x2c 47 | '', # 0x2d 48 | '', # 0x2e 49 | '', # 0x2f 50 | '', # 0x30 51 | '', # 0x31 52 | '', # 0x32 53 | '', # 0x33 54 | '', # 0x34 55 | '', # 0x35 56 | '', # 0x36 57 | '', # 0x37 58 | '', # 0x38 59 | '', # 0x39 60 | '', # 0x3a 61 | '', # 0x3b 62 | '', # 0x3c 63 | '', # 0x3d 64 | '', # 0x3e 65 | '', # 0x3f 66 | '[?]', # 0x40 67 | '[?]', # 0x41 68 | '[?]', # 0x42 69 | '[?]', # 0x43 70 | '[?]', # 0x44 71 | '[?]', # 0x45 72 | '[?]', # 0x46 73 | '[?]', # 0x47 74 | '[?]', # 0x48 75 | '[?]', # 0x49 76 | '[?]', # 0x4a 77 | '[?]', # 0x4b 78 | '[?]', # 0x4c 79 | '[?]', # 0x4d 80 | '[?]', # 0x4e 81 | '[?]', # 0x4f 82 | '', # 0x50 83 | '', # 0x51 84 | '', # 0x52 85 | '', # 0x53 86 | '', # 0x54 87 | '', # 0x55 88 | '', # 0x56 89 | '', # 0x57 90 | '', # 0x58 91 | '', # 0x59 92 | '', # 0x5a 93 | '', # 0x5b 94 | '', # 0x5c 95 | '', # 0x5d 96 | '', # 0x5e 97 | '', # 0x5f 98 | '', # 0x60 99 | '', # 0x61 100 | '', # 0x62 101 | '', # 0x63 102 | '', # 0x64 103 | '', # 0x65 104 | '', # 0x66 105 | '', # 0x67 106 | '', # 0x68 107 | '', # 0x69 108 | '', # 0x6a 109 | '', # 0x6b 110 | '', # 0x6c 111 | '', # 0x6d 112 | '', # 0x6e 113 | '', # 0x6f 114 | '', # 0x70 115 | '', # 0x71 116 | '', # 0x72 117 | '', # 0x73 118 | '', # 0x74 119 | '', # 0x75 120 | '', # 0x76 121 | '', # 0x77 122 | '', # 0x78 123 | '', # 0x79 124 | '', # 0x7a 125 | '', # 0x7b 126 | '', # 0x7c 127 | '', # 0x7d 128 | '', # 0x7e 129 | '', # 0x7f 130 | '', # 0x80 131 | '', # 0x81 132 | '', # 0x82 133 | '', # 0x83 134 | '', # 0x84 135 | '', # 0x85 136 | '', # 0x86 137 | '', # 0x87 138 | '', # 0x88 139 | '', # 0x89 140 | '', # 0x8a 141 | '', # 0x8b 142 | '', # 0x8c 143 | '', # 0x8d 144 | '', # 0x8e 145 | '', # 0x8f 146 | '[?]', # 0x90 147 | '[?]', # 0x91 148 | '', # 0x92 149 | '', # 0x93 150 | '', # 0x94 151 | '', # 0x95 152 | '', # 0x96 153 | '', # 0x97 154 | '', # 0x98 155 | '', # 0x99 156 | '', # 0x9a 157 | '', # 0x9b 158 | '', # 0x9c 159 | '', # 0x9d 160 | '', # 0x9e 161 | '', # 0x9f 162 | '', # 0xa0 163 | '', # 0xa1 164 | '', # 0xa2 165 | '', # 0xa3 166 | '', # 0xa4 167 | '', # 0xa5 168 | '', # 0xa6 169 | '', # 0xa7 170 | '', # 0xa8 171 | '', # 0xa9 172 | '', # 0xaa 173 | '', # 0xab 174 | '', # 0xac 175 | '', # 0xad 176 | '', # 0xae 177 | '', # 0xaf 178 | '', # 0xb0 179 | '', # 0xb1 180 | '', # 0xb2 181 | '', # 0xb3 182 | '', # 0xb4 183 | '', # 0xb5 184 | '', # 0xb6 185 | '', # 0xb7 186 | '', # 0xb8 187 | '', # 0xb9 188 | '', # 0xba 189 | '', # 0xbb 190 | '', # 0xbc 191 | '', # 0xbd 192 | '', # 0xbe 193 | '', # 0xbf 194 | '', # 0xc0 195 | '', # 0xc1 196 | '', # 0xc2 197 | '', # 0xc3 198 | '', # 0xc4 199 | '', # 0xc5 200 | '', # 0xc6 201 | '', # 0xc7 202 | '[?]', # 0xc8 203 | '[?]', # 0xc9 204 | '[?]', # 0xca 205 | '[?]', # 0xcb 206 | '[?]', # 0xcc 207 | '[?]', # 0xcd 208 | '[?]', # 0xce 209 | '[?]', # 0xcf 210 | '[?]', # 0xd0 211 | '[?]', # 0xd1 212 | '[?]', # 0xd2 213 | '[?]', # 0xd3 214 | '[?]', # 0xd4 215 | '[?]', # 0xd5 216 | '[?]', # 0xd6 217 | '[?]', # 0xd7 218 | '[?]', # 0xd8 219 | '[?]', # 0xd9 220 | '[?]', # 0xda 221 | '[?]', # 0xdb 222 | '[?]', # 0xdc 223 | '[?]', # 0xdd 224 | '[?]', # 0xde 225 | '[?]', # 0xdf 226 | '[?]', # 0xe0 227 | '[?]', # 0xe1 228 | '[?]', # 0xe2 229 | '[?]', # 0xe3 230 | '[?]', # 0xe4 231 | '[?]', # 0xe5 232 | '[?]', # 0xe6 233 | '[?]', # 0xe7 234 | '[?]', # 0xe8 235 | '[?]', # 0xe9 236 | '[?]', # 0xea 237 | '[?]', # 0xeb 238 | '[?]', # 0xec 239 | '[?]', # 0xed 240 | '[?]', # 0xee 241 | '[?]', # 0xef 242 | '', # 0xf0 243 | '', # 0xf1 244 | '', # 0xf2 245 | '', # 0xf3 246 | '', # 0xf4 247 | '', # 0xf5 248 | '', # 0xf6 249 | '', # 0xf7 250 | '', # 0xf8 251 | '', # 0xf9 252 | '', # 0xfa 253 | '', # 0xfb 254 | '[?]', # 0xfc 255 | '[?]', # 0xfd 256 | '[?]', # 0xfe 257 | ) 258 | -------------------------------------------------------------------------------- /utils/asciirename/unidecode/x1d7.py: -------------------------------------------------------------------------------- 1 | data = ( 2 | '', # 0x00 3 | '', # 0x01 4 | '', # 0x02 5 | '', # 0x03 6 | '', # 0x04 7 | '', # 0x05 8 | '', # 0x06 9 | '', # 0x07 10 | '', # 0x08 11 | '', # 0x09 12 | '', # 0x0a 13 | '', # 0x0b 14 | '', # 0x0c 15 | '', # 0x0d 16 | '', # 0x0e 17 | '', # 0x0f 18 | '', # 0x10 19 | '', # 0x11 20 | '', # 0x12 21 | '', # 0x13 22 | '', # 0x14 23 | '', # 0x15 24 | '', # 0x16 25 | '', # 0x17 26 | '', # 0x18 27 | '', # 0x19 28 | '', # 0x1a 29 | '', # 0x1b 30 | '', # 0x1c 31 | '', # 0x1d 32 | '', # 0x1e 33 | '', # 0x1f 34 | '', # 0x20 35 | '', # 0x21 36 | '', # 0x22 37 | '', # 0x23 38 | '', # 0x24 39 | '', # 0x25 40 | '', # 0x26 41 | '', # 0x27 42 | '', # 0x28 43 | '', # 0x29 44 | '', # 0x2a 45 | '', # 0x2b 46 | '', # 0x2c 47 | '', # 0x2d 48 | '', # 0x2e 49 | '', # 0x2f 50 | '', # 0x30 51 | '', # 0x31 52 | '', # 0x32 53 | '', # 0x33 54 | '', # 0x34 55 | '', # 0x35 56 | '', # 0x36 57 | '', # 0x37 58 | '', # 0x38 59 | '', # 0x39 60 | '', # 0x3a 61 | '', # 0x3b 62 | '', # 0x3c 63 | '', # 0x3d 64 | '', # 0x3e 65 | '', # 0x3f 66 | '', # 0x40 67 | '', # 0x41 68 | '', # 0x42 69 | '', # 0x43 70 | '', # 0x44 71 | '', # 0x45 72 | '', # 0x46 73 | '', # 0x47 74 | '', # 0x48 75 | '', # 0x49 76 | '', # 0x4a 77 | '', # 0x4b 78 | '', # 0x4c 79 | '', # 0x4d 80 | '', # 0x4e 81 | '', # 0x4f 82 | '', # 0x50 83 | '', # 0x51 84 | '', # 0x52 85 | '', # 0x53 86 | '', # 0x54 87 | '', # 0x55 88 | '', # 0x56 89 | '', # 0x57 90 | '', # 0x58 91 | '', # 0x59 92 | '', # 0x5a 93 | '', # 0x5b 94 | '', # 0x5c 95 | '', # 0x5d 96 | '', # 0x5e 97 | '', # 0x5f 98 | '', # 0x60 99 | '', # 0x61 100 | '', # 0x62 101 | '', # 0x63 102 | '', # 0x64 103 | '', # 0x65 104 | '', # 0x66 105 | '', # 0x67 106 | '', # 0x68 107 | '', # 0x69 108 | '', # 0x6a 109 | '', # 0x6b 110 | '', # 0x6c 111 | '', # 0x6d 112 | '', # 0x6e 113 | '', # 0x6f 114 | '', # 0x70 115 | '', # 0x71 116 | '', # 0x72 117 | '', # 0x73 118 | '', # 0x74 119 | '', # 0x75 120 | '', # 0x76 121 | '', # 0x77 122 | '', # 0x78 123 | '', # 0x79 124 | '', # 0x7a 125 | '', # 0x7b 126 | '', # 0x7c 127 | '', # 0x7d 128 | '', # 0x7e 129 | '', # 0x7f 130 | '', # 0x80 131 | '', # 0x81 132 | '', # 0x82 133 | '', # 0x83 134 | '', # 0x84 135 | '', # 0x85 136 | '', # 0x86 137 | '', # 0x87 138 | '', # 0x88 139 | '', # 0x89 140 | '', # 0x8a 141 | '', # 0x8b 142 | '', # 0x8c 143 | '', # 0x8d 144 | '', # 0x8e 145 | '', # 0x8f 146 | '', # 0x90 147 | '', # 0x91 148 | '', # 0x92 149 | '', # 0x93 150 | '', # 0x94 151 | '', # 0x95 152 | '', # 0x96 153 | '', # 0x97 154 | '', # 0x98 155 | '', # 0x99 156 | '', # 0x9a 157 | '', # 0x9b 158 | '', # 0x9c 159 | '', # 0x9d 160 | '', # 0x9e 161 | '', # 0x9f 162 | '', # 0xa0 163 | '', # 0xa1 164 | '', # 0xa2 165 | '', # 0xa3 166 | '', # 0xa4 167 | '', # 0xa5 168 | '', # 0xa6 169 | '', # 0xa7 170 | '', # 0xa8 171 | '', # 0xa9 172 | '', # 0xaa 173 | '', # 0xab 174 | '', # 0xac 175 | '', # 0xad 176 | '', # 0xae 177 | '', # 0xaf 178 | '', # 0xb0 179 | '', # 0xb1 180 | '', # 0xb2 181 | '', # 0xb3 182 | '', # 0xb4 183 | '', # 0xb5 184 | '', # 0xb6 185 | '', # 0xb7 186 | '', # 0xb8 187 | '', # 0xb9 188 | '', # 0xba 189 | '', # 0xbb 190 | '', # 0xbc 191 | '', # 0xbd 192 | '', # 0xbe 193 | '', # 0xbf 194 | '', # 0xc0 195 | '', # 0xc1 196 | '', # 0xc2 197 | '', # 0xc3 198 | '', # 0xc4 199 | '', # 0xc5 200 | '', # 0xc6 201 | '', # 0xc7 202 | '', # 0xc8 203 | '', # 0xc9 204 | '', # 0xca 205 | '', # 0xcb 206 | '', # 0xcc 207 | '', # 0xcd 208 | '0', # 0xce 209 | '1', # 0xcf 210 | '2', # 0xd0 211 | '3', # 0xd1 212 | '4', # 0xd2 213 | '5', # 0xd3 214 | '6', # 0xd4 215 | '7', # 0xd5 216 | '8', # 0xd6 217 | '9', # 0xd7 218 | '0', # 0xd8 219 | '1', # 0xd9 220 | '2', # 0xda 221 | '3', # 0xdb 222 | '4', # 0xdc 223 | '5', # 0xdd 224 | '6', # 0xde 225 | '7', # 0xdf 226 | '8', # 0xe0 227 | '9', # 0xe1 228 | '0', # 0xe2 229 | '1', # 0xe3 230 | '2', # 0xe4 231 | '3', # 0xe5 232 | '4', # 0xe6 233 | '5', # 0xe7 234 | '6', # 0xe8 235 | '7', # 0xe9 236 | '8', # 0xea 237 | '9', # 0xeb 238 | '0', # 0xec 239 | '1', # 0xed 240 | '2', # 0xee 241 | '3', # 0xef 242 | '4', # 0xf0 243 | '5', # 0xf1 244 | '6', # 0xf2 245 | '7', # 0xf3 246 | '8', # 0xf4 247 | '9', # 0xf5 248 | '0', # 0xf6 249 | '1', # 0xf7 250 | '2', # 0xf8 251 | '3', # 0xf9 252 | '4', # 0xfa 253 | '5', # 0xfb 254 | '6', # 0xfc 255 | '7', # 0xfd 256 | '8', # 0xfe 257 | '9', # 0xff 258 | ) 259 | -------------------------------------------------------------------------------- /utils/asciirename/unidecode/x1f1.py: -------------------------------------------------------------------------------- 1 | data = ( 2 | '0.', # 0x00 3 | '0,', # 0x01 4 | '1,', # 0x02 5 | '2,', # 0x03 6 | '3,', # 0x04 7 | '4,', # 0x05 8 | '5,', # 0x06 9 | '6,', # 0x07 10 | '7,', # 0x08 11 | '8,', # 0x09 12 | '9,', # 0x0a 13 | '', # 0x0b 14 | '', # 0x0c 15 | '', # 0x0d 16 | '', # 0x0e 17 | '', # 0x0f 18 | '(A)', # 0x10 19 | '(B)', # 0x11 20 | '(C)', # 0x12 21 | '(D)', # 0x13 22 | '(E)', # 0x14 23 | '(F)', # 0x15 24 | '(G)', # 0x16 25 | '(H)', # 0x17 26 | '(I)', # 0x18 27 | '(J)', # 0x19 28 | '(K)', # 0x1a 29 | '(L)', # 0x1b 30 | '(M)', # 0x1c 31 | '(N)', # 0x1d 32 | '(O)', # 0x1e 33 | '(P)', # 0x1f 34 | '(Q)', # 0x20 35 | '(R)', # 0x21 36 | '(S)', # 0x22 37 | '(T)', # 0x23 38 | '(U)', # 0x24 39 | '(V)', # 0x25 40 | '(W)', # 0x26 41 | '(X)', # 0x27 42 | '(Y)', # 0x28 43 | '(Z)', # 0x29 44 | '', # 0x2a 45 | '', # 0x2b 46 | '', # 0x2c 47 | '', # 0x2d 48 | '', # 0x2e 49 | '', # 0x2f 50 | '', # 0x30 51 | '', # 0x31 52 | '', # 0x32 53 | '', # 0x33 54 | '', # 0x34 55 | '', # 0x35 56 | '', # 0x36 57 | '', # 0x37 58 | '', # 0x38 59 | '', # 0x39 60 | '', # 0x3a 61 | '', # 0x3b 62 | '', # 0x3c 63 | '', # 0x3d 64 | '', # 0x3e 65 | '', # 0x3f 66 | '', # 0x40 67 | '', # 0x41 68 | '', # 0x42 69 | '', # 0x43 70 | '', # 0x44 71 | '', # 0x45 72 | '', # 0x46 73 | '', # 0x47 74 | '', # 0x48 75 | '', # 0x49 76 | '', # 0x4a 77 | '', # 0x4b 78 | '', # 0x4c 79 | '', # 0x4d 80 | '', # 0x4e 81 | '', # 0x4f 82 | '', # 0x50 83 | '', # 0x51 84 | '', # 0x52 85 | '', # 0x53 86 | '', # 0x54 87 | '', # 0x55 88 | '', # 0x56 89 | '', # 0x57 90 | '', # 0x58 91 | '', # 0x59 92 | '', # 0x5a 93 | '', # 0x5b 94 | '', # 0x5c 95 | '', # 0x5d 96 | '', # 0x5e 97 | '', # 0x5f 98 | '', # 0x60 99 | '', # 0x61 100 | '', # 0x62 101 | '', # 0x63 102 | '', # 0x64 103 | '', # 0x65 104 | '', # 0x66 105 | '', # 0x67 106 | '', # 0x68 107 | '', # 0x69 108 | '', # 0x6a 109 | '', # 0x6b 110 | '', # 0x6c 111 | '', # 0x6d 112 | '', # 0x6e 113 | '', # 0x6f 114 | '', # 0x70 115 | '', # 0x71 116 | '', # 0x72 117 | '', # 0x73 118 | '', # 0x74 119 | '', # 0x75 120 | '', # 0x76 121 | '', # 0x77 122 | '', # 0x78 123 | '', # 0x79 124 | '', # 0x7a 125 | '', # 0x7b 126 | '', # 0x7c 127 | '', # 0x7d 128 | '', # 0x7e 129 | '', # 0x7f 130 | '', # 0x80 131 | '', # 0x81 132 | '', # 0x82 133 | '', # 0x83 134 | '', # 0x84 135 | '', # 0x85 136 | '', # 0x86 137 | '', # 0x87 138 | '', # 0x88 139 | '', # 0x89 140 | '', # 0x8a 141 | '', # 0x8b 142 | '', # 0x8c 143 | '', # 0x8d 144 | '', # 0x8e 145 | '', # 0x8f 146 | '', # 0x90 147 | '', # 0x91 148 | '', # 0x92 149 | '', # 0x93 150 | '', # 0x94 151 | '', # 0x95 152 | '', # 0x96 153 | '', # 0x97 154 | '', # 0x98 155 | '', # 0x99 156 | '', # 0x9a 157 | '', # 0x9b 158 | '', # 0x9c 159 | '', # 0x9d 160 | '', # 0x9e 161 | '', # 0x9f 162 | '', # 0xa0 163 | '', # 0xa1 164 | '', # 0xa2 165 | '', # 0xa3 166 | '', # 0xa4 167 | '', # 0xa5 168 | '', # 0xa6 169 | '', # 0xa7 170 | '', # 0xa8 171 | '', # 0xa9 172 | '', # 0xaa 173 | '', # 0xab 174 | '', # 0xac 175 | '', # 0xad 176 | '', # 0xae 177 | '', # 0xaf 178 | '', # 0xb0 179 | '', # 0xb1 180 | '', # 0xb2 181 | '', # 0xb3 182 | '', # 0xb4 183 | '', # 0xb5 184 | '', # 0xb6 185 | '', # 0xb7 186 | '', # 0xb8 187 | '', # 0xb9 188 | '', # 0xba 189 | '', # 0xbb 190 | '', # 0xbc 191 | '', # 0xbd 192 | '', # 0xbe 193 | '', # 0xbf 194 | '', # 0xc0 195 | '', # 0xc1 196 | '', # 0xc2 197 | '', # 0xc3 198 | '', # 0xc4 199 | '', # 0xc5 200 | '', # 0xc6 201 | '', # 0xc7 202 | '', # 0xc8 203 | '', # 0xc9 204 | '', # 0xca 205 | '', # 0xcb 206 | '', # 0xcc 207 | '', # 0xcd 208 | '', # 0xce 209 | '', # 0xcf 210 | '', # 0xd0 211 | '', # 0xd1 212 | '', # 0xd2 213 | '', # 0xd3 214 | '', # 0xd4 215 | '', # 0xd5 216 | '', # 0xd6 217 | '', # 0xd7 218 | '', # 0xd8 219 | '', # 0xd9 220 | '', # 0xda 221 | '', # 0xdb 222 | '', # 0xdc 223 | '', # 0xdd 224 | '', # 0xde 225 | '', # 0xdf 226 | '', # 0xe0 227 | '', # 0xe1 228 | '', # 0xe2 229 | '', # 0xe3 230 | '', # 0xe4 231 | '', # 0xe5 232 | '', # 0xe6 233 | '', # 0xe7 234 | '', # 0xe8 235 | '', # 0xe9 236 | '', # 0xea 237 | '', # 0xeb 238 | '', # 0xec 239 | '', # 0xed 240 | '', # 0xee 241 | '', # 0xef 242 | '', # 0xf0 243 | '', # 0xf1 244 | '', # 0xf2 245 | '', # 0xf3 246 | '', # 0xf4 247 | '', # 0xf5 248 | '', # 0xf6 249 | '', # 0xf7 250 | '', # 0xf8 251 | '', # 0xf9 252 | '', # 0xfa 253 | '', # 0xfb 254 | '', # 0xfc 255 | '', # 0xfd 256 | '', # 0xfe 257 | '', # 0xff 258 | ) 259 | -------------------------------------------------------------------------------- /utils/python-various/datediff.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # datediff.py 4 | # Copyright (C) 2016 Larroque Stephen 5 | # 6 | # Licensed under the MIT License (MIT) 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # 26 | #================================= 27 | # datediff 28 | # Python 2.7.11 29 | # by Stephen Larroque 30 | # License: MIT 31 | # Creation date: 2016-05-11 32 | #================================= 33 | # 34 | # Description: this scripts make the difference between the first date and all subsequent date as provided in a list of lists. The first date of a sublist is always the reference point, all the subsequent dates will be considered as happening in the future. 35 | # 36 | 37 | from __future__ import print_function 38 | 39 | __version__ = '0.1' 40 | 41 | from datetime import datetime 42 | from pprint import pprint 43 | 44 | # Parameter - EDIT ME 45 | dates_list = { 46 | 'SUBJ1': ['2014-09-12', '2015-09-15', '2015-09-23'], 47 | 'SUBJ2': ['2015-03-18', '2016-05-16', '2016-07-04'], 48 | } 49 | 50 | def compare_two_dates(ref, future, format='%Y-%m-%d'): 51 | '''Compare two dates and return the difference of days''' 52 | a = datetime.strptime(ref, format) 53 | b = datetime.strptime(future, format) 54 | return b - a 55 | 56 | # Main program 57 | res = {} 58 | datetemplate = '%Y-%m-%d' # see http://strftime.org/ 59 | for id, dlist in dates_list.items(): 60 | refdate = datetime.strptime(dlist[0], datetemplate) 61 | res[id] = [str((datetime.strptime(fdate, datetemplate) - refdate).days) + ' days' for fdate in dlist] 62 | 63 | # Display result nicely 64 | for id in dates_list.keys(): 65 | print(id + ' return date ' + dates_list[id][0] + ':') 66 | for j in xrange(1, len(dates_list[id])): 67 | print((' ' * 4) + dates_list[id][j] + ': ' + res[id][j]) 68 | -------------------------------------------------------------------------------- /utils/study-specific/helper_scripts/addcalccommands.m: -------------------------------------------------------------------------------- 1 | % Helper functions for CONN 2nd-level covariates calculation 2 | 3 | % standardize/z-transform a vector 4 | conncentervec = @(a) (a - mean(a)) / std(a); 5 | % standardize matrix 6 | conncentermat = @(a) bsxfun(@rdivide, bsxfun(@minus, a, mean(a,1)), std(a, 0, 1)); 7 | % standardize vector but skipping 0/nan values meant to say missing value 8 | conncentervecnull = @(a) (a(a>0 & a~=NaN) - mean(a(a>0 & a~=NaN))) / std(a(a>0 & a~=NaN)); 9 | % standardize vector, skipping 0/nan values and not mean centering 10 | conncentervecnullnomean = @(a) (a(a>0 & a~=NaN) / std(a>0 & a~=NaN)); 11 | -------------------------------------------------------------------------------- /utils/study-specific/helper_scripts/addpath_conn17f.m: -------------------------------------------------------------------------------- 1 | restoredefaultpath(); 2 | addpath('C:\matlab_tools\spm12'); 3 | addpath('C:\matlab_tools\spm12\matlabbatch'); % for cfg_getfile, try to type `which cfg_getfile -all` 4 | addpath('C:\matlab_tools\art-2015-10'); 5 | addpath('C:\matlab_tools\conn17f-randomize-fix'); 6 | addpath('C:\matlab_tools\helper_scripts'); 7 | fprintf('SPM12 & CONN17F and tools have been correctly added to the path!\n'); 8 | clear all; clear classes; 9 | -------------------------------------------------------------------------------- /utils/study-specific/helper_scripts/addpath_conn18b.m: -------------------------------------------------------------------------------- 1 | restoredefaultpath(); 2 | addpath('C:\matlab_tools\spm12'); 3 | addpath('C:\matlab_tools\spm12\matlabbatch'); % for cfg_getfile, try to type `which cfg_getfile -all` 4 | addpath('C:\matlab_tools\art-2015-10'); 5 | addpath('C:\matlab_tools\conn18b'); 6 | addpath('C:\matlab_tools\helper_scripts'); 7 | fprintf('SPM12 & CONN17F and tools have been correctly added to the path!\n'); 8 | clear all; clear classes; 9 | -------------------------------------------------------------------------------- /utils/study-specific/helper_scripts/addpath_spm12.m: -------------------------------------------------------------------------------- 1 | restoredefaultpath(); 2 | addpath('C:\matlab_tools\spm12'); 3 | addpath('C:\matlab_tools\spm12\matlabbatch'); % for cfg_getfile, try to type `which cfg_getfile -all` 4 | addpath('C:\matlab_tools\art-2015-10'); 5 | addpath('C:\matlab_tools\conn18b'); 6 | addpath('C:\matlab_tools\helper_scripts'); 7 | fprintf('SPM12 and tools have been correctly added to the path!\n'); 8 | clear all; clear classes; 9 | -------------------------------------------------------------------------------- /utils/study-specific/helper_scripts/addpath_spm12_fdr.m: -------------------------------------------------------------------------------- 1 | restoredefaultpath(); 2 | addpath('C:\matlab_tools\spm12_fdr'); 3 | addpath('C:\matlab_tools\spm12_fdr\matlabbatch'); % for cfg_getfile, try to type `which cfg_getfile -all` 4 | addpath('C:\matlab_tools\art-2015-10'); 5 | addpath('C:\matlab_tools\conn18b'); 6 | addpath('C:\matlab_tools\bspmview'); 7 | addpath('C:\matlab_tools\helper_scripts'); 8 | fprintf('SPM12 and tools have been correctly added to the path!\n'); 9 | clear all; clear classes; 10 | -------------------------------------------------------------------------------- /utils/study-specific/helper_scripts/addpath_spm8.m: -------------------------------------------------------------------------------- 1 | restoredefaultpath(); 2 | addpath('C:\matlab_tools\spm8'); 3 | addpath('C:\matlab_tools\spm8\matlabbatch'); 4 | addpath('C:\matlab_tools\art-2015-10'); 5 | addpath('C:\matlab_tools\conn18b'); 6 | addpath('C:\matlab_tools\helper_scripts'); 7 | fprintf('SPM8 and tools have been correctly added to the path!\n'); 8 | clear all; clear classes; 9 | -------------------------------------------------------------------------------- /utils/study-specific/helper_scripts/get_totals.m: -------------------------------------------------------------------------------- 1 | function [t, files] = get_totals(files, thr, msk) 2 | %get_totals - Returns image totals (sum over all voxels), in ml 3 | % t = get_totals 4 | % [t files] = get_totals(files, thr, msk) 5 | % GUI file-selection is used if files not specified as argument (or empty). 6 | % 7 | % If thr is given, this will be treated as an absolute threshold 8 | % (i.e. values below this will be zeroed, hence the total will better match 9 | % the GM analysed in the voxelwise stats, with the same threshold masking). 10 | % 11 | % Similarly, if msk is specified this image will be used as an explicit 12 | % mask (i.e. only non-zero mask voxels will be included). 13 | % GUI file-selection is used if msk is given as empty string (''). 14 | % [Currently, masking assumes that msk matches the voxel dimensions of each 15 | % image, and that therefore, all images have the same dimensions.] 16 | 17 | % check spm version: 18 | if exist('spm_select','file') % should be true for spm5 19 | spm5 = 1; 20 | select = @(msg) spm_select(inf, 'image', msg); 21 | elseif exist('spm_get','file') % should be true for spm2 22 | spm5 = 0; 23 | select = @(msg) spm_get(inf, 'img', msg); 24 | else 25 | error('Failed to locate spm_get or spm_select; please add SPM to Matlab path') 26 | end 27 | 28 | if ( ~exist('files', 'var') || isempty(files) ) 29 | files = select('choose images'); 30 | end 31 | if ( ~exist('thr', 'var') || isempty(thr) ) 32 | thr = -inf; % default to include everything (except NaNs) 33 | end 34 | if ~exist('msk', 'var') 35 | msk = 1; % default to include everything 36 | end 37 | if isempty(msk) 38 | msk = select('Choose mask image'); 39 | end 40 | if ischar(msk) 41 | msk = spm_vol(msk); 42 | end 43 | if isstruct(msk) 44 | msk = spm_read_vols(msk); 45 | end 46 | msk = msk ~= 0; 47 | 48 | vols = spm_vol(files); 49 | N = length(vols); 50 | 51 | t = zeros(N,1); 52 | for n = 1:N 53 | vsz = abs(det(vols(n).mat)); 54 | img = spm_read_vols(vols(n)); 55 | img = img .* msk; 56 | t(n) = sum(img(img > thr)) * vsz / 1000; % vsz in mm^3 (= 0.001 ml) 57 | end 58 | -------------------------------------------------------------------------------- /utils/study-specific/sleep/regex_files.m: -------------------------------------------------------------------------------- 1 | function filesList = regex_files(dirpath, regex) 2 | % filesList = regex_files(dirpath, regex) 3 | % Extract files from a directory using regular expression 4 | 5 | % Get all files in directory 6 | filesList = dir(dirpath); 7 | % Filter out directories 8 | filesList = filesList(~[filesList.isdir]); 9 | % Use regular expression to filter only the files we want 10 | filesList = regexp({filesList.name}, regex, 'match'); 11 | % Concatenate the filenames in a cellarray 12 | %filesList = {filesList.name}; 13 | % Remove empty matches 14 | filesList = [filesList{:}]; 15 | % Prepend the full path before each filename (so that we get absolute paths) 16 | if length(filesList) > 0 17 | filesList = cellfun(@(f) fullfile(dirpath, f), filesList, 'UniformOutput', false); 18 | end 19 | % Return directly the string instead of the cell array if there is only one file matched 20 | if length(filesList) == 1 21 | filesList = filesList{1}; 22 | end 23 | end 24 | --------------------------------------------------------------------------------