From e97b5dc3a6aa662236bb0cb6579f7d6365ff7aa2 Mon Sep 17 00:00:00 2001 From: Kwok-Shing Chan Date: Tue, 24 Jan 2023 14:50:05 +0100 Subject: [PATCH 1/2] fill holes (if any) on mask derived from tissue field fix bug when using strel function with the second input is no double (for Windows) apply mask on fieldmap --- sepia_universal_variables.m | 2 +- utils/refine_brain_mask_using_r2s.m | 8 ++++---- wrapper/BackgroundRemovalMacroIOWrapper.m | 4 +++- wrapper/SepiaIOWrapper.m | 7 ++++++- wrapper/UnwrapPhaseMacroIOWrapper.m | 3 +++ 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/sepia_universal_variables.m b/sepia_universal_variables.m index 163202f..3c91990 100755 --- a/sepia_universal_variables.m +++ b/sepia_universal_variables.m @@ -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')); diff --git a/utils/refine_brain_mask_using_r2s.m b/utils/refine_brain_mask_using_r2s.m index b1d64b6..f950efc 100644 --- a/utils/refine_brain_mask_using_r2s.m +++ b/utils/refine_brain_mask_using_r2s.m @@ -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'); diff --git a/wrapper/BackgroundRemovalMacroIOWrapper.m b/wrapper/BackgroundRemovalMacroIOWrapper.m index 0a6a9fb..dc451f7 100644 --- a/wrapper/BackgroundRemovalMacroIOWrapper.m +++ b/wrapper/BackgroundRemovalMacroIOWrapper.m @@ -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...'); diff --git a/wrapper/SepiaIOWrapper.m b/wrapper/SepiaIOWrapper.m index 974703c..ec88c63 100644 --- a/wrapper/SepiaIOWrapper.m +++ b/wrapper/SepiaIOWrapper.m @@ -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 @@ -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); diff --git a/wrapper/UnwrapPhaseMacroIOWrapper.m b/wrapper/UnwrapPhaseMacroIOWrapper.m index bf20cdf..4f1bbd4 100644 --- a/wrapper/UnwrapPhaseMacroIOWrapper.m +++ b/wrapper/UnwrapPhaseMacroIOWrapper.m @@ -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 From 99d81039377dc119f5d359099c43030772b3ec1a Mon Sep 17 00:00:00 2001 From: Kwok-Shing Chan <39571502+kschan0214@users.noreply.github.com> Date: Fri, 27 Jan 2023 11:58:44 +0100 Subject: [PATCH 2/2] update version --- README.md | 7 ++++++- sepia_universal_variables.m | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5befbc1..0845b62 100755 --- a/README.md +++ b/README.md @@ -41,7 +41,12 @@ If you have a more general question regarding the usage of SEPIA and/or other QS For full update log, please visit https://sepia-documentation.readthedocs.io/en/latest/getting_started/Release-note.html. -### 1.2.1.1 (current master) +### 1.2.2 (current master) +* Fix bug for non-double type input for MATLAB's strel function +* Make sure all holes inside the ROI mask are filled after the background field removal step +* ROI (brain) mask is applied on the fieldmap regardless of what method is chosen + +### 1.2.1.1 (current 941cd5b) * Enable option of GPU processing for FANSI and NDI ### 1.2.1 (current 190dd44) diff --git a/sepia_universal_variables.m b/sepia_universal_variables.m index 3c91990..944605a 100755 --- a/sepia_universal_variables.m +++ b/sepia_universal_variables.m @@ -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.2 dev'; +SEPIA_version = 'v1.2.2'; %% PATH SEPIA_HOME = fileparts(mfilename('fullpath'));