Skip to content

Commit

Permalink
Changed: Added some flags to waitbar window in cat_progressbar to pre…
Browse files Browse the repository at this point in the history
…vent

         unwished popping up of the window.
Added:   New function to calculate laterality index for VBM data.

Changed paths:
MM CHANGES.txt
MM cat_batch_bids.sh
MM cat_batch_cat.sh
MM cat_batch_long.sh
 M cat_progress_bar.m
A  cat_vol_laterality_index.m
  • Loading branch information
ChristianGaser committed Nov 10, 2023
1 parent f157e1a commit 6c1dcd1
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 1 deletion.
16 changes: 15 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
------------------------------------------------------------------------
r2476 | gaser | 2023-11-10 16:02:32

Changed paths:
MM CHANGES.txt
MM cat_batch_bids.sh
MM cat_batch_cat.sh
MM cat_batch_long.sh
M cat_progress_bar.m
A cat_vol_laterality_index.m

Changed: Added some flags to waitbar window in cat_progressbar to prevent
unwished popping up of the window.
Added: New function to calculate laterality index for VBM data.
------------------------------------------------------------------------
r2475 | gaser | 2023-11-10 12:08:18

Changed paths:
Expand Down Expand Up @@ -39,7 +53,7 @@ Changed paths:

Changed: Set default surface processing back to 22 (CS2).
Added: New function to calculate laterality index for volumes.
Fixed: Corrected error in cat_batch_bids.sh wehre cat12 folder was not correctly
Fixed: Corrected error in cat_batch_bids.sh where cat12 folder was not correctly
defined.
------------------------------------------------------------------------
r2470 | gaser | 2023-11-08 21:43:04
Expand Down
3 changes: 3 additions & 0 deletions cat_progress_bar.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ function cat_progress_bar(action,varargin)
catch
Fwaitbar = waitbar(0,arg2);
end

% don't know whether this works, but I have used the parameters from spm_progress_bar
set(Fwaitbar,'IntegerHandle','off','InvertHardcopy','on','PaperPositionMode','auto','Tag','Interactive');

% Set
%-------------------------------------------------------------------
Expand Down
72 changes: 72 additions & 0 deletions cat_vol_laterality_index.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
function cat_vol_laterality_index(P)
% ______________________________________________________________________
% Calculation of laterality index for images in MNI152NLin2009cAsym space
% LI = (L-R)/(R+L)
%
% The result is indicated with a prepended 'LI_' in the dataname
% of the file.
% Please note that only the data of the left hemipshere is stored, since
% the values in the opposite hemisphere would be simply inverted and other-
% wise identical except for the sign.
%
% ______________________________________________________________________
%
% Christian Gaser, Robert Dahnke
% Structural Brain Mapping Group (https://neuro-jena.github.io)
% Departments of Neurology and Psychiatry
% Jena University Hospital
% ______________________________________________________________________
% $Id$

fprintf('Warning: This only works with spatially registered images in MNI152NLin2009cAsym space (CAT12.8 or newer)\n');

if ~nargin
P = spm_select(Inf,'image','Select images for LI estimation',{},pwd,'^T*');
end

V = spm_vol(P);
n = size(P,1);

sym_template = '/Users/gaser/Dropbox/GitHub/cat12-templates-atlases/templates_external/y_MNI152NLin2009cAsym_to_MNI152NLin2009cSym.nii';
Vsym = spm_vol(sym_template);
wvol = cat_vol_defs(struct('field1',{{sym_template}},'images',{{P}},'interp',5,'modulate',0));

for i = 1:n
vol = wvol{1}{i};

% estimate new dimensions for left/right hemisphere
xdim = size(vol,1);
left_xdim = floor(xdim/2);

% consider off x-dimensions
if rem(xdim,2)
right_xdim = ceil(xdim/2) + 1;
else
right_xdim = ceil(xdim/2);
end

% flip values
left_data = vol(1:left_xdim,:,:);
right_data = flipud(vol(right_xdim:xdim,:,:)); % image should be flipped

% estimate laterality index
LI = (left_data-right_data)./(left_data+right_data+eps);

% rename dataname
[pth,nm,xt] = spm_fileparts(deblank(P(i,:)));
flipped_name = fullfile(pth, ['LI_' nm xt]);

% we need origin and voxel size from template
Vout = Vsym;
Vout.fname = flipped_name;
Vout.dim = size(LI);
Vout.dt(1) = 16;
Vout.pinfo(1) = 1;
Vout.mat(1,:) = -Vout.mat(1,:);
Vout.mat(1,4) = Vout.mat(1,4) - 1.5;

Vout.descrip = 'Laterality index';

spm_write_vol(Vout,left_data);
fprintf('Save LI in %s\n',flipped_name);
end

0 comments on commit 6c1dcd1

Please sign in to comment.