Skip to content

Commit

Permalink
Merge branch 'develop' into 804_pspm_display
Browse files Browse the repository at this point in the history
  • Loading branch information
4gwe committed Mar 2, 2025
2 parents 97d961d + 3af188f commit 785ea0a
Show file tree
Hide file tree
Showing 164 changed files with 6,928 additions and 18,388 deletions.
266 changes: 204 additions & 62 deletions doc/PsPM.bib

Large diffs are not rendered by default.

3,574 changes: 2,606 additions & 968 deletions doc/PsPM_Developers_Guide.lyx

Large diffs are not rendered by default.

Binary file modified doc/PsPM_Developers_Guide.pdf
Binary file not shown.
18,404 changes: 2,078 additions & 16,326 deletions doc/PsPM_Manual.lyx

Large diffs are not rendered by default.

Binary file modified doc/PsPM_Manual.pdf
Binary file not shown.
287 changes: 198 additions & 89 deletions doc/PsPM_References.lyx → doc/PsPM_options_documentation.lyx

Large diffs are not rendered by default.

Binary file not shown.
6 changes: 4 additions & 2 deletions doc/PsPM_release_checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
This file contains the steps required for finalising a PsPM release. Many items at the beginning don't have to be followed sequentially. However, it is important that there aren't any revisions (commits) that implement/fix something new in the release branch, because we don't merge these branches back to trunk. Therefore, it is sensible to create the release branch after making absolutely sure that no new stuff will be implemented.

- [ ] Update version number & date in
- [ ] `pspm_msg`
- [ ] `pspm_msg.txt`
- [ ] `pspm_quit`
- [ ] `pspm_ui`
- [ ] `pspm.fig`: Load `pspm.fig` into MATLAB using `openfig`, update `fig.Children(9).String` and save back to `pspm.fig`
- [ ] `pspm_ui_app`
- [ ] Manual and Developers Guide: front pages
- [ ] Make sure both manuals are updated
- [ ] Add release notes section of the new version to manual (at the end) and release\_notes.tex
Expand All @@ -23,3 +23,5 @@ This file contains the steps required for finalising a PsPM release. Many items
- [ ] Add release message to GitHub
- [ ] Change release number on lab webpage (gh-pages branch)
- [ ] Add release message to lab webpage (gh-pages branch)
- [ ] Update `PsPM_installer` in `/src/helper` with the new version number and download link, and merge this pull request on the official release date.

Binary file modified doc/release_notes.pdf
Binary file not shown.
460 changes: 435 additions & 25 deletions doc/release_notes.tex

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions src/f_SCR.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
% ● Format
% [fx, dfdx, dfdP] = f_SCR(Xt,Theta,ut,in)
% ● Arguments
% Theta: 4 ER constants (3 ODE params + time)
% * Theta: 4 ER constants (3 ODE params + time)
% 3 SF constants (3 ODE params)
% 3 values per aSCR (invsigma(peaktime), invsigma(std),
% log(amplitude))
% 1 value per eSCR (log(amplitude))
% 2 values per SF (invsigma(peaktime), log(amplitude))
% 2 values per SCL change (invsigma(time), amplitude)
% ut: row 1 - time (after cue onset)
% * ut: row 1 - time (after cue onset)
% row 2 - number of aSCR
% row 3 - number of eSCR
% row 4 - number of SF
Expand Down Expand Up @@ -89,15 +89,15 @@
[s, dsdx(k)] = sigm(aTheta(k, 2), sig);
aTheta(k, 2) = s + sigma_offset;
aTheta(k, 3) = exp(aTheta(k, 3));
end;
end
if any(isinf(aTheta(:, 3)))
aTheta(isinf(aTheta(:, 3)), 3) = 1e200; % an arbitrary value way below realmax
end;
end
clear sig m s
else
aTheta = [];
aSCR_s = 5;
end;
end

% - event-related responses
if ut(3) > 0
Expand All @@ -109,11 +109,11 @@
eTheta(:, 3) = exp(Theta((Theta_n + 3 * ut(2)) + (1:ut(3))));
if any(isinf(eTheta(:, 3)))
eTheta(isinf(eTheta(:, 3)), 3) = 1e200;
end;
end
else
eTheta = [];
eSCR_o = aSCR_s(end);
end;
end

% - spontaneous fluctuations
if ut(4) > 0
Expand All @@ -125,13 +125,13 @@
sig.G0 = ut(SF_ub(k)) - ut(SF_lb(k));
[t, dtdx(k)] = sigm(Theta(Theta_n + 3 * ut(2) + ut(3) + (k - 1) * 2 + 1), sig);
sfTheta(k, 1) = ut(SF_lb(k)) + t; % lower bound plus parameter vaue
end;
end
sfTheta(:, 2) = sigma;
sfTheta(:, 3) = exp(Theta((Theta_n + 3 * ut(2) + ut(3)) + (2:2:(2 * ut(4)))));
else
sfTheta = [];
SF_ub = eSCR_o;
end;
end

% - SCL changes
if ut(5) > 0
Expand All @@ -143,12 +143,12 @@
sig.G0 = ut(SCL_ub(k)) - ut(SCL_lb(k));
[t, dtscldx(k)] = sigm(Theta(Theta_n + 3 * ut(2) + ut(3) + 2 * ut(4) + (k - 1) * 2 + 1), sig);
SCLtheta(k, 1) = ut(SCL_lb(k)) + t; % lower bound plus parameter vaue
end;
end
SCLtheta(:, 2) = sigma_SCL;
SCLtheta(:, 3) = Theta((Theta_n + 3 * ut(2) + ut(3)) + 2 * ut(4) + (2:2:(2 * ut(5))));
else
SCLtheta = [];
end;
end

% ODE
% ------------------------------------------------------------------------
Expand Down Expand Up @@ -190,33 +190,33 @@
Jp(3, 7 + (1:3:(3 * ut(2)))) = gu(ut(1), aTheta, 0) .* (ut(1) - aTheta(:, 1)) .* (aTheta(:, 2)).^-2 .* dmdx;
Jp(3, 7 + (2:3:(3 * ut(2)))) = gu(ut(1), aTheta, 0) .* (ut(1) - aTheta(:, 1)).^2 .* (aTheta(:, 2)).^-3 .* dsdx;
Jp(3, 7 + (3:3:(3 * ut(2)))) = gu(ut(1), aTheta, 0);
end;
end

if ~isempty(eTheta)
Jp(3, (7 + 3 * ut(2)) + (1:ut(3))) = gu(ut(1), eTheta, 0);
end;
end

if ~(isempty(eTheta) && isempty(aTheta))
allTheta = [eTheta; aTheta];
Jp(3, 4) = sum(gu(ut(1), allTheta, 0) .* 1./(allTheta(:, 2).^2) .* (ut(1) - allTheta(:, 1)) .* exp(Theta(4)));
end;
end

if ~isempty(sfTheta)
Jp(6, (7 + 3 * ut(2) + ut(3)) + (1:2:(2 * ut(4)))) = gu(ut(1), sfTheta, 0) .* (ut(1) - sfTheta(:, 1)) .* sfTheta(:, 2).^-2 .* dtdx;
Jp(6, (7 + 3 * ut(2) + ut(3)) + (2:2:(2 * ut(4)))) = gu(ut(1), sfTheta, 0);
end;
end

if ~isempty(SCLtheta)
Jp(7, (7 + 3 * ut(2) + ut(3)) + 2 * ut(4) + (1:2:(2 * ut(5)))) = gu(ut(1), SCLtheta, 0) .* 1./(sigma_SCL.^2) .* (ut(1) - SCLtheta(:, 1)) .* dtscldx;
SCLtheta(:, 3) = 1; % we don't take the exp(amp) here, so dSCLdamp = gu for unit amplitude
Jp(7, (7 + 3 * ut(2) + ut(3)) + 2 * ut(4) + (2:2:(2 * ut(5)))) = gu(ut(1), SCLtheta, 0);
end;
end

dfdP = dt .* Jp';

if any(isweird(fx(:))), error('Weird values in f_SCR'); end;
if any(isweird(dfdx(:))), error('Weird values in f_SCR'); end;
if any(isweird(dfdP(:))), error('Weird values in f_SCR'); end;
if any(isweird(fx(:))), error('Weird values in f_SCR'); end
if any(isweird(dfdx(:))), error('Weird values in f_SCR'); end
if any(isweird(dfdP(:))), error('Weird values in f_SCR'); end


return;
Expand All @@ -237,10 +237,10 @@
gu = a .* exp(-(ut - mu).^2 ./ (2 .* sigma.^2));
if f
gu = sum(gu);
end;
end
else
gu = 0;
end;
end
return;

% =========================================================================
Expand Down
18 changes: 9 additions & 9 deletions src/f_SF.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
% ● Format
% [fx, dfdx] = f_SF(Xt,Theta,ut,in)
% ● Arguments
% Theta: 3 general constants
% 2 value per SF (time, log(amplitude))
% ut: row 1 - time (after cue onset)
% row 2 - number of SF
% * Theta: 3 general constants
% 2 value per SF (time, log(amplitude))
% * ut: row 1 - time (after cue onset)
% row 2 - number of SF
% ● History
% Introduced in PsPM 3.0
% Written in 2008-2015 by Dominik R Bach (Wellcome Trust Centre for Neuroimaging)

%% initialise
global settings;
if isempty(settings), pspm_init; end;
if isempty(settings), pspm_init; end
% settings
Theta_n = 3; % number of parameters for the peripheral function (the rest is for the neural function)
try
Expand All @@ -45,10 +45,10 @@
sfTheta(n, 1) = Theta((n - 1) * 2 + Theta_n + 1);
sfTheta(n, 2) = sigma;
sfTheta(n, 3) = exp(Theta((n - 1) * 2 + Theta_n + 2));
end;
end
else
sfTheta = [];
end;
end
% ODE 3rd order + gaussian
xdot = [Xt(2)
Xt(3)
Expand All @@ -72,8 +72,8 @@
gu = a .* exp(-(ut - mu).^2 ./ (2 .* sigma.^2));
if f
gu = sum(gu);
end;
end
else
gu = 0;
end;
end
return;
20 changes: 12 additions & 8 deletions src/g_SCR.m
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
function [gx,dgdx,dgdPhi] = g_SCR(Xt,Phi,ut,inG)
% ● Description
% TBA.
% This is the SCR observation function required by the VBA toolbox. It
% adds the three generative processes (phasic SCR, SF, SCL) modelled in
% f_SCR.
% ● Format
% [gx,dgdx,dgdPhi] = g_SCR(Xt,Phi,ut,inG)
% ● Arguments
% Xt:
% Phi:
% ut:
% inG:
% Xt: a 7-element vector
% Phi: input required by VBA, ignored
% ut: input required by VBA, ignored
% inG: input required by VBA, ignored
% ● History
% Introduced in PsPM 3.0
% Written in 2008-2015 by Dominik R Bach (Wellcome Trust Centre for Neuroimaging)

global settings;
if isempty(settings), pspm_init; end;
if isempty(settings), pspm_init; end
gx = Xt(1) + Xt(4) + Xt(7);
dgdx = zeros(size(Xt,1),1);
dgdx([1;4;7]) = 1;
dgdPhi = [];
if any(isnan(gx)|isinf(gx)), keyboard; end;
if any(isnan(dgdx)|isinf(dgdx)), keyboard; end;
if any(isnan(gx)|isinf(gx)), keyboard; end
if any(isnan(dgdx)|isinf(dgdx)), keyboard; end
8 changes: 4 additions & 4 deletions src/helper/PsPM_installer.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
% This is a convenience PsPM installer. As an alternative, download the
% lastest release from https://github.com/bachlab/PsPM, or clone the
% develop branch.
% Uzay Gökay & Dominik Bach, 2024
% Uzay Gökay & Dominik Bach, 2025

fprintf('Welcome to the PsPM installer.\n');
[indx,tf] = listdlg('ListString',{'Latest PsPM release', 'GLM tutorial dataset', 'DCM tutorial dataset'}, ...
Expand All @@ -20,9 +20,9 @@
if ismember(1, indx)

% GitHub release URL for PsPM and the desired version
githubReleaseURL = 'https://github.com/bachlab/PsPM/releases/download';
version = 'v6.1.2';
packageName = 'PsPM_v6.1.2';
githubReleaseURL = 'https://github.com/bachlab/PsPM/releases/download';
version = 'v7.0.0';
packageName = 'PsPM_v7.0.0';

% Create the destination folder if it does not exist
if ~exist(destinationFolder, 'dir')
Expand Down
2 changes: 1 addition & 1 deletion src/pspm.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function pspm(varargin)
% ● Description
% pspm.m handles the main GUI for PsPM
% ● Developer's notes
% ● Developer
% PsPM will no longer support GUIDE and only use App Designer for UI.
% App Designer is available for MATLAB that is later than version R2016a (9.0).
% ● History
Expand Down
2 changes: 1 addition & 1 deletion src/pspm_align_channels.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
% ● Arguments
% * data : [struct] the input data to be processed, in PsPM data format.
% * induration : [double] the duration of the input data.
%Copyright
%History
% Introduced in PsPM 3.1
% Written in 2008-2016 by Dominik R Bach (Wellcome Trust Centre for Neuroimaging)
% Maintained in 2022 by Teddy
Expand Down
Binary file modified src/pspm_appdesigner.mlapp
Binary file not shown.
Binary file modified src/pspm_appdesigner2019.mlapp
Binary file not shown.
14 changes: 7 additions & 7 deletions src/pspm_bf_FIR.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,29 @@
%% Check input arguments
if nargin==0
errmsg='No sampling interval stated'; warning('ID:invalid_input', errmsg); return;
end;
end
n = 30;
d = 1;
td = varargin{1}(1);
if nargin == 1 && numel(varargin{1}) > 1
n = varargin{1}(2);
if numel(varargin{1}) >= 3
d = varargin{1}(3);
end;
end

elseif nargin > 1
if nargin >= 2
n = varargin{2}(1);
end;
end
if nargin >= 3
d = varargin{3}(1);
end;
end;
end
end
if td > d
warning('ID:invalid_input', 'Time resolution is larger than duration of the function.'); return;
elseif td == 0
warning('ID:invalid_input', 'Time resolution must be larger than 0.'); return;
end;
end
% initialise FIR
FIR = [zeros(1, n); zeros(round((d*n/td)), n);];
% generate timestamps
Expand All @@ -50,5 +50,5 @@
stops=(d*reg)/td;
FIR(starts:stops, reg)=1;
starts=stops+1;
end;
end
return
8 changes: 4 additions & 4 deletions src/pspm_bf_hprf_e.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
% ● Arguments
% * td : time resolution in second.
% * b : number of basis functions. Default as 1:6.
% ● Developer's Notes
% ● Developer
% Basis functions will be orthogonalized using spm_orth by default. Onsets
% pspm_glm must be shifted by 5 s to account for the pre-event epoch.
% Put in values 1:6 for b in order to get following basis functions:
Expand All @@ -25,10 +25,10 @@

%% input checks
global settings;
if isempty(settings), pspm_init; end;
if isempty(settings), pspm_init; end
if nargin < 1
errmsg = 'No sampling interval stated'; warning('ID:invalid_input', errmsg); return;
end;
end
varargin = cell2mat(varargin);
if length(varargin)==1
b=1:6;
Expand All @@ -48,7 +48,7 @@
warning('ID:invalid_input', 'Time resolution is larger than duration of the function.'); return;
elseif td == 0
warning('ID:invalid_input', 'Time resolution must be larger than 0.'); return;
end;
end

x = (0:td:50-td);
bf=[];
Expand Down
10 changes: 5 additions & 5 deletions src/pspm_bf_hprf_fc_f.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

%% initialise
global settings;
if isempty(settings), pspm_init; end;
if isempty(settings), pspm_init; end
if nargin < 1
errmsg = 'No sampling interval stated'; warning('ID:invalid_input',errmsg); return;
end;
end
if nargin < 2
soa = 3.5;
end;
end
if nargin < 3
% table 2 row 3 in Castegnetti et al. 2016
%p=[43.2180170215633,0.195621916215104,-6.9671,81.0383536117737];
Expand All @@ -30,7 +30,7 @@
% before
% amplitude does not matter because it will be downscaled to 1 by the
% calling function
end;
end
x0 = p(3);
b = p(2);
a = p(1);
Expand All @@ -49,7 +49,7 @@
elseif soa > 8
warning(['SOA longer than 8s is not recommended. ', ...
'Use at own risk.']);
end;
end
shift = soa + x0;
x = (start:td:stop-td)';
% try not to use stats toolbox, but stats toolbox has very good
Expand Down
2 changes: 1 addition & 1 deletion src/pspm_bf_hprf_rew.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
% [bs, x] = pspm_bf_hprf_fc(TD)
% ● Arguments
% * td : time resolution in second.
% ● References:
% ● References
% GLM for reward-conditioned bradycardia:
% Xia Y, Liu H, Kälin OK, Gerster S, Bach DR (2024). Measuring
% human Pavlovian appetitive conditioning and memory retention.
Expand Down
Loading

0 comments on commit 785ea0a

Please sign in to comment.