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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ demos/*/cfg/*.json
tests/*.png
tests/group/*
tests/*/*.json
tests/dummyData/derivatives/cpp_spm/sub-*/
tests/dummyData/derivatives/cpp_spm*/sub-*/

# ignore content of the build folder of the doc
docs/build/*
Expand Down
57 changes: 13 additions & 44 deletions demos/MoAE/MoAE_run.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
% Smoothing to apply
FWHM = 6;

downloadData = false;
downloadData = true;

run ../../initCppSpm.m;

Expand All @@ -23,58 +23,27 @@
dowload_MoAE_ds(downloadData);

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

% In case you just want to run segmentation and skull stripping
%
% bidsSegmentSkullStrip(opt);
%

bidsSegmentSkullStrip(opt);

% NOTE: skull stripping is also included in 'bidsSpatialPrepro'

% bidsSTC(opt);
bidsSTC(opt);

% bidsSpatialPrepro(opt);
bidsSpatialPrepro(opt);

% The following do not run on octave for now (because of spmup)
% anatomicalQA(opt);
% bidsResliceTpmToFunc(opt);
% functionalQA(opt);
%
% bidsSmoothing(FWHM, opt);

% The following crash on Travis CI
% bidsFFX('specifyAndEstimate', opt, FWHM);
% bidsFFX('contrasts', opt, FWHM);
% bidsResults(opt, FWHM);

%%
function dowload_MoAE_ds(downloadData)

if downloadData
bidsSmoothing(FWHM, opt);

% URL of the data set to download
URL = 'http://www.fil.ion.ucl.ac.uk/spm/download/data/MoAEpilot/MoAEpilot.bids.zip';

working_directory = fileparts(mfilename('fullpath'));

% clean previous runs
if exist(fullfile(working_directory, 'inputs'), 'dir')
rmdir(fullfile(working_directory, 'inputs'), 's');
end

spm_mkdir(fullfile(working_directory, 'inputs'));

%% Get data
fprintf('%-10s:', 'Downloading dataset...');
urlwrite(URL, 'MoAEpilot.zip');
fprintf(1, ' Done\n\n');

fprintf('%-10s:', 'Unzipping dataset...');
unzip('MoAEpilot.zip');
movefile('MoAEpilot', fullfile(working_directory, 'inputs', 'raw'));
fprintf(1, ' Done\n\n');

end

end
% The following crash on Travis CI
bidsFFX('specifyAndEstimate', opt, FWHM);
bidsFFX('contrasts', opt, FWHM);
bidsResults(opt, FWHM);
16 changes: 0 additions & 16 deletions demos/MoAE/MoAE_slice_display.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,3 @@

%% Display the layers
[settings, p] = sd_display(layers, settings);

%% Helper function
function [anat_normalized_file, anatRange] = return_normalized_anat_file(opt, subLabel)

[BIDS, opt] = getData(opt);
[~, anatDataDir] = getAnatFilename(BIDS, subLabel, opt);
anat_normalized_file = spm_select('FPList', ...
anatDataDir, ...
'^wm.*skullstripped.nii$');

hdr = spm_vol(anat_normalized_file);
vol = spm_read_vols(hdr);

anatRange = [min(vol(:)) max(vol(:))];

end
31 changes: 31 additions & 0 deletions demos/MoAE/dowload_MoAE_ds.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
% (C) Copyright 2021 Remi Gau

function dowload_MoAE_ds(downloadData)

if downloadData

% URL of the data set to download
URL = 'http://www.fil.ion.ucl.ac.uk/spm/download/data/MoAEpilot/MoAEpilot.bids.zip';

working_directory = fileparts(mfilename('fullpath'));

% clean previous runs
if exist(fullfile(working_directory, 'inputs'), 'dir')
rmdir(fullfile(working_directory, 'inputs'), 's');
end

spm_mkdir(fullfile(working_directory, 'inputs'));

%% Get data
fprintf('%-10s:', 'Downloading dataset...');
urlwrite(URL, 'MoAEpilot.zip');
fprintf(1, ' Done\n\n');

fprintf('%-10s:', 'Unzipping dataset...');
unzip('MoAEpilot.zip');
movefile('MoAEpilot', fullfile(working_directory, 'inputs', 'raw'));
fprintf(1, ' Done\n\n');

end

end
16 changes: 16 additions & 0 deletions demos/MoAE/return_normalized_anat_file.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
% (C) Copyright 2021 Remi Gau

function [anat_normalized_file, anatRange] = return_normalized_anat_file(opt, subLabel)

[BIDS, opt] = getData(opt);
[~, anatDataDir] = getAnatFilename(BIDS, subLabel, opt);
anat_normalized_file = spm_select('FPList', ...
anatDataDir, ...
'^wm.*skullstripped.nii$');

hdr = spm_vol(anat_normalized_file);
vol = spm_read_vols(hdr);

anatRange = [min(vol(:)) max(vol(:))];

end
3 changes: 1 addition & 2 deletions demos/spm_face_rep/FaceRep_getOption.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

opt = [];

% task to analyze
opt.taskName = 'facerepetition';

% The directory where the data are located
opt.dataDir = fullfile(fileparts(mfilename('fullpath')), 'outputs', 'raw');
opt.dir.roi = fullfile(opt.dataDir, '..', 'derivatives', 'cpp_spm-roi');

opt.model.hrfDerivatives = [1 1];

Expand Down
6 changes: 1 addition & 5 deletions demos/spm_face_rep/FaceRep_getOptionResults.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
'models', ...
'model-faceRepetition_smdl.json');

opt.glmQA.do = false;
opt.glm.QA.do = false;

% Specify the result to compute
opt.result.Steps(1) = returnDefaultResultsStructure();
Expand All @@ -24,17 +24,13 @@

% Specify how you want your output (all the following are on false by default)
opt.result.Steps(1).Output.png = true();

opt.result.Steps(1).Output.csv = true();

opt.result.Steps(1).Output.thresh_spm = true();

opt.result.Steps(1).Output.binary = true();

% MONTAGE FIGURE OPTIONS
opt.result.Steps(1).Output.montage.do = true();
opt.result.Steps(1).Output.montage.slices = -26:3:6; % in mm
% axial is default 'sagittal', 'coronal'
opt.result.Steps(1).Output.montage.orientation = 'axial';

end
2 changes: 1 addition & 1 deletion demos/spm_face_rep/face_rep_anat.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
clear;
clc;

downloadData = false;
downloadData = true;

run ../../initCppSpm.m;

Expand Down
1 change: 1 addition & 0 deletions demos/spm_face_rep/face_rep_func.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
bidsSmoothing(FWHM, opt);

% The following crash on Travis CI
opt.dir.stats = opt.derivativesDir;
bidsFFX('specifyAndEstimate', opt, FWHM);
bidsFFX('contrasts', opt, FWHM);

Expand Down
13 changes: 13 additions & 0 deletions demos/spm_face_rep/face_rep_resolution.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

clear;
clc;
close all;

FWHM = 6;

Expand All @@ -29,6 +30,8 @@

reportBIDS(opt);

modelFile = opt.model.file;

for iResolution = 1:0.5:3

opt.funcVoxelDims = repmat(iResolution, 1, 3);
Expand All @@ -39,6 +42,16 @@
'derivatives', ...
['cpp_spm-res' num2str(iResolution)]), 'cpath');

content = spm_jsonread(opt.model.file);
content.Name = [content.Name, ' resolution - ', num2str(iResolution)];

p = bids.internal.parse_filename(modelFile);
p.model = [p.model, ' resolution', num2str(iResolution)];
newModel = spm_file(opt.model.file, 'filename', createFilename(p));
opt.model.file = newModel;

spm_jsonwrite(newModel, content, struct('indent', ' '));

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is only for this function to create names (in order to do so, we need to create different model.json files) for different resolution? so that spatial preprocssing folders would be different?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is only to create a different GLM folder name.

This is a bit "ugly" because everything in those json is the same: but I was trying to find a way to create different folder names that would not involve adding another option to the pile and would instead reuse something we already have to create GLM folder names.

Does that make sense?

Another option could have been to have a different cpp_spm-stats folder for each resolution but then all the stats would not be centralized.

I think there is only so much data curation that can be automatized.

bidsCopyRawFolder(opt, 1);

bidsSTC(opt);
Expand Down
6 changes: 6 additions & 0 deletions demos/spm_face_rep/face_rep_roi_analysis.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@
opt.roi.name = {'V1v', 'V1d'};
opt.roi.space = {'MNI', 'individual'};

opt.dir.stats = fullfile(opt.dataDir, '..', 'derivatives', 'cpp_spm-stats');

bidsCreateROI(opt);

opt.glm.roibased.do = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this option is set to false, would it do the whole brain analysis with different resolution spatial preprocessing?


bidsRoiBasedGLM(opt);
58 changes: 1 addition & 57 deletions demos/spm_face_rep/models/model-faceRepetition_smdl.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Name": "face repetition resampling",
"Name": "resampling",
"Description": "model for face repetition to check resampling effects",
"Input": {
"task": "facerepetition"
Expand Down Expand Up @@ -69,62 +69,6 @@
"type": "t"
}
]
},
{
"Level": "run",
"Transformations": [
{
"Name": "Factor",
"Inputs": [
"trial_type"
]
},
{
"Name": "Convolve",
"Model": "spm",
"Inputs": [
" "
]
}
],
"Model": {
"X": [
"trial_type.F1",
"trial_type.F2",
"trial_type.N1",
"trial_type.N2",
"trans_x",
"trans_y",
"trans_z",
"rot_x",
"rot_y",
"rot_z"
],
"Options": {
"high_pass_filter_cutoff_secs": 128
},
"Software": {
"SPM": {
"whitening": "FAST"
}
},
"Mask": " "
},
"AutoContrasts": [
"trial_type.F1",
"trial_type.F2",
"trial_type.N1",
"trial_type.N2"
]
},
{
"Level": "dataset",
"AutoContrasts": [
"trial_type.F1",
"trial_type.F2",
"trial_type.N1",
"trial_type.N2"
]
}
]
}
2 changes: 1 addition & 1 deletion miss_hit.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# styly guide (https://florianschanda.github.io/miss_hit/style_checker.html)
line_length: 100
regex_function_name: "[a-z]+(_*([a-zA-Z0-9]){1}[A-Za-z]+)*" # almost anything goes in the root folder
regex_function_name: "[a-z]+(_*([a-zA-Z0-9]){1}[A-Za-z]+)*"
exclude_dir: "lib"
copyright_entity: "JH"
copyright_entity: "DSS"
Expand Down
2 changes: 1 addition & 1 deletion src/batches/setBatchEstimateModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
matlabbatch{end}.spm.stats.fmri_est.spmmat = spmMatFile;

writeResiduals = true();
if ~opt.glmQA.do
if ~opt.glm.QA.do
writeResiduals = false();
end
matlabbatch{end}.spm.stats.fmri_est.write_residuals = writeResiduals;
Expand Down
7 changes: 6 additions & 1 deletion src/defaults/checkOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,17 @@

opt = orderfields(opt);

opt = setStatsDir(opt);

end

function fieldsToSet = setDefaultOption()
% this defines the missing fields

fieldsToSet.dataDir = '';
fieldsToSet.derivativesDir = '';
fieldsToSet.dir = struct('raw', '', ...
'derivatives', '');

fieldsToSet.groups = {''};
fieldsToSet.subjects = {[]};
Expand Down Expand Up @@ -113,7 +117,8 @@
fieldsToSet.model.hrfDerivatives = [0 0];
fieldsToSet.contrastList = {};

fieldsToSet.glmQA.do = true;
fieldsToSet.glm.QA.do = true;
fieldsToSet.glm.roibased.do = false;

% specify the results to compute
fieldsToSet.result.Steps = returnDefaultResultsStructure();
Expand Down
2 changes: 1 addition & 1 deletion src/group_level/getRFXdir.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
end

rfxDir = fullfile( ...
opt.derivativesDir, ...
opt.dir.stats, ...
'group', ...
glmDirName);

Expand Down
Loading