diff --git a/.gitignore b/.gitignore index d45e56933..582c91839 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ settings.json .datalad **/*.tsv *.png -*.json **/*.pyc *.DS_Store diff --git a/bids_examples/attention/attention_prov.json b/bids_examples/attention/attention_prov.json new file mode 100644 index 000000000..e3593fb29 --- /dev/null +++ b/bids_examples/attention/attention_prov.json @@ -0,0 +1,875 @@ +{ + "@context": "https://raw.githubusercontent.com/cmaumet/BIDS-prov/context-type-indexing/context.json", + "@id": "http://example.org/ds00000X", + "generatedAt": "2020-03-10T10:00:00", + "wasGeneratedBy": { + "@id": "INRIA", + "@type": "Project", + "startedAt": "2016-09-01T10:00:00", + "wasAssociatedWith": { + "@id": "NIH", + "@type": "Organization", + "hadRole": "Funding" + } + }, + "records": { + "prov:Agent": [ + { + "@id": "RRID:SCR_007037", + "@type": "prov:SoftwareAgent", + "label": "SPM" + } + ], + "prov:Activity": [ + { + "@id": "niiri:cfg_basicio.file_dir.dir_ops.cfg_mkdir._1rkywtmnYZw", + "label": "file_dir.dir_ops.cfg_mkdir._1", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "parent", + "cellstr(data_path);" + ], + [ + "name", + "'GLM';" + ] + ] + }, + { + "@id": "niiri:spm.stats.fmri_spec._2TXfyAojpvI", + "label": "stats.fmri_spec._2", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "dir", + "cellstr(fullfile(data_path,'GLM'));" + ], + [ + "timing.units", + "'scans';" + ], + [ + "timing.RT", + "3.22;" + ], + [ + "sess.scans", + "cellstr(f);" + ], + [ + "sess.hpf", + "192;" + ] + ] + }, + { + "@id": "niiri:spm.stats.fmri_est.spmmat_3RDitMXCFql", + "label": "stats.fmri_est.spmmat_3", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(fullfile(data_path,'GLM','SPM.mat'));" + ] + ] + }, + { + "@id": "niiri:spm.stats.con._4FiSgErwgjp", + "label": "stats.con._4", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "spmmat", + "cellstr(fullfile(data_path,'GLM','SPM.mat'));" + ], + [ + "fcon.name", + "'Effects of interest';" + ], + [ + "fcon.weights", + "[eye(3), zeros(3,4)];" + ], + [ + "tcon.name", + "'Attention';" + ], + [ + "tcon.weights", + "[0, -1, 1, 0, 0, 0, 0];" + ], + [ + "tcon.name", + "'Motion';" + ], + [ + "tcon.weights", + "[-2, 1, 1, 0, 0, 0, 0];" + ] + ] + }, + { + "@id": "niiri:spm._5OzYosroaGt", + "label": "_5", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "results.spmmat", + "cellstr(fullfile(data_path,'GLM','SPM.mat'));" + ], + [ + "conspec.contrasts", + "3;" + ], + [ + "conspec.threshdesc", + "'FWE';" + ], + [ + "conspec.thresh", + "0.05;" + ], + [ + "conspec.extent", + "0;" + ], + [ + "results.print", + "false;" + ], + [ + "voi.spmmat", + "cellstr(fullfile(data_path,'GLM','SPM.mat'));" + ], + [ + "voi.adjust", + "1;" + ], + [ + "voi.session", + "1;" + ], + [ + "voi.name", + "'V2';" + ], + [ + "spm.spmmat", + "{''};" + ], + [ + "spm.contrast", + "3;" + ], + [ + "spm.threshdesc", + "'FWE';" + ], + [ + "spm.thresh", + "0.05;" + ], + [ + "spm.extent", + "0;" + ], + [ + "sphere.centre", + "[15, -78, -9];" + ], + [ + "sphere.radius", + "6;" + ], + [ + "local.spm", + "1;" + ], + [ + "voi.expression", + "'i1 & i2';" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.spmmat_6xRzygsRBUM", + "label": "stats.ppi.spmmat_6", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(fullfile(data_path,'GLM','SPM.mat'));" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.type.ppi.voi_7ALyAIETytn", + "label": "stats.ppi.type.ppi.voi_7", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(fullfile(data_path,'GLM','VOI_V2_1.mat'));" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.type.ppi.u_8iGETPWhaZF", + "label": "stats.ppi.type.ppi.u_8", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "[2, 1, -1;, 3, 1, 1];" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.name_9hbhRUFczQW", + "label": "stats.ppi.name_9", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "'V2x(Att-NoAtt)';" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.disp_10fKOgOQBPsv", + "label": "stats.ppi.disp_10", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "0;" + ] + ] + }, + { + "@id": "niiri:cfg_basicio.file_dir.dir_ops.cfg_mkdir.parent_12GbkQgzeGwU", + "label": "dir_ops.cfg_mkdir.parent_12", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(data_path);" + ] + ] + }, + { + "@id": "niiri:cfg_basicio.file_dir.dir_ops.cfg_mkdir.name_14BzStpTjsTO", + "label": "dir_ops.cfg_mkdir.name_14", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "'PPI';" + ] + ] + }, + { + "@id": "niiri:spm.stats.fmri_spec.dir_17ORVqcwCMFZ", + "label": "stats.fmri_spec.dir_17", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(fullfile(data_path,'PPI'));" + ] + ] + }, + { + "@id": "niiri:spm.stats.fmri_spec.timing.units_20SByPYCIJrG", + "label": "stats.fmri_spec.timing.units_20", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "'scans';" + ] + ] + }, + { + "@id": "niiri:spm.stats.fmri_spec.timing.RT_23vNekAsahSi", + "label": "stats.fmri_spec.timing.RT_23", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "3.22;" + ] + ] + }, + { + "@id": "niiri:spm.stats.fmri_spec.sess.scans_26YxsrhYtTWR", + "label": "stats.fmri_spec.sess.scans_26", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(f);" + ] + ] + }, + { + "@id": "niiri:spm.stats.fmri_spec.sess.multi_reg_29CxuoxCneUO", + "label": "stats.fmri_spec.sess.multi_reg_29", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "{..." + ] + ] + }, + { + "@id": "niiri:spm.stats.fmri_spec.sess.hpf_32PHyafHCZjM", + "label": "stats.fmri_spec.sess.hpf_32", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "192;" + ] + ] + }, + { + "@id": "niiri:spm.stats.fmri_est.spmmat_36kKBkYPIWhD", + "label": "stats.fmri_est.spmmat_36", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(fullfile(data_path,'PPI','SPM.mat'));" + ] + ] + }, + { + "@id": "niiri:spm.stats.con.spmmat_41RVttxyJitW", + "label": "stats.con.spmmat_41", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(fullfile(data_path,'PPI','SPM.mat'));" + ] + ] + }, + { + "@id": "niiri:spm.stats.con.consess1.tcon.name_46YCLcMpZODX", + "label": "stats.con.consess{1}.tcon.name_46", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "'PPI-Interaction';" + ] + ] + }, + { + "@id": "niiri:spm.stats.con.consess1.tcon.weights_51wpPZRZmINd", + "label": "con.consess{1}.tcon.weights_51", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "[1, 0, 0, 0, 0, 0, 0];" + ] + ] + }, + { + "@id": "niiri:spm.stats.results.spmmat_57TKhnUuzZYV", + "label": "stats.results.spmmat_57", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(fullfile(data_path,'PPI','SPM.mat'));" + ] + ] + }, + { + "@id": "niiri:spm.stats.results.conspec.contrasts_63mJVGSccOve", + "label": "results.conspec.contrasts_63", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "1;" + ] + ] + }, + { + "@id": "niiri:spm.stats.results.conspec.threshdesc_69LYVTDIotUL", + "label": "results.conspec.threshdesc_69", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "'none';" + ] + ] + }, + { + "@id": "niiri:spm.stats.results.conspec.thresh_75gFXBJEvYLZ", + "label": "stats.results.conspec.thresh_75", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "0.01;" + ] + ] + }, + { + "@id": "niiri:spm.stats.results.conspec.extent_81zfPoLeoEpo", + "label": "stats.results.conspec.extent_81", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "3;" + ] + ] + }, + { + "@id": "niiri:spm.stats.results.print_87ERHFUEGIbk", + "label": "stats.results.print_87", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "false;" + ] + ] + }, + { + "@id": "niiri:spm.util.voi.spmmat_88nMkRBojgsD", + "label": "util.voi.spmmat_88", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(fullfile(data_path,'GLM','SPM.mat'));" + ] + ] + }, + { + "@id": "niiri:spm.util.voi.adjust_89krodWuBtoY", + "label": "util.voi.adjust_89", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "1;" + ] + ] + }, + { + "@id": "niiri:spm.util.voi.session_90YgttsPjhPI", + "label": "util.voi.session_90", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "1;" + ] + ] + }, + { + "@id": "niiri:spm.util.voi.name_91JQFWvzvcun", + "label": "util.voi.name_91", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "'V5';" + ] + ] + }, + { + "@id": "niiri:spm.util.voi.roi1.spm.spmmat_92BnwKoDHUwq", + "label": "util.voi.roi{1}.spm.spmmat_92", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "{''};" + ] + ] + }, + { + "@id": "niiri:spm.util.voi.roi1.spm.contrast_93LKOpIXTwHR", + "label": "util.voi.roi{1}.spm.contrast_93", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "3;" + ] + ] + }, + { + "@id": "niiri:spm.util.voi.roi1.spm.threshdesc_94oKRphVzlWh", + "label": "util.voi.roi{1}.spm.threshdesc_94", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "'FWE';" + ] + ] + }, + { + "@id": "niiri:spm.util.voi.roi1.spm.thresh_95sEYsgKBoHk", + "label": "util.voi.roi{1}.spm.thresh_95", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "0.001;" + ] + ] + }, + { + "@id": "niiri:spm.util.voi.roi1.spm.extent_96YLYszYFFtF", + "label": "util.voi.roi{1}.spm.extent_96", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "3;" + ] + ] + }, + { + "@id": "niiri:spm.util.voi.roi2.sphere.centre_97NeuzCndmln", + "label": "util.voi.roi{2}.sphere.centre_97", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "[39, -72, 0];" + ] + ] + }, + { + "@id": "niiri:spm.util.voi.roi2.sphere.radius_98qvybdYlcEe", + "label": "util.voi.roi{2}.sphere.radius_98", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "6;" + ] + ] + }, + { + "@id": "niiri:spm.util.voi.roi2.sphere.move.local.spm_99reIsWsIGna", + "label": "voi.roi{2}.sphere.move.local.spm_99", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "1;" + ] + ] + }, + { + "@id": "niiri:spm.util.voi.expression_100rBFaDdnnnZ", + "label": "util.voi.expression_100", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "'i1 & i2';" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.spmmat_102QmIhnDkmyJ", + "label": "stats.ppi.spmmat_102", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(fullfile(data_path,'GLM','SPM.mat'));" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.type.ppi.voi_104MRRTnRSvRp", + "label": "stats.ppi.type.ppi.voi_104", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(fullfile(data_path,'GLM','VOI_V2_1.mat'));" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.type.ppi.u_106QozPbpgqqv", + "label": "stats.ppi.type.ppi.u_106", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "[2, 1, 1];" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.name_108bvAFeoaSMU", + "label": "stats.ppi.name_108", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "'V2xNoAtt';" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.disp_110GQFCkHeIYG", + "label": "stats.ppi.disp_110", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "0;" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.spmmat_113ILWxgcWXdz", + "label": "stats.ppi.spmmat_113", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(fullfile(data_path,'GLM','SPM.mat'));" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.type.ppi.voi_116BdZbpAdTDK", + "label": "stats.ppi.type.ppi.voi_116", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(fullfile(data_path,'GLM','VOI_V2_1.mat'));" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.type.ppi.u_119WelCyvLEPK", + "label": "stats.ppi.type.ppi.u_119", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "[3, 1, 1];" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.name_122ZYpmPqNvNQ", + "label": "stats.ppi.name_122", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "'V2xAtt';" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.disp_125ZvEIEQOmmo", + "label": "stats.ppi.disp_125", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "0;" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.spmmat_129oKClkwAORD", + "label": "stats.ppi.spmmat_129", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(fullfile(data_path,'GLM','SPM.mat'));" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.type.ppi.voi_133YDMfeQxzjG", + "label": "stats.ppi.type.ppi.voi_133", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(fullfile(data_path,'GLM','VOI_V5_1.mat'));" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.type.ppi.u_137HTWEkQlCUU", + "label": "stats.ppi.type.ppi.u_137", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "[2, 1, 1];" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.name_141wVBHLFEztT", + "label": "stats.ppi.name_141", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "'V5xNoAtt';" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.disp_145OGdKxkyiwV", + "label": "stats.ppi.disp_145", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "0;" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.spmmat_150PifFrQfqpS", + "label": "stats.ppi.spmmat_150", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(fullfile(data_path,'GLM','SPM.mat'));" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.type.ppi.voi_155KnnlOtqrcy", + "label": "stats.ppi.type.ppi.voi_155", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "cellstr(fullfile(data_path,'GLM','VOI_V5_1.mat'));" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.type.ppi.u_160fknGYLiSgY", + "label": "stats.ppi.type.ppi.u_160", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "[3, 1, 1];" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.name_165cdbeETVDzU", + "label": "stats.ppi.name_165", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "'V5xAtt';" + ] + ] + }, + { + "@id": "niiri:spm.stats.ppi.disp_170OHNjMkynfK", + "label": "stats.ppi.disp_170", + "used": [], + "wasAssociatedWith": "RRID:SCR_007037", + "attributes": [ + [ + "", + "0;" + ] + ] + } + ], + "prov:Entity": [] + } +} \ No newline at end of file diff --git a/bids_examples/attention/func/snffM00587_0016.hdr b/bids_examples/attention/func/snffM00587_0016.hdr new file mode 100644 index 000000000..f48142be9 Binary files /dev/null and b/bids_examples/attention/func/snffM00587_0016.hdr differ diff --git a/bids_examples/attention/func/snffM00587_0016.img b/bids_examples/attention/func/snffM00587_0016.img new file mode 100644 index 000000000..a1452faab Binary files /dev/null and b/bids_examples/attention/func/snffM00587_0016.img differ diff --git a/bids_examples/attention/func/snffM00587_0017.hdr b/bids_examples/attention/func/snffM00587_0017.hdr new file mode 100644 index 000000000..f48142be9 Binary files /dev/null and b/bids_examples/attention/func/snffM00587_0017.hdr differ diff --git a/bids_examples/attention/func/snffM00587_0017.img b/bids_examples/attention/func/snffM00587_0017.img new file mode 100644 index 000000000..113b4b977 Binary files /dev/null and b/bids_examples/attention/func/snffM00587_0017.img differ diff --git a/bids_examples/attention/func/snffM00587_0018.hdr b/bids_examples/attention/func/snffM00587_0018.hdr new file mode 100644 index 000000000..f48142be9 Binary files /dev/null and b/bids_examples/attention/func/snffM00587_0018.hdr differ diff --git a/bids_examples/attention/func/snffM00587_0018.img b/bids_examples/attention/func/snffM00587_0018.img new file mode 100644 index 000000000..e22225287 Binary files /dev/null and b/bids_examples/attention/func/snffM00587_0018.img differ diff --git a/bids_examples/attention/func/snffM00587_0019.hdr b/bids_examples/attention/func/snffM00587_0019.hdr new file mode 100644 index 000000000..f48142be9 Binary files /dev/null and b/bids_examples/attention/func/snffM00587_0019.hdr differ diff --git a/bids_examples/attention/func/snffM00587_0019.img b/bids_examples/attention/func/snffM00587_0019.img new file mode 100644 index 000000000..4c9bd1985 Binary files /dev/null and b/bids_examples/attention/func/snffM00587_0019.img differ diff --git a/bids_examples/attention/ppi_spm12_batch.m b/bids_examples/attention/ppi_spm12_batch.m new file mode 100644 index 000000000..3f2014bf3 --- /dev/null +++ b/bids_examples/attention/ppi_spm12_batch.m @@ -0,0 +1,284 @@ +% This batch script analyses the Attention to Visual Motion fMRI dataset +% available from the SPM website using PPI: +% http://www.fil.ion.ucl.ac.uk/spm/data/attention/ +% as described in the SPM manual: +% http://www.fil.ion.ucl.ac.uk/spm/doc/manual.pdf#Chap:data:ppi +%__________________________________________________________________________ +% Copyright (C) 2014 Wellcome Trust Centre for Neuroimaging + +% Guillaume Flandin & Darren Gitelman +% $Id: ppi_spm12_batch.m 11 2014-09-29 18:54:09Z guillaume $ + +% Directory containing the Attention data +%-------------------------------------------------------------------------- +data_path = fileparts(mfilename('fullpath')); +if isempty(data_path), data_path = pwd; end +fprintf('%-40s:', 'Downloading Attention dataset...'); +urlwrite('http://www.fil.ion.ucl.ac.uk/spm/download/data/attention/attention.zip','attention.zip'); +unzip(fullfile(data_path,'attention.zip')); +data_path = fullfile(data_path,'attention'); +fprintf(' %30s\n', '...done'); + +% Initialise SPM +%-------------------------------------------------------------------------- +spm('Defaults','fMRI'); +spm_jobman('initcfg'); +% spm_get_defaults('cmdline',true); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% GLM SPECIFICATION, ESTIMATION, INFERENCE, RESULTS +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Load factors +%-------------------------------------------------------------------------- +factors = load(fullfile(data_path,'factors.mat')); + +clear matlabbatch + +% OUTPUT DIRECTORY +%========================================================================== +matlabbatch{1}.cfg_basicio.file_dir.dir_ops.cfg_mkdir.parent = cellstr(data_path); +matlabbatch{1}.cfg_basicio.file_dir.dir_ops.cfg_mkdir.name = 'GLM'; + +% MODEL SPECIFICATION +%========================================================================== + +% Directory +%-------------------------------------------------------------------------- +matlabbatch{2}.spm.stats.fmri_spec.dir = cellstr(fullfile(data_path,'GLM')); + +% Timing +%-------------------------------------------------------------------------- +matlabbatch{2}.spm.stats.fmri_spec.timing.units = 'scans'; +matlabbatch{2}.spm.stats.fmri_spec.timing.RT = 3.22; + +% Session +%-------------------------------------------------------------------------- +f = spm_select('FPList', fullfile(data_path,'functional'), '^snf.*\.img$'); +matlabbatch{2}.spm.stats.fmri_spec.sess.scans = cellstr(f); +matlabbatch{2}.spm.stats.fmri_spec.sess.cond(1).name = 'Stationary'; +matlabbatch{2}.spm.stats.fmri_spec.sess.cond(1).onset = factors.stat; +matlabbatch{2}.spm.stats.fmri_spec.sess.cond(1).duration = 10; +matlabbatch{2}.spm.stats.fmri_spec.sess.cond(2).name = 'No-Attention'; +matlabbatch{2}.spm.stats.fmri_spec.sess.cond(2).onset = factors.natt; +matlabbatch{2}.spm.stats.fmri_spec.sess.cond(2).duration = 10; +matlabbatch{2}.spm.stats.fmri_spec.sess.cond(3).name = 'Attention'; +matlabbatch{2}.spm.stats.fmri_spec.sess.cond(3).onset = factors.att; +matlabbatch{2}.spm.stats.fmri_spec.sess.cond(3).duration = 10; + +% Block effect to model the different sessions +%-------------------------------------------------------------------------- +matlabbatch{2}.spm.stats.fmri_spec.sess.regress(1).name = 'Session 1'; +matlabbatch{2}.spm.stats.fmri_spec.sess.regress(1).val = kron([1 0 0 0]',ones(90,1)); +matlabbatch{2}.spm.stats.fmri_spec.sess.regress(2).name = 'Session 2'; +matlabbatch{2}.spm.stats.fmri_spec.sess.regress(2).val = kron([0 1 0 0]',ones(90,1)); +matlabbatch{2}.spm.stats.fmri_spec.sess.regress(3).name = 'Session 3'; +matlabbatch{2}.spm.stats.fmri_spec.sess.regress(3).val = kron([0 0 1 0]',ones(90,1)); + +% High-pass filter +%-------------------------------------------------------------------------- +matlabbatch{2}.spm.stats.fmri_spec.sess.hpf = 192; + +% MODEL ESTIMATION +%========================================================================== +matlabbatch{3}.spm.stats.fmri_est.spmmat = cellstr(fullfile(data_path,'GLM','SPM.mat')); + +% INFERENCE +%========================================================================== +matlabbatch{4}.spm.stats.con.spmmat = cellstr(fullfile(data_path,'GLM','SPM.mat')); +matlabbatch{4}.spm.stats.con.consess{1}.fcon.name = 'Effects of interest'; +matlabbatch{4}.spm.stats.con.consess{1}.fcon.weights = [eye(3) zeros(3,4)]; +matlabbatch{4}.spm.stats.con.consess{2}.tcon.name = 'Attention'; +matlabbatch{4}.spm.stats.con.consess{2}.tcon.weights = [0 -1 1 0 0 0 0]; +matlabbatch{4}.spm.stats.con.consess{3}.tcon.name = 'Motion'; +matlabbatch{4}.spm.stats.con.consess{3}.tcon.weights = [-2 1 1 0 0 0 0]; + +% RESULTS +%========================================================================== +%matlabbatch{5}.spm.stats.results.spmmat = cellstr(fullfile(data_path,'GLM','SPM.mat')); +%matlabbatch{5}.spm.stats.results.conspec.contrasts = 3; +%matlabbatch{5}.spm.stats.results.conspec.threshdesc = 'FWE'; +%matlabbatch{5}.spm.stats.results.conspec.thresh = 0.05; +%matlabbatch{5}.spm.stats.results.conspec.extent = 0; +%matlabbatch{5}.spm.stats.results.print = false; + +% VOI: EXTRACTING TIME SERIES: V2 [15 -78 -9] +%========================================================================== +matlabbatch{5}.spm.util.voi.spmmat = cellstr(fullfile(data_path,'GLM','SPM.mat')); +matlabbatch{5}.spm.util.voi.adjust = 1; +matlabbatch{5}.spm.util.voi.session = 1; +matlabbatch{5}.spm.util.voi.name = 'V2'; +matlabbatch{5}.spm.util.voi.roi{1}.spm.spmmat = {''}; +matlabbatch{5}.spm.util.voi.roi{1}.spm.contrast = 3; +matlabbatch{5}.spm.util.voi.roi{1}.spm.threshdesc = 'FWE'; +matlabbatch{5}.spm.util.voi.roi{1}.spm.thresh = 0.05; +matlabbatch{5}.spm.util.voi.roi{1}.spm.extent = 0; +matlabbatch{5}.spm.util.voi.roi{2}.sphere.centre = [15 -78 -9]; +matlabbatch{5}.spm.util.voi.roi{2}.sphere.radius = 6; +matlabbatch{5}.spm.util.voi.roi{2}.sphere.move.local.spm = 1; +matlabbatch{5}.spm.util.voi.expression = 'i1 & i2'; + +spm_jobman('run',matlabbatch); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% PSYCHO-PHYSIOLOGIC INTERACTION +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +clear matlabbatch + +% GENERATE PPI STRUCTURE +%========================================================================== +matlabbatch{1}.spm.stats.ppi.spmmat = cellstr(fullfile(data_path,'GLM','SPM.mat')); +matlabbatch{1}.spm.stats.ppi.type.ppi.voi = cellstr(fullfile(data_path,'GLM','VOI_V2_1.mat')); +matlabbatch{1}.spm.stats.ppi.type.ppi.u = [2 1 -1; 3 1 1]; +matlabbatch{1}.spm.stats.ppi.name = 'V2x(Att-NoAtt)'; +matlabbatch{1}.spm.stats.ppi.disp = 0; + +% OUTPUT DIRECTORY +%========================================================================== +matlabbatch{2}.cfg_basicio.file_dir.dir_ops.cfg_mkdir.parent = cellstr(data_path); +matlabbatch{2}.cfg_basicio.file_dir.dir_ops.cfg_mkdir.name = 'PPI'; + +% MODEL SPECIFICATION +%========================================================================== + +% Directory +%-------------------------------------------------------------------------- +matlabbatch{3}.spm.stats.fmri_spec.dir = cellstr(fullfile(data_path,'PPI')); + +% Timing +%-------------------------------------------------------------------------- +matlabbatch{3}.spm.stats.fmri_spec.timing.units = 'scans'; +matlabbatch{3}.spm.stats.fmri_spec.timing.RT = 3.22; + +% Session +%-------------------------------------------------------------------------- +f = spm_select('FPList', fullfile(data_path,'functional'), '^snf.*\.img$'); +matlabbatch{3}.spm.stats.fmri_spec.sess.scans = cellstr(f); + +% Regressors +%-------------------------------------------------------------------------- +matlabbatch{3}.spm.stats.fmri_spec.sess.multi_reg = {... + fullfile(data_path,'GLM','PPI_V2x(Att-NoAtt).mat');... + fullfile(data_path,'multi_block_regressors.mat')}; + +% High-pass filter +%-------------------------------------------------------------------------- +matlabbatch{3}.spm.stats.fmri_spec.sess.hpf = 192; + +% MODEL ESTIMATION +%========================================================================== +matlabbatch{4}.spm.stats.fmri_est.spmmat = cellstr(fullfile(data_path,'PPI','SPM.mat')); + +% INFERENCE +%========================================================================== +matlabbatch{5}.spm.stats.con.spmmat = cellstr(fullfile(data_path,'PPI','SPM.mat')); +matlabbatch{5}.spm.stats.con.consess{1}.tcon.name = 'PPI-Interaction'; +matlabbatch{5}.spm.stats.con.consess{1}.tcon.weights = [1 0 0 0 0 0 0]; + +% RESULTS +%========================================================================== +matlabbatch{6}.spm.stats.results.spmmat = cellstr(fullfile(data_path,'PPI','SPM.mat')); +matlabbatch{6}.spm.stats.results.conspec.contrasts = 1; +matlabbatch{6}.spm.stats.results.conspec.threshdesc = 'none'; +matlabbatch{6}.spm.stats.results.conspec.thresh = 0.01; +matlabbatch{6}.spm.stats.results.conspec.extent = 3; +matlabbatch{6}.spm.stats.results.print = false; + +spm_jobman('run',matlabbatch); + +% JUMP TO V5 AND OVERLAY ON A STRUCTURAL IMAGE +%-------------------------------------------------------------------------- +spm_mip_ui('SetCoords',[39 -72 0]); +spm_sections(xSPM,findobj(spm_figure('FindWin','Interactive'),'Tag','hReg'),... + fullfile(data_path,'structural','nsM00587_0002.img')); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% PSYCHO-PHYSIOLOGIC INTERACTION GRAPH +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +clear matlabbatch + +% VOI: EXTRACTING TIME SERIES: V5 [39 -72 0] +%========================================================================== +matlabbatch{1}.spm.util.voi.spmmat = cellstr(fullfile(data_path,'GLM','SPM.mat')); +matlabbatch{1}.spm.util.voi.adjust = 1; +matlabbatch{1}.spm.util.voi.session = 1; +matlabbatch{1}.spm.util.voi.name = 'V5'; +matlabbatch{1}.spm.util.voi.roi{1}.spm.spmmat = {''}; +matlabbatch{1}.spm.util.voi.roi{1}.spm.contrast = 3; +matlabbatch{1}.spm.util.voi.roi{1}.spm.threshdesc = 'FWE'; +matlabbatch{1}.spm.util.voi.roi{1}.spm.thresh = 0.001; +matlabbatch{1}.spm.util.voi.roi{1}.spm.extent = 3; +matlabbatch{1}.spm.util.voi.roi{2}.sphere.centre = [39 -72 0]; +matlabbatch{1}.spm.util.voi.roi{2}.sphere.radius = 6; +matlabbatch{1}.spm.util.voi.roi{2}.sphere.move.local.spm = 1; +matlabbatch{1}.spm.util.voi.expression = 'i1 & i2'; + +% GENERATE PPI STRUCTURE: V2xNoAtt +%========================================================================== +matlabbatch{2}.spm.stats.ppi.spmmat = cellstr(fullfile(data_path,'GLM','SPM.mat')); +matlabbatch{2}.spm.stats.ppi.type.ppi.voi = cellstr(fullfile(data_path,'GLM','VOI_V2_1.mat')); +matlabbatch{2}.spm.stats.ppi.type.ppi.u = [2 1 1]; +matlabbatch{2}.spm.stats.ppi.name = 'V2xNoAtt'; +matlabbatch{2}.spm.stats.ppi.disp = 0; + +% GENERATE PPI STRUCTURE: V2xAtt +%========================================================================== +matlabbatch{3}.spm.stats.ppi.spmmat = cellstr(fullfile(data_path,'GLM','SPM.mat')); +matlabbatch{3}.spm.stats.ppi.type.ppi.voi = cellstr(fullfile(data_path,'GLM','VOI_V2_1.mat')); +matlabbatch{3}.spm.stats.ppi.type.ppi.u = [3 1 1]; +matlabbatch{3}.spm.stats.ppi.name = 'V2xAtt'; +matlabbatch{3}.spm.stats.ppi.disp = 0; + +% GENERATE PPI STRUCTURE: V5xNoAtt +%========================================================================== +matlabbatch{4}.spm.stats.ppi.spmmat = cellstr(fullfile(data_path,'GLM','SPM.mat')); +matlabbatch{4}.spm.stats.ppi.type.ppi.voi = cellstr(fullfile(data_path,'GLM','VOI_V5_1.mat')); +matlabbatch{4}.spm.stats.ppi.type.ppi.u = [2 1 1]; +matlabbatch{4}.spm.stats.ppi.name = 'V5xNoAtt'; +matlabbatch{4}.spm.stats.ppi.disp = 0; + +% GENERATE PPI STRUCTURE: V5xAtt +%========================================================================== +matlabbatch{5}.spm.stats.ppi.spmmat = cellstr(fullfile(data_path,'GLM','SPM.mat')); +matlabbatch{5}.spm.stats.ppi.type.ppi.voi = cellstr(fullfile(data_path,'GLM','VOI_V5_1.mat')); +matlabbatch{5}.spm.stats.ppi.type.ppi.u = [3 1 1]; +matlabbatch{5}.spm.stats.ppi.name = 'V5xAtt'; +matlabbatch{5}.spm.stats.ppi.disp = 0; + +spm_jobman('run',matlabbatch); + +% PLOT THE PPI INTERACTION VECTORS UNDER EACH ATTENTIONAL CONDITION +%========================================================================== +load('PPI_V2xNoAtt.mat'); PPI2NATT = PPI; +load('PPI_V2xAtt.mat'); PPI2ATT = PPI; +load('PPI_V5xNoAtt.mat'); PPI5NATT = PPI; +load('PPI_V5xAtt.mat'); PPI5ATT = PPI; + +figure; +plot(PPI2NATT.ppi,PPI5NATT.ppi,'k.'); +hold on +plot(PPI2ATT.ppi,PPI5ATT.ppi,'r.'); + +% BEST FIT LINES: NO ATTENTION +%-------------------------------------------------------------------------- +x = PPI2NATT.ppi(:); +x = [x, ones(size(x))]; +y = PPI5NATT.ppi(:); +B = x\y; +y1 = B(1)*x(:,1)+B(2); +plot(x(:,1),y1,'k-'); + +% BEST FIT LINES: ATTENTION +%-------------------------------------------------------------------------- +x = PPI2ATT.ppi(:); +x = [x, ones(size(x))]; +y = PPI5ATT.ppi(:); +B = x\y; +y1 = B(1)*x(:,1)+B(2); +plot(x(:,1),y1,'r-'); + +legend('No Attention','Attention') +xlabel('V2 activity') +ylabel('V5 response') +title('Psychophysiologic Interaction') diff --git a/bids_prov/spm_parser.py b/bids_prov/spm_parser.py index 624bb21e9..e7aeb53b3 100644 --- a/bids_prov/spm_parser.py +++ b/bids_prov/spm_parser.py @@ -52,13 +52,6 @@ def preproc_param_value(val): return val -def readlines(filename): - with open(filename) as fd: - for line in fd: - if line.startswith("matlabbatch"): - yield line[:-1] # remove "\n" - - def group_lines(lines): """Group line by their activity id @@ -82,16 +75,19 @@ def group_lines(lines): {'file_ops.file_move._1': ['call', 'different.call']} """ res = defaultdict(list) + for line in lines: - a = re.search(r"\{\d+\}", line) + a = re.search(r"matlabbatch(\{\d+\})", line) if a: - g = a.group()[1:-1] + g = int(a.group(1)[1:-1]) + if res and max(res.keys()) > g: + g += max(res.keys()) res[g].append(line[a.end() + 1 :]) new_res = dict() for k, v in res.items(): common_prefix = os.path.commonprefix([_.split(" = ")[0] for _ in v]) - new_key = f"{common_prefix}_{k}" + new_key = f"{common_prefix}_{str(k)}" new_res[new_key] = [_[len(common_prefix) :] for _ in v] return new_res @@ -106,7 +102,7 @@ def get_records(task_groups: dict, records=defaultdict(list)): """ entities_ids = set() for activity_name, values in task_groups.items(): - activity_id = "niiri:" + activity_name + get_id() + activity_id = "niiri:" + re.sub(r"[\{\}]", "", activity_name) + get_id() activity = { "@id": activity_id, "label": format_activity_name(activity_name), @@ -215,8 +211,8 @@ def spm_to_bids_prov(filenames, output_file, context_url): graph = conf.get_empty_graph(context_url=context_url) - lines = readlines(filename) - tasks = group_lines(lines) + with open(filename) as fd: + tasks = group_lines(fd) records = get_records(tasks) graph["records"].update(records)