forked from sevimcengiz/Oryx-MRSI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConc_CRLB_Generation.m
73 lines (59 loc) · 2.53 KB
/
Conc_CRLB_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
67
68
69
70
71
72
73
%% This function generates NIfTI volumes which keeps CRLB values of all metabolites.
% Inputs: P info struct, All concentration values parsed from LCModel output files.
% All maps will be saved under ~nifti/CRLB_maps folder as a nifti file.
% Author: Sevim Cengiz, Bogazici University , 2022 - For revision
% Contact: [email protected]
function Conc_CRLB_Generation(Pinfo,AllNumStd,coreg_path,Metabolites,referancemetabolite)
[sli row col]=size(Pinfo.littlevoxels);
fcsf=Pinfo.frac_CSF;
includedvoxels=ones(1,sli,row,col);
litvox_pixloc=Pinfo.metab;
metno=size(Metabolites);
for n=1:metno(1,2)
if referancemetabolite=='NAA'
refmetpressname='NAA+NAAG';
elseif referancemetabolite=='Cr'
refmetpressname='Cr+PCr';
elseif referancemetabolite=='Cho'
refmetpressname='GPC+PCh'
elseif referancemetabolite=='Lac'
refmetpressname='Lac'
else
refmetpressname=referancemetabolite;
end
MRIFOVMask_file=load_untouch_nii([coreg_path,filesep,Pinfo.sparname,'_FOV_mask.nii']);
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']);
MRIpressMask_file=load_untouch_nii([coreg_path,filesep,Pinfo.sparname,'_',refmetpressname,'_PressBox_mask.nii']);
%% LCModel concentration results are used after exclusion criteria.
for isli=1:sli
for irow=1:row
for icol=1:col
if includedvoxels(1,isli,irow,icol)==1 || includedvoxels(1,isli,irow,icol)==0
loc=litvox_pixloc(1).littlevoxels(isli,irow,icol).loc;
[xx,yy] =size(loc);
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)=AllNumStd(n,isli,irow,icol);
end
end
end
end
end
out_mask=[Pinfo.spectrapath,filesep,'nifti',filesep,'CRLB_maps'];
if ~exist(out_mask,'dir')
mkdir(out_mask);
end
Mask_path=[out_mask,filesep,Pinfo.sparname,'_',Metabolites(n).name,'_CRLB.nii'];
mask=(MRIFOVMask_file.img.*MRIpressMask_file.img);
MRIFOVMask_file.img=mask;
MRIFOVMask_file.img=MRIFOVMask_file.img;
MRIFOVMask_file.untouch=1;
MRIFOVMask_file.fileprefix= Mask_path;
save_untouch_nii(MRIFOVMask_file, Mask_path)
end
%% kk