Skip to content

Commit

Permalink
fill holes (if any) on mask derived from tissue field
Browse files Browse the repository at this point in the history
fix bug when using strel function with the second input is no double (for Windows)
apply mask on fieldmap
  • Loading branch information
Kwok-Shing Chan committed Jan 24, 2023
1 parent 941cd5b commit e97b5dc
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion sepia_universal_variables.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
% DO NOT change the order of the entities, add a new one at the end instead
%
%% Version
SEPIA_version = 'v1.2.1.1';
SEPIA_version = 'v1.2.2 dev';

%% PATH
SEPIA_HOME = fileparts(mfilename('fullpath'));
Expand Down
8 changes: 4 additions & 4 deletions utils/refine_brain_mask_using_r2s.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@
open_radius_voxel = min(round(open_radius_mm ./ voxelSize));
close_radius_voxel = min(round(close_radius_mm ./ voxelSize));

% remove disconnected voxels
mask_r2s_morph = imopen(mask_r2s, strel('sphere', open_radius_voxel));
% remove disconnected voxels, 20230124 v1.2.2: second input of strel has to be double
mask_r2s_morph = imopen(mask_r2s, strel('sphere', double(open_radius_voxel)));
% get the largest single object
mask_r2s_morph = getLargestObject(mask_r2s_morph);
% reconnect voxels
mask_r2s_morph = imclose(mask_r2s_morph, strel('sphere', close_radius_voxel));
% reconnect voxels, 20230124 v1.2.2: second input of strel has to be double
mask_r2s_morph = imclose(mask_r2s_morph, strel('sphere', double(close_radius_voxel)));
% make sure no holes in the centre of the brain
mask_r2s_morph = imfill(mask_r2s_morph,'holes');

Expand Down
4 changes: 3 additions & 1 deletion wrapper/BackgroundRemovalMacroIOWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@
clear totalField maskLocalfield % clear variables that no longer be needed

% generate new mask based on backgroudn field removal result
mask_QSM = localField ~= 0;
% mask_QSM = localField ~=0;
% 20230124 v1.2.2: make sure no holes inide ROIs
mask_QSM = imfill(localField ~= 0, 'holes');

% save results
fprintf('Saving local field map...');
Expand Down
7 changes: 6 additions & 1 deletion wrapper/SepiaIOWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@
% core of temporo-spatial phase unwrapping
[totalField,fieldmapSD,fieldmapUnwrapAllEchoes,mask] = estimateTotalField(fieldMap,mask,matrixSize,voxelSize,algorParam,headerAndExtraData);

% 20230124 v1.2.2: apply mask on derived map
totalField = totalField .* double(mask);

% save unwrapped phase if chosen
if ~isempty(fieldmapUnwrapAllEchoes) && isSaveUnwrappedEcho
% save the output
Expand Down Expand Up @@ -292,7 +295,9 @@
clear totalField maskLocalfield % clear variables that no longer be needed

% generate new mask based on backgroudn field removal result
mask_QSM = localField ~=0;
% mask_QSM = localField ~=0;
% 20230124 v1.2.2: make sure no holes inide ROIs
mask_QSM = imfill(localField ~= 0, 'holes');

fprintf('Saving local field map...');
save_nii_quick(outputNiftiTemplate,localField, outputFileList.localField);
Expand Down
3 changes: 3 additions & 0 deletions wrapper/UnwrapPhaseMacroIOWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@
% core of temporo-spatial phase unwrapping
[totalField,fieldmapSD,fieldmapUnwrapAllEchoes,mask] = estimateTotalField(fieldMap,mask,matrixSize,voxelSize,algorParam,headerAndExtraData);

% 20230124 v1.2.2: apply mask on derived map
totalField = totalField .* double(mask);

% save unwrapped phase if chosen
if ~isempty(fieldmapUnwrapAllEchoes) && isSaveUnwrappedEcho
% save the output
Expand Down

0 comments on commit e97b5dc

Please sign in to comment.