Skip to content

Commit 0969d9a

Browse files
committed
(1) Fixed: Corrected issue in using other Templates and output resolutions
in the longitudinal pipeline. Use default 1.5 mm in average processing that has to fit to the TPM in cat_long_main. Removed the warning for different output resolutions in cat_long_multi_run. Corrected definitions in cat_main_registration. (2) Fixed: Corrected problem with missing text in the cat_report. (3) Fixed: Corrected an bug in writing the affine/rigid background image in cat_main_write. (4) Fixed: Corrected bug in LAS in case of some image with negative background. Changed paths: M CHANGES.txt M cat_long_main.m M cat_long_multi_run.m M cat_main_LAS.m M cat_main_registration.m M cat_main_reportfig.m
1 parent 4d180e4 commit 0969d9a

File tree

6 files changed

+68
-26
lines changed

6 files changed

+68
-26
lines changed

CHANGES.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
------------------------------------------------------------------------
2+
r2565 | robertdahnke | 2024-03-14 15:38:20
3+
4+
Changed paths:
5+
M CHANGES.txt
6+
M cat_long_main.m
7+
M cat_long_multi_run.m
8+
M cat_main_LAS.m
9+
M cat_main_registration.m
10+
M cat_main_reportfig.m
11+
12+
(1) Fixed: Corrected issue in using other Templates and output resolutions
13+
in the longitudinal pipeline. Use default 1.5 mm in average processing
14+
that has to fit to the TPM in cat_long_main. Removed the warning
15+
for different output resolutions in cat_long_multi_run. Corrected
16+
definitions in cat_main_registration.
17+
(2) Fixed: Corrected problem with missing text in the cat_report.
18+
(3) Fixed: Corrected an bug in writing the affine/rigid background image in
19+
cat_main_write.
20+
(4) Fixed: Corrected bug in LAS in case of some image with negative background.
21+
------------------------------------------------------------------------
222
r2564 | gaser | 2024-03-10 19:24:34
323

424
Changed paths:

cat_long_main.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,13 +529,20 @@
529529
end
530530
end
531531
end
532-
532+
533533
% RD202102: differentiation between user levels not tested yet !
534534
if exist('extopts','var') && isfield(extopts,'bb')
535535
matlabbatch{mbi}.spm.tools.cat.estwrite.extopts.bb = 1; % use TPM output BB
536536
elseif exist('extopts','var') && isfield(extopts,'registration') && isfield(extopts.registration,'bb')
537537
matlabbatch{mbi}.spm.tools.cat.estwrite.extopts.registration.bb = 1; % use TPM output BB
538538
end
539+
% RD202403: run average for 1.5 mm to combine it with the TPM
540+
if exist('extopts','var') && isfield(extopts,'vox')
541+
matlabbatch{mbi}.spm.tools.cat.estwrite.extopts.vox = 1.5;
542+
elseif exist('extopts','var') && isfield(extopts,'registration') && isfield(extopts.registration,'vox')
543+
matlabbatch{mbi}.spm.tools.cat.estwrite.extopts.registration.vox = 1.5;
544+
end
545+
539546

540547
if exist('output','var') && ~isempty(output)
541548
matlabbatch{mbi}.spm.tools.cat.estwrite.output = output;

cat_long_multi_run.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414

1515
if isdeployed, job.nproc = 0; end
1616

17-
if isfield(job.extopts,'vox') && job.extopts.vox ~= 1.5
18-
job.extopts.vox = 1.5;
19-
fprintf('\n---------------------------------------------------------------------------\n');
20-
fprintf('Warning: No change of output voxel size possible for longitudinal pipeline!\n');
21-
fprintf('---------------------------------------------------------------------------\n');
22-
end
23-
2417
% use some options from GUI or default file
2518
opts = job.opts;
2619
extopts = job.extopts;

cat_main_LAS.m

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,9 @@
802802
end
803803
else
804804
% simple
805-
Ynb = smooth3( Ycls{6})>128 & Yg<0.3;
805+
% RD202403: avoid skull-stripped voxels and neighbors
806+
Ynb = smooth3( Ycls{6})>128 & Yg<0.3 & ...
807+
~cat_vol_morph(Yg==0,'d'); % avoid arificial regions
806808
%Ynb = cat_vol_morph(Ynb,'e',4*vxv);
807809

808810
Ylab{3} = ones(size(Ygm),'single') .* min( [ T3th(1) , cat_stat_nanmean(Ysrc(Ycm(:))) ] );
@@ -813,12 +815,13 @@
813815
Ylab{1} = Ylab{1} .* T3th(2) / cat_stat_kmeans( Ylab{1}(Ygm(:)>0.5), 1);
814816
Ylab{3} = Ylab{3} .* T3th(1) / cat_stat_kmeans( Ylab{3}(Ycm(:)>0.5), 1);
815817

816-
% RD202110: corrected cases with incorrect background region Ynb
818+
%% RD202110: corrected cases with incorrect background region Ynb
819+
% RD202403: there are allways some voxels .. somegthing is wrong here
820+
%if sum(Ynb(:)>0.5)>0
821+
% Ynb = smooth3( Ycls{6})>128 & Yg<0.3;
822+
%end
817823
if sum(Ynb(:)>0.5)>0
818-
Ynb = smooth3( Ycls{6})>128 & Yg<0.3;
819-
end
820-
if sum(Ynb(:)>0.5)>0
821-
Ylab{6} = Ylab{6} .* cat_stat_kmeans( Ysrc(Ynb(:)>0.5) , 1) / max(eps,cat_stat_kmeans( Ylab{6}(Ynb(:)>0.5) , 1));
824+
Ylab{6} = Ylab{6} .* abs(cat_stat_kmeans( Ysrc(Ynb(:)>0.5) , 1)) / max(eps,abs(cat_stat_kmeans( Ylab{6}(Ynb(:)>0.5) , 1)));
822825
else
823826
Ylab{6} = min(Ysrc(:));
824827
end

cat_main_registration.m

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,14 @@
340340
% M0 for the individual volume
341341
% M1* for the different normalized spaces
342342
% Mad for the Dartel template with different BB as the TPM
343-
M0 = res.image.mat;
344-
if isfield( job.extopts , 'bb' ) && numel( job.extopts.bb ) == 1 && job.extopts.bb == 1
345-
M1 = tpmM;
346-
else
347-
imat = spm_imatrix(tmpM); imat(1:3) = imat(1:3) + imat(7:9).*(tdim - (newres/tmpres*odim))/2; imat(7:9) = imat(7:9) * newres/tmpres; M1 = spm_matrix(imat);
348-
end
343+
M0 = res.image.mat;
344+
% RD202403: modified to support output of the given voxel size vox - see also below. cleanup later.
345+
%if isfield( job.extopts , 'bb' ) && numel( job.extopts.bb ) == 1 && job.extopts.bb == 1 %&& job.extopts.vox == abs(tmpM(1))
346+
% M1 = tpmM;
347+
% imat = spm_imatrix(tmpM); imat(1:3) = imat(1:3) + imat(7:9).*(tdim - (newres/tmpres*odim))/2; imat(7:9) = imat(7:9) * newres/tmpres; M1 = spm_matrix(imat);
348+
%else
349+
imat = spm_imatrix(tmpM); imat(1:3) = imat(1:3) + imat(7:9).*(tdim - (newres/tmpres*odim))/2; imat(7:9) = imat(7:9) * newres/tmpres; M1 = spm_matrix(imat);
350+
%end
349351
imat = spm_imatrix(eye(4)); imat(1:3) = imat(1:3) + imat(7:9).*(tdim - (newres/tmpres*odim))/2; imat(7:9) = imat(7:9) * newres/tmpres; Mad = spm_matrix(imat);
350352

351353
% affine and rigid parameters for registration
@@ -468,12 +470,12 @@
468470
% mat matrices for different spaces
469471
% - here M1 == M1t
470472
M0 = res.image.mat; % for (interpolated) individual volume
471-
if isfield( job.extopts , 'bb' ) && numel( job.extopts.bb ) == 1 && job.extopts.bb == 1
472-
M1 = tpmM;
473-
else
474-
imat = spm_imatrix(tmpM); imat(1:3) = imat(1:3) + imat(7:9).*(tdim - (newres/tmpres*odim))/2; imat(7:9) = imat(7:9) * newres/tmpres;
475-
M1 = spm_matrix(imat);
476-
end
473+
% RD202403: modified to support output of the given voxel size vox - see also above. cleanup later.
474+
%if isfield( job.extopts , 'bb' ) && numel( job.extopts.bb ) == 1 && job.extopts.bb == 1
475+
% M1 = tpmM;
476+
%else
477+
imat = spm_imatrix(tmpM); imat(1:3) = imat(1:3) + imat(7:9).*(tdim - (newres/tmpres*odim))/2; imat(7:9) = imat(7:9) * newres/tmpres; M1 = spm_matrix(imat);
478+
%end
477479

478480
% estimate the inverse transformation
479481
yid = spm_diffeo('invdef', Yy , sdim, inv(tpmM\M1), M1\res.Affine*M0);

cat_main_reportfig.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,23 @@ function cat_main_reportfig(Ym,Yp0,Yl1,Psurf,job,qa,res,str)
4242
fg = spm_figure('FindWin','Graphics');
4343
set(0,'CurrentFigure',fg)
4444

45+
% remove CAT12 figure background image from start
46+
try
47+
fgc = get(fg,'Children');
48+
if ~isempty(fgc)
49+
fgcc = get(fgc,'Children');
50+
if ~isempty(fgcc)
51+
% remove figure elements to prevent further interations
52+
delete(fgcc);
53+
spm_figure('Clear',fg)
54+
55+
% run the reportfig function the first time to fully clear the
56+
% changes by the cat start figure
57+
cat_main_reportfig(Ym,Yp0,Yl1,[],job,qa,res,str)
58+
end
59+
end
60+
end
61+
4562
def.extopts.report.useoverlay = 2; % different p0 overlays, described below in the Yp0 print settings
4663
% (0 - no, 1 - red mask, 2 - blue BG, red BVs, WMHs [default] ... )
4764
def.extopts.report.type = 2; % (1 - Yo,Ym,Yp0,CS-top, 2 - Yo,Yp0,CS-left-right-top)

0 commit comments

Comments
 (0)