Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/run_system_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ name: system tests
on:
push:
branches:
- master
- main
pull_request:
branches:
- 'master'
- 'main'
schedule:
- cron: "* * 1 * *"
- cron: "0 0 1 * *"

env:
OCTFLAGS: --no-gui --no-window-system --silent
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ on:
pull_request:
branches: '*'
schedule:
- cron: "* * 1 * *"
- cron: "0 0 1 * *"

env:
OCTFLAGS: --no-gui --no-window-system --silent
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
url = https://github.com/bramzandbelt/slice_display.git
[submodule "lib/brain_colours"]
path = lib/brain_colours
url = https://github.com/CPernet/brain_colours.git
url = https://github.com/CPernet/brain_colours.git
14 changes: 7 additions & 7 deletions demos/MoAE/moae_create_roi_extract_data.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
% we get the con image to extract data
% we can do this by using the "label-XXXX" from the mask
p = bids.internal.parse_filename(spm_file(maskImage, 'filename'));
conImage = spm_select('FPList', ffxDir, ['^con_' p.label '.nii$']);
conImage = spm_select('FPList', ffxDir, ['^con_' p.entities.label '.nii$']);

%% Create ROI right auditory cortex
sphere.location = [57 -22 11];
Expand All @@ -35,12 +35,12 @@
[~, roiFile] = createRoi('expand', specification, conImage, pwd, saveROI);

% rename mask image
newname.desc = 'right auditory cortex';
newname.task = '';
newname.label = '';
newname.p = '';
newname.k = '';
newname.MC = '';
newname.entities.desc = 'right auditory cortex';
newname.entities.task = '';
newname.entities.label = '';
newname.entities.p = '';
newname.entities.k = '';
newname.entities.MC = '';
rightRoiFile = renameFile(roiFile, newname);

%% same but with left hemisphere
Expand Down
2 changes: 1 addition & 1 deletion demos/MoAE/moae_run.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
download_moae_ds(downloadData);

%% Run batches
reportBIDS(opt);
% reportBIDS(opt);
bidsCopyRawFolder(opt, 1);

% In case you just want to run segmentation and skull stripping
Expand Down
2 changes: 1 addition & 1 deletion demos/MoAE/moae_slice_display.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
%
% - t-statistics opacity-coded

spmTImage = spm_select('FPList', ffxDir, ['^spmT_' p.label '.nii$']);
spmTImage = spm_select('FPList', ffxDir, ['^spmT_' p.entities.label '.nii$']);
layers(2).opacity.file = spmTImage;

layers(2).opacity.range = [2 3];
Expand Down
2 changes: 1 addition & 1 deletion lib/CPP_ROI
Submodule CPP_ROI updated 450 files
2 changes: 1 addition & 1 deletion lib/bids-matlab
Submodule bids-matlab updated 551 files
2 changes: 1 addition & 1 deletion manualTests/test_moae.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

%% Run batches

reportBIDS(opt);
% reportBIDS(opt);

bidsCopyRawFolder(opt, 1);

Expand Down
2 changes: 1 addition & 1 deletion src/batches/setBatchEstimateModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
matlabbatch{end}.spm.stats.fmri_est.spmmat = spmMatFile;

writeResiduals = true();
if ~opt.glm.QA.do
if ~opt.QA.glm.do
writeResiduals = false();
end
matlabbatch{end}.spm.stats.fmri_est.write_residuals = writeResiduals;
Expand Down
21 changes: 11 additions & 10 deletions src/batches/setBatchResults.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
%
% (C) Copyright 2019 CPP_SPM developers

result.outputNameStructure.sub = result.label;
result.outputNameStructure.desc = result.Contrasts.Name;
result.outputNameStructure.p = num2str(result.Contrasts.p);
result.outputNameStructure.k = num2str(result.Contrasts.k);
result.outputNameStructure.MC = result.Contrasts.MC;
result.outputNameStructure.use_schema = false;
result.outputNameStructure.entities.sub = result.label;
result.outputNameStructure.entities.desc = result.Contrasts.Name;
result.outputNameStructure.entities.p = num2str(result.Contrasts.p);
result.outputNameStructure.entities.k = num2str(result.Contrasts.k);
result.outputNameStructure.entities.MC = result.Contrasts.MC;

fieldsToSet = returnDefaultResultsStructure();
result = setFields(result, fieldsToSet);
Expand Down Expand Up @@ -58,13 +59,13 @@

if result.Output.thresh_spm
result.outputNameStructure.ext = '';
export{end + 1}.tspm.basename = createFilename(result.outputNameStructure);
export{end + 1}.tspm.basename = bids.create_filename(result.outputNameStructure);
end

if result.Output.binary
result.outputNameStructure.ext = '';
result.outputNameStructure.type = 'mask';
export{end + 1}.binary.basename = createFilename(result.outputNameStructure);
result.outputNameStructure.suffix = 'mask';
export{end + 1}.binary.basename = bids.create_filename(result.outputNameStructure);
end

if result.Output.NIDM_results
Expand Down Expand Up @@ -92,8 +93,8 @@

% Not sure why the name of the figure does not come out right
result.outputNameStructure.ext = '';
result.outputNameStructure.type = 'montage';
matlabbatch{end + 1}.spm.util.print.fname = createFilename(result.outputNameStructure);
result.outputNameStructure.suffix = 'montage';
matlabbatch{end + 1}.spm.util.print.fname = bids.create_filename(result.outputNameStructure);
matlabbatch{end}.spm.util.print.fig.figname = 'SliceOverlay';
matlabbatch{end}.spm.util.print.opts = 'png';

Expand Down
6 changes: 5 additions & 1 deletion src/batches/setBatchSubjectLevelContrasts.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@

spmMatFile = cellstr(fullfile(ffxDir, 'SPM.mat'));

load(spmMatFile{1}, 'SPM');

model = spm_jsonread(opt.model.file);

% Create Contrasts
contrasts = specifyContrasts(ffxDir, opt.taskName, opt);
contrasts = specifyContrasts(SPM, opt.taskName, model);
for icon = 1:size(contrasts, 2)
consess{icon}.tcon.name = contrasts(icon).name; %#ok<*AGROW>
consess{icon}.tcon.convec = contrasts(icon).C;
Expand Down
2 changes: 1 addition & 1 deletion src/batches/setBatchSubjectLevelGLMSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
% we will use to upsample our model during regression creation
fileName = bids.query(BIDS, 'data', ...
'sub', subLabel, ...
'type', 'bold');
'suffix', 'bold');
fileName = strrep(fileName{1}, '.gz', '');
hdr = spm_vol(fileName);
% we are assuming axial acquisition here
Expand Down
20 changes: 11 additions & 9 deletions src/batches/setBatchSubjectLevelResults.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@
result.contrastNb = getContrastNb(result);

result.outputNameStructure = struct( ...
'type', 'spmT', ...
'suffix', 'spmT', ...
'ext', '.nii', ...
'sub', '', ...
'task', opt.taskName, ...
'space', opt.space, ...
'desc', '', ...
'label', 'XXXX', ...
'p', '', ...
'k', '', ...
'MC', '');
'use_schema', 'false', ...
'entities', struct('sub', '', ...
'task', opt.taskName, ...
'space', opt.space, ...
'desc', '', ...
'label', sprintf('%04.0f', ...
result.contrastNb), ...
'p', '', ...
'k', '', ...
'MC', ''));

matlabbatch = setBatchResults(matlabbatch, result);

Expand Down
2 changes: 1 addition & 1 deletion src/defaults/createDefaultModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
% list all the *events.tsv files for that task and make a lis of all the
% trial_types
eventFiles = bids.query(BIDS, 'data', ...
'type', 'events', ...
'suffix', 'events', ...
'task', opt.taskName);

trialTypeList = {};
Expand Down
2 changes: 1 addition & 1 deletion src/fieldmaps/getMetadataFromIntendedForFunc.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

funcMetadata = bids.query(BIDS, 'metadata', ...
'modality', 'func', ...
'type', fragments.type, ...
'suffix', fragments.suffix, ...
'sub', fragments.sub, ...
'ses', fragments.ses, ...
'run', fragments.run, ...
Expand Down
18 changes: 10 additions & 8 deletions src/fieldmaps/getVdmFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@

fragments = bids.internal.parse_filename(boldFilename);

if ~isfield(fragments, 'ses')
fragments.ses = '';
entities = fragments.entities;

if ~isfield(entities, 'ses')
entities.ses = '';
end

modalities = bids.query(BIDS, 'modalities', ...
'sub', fragments.sub, ...
'ses', fragments.ses);
'sub', entities.sub, ...
'ses', entities.ses);

if opt.useFieldmaps && any(ismember('fmap', modalities))
% We loop through the field maps and find the one that is intended for this
Expand All @@ -37,13 +39,13 @@

fmapFiles = bids.query(BIDS, 'data', ...
'modality', 'fmap', ...
'sub', fragments.sub, ...
'ses', fragments.ses);
'sub', entities.sub, ...
'ses', entities.ses);

fmapMetadata = bids.query(BIDS, 'metadata', ...
'modality', 'fmap', ...
'sub', fragments.sub, ...
'ses', fragments.ses);
'sub', entities.sub, ...
'ses', entities.ses);

for iFile = 1:size(fmapFiles, 1)

Expand Down
4 changes: 2 additions & 2 deletions src/getAnatFilename.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
anat = bids.query(BIDS, 'data', ...
'sub', subLabel, ...
'ses', anatSession, ...
'type', anatSuffix);
'suffix', anatSuffix);

if isempty(anat)

Expand All @@ -58,7 +58,7 @@

function checkAvailableSuffix(BIDS, subLabel, anatType)

availableSuffixes = bids.query(BIDS, 'types', ...
availableSuffixes = bids.query(BIDS, 'suffixes', ...
'sub', subLabel);

if ~strcmp(anatType, availableSuffixes)
Expand Down
6 changes: 6 additions & 0 deletions src/getBoldFilename.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@

[BIDS, subID, sessionID, runID, opt] = deal(varargin{:});

if isempty(opt.query)
opt.query = struct('extension', '.nii');
else
opt.query.extension = '.nii';
end

% get the filename for this bold run for this task
boldFileName = getInfo(BIDS, subID, opt, 'Filename', sessionID, runID, 'bold');

Expand Down
18 changes: 9 additions & 9 deletions src/getData.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [BIDS, opt] = getData(opt, BIDSdir, type)
function [BIDS, opt] = getData(opt, BIDSdir, suffix)
%
% Reads the specified BIDS data set and updates the list of subjects to analyze.
%
Expand Down Expand Up @@ -35,14 +35,14 @@
end
derivativesDir = BIDSdir;

if nargin < 3 || (exist('type', 'var') && isempty(type))
type = 'bold';
if nargin < 3 || (exist('type', 'var') && isempty(suffix))
suffix = 'bold';
end

if isfield(opt, 'taskName')
fprintf(1, 'FOR TASK: %s\n', opt.taskName);
else
type = 'T1w';
suffix = 'T1w';
end

% we let SPM figure out what is in this BIDS data set
Expand All @@ -66,29 +66,29 @@
% get metadata for bold runs for that task
% we take those from the first run of the first subject assuming it can
% apply to all others.
opt = getMetaData(BIDS, opt, opt.subjects, type);
opt = getMetaData(BIDS, opt, opt.subjects, suffix);

fprintf(1, 'WILL WORK ON SUBJECTS\n');
disp(opt.subjects);

end

function opt = getMetaData(BIDS, opt, subjects, type)
function opt = getMetaData(BIDS, opt, subjects, suffix)

% TODO
% THIS NEEDS FIXING AS WE MIGHT WANT THE METADATA OF THE SUBJECTS SELECTED
% RATHER THAN THE FIRST SUBJECT OF THE DATASET

switch type
switch suffix
case 'bold'
metadata = bids.query(BIDS, 'metadata', ...
'task', opt.taskName, ...
'sub', subjects{1}, ...
'type', type);
'suffix', suffix);
case 'T1w'
metadata = bids.query(BIDS, 'metadata', ...
'sub', subjects{1}, ...
'type', type);
'suffix', suffix);
end

if iscell(metadata)
Expand Down
14 changes: 7 additions & 7 deletions src/getInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
% If info = ``filename``, this returns the name of the file for a specified
% session and run::
%
% filenames = getInfo(BIDS, subLabel, opt, 'filename', sessionID, runID, type)
% filenames = getInfo(BIDS, subLabel, opt, 'filename', sessionID, runID, suffix)
%
%
% :param BIDS: returned by bids.layout when exploring a BIDS data set.
Expand All @@ -42,8 +42,8 @@
% :param runIdx: run index label (for `run-001`, the label will be `001`)
% :type runIdx: string
%
% :param type: datatype (``bold``, ``events``, ``physio``)
% :type type: string
% :param suffix: datatype (``bold``, ``events``, ``physio``)
% :type suffix: string
%
% (C) Copyright 2020 CPP_SPM developers

Expand Down Expand Up @@ -84,13 +84,13 @@
'sub', subLabel, ...
'task', opt.taskName, ...
'ses', session, ...
'type', 'bold');
'suffix', 'bold');

query = setFields(query, opt.query);

runs = bids.query(BIDS, 'runs', query);

nbRuns = size(runs, 2);
nbRuns = numel(runs);

if nbRuns == 0
nbRuns = 1;
Expand All @@ -101,14 +101,14 @@

case 'filename'

[session, run, type] = deal(varargin{:});
[session, run, suffix] = deal(varargin{:});

query = struct( ...
'sub', subLabel, ...
'task', opt.taskName, ...
'ses', session, ...
'run', run, ...
'type', type);
'suffix', suffix);

% use the extra query options specified in the options
query = setFields(query, opt.query);
Expand Down
Loading