-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
When using .nii images, should the WM and GM complexity be calculated based on segmented .nii files c1 and c2 as in the code below?
Roger
indir = '/media/chris/OCTO/ABCPROJECT_IN';
outdir = '/media/chris/GoldenBoy/FractalsFinally';
cd (indir);
% 20180313 CRM
gmf = dir('/c1.nii')
wmf = dir('/c2.nii')
for i = 1:length(gmf)
%% load nii data, using one of three options
% (1) Matlab 2017b+ has this built-in as 'niftiread'
targetfile = fullfile(gmf(i).folder, gmf(i).name);
V = niftiread(targetfile);
bsplit = strsplit(gmf(i).name,'_');
subjName = bsplit{2};
%% select voxels to be part of region label
% make sure this value is one of the regions included in the intensity coding of the parcellated/segmented image
% e.g., confirm with "unique(V)"fullfil
% if this region code doesn't exist, the toolbox will enter debug mode and say the region wasn't found
vol = V == 1;
%% do calcFD
% add the calcFD path to the MATLAB environment
%addpath('../calcFD')
% define desired box kernel sizes
r = 2.^[0:4]; % i.e., [1,2,4,8,16]
% determine the 'counts' using the dilation algorithm
n = calcFD_dilate(vol,r);
% perform a simple linear regression of the log2-transformed box sizes and log2-transformed counts
c = [log2(r)' ones(length(r),1)] \ -log2(n)';
% take the coefficient corresponding to the slope as the fractal dimensionality (fd) value
fd = c(1);
data(i).name = subjName;
data(i).gm_fd = fd;
fprintf('Successfully processed GM for %s with value of %d\n',subjName,fd);
% (1) Matlab 2017b+ has this built-in as 'niftiread'
targetfile = fullfile(wmf(i).folder, wmf(i).name);
V = niftiread(targetfile);
bsplit = strsplit(wmf(i).name,'_');
subjName = bsplit{2};
%% select voxels to be part of region label
% make sure this value is one of the regions included in the intensity coding of the parcellated/segmented image
% e.g., confirm with "unique(V)"fullfil
% if this region code doesn't exist, the toolbox will enter debug mode and say the region wasn't found
vol = V == 1;
%% do calcFD
% add the calcFD path to the MATLAB environment
%addpath('../calcFD')
% define desired box kernel sizes
r = 2.^[0:4]; % i.e., [1,2,4,8,16]
% determine the 'counts' using the dilation algorithm
n = calcFD_dilate(vol,r);
% perform a simple linear regression of the log2-transformed box sizes and log2-transformed counts
c = [log2(r)' ones(length(r),1)] \ -log2(n)';
% take the coefficient corresponding to the slope as the fractal dimensionality (fd) value
fd = c(1);
data(i).wm_fd = fd;
fprintf('Successfully processed WM for %s with value of %d\n',subjName,fd);
end
t= struct2table(data)
writetable(t,'subjID_GM_WM_spreadsheet.xls')
copyfile('subjID_GM_WM_spreadsheet.xls',outdir)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels