-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsourceInterpoateAndNormalise.m
More file actions
36 lines (28 loc) · 1.19 KB
/
Copy pathsourceInterpoateAndNormalise.m
File metadata and controls
36 lines (28 loc) · 1.19 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
function [ sourceNormalised ] = sourceInterpoateAndNormalise( source, mriStruct )
% This function returns the source reconstruction structure normalised to MNI, per trial
% INPUT: source - a source structure obtained via ft_sourceanalysis.
% mriStruct - an MRI struct obtained via ft_read_mri
% OUTPUT: sourceNormalised - the source structure normalisedto MNI coordinates
%
% NOTE: Normalisation is performed per trial.
anatomical = mriStruct;
trialsNum = length(source.trial);
sourceInterpolated = cell(1,trialsNum);
functional = source;
functional = rmfield(functional,'trial');
functional.df = 1; % "functional" will only have one trial at a time
cfg.parameter = 'pow';
sourceNormalised = cell(1,trialsNum);
cfgNorm = [];
cfgNorm.spmversion = 'spm8';
cfgNorm.coordsys = 'spm'; %WE HAVE TO CHECK THAT
cfgNorm.nonlinear = 'no';
CHECK = ft_sourceinterpolate(cfg, source,anatomical);
for trialI = 1:trialsNum
% Interpolate each trial
functional.pow = source.trial(trialI).pow;
sourceInterpolated{trialI} = ft_sourceinterpolate(cfg, functional,anatomical);
%Normalise each trial
sourceNormalised{trialI} = ft_volumenormalise(cfgNorm, sourceInterpolated{trialI});
end
end