forked from sevimcengiz/Oryx-MRSI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
corrected_conc_map_generation.m
66 lines (52 loc) · 2.41 KB
/
corrected_conc_map_generation.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
%% This function generates CSF corrected concentration Maps of all metabolites.
% Inputs: P info struct, All concentration values parsed from LCModel output files.
% CSF corrected concentration map results will be under
% ~nifti/corrected_conc_maps folder as a nifti format.
% CSF correction is done using this formula: C=C0(1/(1-Vcsf),
% where C0 is concentration value parsed from LCModel outputs, Vcsf is the
% fraction value of CSF.
% Author: Sevim Cengiz, Bogazici University , 2020
% Contact: sevim_cengiz@icloud.com
function corrected_conc_map_generation(Pinfo,AllConc,coreg_path,Metabolites,includedvoxels)
[sli row col]=size(Pinfo.littlevoxels);
fcsf=Pinfo.frac_CSF;
litvox_pixloc=Pinfo.metab;
metno=size(Metabolites);
for n=1:metno(1,2)
MRIFOVMask_file=load_untouch_nii([coreg_path,filesep,Pinfo.sparname,'_FOV_mask.nii']); %newly added
im_size=size(MRIFOVMask_file.img);
MRIFOVMask_file.img=zeros(im_size);
MRIpressMask_file=load_untouch_nii([coreg_path,filesep,Pinfo.sparname,'_',Metabolites(n).name,'_PressBox_mask.nii']);
%% Corrected metabolite concentration maps were generated using this formula
% C=C0(1/(1-Vcsf)
for isli=1:sli
for irow=1:row
for icol=1:col
if includedvoxels(n,isli,irow,icol)==1
loc=litvox_pixloc(1).littlevoxels(isli,irow,icol).loc;
[xx,yy] =size(loc);
C0=AllConc(n,isli,irow,icol);
Vcsf=fcsf(1,isli,irow,icol);
CorrMetConc=C0*(1/(1-Vcsf));
for kk=1:xx
locations=loc(kk,:);
lx=locations(1,1);
ly=locations(1,2);
lz=locations(1,3);
MRIFOVMask_file.img(lx,ly,lz)=CorrMetConc;
end
end
end
end
end
out_mask2=[Pinfo.spectrapath,filesep,'nifti',filesep,'corrected_conc_maps'];
if ~exist(out_mask2,'dir')
mkdir(out_mask2);
end
Mask_path=[out_mask2,filesep,Pinfo.sparname,'_',Metabolites(n).name,'_conc_corrected.nii'];
mask=(MRIFOVMask_file.img.*MRIpressMask_file.img);
MRIFOVMask_file.img=mask;
MRIFOVMask_file.untouch=1;
MRIFOVMask_file.fileprefix= Mask_path;
save_untouch_nii(MRIFOVMask_file, Mask_path)
end