-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from kschan0214/dev1.2.2.5
Dev1.2.2.5
- Loading branch information
Showing
14 changed files
with
101 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
%% SpecifyAtlasDirectory.m | ||
% | ||
% Description: Specify directories of the atlas | ||
% | ||
% Kwok-Shing Chan @ MGH | ||
% [email protected] | ||
% Date created: 9 October 2023 | ||
% Date modified: | ||
% | ||
%% Specify the directories of the atlas here | ||
% please do not change | ||
SEPIA_ANALYSIS_SEGMENTATION_dir = fullfile(SEPIA_HOME,'analysis','segmentation'); | ||
SEPIA_ATLAS_dir = fullfile(SEPIA_HOME,'atlas'); | ||
|
||
% These are the default directories if you use the 'download_atlas.sh' shell script | ||
% If you prefer the atlases to be stored at a different paths, you may | ||
% modified the paths here | ||
|
||
% AHEAD atlas | ||
AHEAD_ATLAS_HOME = fullfile(SEPIA_ATLAS_dir,'AHEAD_atlas'); | ||
% CIT168 atlas | ||
CIT168_reinf_learn_ATLAS_HOME = fullfile(SEPIA_ATLAS_dir,'CIT168_Reinf_Learn_v1.1.0'); | ||
% MUSUS-100 atlas | ||
MuSus100_ATLAS_HOME = fullfile(SEPIA_ATLAS_dir,'MuSus-100_Atlas'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
%% This file specifies the Checkpoint of xQSM | ||
|
||
% Specify the directory of the xQSM code from Github | ||
deepMRI_HOME = '/project/3015069.05/bids/code/deepMRI/'; | ||
deepMRI_HOME = '/home/common/matlab/sepia/external/deepMRI/'; | ||
% If you have your own trained network, specify the file that contains the trained parameters | ||
% otherwise, uses the one provided with the tool | ||
checkpoints = '/project/3015069.05/bids/code/deepMRI/BFRNet_data/checkpoints/BFRnet_L2_64PS_24BS_45Epo_NewHCmix.mat'; | ||
checkpoints = '/home/common/matlab/sepia/external/deepMRI/BFRNet_data/checkpoints/BFRnet_L2_64PS_24BS_45Epo_NewHCmix.mat'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
%% This file specifies the Python environment and Checkpoint of QSMnet+ | ||
|
||
% Specify the directory of the QSMnet+ code from Github | ||
QSMnet_HOME = '/project/3015069.05/bids/code/QSMnet/'; | ||
QSMnet_HOME = '/home/common/matlab/sepia/external/QSMnet/QSMnet-9ca283a'; | ||
% Specify the Python environment that has QSMnet+ installed | ||
python_interpreter = '/project/3015069.05/bids/code/QSMnet/qsmnet/bin/python'; | ||
python_interpreter = '/home/common/matlab/sepia/external/QSMnet/QSMnet-9ca283a/qsmnet/bin/python'; | ||
% Specify the directory that contains the trained parameters | ||
dir_net = fullfile(QSMnet_HOME,'Checkpoints/'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
% Kwok-shing Chan @ DCCN | ||
% [email protected] | ||
% Date created: 6 October 2022 | ||
% Date last modified: | ||
% Date modified: 9 October 2023 | ||
% | ||
% | ||
function get_AHEAD_atlas_labels(input,output_dir,algorParam) | ||
|
@@ -36,9 +36,11 @@ function get_AHEAD_atlas_labels(input,output_dir,algorParam) | |
if status == 127 | ||
setenv('PATH', [getenv('PATH') ':' ANTS_HOME]); | ||
end | ||
SEPIA_ANALYSIS_SEGMENTATION_dir = fullfile(SEPIA_HOME,'analysis','segmentation'); | ||
SEPIA_ATLAS_dir = fullfile(SEPIA_HOME,'atlas'); | ||
AHEAD_ATLAS_dir = fullfile(SEPIA_ATLAS_dir,'AHEAD_atlas'); | ||
% get atlas directory | ||
SpecifyAtlasDirectory; | ||
% SEPIA_ANALYSIS_SEGMENTATION_dir = fullfile(SEPIA_HOME,'analysis','segmentation'); | ||
% SEPIA_ATLAS_dir = fullfile(SEPIA_HOME,'atlas'); | ||
% AHEAD_ATLAS_HOME = fullfile(SEPIA_ATLAS_dir,'AHEAD_atlas'); | ||
|
||
output_tmp_dir = fullfile(output_dir,'AHEAD_intermediate_files',filesep); | ||
if ~exist(output_dir,'dir') | ||
|
@@ -81,11 +83,11 @@ function get_AHEAD_atlas_labels(input,output_dir,algorParam) | |
save_nii_img_only(T1w_nii,img_hybrid_nii, img_hybrid ); | ||
|
||
% create hybrid T1w+QSM image on the atlas data | ||
t1w = load_nii_img_only(fullfile(AHEAD_ATLAS_dir,'Templates_mni09b','ahead_final_med_r1map_n104_mni09b.nii.gz')); | ||
Chi_t1w = load_nii_img_only(fullfile(AHEAD_ATLAS_dir,'Templates_mni09b','ahead_final_med_qsm_n104_mni09b.nii.gz')); | ||
t1w = load_nii_img_only(fullfile(AHEAD_ATLAS_HOME,'Templates_mni09b','ahead_final_med_r1map_n104_mni09b.nii.gz')); | ||
Chi_t1w = load_nii_img_only(fullfile(AHEAD_ATLAS_HOME,'Templates_mni09b','ahead_final_med_qsm_n104_mni09b.nii.gz')); | ||
mask_t1 = t1w ~= 0; | ||
img_hybrid = compute_hybrid_t1w_chi(t1w, Chi_t1w, mask_t1, 400, 0.5 ); | ||
save_nii_img_only(fullfile(AHEAD_ATLAS_dir,'Templates_mni09b','ahead_final_med_r1map_n104_mni09b.nii.gz'),template_hybrid_nii, img_hybrid); | ||
save_nii_img_only(fullfile(AHEAD_ATLAS_HOME,'Templates_mni09b','ahead_final_med_r1map_n104_mni09b.nii.gz'),template_hybrid_nii, img_hybrid); | ||
clear img_hybrid Chi_t1w t1w mask_t1 | ||
|
||
% Step 4: register hybrid image to template space, non linear transform | ||
|
@@ -99,20 +101,20 @@ function get_AHEAD_atlas_labels(input,output_dir,algorParam) | |
t1_2_t1wTemplate_mat = fullfile(output_tmp_dir, 'T1w_2_Template_hybrid_image_0GenericAffine.mat'); | ||
t1_2_t1wTemplate_inverseWrap_nii = fullfile(output_tmp_dir, 'T1w_2_Template_hybrid_image_1InverseWarp.nii.gz'); | ||
|
||
mask_list = dir(fullfile(AHEAD_ATLAS_dir,'structures_mni09b','*_mask-*nii*')); | ||
mask_list = dir(fullfile(AHEAD_ATLAS_HOME,'structures_mni09b','*_mask-*nii*')); | ||
mode_interp = 1; % 1=GenericLabel; 2=linear | ||
mode_4D = 0; % 0=3D; 3=4D; equivalent to option -e in antsApplyTransforms see ANTs doc | ||
for k = 1:numel(mask_list) | ||
label_nii = fullfile(AHEAD_ATLAS_dir,'structures_mni09b',mask_list(k).name); | ||
label_nii = fullfile(AHEAD_ATLAS_HOME,'structures_mni09b',mask_list(k).name); | ||
cmd = ['sh ' shell_script ' ' output_tmp_dir ' ' num2str(mode_interp) ' ' num2str(mode_4D) ' ' label_nii ' ' Chi_nii ' ' gre_2_T1w_mat ' ' t1_2_t1wTemplate_mat ' ' t1_2_t1wTemplate_inverseWrap_nii]; | ||
system(cmd); | ||
end | ||
|
||
prob_list = dir(fullfile(AHEAD_ATLAS_dir,'structures_mni09b','*_proba-*nii*')); | ||
prob_list = dir(fullfile(AHEAD_ATLAS_HOME,'structures_mni09b','*_proba-*nii*')); | ||
mode_interp = 2; % 1=GenericLabel; 2=linear | ||
mode_4D = 0; % 0=3D; 3=4D; equivalent to option -e in antsApplyTransforms see ANTs doc | ||
for k = 1:numel(prob_list) | ||
label_nii = fullfile(AHEAD_ATLAS_dir,'structures_mni09b',prob_list(k).name); | ||
label_nii = fullfile(AHEAD_ATLAS_HOME,'structures_mni09b',prob_list(k).name); | ||
cmd = ['sh ' shell_script ' ' output_tmp_dir ' ' num2str(mode_interp) ' ' num2str(mode_4D) ' ' label_nii ' ' Chi_nii ' ' gre_2_T1w_mat ' ' t1_2_t1wTemplate_mat ' ' t1_2_t1wTemplate_inverseWrap_nii]; | ||
system(cmd); | ||
end | ||
|
@@ -126,20 +128,20 @@ function get_AHEAD_atlas_labels(input,output_dir,algorParam) | |
% Step 1: Apply tranformation | ||
shell_script = fullfile(SEPIA_ANALYSIS_SEGMENTATION_dir,'ANTs_gre_2_t1wAtlas_applyTransform.sh'); | ||
|
||
mask_list = dir(fullfile(AHEAD_ATLAS_dir,'structures_mni09b','*_mask-*nii*')); | ||
mask_list = dir(fullfile(AHEAD_ATLAS_HOME,'structures_mni09b','*_mask-*nii*')); | ||
mode_interp = 1; % 1=GenericLabel; 2=linear | ||
mode_4D = 0; % 0=3D; 3=4D; equivalent to option -e in antsApplyTransforms see ANTs doc | ||
for k = 1:numel(mask_list) | ||
label_nii = fullfile(AHEAD_ATLAS_dir,'structures_mni09b',mask_list(k).name); | ||
label_nii = fullfile(AHEAD_ATLAS_HOME,'structures_mni09b',mask_list(k).name); | ||
cmd = ['sh ' shell_script ' ' output_tmp_dir ' ' num2str(mode_interp) ' ' num2str(mode_4D) ' ' label_nii ' ' GRE_nii ' ' gre_2_T1w_mat ' ' t1_2_t1wTemplate_mat ' ' t1_2_t1wTemplate_inverseWrap_nii]; | ||
system(cmd); | ||
end | ||
|
||
prob_list = dir(fullfile(AHEAD_ATLAS_dir,'structures_mni09b','*_proba-*nii*')); | ||
prob_list = dir(fullfile(AHEAD_ATLAS_HOME,'structures_mni09b','*_proba-*nii*')); | ||
mode_4D = 0; % 0=3D; 3=4D; equivalent to option -e in antsApplyTransforms see ANTs doc | ||
mode_interp = 2; % 1=GenericLabel; 2=linear | ||
for k = 1:numel(prob_list) | ||
label_nii = fullfile(AHEAD_ATLAS_dir,'structures_mni09b',prob_list(k).name); | ||
label_nii = fullfile(AHEAD_ATLAS_HOME,'structures_mni09b',prob_list(k).name); | ||
cmd = ['sh ' shell_script ' ' output_tmp_dir ' ' num2str(mode_interp) ' ' num2str(mode_4D) ' ' label_nii ' ' GRE_nii ' ' gre_2_T1w_mat ' ' t1_2_t1wTemplate_mat ' ' t1_2_t1wTemplate_inverseWrap_nii]; | ||
system(cmd); | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
% Kwok-shing Chan @ DCCN | ||
% [email protected] | ||
% Date created: 6 October 2022 | ||
% Date last modified: | ||
% Date modified: 9 October 2023 | ||
% | ||
% | ||
function get_CIT168_reinf_learn_labels(input,output_dir,algorParam) | ||
|
@@ -36,11 +36,13 @@ function get_CIT168_reinf_learn_labels(input,output_dir,algorParam) | |
if status == 127 | ||
setenv('PATH', [getenv('PATH') ':' ANTS_HOME]); | ||
end | ||
SEPIA_ANALYSIS_SEGMENTATION_dir = fullfile(SEPIA_HOME,'analysis','segmentation'); | ||
SEPIA_ATLAS_dir = fullfile(SEPIA_HOME,'atlas'); | ||
CIT168_reinf_learn_ATLAS_dir = fullfile(SEPIA_ATLAS_dir,'CIT168_Reinf_Learn_v1.1.0'); | ||
% get atlas directory | ||
SpecifyAtlasDirectory; | ||
% SEPIA_ANALYSIS_SEGMENTATION_dir = fullfile(SEPIA_HOME,'analysis','segmentation'); | ||
% SEPIA_ATLAS_dir = fullfile(SEPIA_HOME,'atlas'); | ||
% CIT168_reinf_learn_ATLAS_HOME = fullfile(SEPIA_ATLAS_dir,'CIT168_Reinf_Learn_v1.1.0'); | ||
|
||
template_nii = fullfile(CIT168_reinf_learn_ATLAS_dir,'MNI152-Nonlin-Asym-2009c','CIT168toMNI152-2009c_T1w_brain.nii.gz'); | ||
template_nii = fullfile(CIT168_reinf_learn_ATLAS_HOME,'MNI152-Nonlin-Asym-2009c','CIT168toMNI152-2009c_T1w_brain.nii.gz'); | ||
|
||
output_tmp_dir = fullfile(output_dir,'CIT168_reinf_learn_intermediate_files',filesep); | ||
if ~exist(output_dir,'dir') | ||
|
@@ -75,14 +77,14 @@ function get_CIT168_reinf_learn_labels(input,output_dir,algorParam) | |
% deterministic labels | ||
mode_interp = 1; % 1=GenericLabel; 2=linear | ||
mode_4D = 0; % 0=3D; 3=4D; equivalent to option -e in antsApplyTransforms see ANTs doc | ||
label_nii = fullfile(CIT168_reinf_learn_ATLAS_dir,'MNI152-Nonlin-Asym-2009c','CIT168toMNI152-2009c_det.nii.gz'); | ||
label_nii = fullfile(CIT168_reinf_learn_ATLAS_HOME,'MNI152-Nonlin-Asym-2009c','CIT168toMNI152-2009c_det.nii.gz'); | ||
cmd = ['sh ' shell_script ' ' output_tmp_dir ' ' num2str(mode_interp) ' ' num2str(mode_4D) ' ' label_nii ' ' GRE_nii ' ' gre_2_T1w_mat ' ' t1_2_t1wTemplate_mat ' ' t1_2_t1wTemplate_inverseWrap_nii]; | ||
system(cmd); | ||
|
||
% probabilistic labels | ||
mode_interp = 2; % 1=GenericLabel; 2=linear | ||
mode_4D = 3; % 0=3D; 3=4D; equivalent to option -e in antsApplyTransforms see ANTs doc | ||
label_nii = fullfile(CIT168_reinf_learn_ATLAS_dir,'MNI152-Nonlin-Asym-2009c','CIT168toMNI152-2009c_prob.nii.gz'); | ||
label_nii = fullfile(CIT168_reinf_learn_ATLAS_HOME,'MNI152-Nonlin-Asym-2009c','CIT168toMNI152-2009c_prob.nii.gz'); | ||
cmd = ['sh ' shell_script ' ' output_tmp_dir ' ' num2str(mode_interp) ' ' num2str(mode_4D) ' ' label_nii ' ' GRE_nii ' ' gre_2_T1w_mat ' ' t1_2_t1wTemplate_mat ' ' t1_2_t1wTemplate_inverseWrap_nii]; | ||
system(cmd); | ||
|
||
|
@@ -97,22 +99,22 @@ function get_CIT168_reinf_learn_labels(input,output_dir,algorParam) | |
% deterministic labels | ||
mode_interp = 1; % 1=GenericLabel; 2=linear | ||
mode_4D = 0; % 0=3D; 3=4D; equivalent to option -e in antsApplyTransforms see ANTs doc | ||
label_nii = fullfile(CIT168_reinf_learn_ATLAS_dir,'MNI152-Nonlin-Asym-2009c','CIT168toMNI152-2009c_det.nii.gz'); | ||
label_nii = fullfile(CIT168_reinf_learn_ATLAS_HOME,'MNI152-Nonlin-Asym-2009c','CIT168toMNI152-2009c_det.nii.gz'); | ||
cmd = ['sh ' shell_script ' ' output_tmp_dir ' ' num2str(mode_interp) ' ' num2str(mode_4D) ' ' label_nii ' ' GRE_nii ' ' gre_2_T1w_mat ' ' t1_2_t1wTemplate_mat ' ' t1_2_t1wTemplate_inverseWrap_nii]; | ||
system(cmd); | ||
|
||
% probabilistic labels | ||
mode_interp = 2; % 1=GenericLabel; 2=linear | ||
mode_4D = 3; % 0=3D; 3=4D; equivalent to option -e in antsApplyTransforms see ANTs doc | ||
label_nii = fullfile(CIT168_reinf_learn_ATLAS_dir,'MNI152-Nonlin-Asym-2009c','CIT168toMNI152-2009c_prob.nii.gz'); | ||
label_nii = fullfile(CIT168_reinf_learn_ATLAS_HOME,'MNI152-Nonlin-Asym-2009c','CIT168toMNI152-2009c_prob.nii.gz'); | ||
cmd = ['sh ' shell_script ' ' output_tmp_dir ' ' num2str(mode_interp) ' ' num2str(mode_4D) ' ' label_nii ' ' GRE_nii ' ' gre_2_T1w_mat ' ' t1_2_t1wTemplate_mat ' ' t1_2_t1wTemplate_inverseWrap_nii]; | ||
system(cmd); | ||
|
||
end | ||
|
||
copyfile(fullfile(output_tmp_dir,'CIT168toMNI152-2009c_det_2gre.nii.gz'),fullfile(output_dir)); | ||
copyfile(fullfile(output_tmp_dir,'CIT168toMNI152-2009c_prob_2gre.nii.gz'),fullfile(output_dir)); | ||
copyfile(fullfile(CIT168_reinf_learn_ATLAS_dir,'labels.txt'),fullfile(output_dir,'CIT168_reinf_learn_labels.txt')); | ||
copyfile(fullfile(CIT168_reinf_learn_ATLAS_HOME,'labels.txt'),fullfile(output_dir,'CIT168_reinf_learn_labels.txt')); | ||
|
||
disp('Segmentation is done!') | ||
|
||
|
Oops, something went wrong.