Skip to content

Commit

Permalink
Merge pull request #73 from kschan0214/dev1.2.2.6
Browse files Browse the repository at this point in the history
Dev1.2.2.6
  • Loading branch information
kschan0214 authored Dec 4, 2023
2 parents 8630efe + c4c4e8a commit 3db9be4
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 38 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ 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.2.5 (current master)
### 1.2.2.6 (current master)
* Support read Input/Output information from sepia_config.m
* Phase DICOM values are rescaled using the max/min values in the data instead of rescale slope/intercept of the NIFTI

### 1.2.2.5 (commit 8630efe)
* Fix the mismatch between SEPIA defined B0 direction and LPCNN when it is not along the z-direction
* Fix the shared library issue when using ROMEO with latest versions of Matlab on Linux (see [here](https://github.com/korbinian90/ROMEO))
* Allow user to define atlases' directory paths
Expand Down
10 changes: 5 additions & 5 deletions SpecifyToolboxesDirectory.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
% Date modified: 25 Feb 2022 (v1.2)
%
%% Specify the directories of the toolbox here
MEDI_HOME = '/path/to/MEDI/Toolboxes/';
MEDI_HOME = '/path/to/MEDI/Toolbox/';
STISuite_HOME = '/path/to/STI/Suite/';
FANSI_HOME = '/path/to/FANSI/Toolboxes/';
SEGUE_HOME = '/path/to/SEGUE/Toolboxes/';
MRITOOLS_HOME = '/path/to/ROMEO/Toolboxes/';
MRISC_HOME = '/path/to/MRISusceptibilityCalculationmethods/Toolboxes/';
FANSI_HOME = '/path/to/FANSI/Toolbox/';
SEGUE_HOME = '/path/to/SEGUE/Toolbox/';
MRITOOLS_HOME = '/path/to/MRITOOLS/mritools_ubuntu-20.04_3.6.6/';
MRISC_HOME = '/path/to/MRISusceptibilityCalculationmethods/Toolbox/';
ANTS_HOME = '/path/to/ANTs/bin/';

%% if you have any missing toolboxes, then specify it as empty array
Expand Down
116 changes: 116 additions & 0 deletions gui_func/callback/config/set_config_Callback.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ function set_config_Callback(config_filename,h)
isModifyUnwrap = false;
isModifyBFR = false;
isModifyQSM = false;
isModifyIO = false;

str_pattern = 'input';
idx = regexp(config_txt,str_pattern,'once');
if ~isempty(idx)
isModifyIO = true;
end
str_pattern = '.general.';
idx = regexp(config_txt,str_pattern,'once');
if ~isempty(idx)
Expand All @@ -47,6 +53,116 @@ function set_config_Callback(config_filename,h)
end

%% Panel: I/O
if isModifyIO
input_action_handle = h.dataIO.edit.input;
input1_action_handle = h.dataIO.edit.inputData1;
input2_action_handle = h.dataIO.edit.inputData2;
input3_action_handle = h.dataIO.edit.inputData3;
header_action_handle = h.dataIO.edit.inputHeader;
mask_action_handle = h.dataIO.edit.maskdir;
output_action_handle = h.dataIO.edit.output;

isAllInputEmpty = (isempty(input_action_handle.String) .* isempty(input1_action_handle.String) .* ...
isempty(input2_action_handle.String).* isempty(input3_action_handle.String) .* ...
isempty(header_action_handle.String))>0;

isModifyOutput = true;

% check which input method was used in the config file
ind = regexp(config_txt, regexptranslate('wildcard','input(*).name'), 'once');
if ~isempty(ind)
isFileIO = true;
else
isFileIO = false;
end

% Directory input method
action_handle = input_action_handle;
if isAllInputEmpty && ~isFileIO % only modify the field if all IO fields are empty
str_pattern = 'input';
str_end_idx = regexp(config_txt,str_pattern,'end');
indicator_idx = regexp(config_txt,'''');
str = config_txt(indicator_idx(find(indicator_idx > str_end_idx(1), 1 ))+1:indicator_idx(find(indicator_idx > str_end_idx(1), 1 )+1)-1);

if prod(~isnan(str)) && isfolder(str)
set(action_handle,'String',str);
else
isModifyOutput = false;
end
end

% File input method
% input 1
action_handle = input1_action_handle;
if and(isempty(input_action_handle.String),isempty(get(action_handle,'String')))
str_pattern = 'input\(1).name';
str = get_string_as_string(config_txt, str_pattern);
if prod(~isnan(str)) && isfile(str)
set(action_handle,'String',str);
else
isModifyOutput = false;
end
end

% input 2
action_handle = input2_action_handle;
if and(isempty(input_action_handle.String),isempty(get(action_handle,'String')))
str_pattern = 'input\(2).name';
str = get_string_as_string(config_txt, str_pattern);
if prod(~isnan(str)) && isfile(str)
set(action_handle,'String',str);
else
isModifyOutput = false;
end
end

% input 3
action_handle = input3_action_handle;
if and(isempty(input_action_handle.String),isempty(get(action_handle,'String')))
str_pattern = 'input\(3).name';
str = get_string_as_string(config_txt, str_pattern);
if prod(~isnan(str)) && isfile(str)
set(action_handle,'String',str);
else
isModifyOutput = false;
end
end

% header input
action_handle = header_action_handle;
if and(isempty(input_action_handle.String),isempty(get(action_handle,'String')))
str_pattern = 'input\(4).name';
str = get_string_as_string(config_txt, str_pattern);
if prod(~isnan(str)) && isfile(str)
set(action_handle,'String',str);
else
isModifyOutput = false;
end
end

% mask
action_handle = mask_action_handle;
if isempty(get(action_handle,'String'))
str_pattern = 'mask_filename = ';
str = get_string_as_string(config_txt, str_pattern);
if prod(~isnan(str))
set(action_handle,'String',str);
end
end

% output
action_handle = output_action_handle;
if isempty(get(action_handle,'String'))
str_pattern = 'output_basename = ';
str = get_string_as_string(config_txt, str_pattern);
if prod(~isnan(str)) && isModifyOutput
set(action_handle,'String',str);
end
end


end

if isModifyGeneral

% invert phase data
Expand Down
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.2.5';
SEPIA_version = 'v1.2.2.6';

%% PATH
SEPIA_HOME = fileparts(mfilename('fullpath'));
Expand Down
35 changes: 6 additions & 29 deletions utils/DICOM2Phase.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,14 @@
% Date created: 11 April 2018
% Date modified: 12 June 2018
% Date modified: 4 August 2022 (v1.0.1)
%
% Date modified: 3 December 2023 (v1.2.6.6)
%
function phase = DICOM2Phase(niiPhase)
% % change datatype to double
% dicomPhase = double(niiPhase.img);
% get scale slope
scaleSlope=niiPhase.hdr.dime.scl_slope;
% get scale inetercept
scaleIntercept=niiPhase.hdr.dime.scl_inter;

% rescale phase
phase_rescale = single(niiPhase.img) * scaleSlope + scaleIntercept;
% find maximum and minimum in the data after rescaling
max_rescale = max(phase_rescale(:));
min_rescale = min(phase_rescale(:));

% rescale phase data between -pi and pi usng the max and min in the data
% the limitation of this method is that if the max and min values might not
% corresponding to pi and -pi
phase = (phase_rescale - min_rescale) / (max_rescale - min_rescale) *2*pi - pi;

% % compute the new maximum value
% newMax = niiPhase.hdr.dime.glmax*scaleSlope + scaleIntercept;
% % compute the new minimum value
% newMin = niiPhase.hdr.dime.glmin*scaleSlope + scaleIntercept;
% % +1 for 0
% fullRange = newMax-newMin + 1;
%
% % scale to true value of nifti file
% dicomPhaseRescale = (dicomPhase*scaleSlope) + scaleIntercept ;
% % scale the full range to [-pi,pi)
% phase = (dicomPhaseRescale-newMin) / fullRange * 2*pi - pi;
% suggested by Simon
phase = single(niiPhase.img); clear niiPhase;
max_phase = max(phase(:));
min_phase = min(phase(:));
phase = (phase - min_phase) / (max_phase - min_phase) *2*pi - pi;

end
4 changes: 2 additions & 2 deletions utils/get_filename_in_directory.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
numFiles = 0;

% check all files in the list
for klist = 1:length(fileList)
if ContainName(fileList(klist).name,pattern)
for klist = 1:length(fileList) % ignore hidden file
if ContainName(fileList(klist).name,pattern) && ~strcmp(fileList(klist).name(1),'.')
numFiles = numFiles + 1;
file(numFiles).name = fullfile(fileList(klist).folder,fileList(klist).name);
end
Expand Down

0 comments on commit 3db9be4

Please sign in to comment.