Skip to content
Open
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
18 changes: 12 additions & 6 deletions classdefs/@pmNoise/pmNoise.m
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,13 @@ function compute(noise)
% Frequency [Hz]
fNoise = noise.cardiac_frequency*(1 + noise.jitter(1)*randn(1,1));
% Amplitude
aNoise = noise.cardiac_amplitude*(1 + noise.jitter(2)*randn(1,1));
aNoise = noise.cardiac_amplitude * abs(1 + noise.jitter(2)*randn(1,1));
% Time points
t = noise.PM.timePointsSeries;
% Calculate the noise
tmpNoise{2} = aNoise * sin(2 * pi .* t .* fNoise);
phi = 2*pi*rand(1,1);
tmp = aNoise * sin(2*pi.*t.*fNoise + phi);
tmpNoise{2} = tmp - mean(tmp);
end

% RESPIRATORY
Expand All @@ -349,11 +351,13 @@ function compute(noise)
% Frequency [Hz]
fNoise = noise.respiratory_frequency*(1 + noise.jitter(1)*randn(1,1));
% Amplitude
aNoise = noise.respiratory_amplitude * (1 + noise.jitter(2)*randn(1,1));
aNoise = noise.respiratory_amplitude * abs(1 + noise.jitter(2)*randn(1,1));
% Time points
t = noise.PM.timePointsSeries;
% Calculate the noise
tmpNoise{3} = aNoise * sin(2 * pi .* t .* fNoise);
phi = 2*pi*rand(1,1);
tmp = aNoise * sin(2*pi.*t.*fNoise + phi);
tmpNoise{3} = tmp - mean(tmp);
end

% LOW FREQU DRIFT
Expand All @@ -370,7 +374,7 @@ function compute(noise)

% Jitter: see cardiac and respiratory
fNoise = noise.lowfrequ_frequ * (1 + noise.jitter(1)*randn(1,1));
aNoise = noise.lowfrequ_amplitude * (1 + noise.jitter(2)*randn(1,1));
aNoise = noise.lowfrequ_amplitude * abs(1 + noise.jitter(2)*randn(1,1));

n = floor(2 * (noise.PM.timePointsN * noise.PM.TR)/fNoise + 1);
if (n < 3)
Expand All @@ -380,7 +384,8 @@ function compute(noise)
driftbase = spmdrift(:,2:end); % Eliminate the DC term
driftbase = sum(driftbase,2)';
% Now we need to scale this noise to the actual noise values
tmpNoise{4} = aNoise * driftbase;
tmp = aNoise * driftbase;
tmpNoise{4} = tmp - mean(tmp);
end


Expand All @@ -393,6 +398,7 @@ function compute(noise)
end

% RETURN VALUES
vals = vals - mean(vals);
noise.values = vals;

end
Expand Down