-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathmoae_03_slice_display.m
More file actions
95 lines (69 loc) · 2.63 KB
/
moae_03_slice_display.m
File metadata and controls
95 lines (69 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
% This script shows how to display the results of a GLM
% by having on the same image:
%
% - the beta estimates
% - the t statistics
% - ROI contours
%
%
% (C) Copyright 2021 Remi Gau
clear;
close all;
clc;
addpath(fullfile(pwd, '..', '..'));
bidspm();
this_dir = fileparts(mfilename('fullpath'));
subLabel = '01';
opt.pipeline.type = 'stats';
opt.dir.raw = fullfile(this_dir, 'inputs', 'raw');
opt.dir.derivatives = fullfile(this_dir, 'outputs', 'derivatives');
opt.dir.preproc = fullfile(opt.dir.derivatives, 'bidspm-preproc');
opt.dir.roi = fullfile(opt.dir.derivatives, 'bidspm-roi');
opt.dir.stats = fullfile(opt.dir.derivatives, 'bidspm-stats');
opt.model.file = fullfile(this_dir, 'models', 'model-MoAE_smdl.json');
% read the model
opt = checkOptions(opt);
opt.results = opt.model.bm.Nodes{1}.Model.Software.bidspm.Results{1};
opt = checkOptions(opt);
% we get the con image to extract data
ffxDir = getFFXdir(subLabel, opt);
maskImage = spm_select('FPList', ffxDir, '^.*_mask.nii$');
bf = bids.File(spm_file(maskImage, 'filename'));
conImage = spm_select('FPList', ffxDir, ['^con_' bf.entities.label '.nii$']);
%% Layers to put on the figure
layers = sd_config_layers('init', {'truecolor', 'dual', 'contour'});
% Layer 1: Anatomical map
[anat_normalized_file, anatRange] = return_normalized_anat_file(opt, subLabel);
layers(1).color.file = anat_normalized_file;
layers(1).color.range = [0 anatRange(2)];
layers(1).color.map = gray(256);
%% Layer 2: Dual-coded layer
%
% - contrast estimates color-coded;
layers(2).color.file = conImage;
color_map_folder = fullfile(fileparts(which('map_luminance')), '..', 'mat_maps');
load(fullfile(color_map_folder, 'diverging_bwr_iso.mat'));
layers(2).color.map = diverging_bwr;
layers(2).color.range = [-4 4];
layers(2).color.label = '\beta_{listening} - \beta_{baseline} (a.u.)';
%% Layer 2: Dual-coded layer
%
% - t-statistics opacity-coded
spmTImage = spm_select('FPList', ffxDir, ['^spmT_' bf.entities.label '.nii$']);
layers(2).opacity.file = spmTImage;
layers(2).opacity.range = [0 3];
layers(2).opacity.label = '| t |';
%% Layer 3 and 4: Contour of ROI
contour = spm_select('FPList', ffxDir, ['^sub.*' bf.entities.label '.*_mask.nii']);
layers(3).color.file = contour;
layers(3).color.map = [0 0 0];
layers(3).color.line_width = 2;
%% Settings
settings = sd_config_settings('init');
% we reuse the details for the SPM montage
settings.slice.disp_slices = opt.results(1).montage.slices;
settings.slice.orientation = opt.results(1).montage.orientation;
settings.fig_specs.n.slice_column = 4;
settings.fig_specs.title = opt.results(1).name;
%% Display the layers
[settings, p] = sd_display(layers, settings);