Skip to content

Commit

Permalink
Merge pull request #584 from Remi-Gau/parametric_and_f_test
Browse files Browse the repository at this point in the history
[ENH] add F test
  • Loading branch information
Remi-Gau authored May 25, 2022
2 parents 89eef2c + 7edae94 commit d14cdca
Show file tree
Hide file tree
Showing 63 changed files with 819 additions and 221 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/run_system_tests_matlab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ jobs:
- name: Copy Macs toolbox to SPM inputs_folder
run: cp -rv lib/MACS spm12/toolbox/MACS

- name: Prepare data
run: |
inputs_folder='demos/MoAE/inputs/'
mkdir $inputs_folder
curl http://www.fil.ion.ucl.ac.uk/spm/download/data/MoAEpilot/MoAEpilot.bids.zip --output $inputs_folder'MoAEpilot.zip'
unzip $inputs_folder'MoAEpilot.zip' -d $inputs_folder
mv $inputs_folder/MoAEpilot $inputs_folder/raw
- name: Run commands
uses: matlab-actions/run-command@v1.0.1
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/system_tests_matlab.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

addpath(fullfile(root_dir, 'spm12'));

cd demos/MoAE;
download_moae_ds(true);

cd(fullfile(root_dir, 'manualTests'));

run test_moae;
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<!-- markdown-link-check-disable -->

<!-- .. only:: html -->

[![Documentation Status: stable](https://readthedocs.org/projects/cpp_spm/badge/?version=stable)](https://cpp_spm.readthedocs.io/en/stable/?badge=stable)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/cpp-lln-lab/CPP_SPM/dev)
[![miss_hit_quality](https://github.com/cpp-lln-lab/CPP_SPM/actions/workflows/miss_hit_quality.yml/badge.svg)](https://github.com/cpp-lln-lab/CPP_SPM/actions/workflows/miss_hit_quality.yml)
Expand Down Expand Up @@ -102,8 +104,8 @@ filenames.
### Statistics

The model specification are set up using the
[BIDS stats model](https://bids-standard.github.io/stats-models/intro.html) and
can be used to perform:
[BIDS stats model](https://bids-standard.github.io/stats-models/) and can be
used to perform:

- whole GLM at the subject level
- whole brain GLM at the group level à la SPM (meaning using a summary
Expand Down
2 changes: 1 addition & 1 deletion cpp_spm.m
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ function detectCppSpm()
for i = 1:numel(workflowsDir)
fprintf(' * %s\n', fullfile(workflowsDir{i}, '..', '..'));
end
error('Remove all but one with ''pathtool''' .\ n'); % or ''spm_rmpath
error('Remove all but one with ''pathtool''.\n'); % or ''spm_rmpath

end
end
Expand Down
4 changes: 1 addition & 3 deletions demos/face_repetition/face_rep_02_stats.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
% (C) Copyright 2019 Remi Gau

% TODO
% - compute the relevant contrasts
% - compute motion effect
% - run parametric model

clear;
Expand All @@ -21,7 +19,7 @@
opt = face_rep_get_option_results();
opt.space = 'IXI549Space';

bidsFFX('specifyAndEstimate', opt);
% bidsFFX('specifyAndEstimate', opt);
bidsFFX('contrasts', opt);

bidsResults(opt);
10 changes: 8 additions & 2 deletions demos/face_repetition/face_rep_get_option_results.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
'model-faceRepetition_smdl.json');

% Specify the result to compute
opt.results = defaultResultsStructure();
opt.results.nodeName = 'run_level';

opt.results.name = 'faces_gt_baseline_1';
Expand All @@ -25,12 +26,17 @@
opt.results.csv = true();
opt.results.threshSpm = true();
opt.results.binary = true();

% MONTAGE FIGURE OPTIONS
opt.results.montage.do = true();
opt.results.montage.slices = -26:3:6; % in mm
opt.results.montage.orientation = 'axial';

results = defaultResultsStructure();
results.nodeName = 'run_level';
results.name = 'motion';
results.png = true();

opt.results(2) = results;

%% DO NOT TOUCH
opt = checkOptions(opt);
saveOptions(opt);
Expand Down
20 changes: 20 additions & 0 deletions demos/face_repetition/models/model-faceRepetition_smdl.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,26 @@
-1
],
"Test": "t"
},
{
"Name": "motion",
"ConditionList": [
"trans_x",
"trans_y",
"trans_z",
"rot_x",
"rot_y",
"rot_z"
],
"Weights": [
1,
1,
1,
1,
1,
1
],
"Test": "F"
}
]
}
Expand Down
6 changes: 5 additions & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ BUILDDIR = build
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile
.PHONY: help Makefile cpp_spm-manual.pdf

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
Expand All @@ -21,10 +21,14 @@ help:

clean:
rm -rf $(BUILDDIR)
rm -f cpp_spm-manual.pdf
clean_default_options: source/default_options.m
sed -i "s@/home/remi/matlab/SPM/spm12@spm12_dir@g" source/default_options.m
sed -i "s@/home/remi/github/CPP_SPM/docs/derivatives@derivatives@g" source/default_options.m
sed -i "s@/home/remi/github/CPP_SPM/docs/jobs@jobs@g" source/default_options.m
sed -i "s@\t@ @g" source/default_options.m
view:
firefox build/html/index.html

cpp_spm-manual.pdf:
bash create_manual.sh
Binary file modified docs/cpp_spm-manual.pdf
Binary file not shown.
11 changes: 6 additions & 5 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
sys.path.insert(0, os.path.abspath("../.."))


# The full version, including alpha/beta/rc tags
with open('../../version.txt', encoding='utf-8') as version_file:
release = version_file.read()

# -- Project information -----------------------------------------------------

project = "CPP SPM"
copyright = "2020, the CPP SPM pipeline dev team"
author = "the CPP SPM pipeline dev team"

# The full version, including alpha/beta/rc tags
release = "v1.1.3dev"


# -- General configuration ---------------------------------------------------

Expand Down Expand Up @@ -68,9 +69,9 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
html_static_path = ["images"]

html_logo = "_static/cpp_lab_logo.png"
html_logo = "images/cpp_lab_logo.png"

html_theme_options = {
"collapse_navigation": False,
Expand Down
6 changes: 4 additions & 2 deletions docs/source/defaults.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,7 @@ spm to BIDS filename conversion
list of defaults
================

.. literalinclude:: default_options.m
:language: matlab
.. only:: html

.. literalinclude:: default_options.m
:language: matlab
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
10 changes: 5 additions & 5 deletions docs/source/preprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ More info available on this page of the
`SPM wikibook <https://en.wikibooks.org/wiki/SPM/Slice_Timing>`_.

.. _fig_stc:
.. figure:: _static/bidsSTC/out.png
.. figure:: images/bidsSTC/out.png
:align: center

Slice timing correction workflow
Expand Down Expand Up @@ -74,13 +74,13 @@ The figures below show the ``bidsSpatialPrepro`` workflow as it would run using
realign and unwarp (default) and with normalization to SPM MNI space (``IXI549Space``).

.. _fig_spatialPrepro-anat:
.. figure:: _static/bidsSpatialPrepro/out_anat.png
.. figure:: images/bidsSpatialPrepro/out_anat.png
:align: center

Anatomical component of the spatial preprocessing workflow

.. _fig_spatialPrepro-func:
.. figure:: _static/bidsSpatialPrepro/out_func.png
.. figure:: images/bidsSpatialPrepro/out_func.png
:align: center

Functional component of the spatial preprocessing workflow
Expand All @@ -96,7 +96,7 @@ Perform smoothing of the functional data by running ``bidsSmoothing``
.. autofunction:: bidsSmoothing

.. _fig_smoothing:
.. figure:: _static/bidsSmoothing/out.png
.. figure:: images/bidsSmoothing/out.png
:align: center

Smoothing workflow
Expand All @@ -108,7 +108,7 @@ Others
.. autofunction:: bidsSegmentSkullStrip

.. _fig_segmentSkullstrip:
.. figure:: _static/bidsSegmentSkullstrip/out.png
.. figure:: images/bidsSegmentSkullstrip/out.png
:align: center

Segment and skullstrip workflow
Expand Down
2 changes: 1 addition & 1 deletion docs/source/quality_analysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Quality control
.. autofunction:: functionalQA

.. _fig_spatialPrepro-reports:
.. figure:: _static/bidsSpatialPrepro/out_report.png
.. figure:: images/bidsSpatialPrepro/out_report.png
:align: center

workflows for QA as part of the spatial preprocessing workflow
Expand Down
10 changes: 5 additions & 5 deletions docs/source/statistics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The mat files can directly be ingested by SPM:
the TSV files are there for both logging and interoperability.

.. _fig_FFX-specification:
.. figure:: _static/bidsFFX/out.png
.. figure:: images/bidsFFX/out.png
:align: center

Subject level GLM specification workflow for model specification
Expand All @@ -72,16 +72,16 @@ Compute results

.. autofunction:: bidsResults

:download:`CSV output example <_static/results_fig/output.csv>`
:download:`CSV output example <images/results_fig/output.csv>`

.. _MoAE_output_figure:
.. figure:: _static/results_fig/output.png
.. figure:: images/results_fig/output.png
:align: center

Example of subject level results from the MoAE demo

.. _MoAE_montage_figure:
.. figure:: _static/results_fig/montage.png
.. figure:: images/results_fig/montage.png
:align: center

Example of subject level montage from the MoAE demo
Expand All @@ -98,7 +98,7 @@ An example of how to use it is available in the ``moae_04_slice_display.m``
script in the MoAE demo.

.. _MoAE_slice_display_figure:
.. figure:: _static/results_fig/slice_display.png
.. figure:: images/results_fig/slice_display.png
:align: center

Example of subject level slice display from the MoAE demo
Expand Down
3 changes: 3 additions & 0 deletions src/batches/stats/setBatchContrasts.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
%
% :param matlabbatch:
% :type matlabbatch: cell
%
% :param opt:
% :type opt: structure
%
% :param spmMatFile:
% :type spmMatFile: string
%
% :param consess:
% :type consess: cell
%
Expand Down
19 changes: 19 additions & 0 deletions src/batches/stats/setBatchGroupLevelContrasts.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
function matlabbatch = setBatchGroupLevelContrasts(matlabbatch, opt, nodeName)
%
% USAGE::
%
% matlabbatch = setBatchGroupLevelContrasts(matlabbatch, opt, nodeName)
%
% :param matlabbatch:
% :type matlabbatch: structure
%
% :param opt:
% :type opt: structure
%
% :param nodeName:
% :type nodeName: string
%
% :returns: - :matlabbatch:
%
%
%
% See also: setBatchContrasts, specifyContrasts, setBatchSubjectLevelContrasts
%
% (C) Copyright 2019 CPP_SPM developers

Expand Down
34 changes: 27 additions & 7 deletions src/batches/stats/setBatchSubjectLevelContrasts.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function matlabbatch = setBatchSubjectLevelContrasts(matlabbatch, opt, subLabel)
function matlabbatch = setBatchSubjectLevelContrasts(matlabbatch, opt, subLabel, nodeName)
%
% set batch for run and subject level contrasts
%
Expand All @@ -17,6 +17,10 @@
%
% :returns: - :matlabbatch:
%
%
% See also: bidsFFX, specifyContrasts, setBatchContrasts
%
%
% (C) Copyright 2019 CPP_SPM developers

printBatchName('subject level contrasts specification', opt);
Expand All @@ -31,15 +35,31 @@
model = opt.model.bm;

% Create Contrasts
contrasts = specifyContrasts(SPM, model);
if nargin < 4 || isempty(nodeName)
contrasts = specifyContrasts(SPM, model);
else
contrasts = specifyContrasts(SPM, model, nodeName);
end

consess = {};
for icon = 1:size(contrasts, 2)
if any(contrasts(icon).C)
consess{end + 1}.tcon.name = contrasts(icon).name; %#ok<*AGROW>
consess{end}.tcon.convec = contrasts(icon).C;
consess{end}.tcon.sessrep = 'none';
for icon = 1:numel(contrasts)

if any(contrasts(icon).C(:))

con.name = contrasts(icon).name;
con.convec = contrasts(icon).C;
con.sessrep = 'none';

switch contrasts(icon).type
case 't'
consess{end + 1}.tcon = con; %#ok<*AGROW>

case 'F'
consess{end + 1}.fcon = con; %#ok<*AGROW>
end

end

end

matlabbatch = setBatchContrasts(matlabbatch, opt, spmMatFile, consess);
Expand Down
4 changes: 2 additions & 2 deletions src/batches/stats/setBatchSubjectLevelResults.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
result.name = char(result.name);
result.name = regexify(result.name);

msg = sprintf('Skipping contrast named "%s"', result.name(2:end - 1));
msg = sprintf('Skipping contrast named "%s"', deregexify(result.name));
errorHandling(mfilename(), 'skippingContrastResults', msg, true, opt.verbosity);
return

Expand All @@ -44,7 +44,7 @@

msg = sprintf('\nGetting too many contrasts in SPM file\n%s\nfor the name:\n %s', ...
fullfile(result.dir, 'SPM.mat'), ...
result.name(2:end - 1));
deregexify(result.name));
errorHandling(mfilename(), 'noMatchingContrastName', msg, true, opt.verbosity);
return

Expand Down
Loading

0 comments on commit d14cdca

Please sign in to comment.