Skip to content

Commit

Permalink
Bugfix: Prefer TPM.nii from SPM plugin when doing CAT12 segmentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rcassani committed Oct 2, 2023
1 parent d9f049d commit 3a38bdb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion doc/license.html
Expand Up @@ -5,7 +5,7 @@
<body alink="#fff000" link="#fff000" vlink="#fff000">
<h4><span style="font-family: Arial Black; color: #ffffff;"><strong>THERE IS NO UNDO BUTTON!<BR>SET UP A <FONT color=red>BACKUP</FONT> OF YOUR DATABASE</strong></span></h4>
<HR>
<!-- LICENCE_START -->Version: 3.230919 (19-Sep-2023)<br>
<!-- LICENCE_START -->Version: 3.231002 (02-Oct-2023)<br>
<span style="font-style: italic;">COPYRIGHT &copy; 2000-2023
USC &amp; McGill University.<br>
</span>
Expand Down
2 changes: 1 addition & 1 deletion doc/version.txt
@@ -1,2 +1,2 @@
% Brainstorm
% v. 3.230919 (19-Sep-2023)
% v. 3.231002 (02-Oct-2023)
13 changes: 11 additions & 2 deletions toolbox/core/bst_get.m
Expand Up @@ -2804,16 +2804,22 @@
end

case 'SpmTpmAtlas'
preferSpm = 0;
% CALL: bst_get('SpmTpmAtlas', 'SPM')
if (nargin >= 2) && strcmpi(varargin{2}, 'SPM')
preferSpm = 1;
end

% Get template file
tpmUser = bst_fullfile(bst_get('BrainstormUserDir'), 'defaults', 'spm', 'TPM.nii');
if file_exist(tpmUser)
if file_exist(tpmUser) && ~preferSpm
argout1 = tpmUser;
disp(['BST> SPM12 template found: ' tpmUser]);
return;
end
% If it does not exist: check in brainstorm3 folder
tpmDistrib = bst_fullfile(bst_get('BrainstormHomeDir'), 'defaults', 'spm', 'TPM.nii');
if file_exist(tpmDistrib)
if file_exist(tpmDistrib) && ~preferSpm
argout1 = tpmDistrib;
disp(['BST> SPM12 template found: ' tpmDistrib]);
return;
Expand All @@ -2826,6 +2832,9 @@
argout1 = tpmSpm;
disp(['BST> SPM12 template found: ' tpmSpm]);
return;
elseif preferSpm
argout1 = bst_get('SpmTpmAtlas');
return
end
else
tpmSpm = '';
Expand Down
10 changes: 6 additions & 4 deletions toolbox/process/functions/process_segment_cat12.m
Expand Up @@ -117,11 +117,11 @@
else
isCerebellum = 1;
end
% TPM atlas
% % TPM atlas, preferably from SPM plugin
if isfield(sProcess.options, 'tpmnii') && isfield(sProcess.options.tpmnii, 'Value') && ~isempty(sProcess.options.tpmnii.Value) && ~isempty(sProcess.options.tpmnii.Value{1})
TpmNii = sProcess.options.tpmnii.Value{1};
else
TpmNii = bst_get('SpmTpmAtlas');
TpmNii = bst_get('SpmTpmAtlas', 'SPM');
end
% Thickness maps
if isfield(sProcess.options, 'extramaps') && isfield(sProcess.options.extramaps, 'Value') && ~isempty(sProcess.options.extramaps.Value)
Expand Down Expand Up @@ -191,7 +191,8 @@
end
% Check provided TPM.nii
if isempty(TpmNii)
TpmNii = bst_get('SpmTpmAtlas');
% TPM atlas, preferably from SPM plugin
TpmNii = bst_get('SpmTpmAtlas', 'SPM');
end

% ===== GET SUBJECT =====
Expand Down Expand Up @@ -430,8 +431,9 @@ function ComputeInteractive(iSubject, iAnatomy) %#ok<DEFNU>
end
% Open progress bar
bst_progress('start', 'CAT12', 'CAT12 MRI segmentation...');
% TPM atlas, preferably from SPM plugin
TpmNii = bst_get('SpmTpmAtlas', 'SPM');
% Run CAT12
TpmNii = bst_get('SpmTpmAtlas');
isInteractive = 1;
isSphReg = 1;
isCerebellum = 0;
Expand Down

0 comments on commit 3a38bdb

Please sign in to comment.