Skip to content

Commit

Permalink
Towards 0 failures..
Browse files Browse the repository at this point in the history
  • Loading branch information
adhusch committed Apr 27, 2018
1 parent d4fcee5 commit ea17730
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/Functions/extractBrainConvHull.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
ctIso = niiCT.img; % = downsampleImage(niiCT.img, niiCT.voxsize, niiCT.voxdim);

% threshold
threImg = (ctIso > LOWER_CT_BRAIN_THRESHOLD & ctIso < UPPER_CT_BRAIN_THRESHOLD);
ctIsoMedFilt = medfilt3(ctIso);
threImg = (ctIsoMedFilt > LOWER_CT_BRAIN_THRESHOLD & ctIsoMedFilt < UPPER_CT_BRAIN_THRESHOLD);
%threImg = reshape(threImg,niiCT.voxdim');
[xx,yy,zz] = ndgrid(-2:2);
structEle = sqrt(xx.^2 + yy.^2 + zz.^2) <= 2.5 / sqrt(max(niiCT.voxsize));
Expand All @@ -38,10 +39,12 @@
%G = gpuArray(structure); % if we have CUDA..

% morphology
%threImg = medfilt3(threImg);
morphImg = imopen(threImg,structEle);
morphFaction = sum(morphImg(:)) / numel(morphImg);
if(morphFaction < 0.05 || morphFaction > 0.3)
if(morphFaction < 0.06 || morphFaction > 0.3)
warning('Uncommon fraction of CT data in threshold range (15-60 HU). Trying to compensate. Make sure to use "soft tissue" reconstruction filters for the CT (e.g. J30 kernel) if this fails. ')
threImg = medfilt3(threImg);
morphImg = imclose(threImg,structEle); %maybe we have a super noise brain tissue image, thus to CLOSE instead of open first
morphImg = imerode(morphImg,structEle); % due to the closing all masks will enlarge, i.e. the brain mask might cover the ckull, thus we have to shrink it at the very end again
end
Expand All @@ -63,7 +66,7 @@
convHullBrainMask = false(size(roughBrainMask));
maskedCT = ctIso;
maskedCT(~roughBrainMask) = NaN; %threshold the roughBrainMask again to make sure no skull is contained due to morphology
roughBrainMask = (maskedCT > LOWER_CT_BRAIN_THRESHOLD & maskedCT < UPPER_CT_BRAIN_THRESHOLD);
roughBrainMask = (maskedCT > LOWER_CT_BRAIN_THRESHOLD & maskedCT < UPPER_CT_BRAIN_THRESHOLD); %TODO check if removable
for i=1:size(roughBrainMask,3)
convHullBrainMask(:,:,i) = bwconvhull(roughBrainMask(:,:,i));
roughBrainMask(:,:,i) = imfill(roughBrainMask(:,:,i), 'holes');
Expand Down
2 changes: 1 addition & 1 deletion src/Functions/extractElectrodePointclouds.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

function [elecsPointcloudStruct, brainMask] = extractElectrodePointclouds(niiCT, varargin)
% CONSTANTS
LAMBDA_1 = 30; %
LAMBDA_1 = 25; % elec latent space length [mm]

%% Optional Arguments and Default Values
argParser = inputParser();
Expand Down
2 changes: 1 addition & 1 deletion src/PaCER.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
args.contactDetectionMethod = 'contactAreaCenter';
end
%% Checks
if(~isa(niiCT, 'NiftiMod'))
if(~isa(niiCT, 'NiftiMod') && ~isa(niiCT, 'NiftiModSPM') )
disp('First parameter is not a nifti object. Intrepretating as filename and tring to load a nifti file with that name from disk...');
niiCT = NiftiMod(niiCT);
end
Expand Down

0 comments on commit ea17730

Please sign in to comment.