-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.m
66 lines (55 loc) · 2.3 KB
/
main.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 script loads channel-wise in vivo B1+ datasets of the human cervical
% and thoracolumbar spine at 7T and to compute and evaluate universal
% RF shims as described in:
%
% Aigner, Sanchez Alarcon, D'Astous, Alonso-Ortiz, Cohen-Adad and
% Schmitter. Calibration-Free Parallel Transmission of the Cervical,
% Thoracic, and Lumbar Spinal Cord at 7T. Submitted to MRM
%
% The channel-wise in vivo B1+ datasets of the human body at 7T are
% available at: https://doi.org/10.6084/m9.figshare.25233385.v1 .
%
% Created by Christoph S. Aigner, PTB, February 2024.
% Email: christoph.aigner@ptb.de
%
% This code is free under the terms of the GPL-3.0 license.
filename = 'data/CSpine_data.mat'; % CSPINE datasets
% filename = 'data/TLSpine_data.mat'; % TLSPINE datasets
%check if the files exist and load the in vivo B1+ datasets
if isfile(filename)
% File exists.
load(filename);
else
% File does not exist.
disp('The channel-wise in vivo B1+ datasets are available at:');
disp('https://doi.org/10.6084/m9.figshare.25233385.v1');
end
%load the phase init
load('data/Matlab_WS_Startphases_cxX0_1000x64.mat');
%params
optsdef.BETA0 = cxX0; %starting phase
optsdef.NOOFSTARTPHASES = 8; %compute 8 solutions with different init
optsdef.LAMBDA = 0.05; %cost homogeneity-efficiency weighting
numb_subjects = size(ROI.masks,3);
%compute universal RF shims with different phase inits
[betaAll,fAll] = b1_phase_shimming_TXfct(B1p.cxmap,ROI.masks,optsdef);
%now determin the best solution
[mmin, mind] = min(fAll);
lSolution = mind;
%calculate values for best solution
Shim.CurSet = betaAll(:,lSolution);
Shim.Values = quantify_phase_shim_TXfct(Shim.CurSet,B1p.cxmap,ROI.masks);
mtmp = abs(multiprod(B1p.cxmap,makeColVec(Shim.CurSet),4,1));
Shim.B1pred_mag = abs(mtmp);
Shim.B1pred_pha = angle(mtmp);
%calculate values for all solutions:
ShimStr.BestShim = Shim.CurSet;
ShimStr.AllShims = betaAll;
ShimStr.NoOfStartingPhases = optsdef.NOOFSTARTPHASES;
ShimStr.Values = Shim.Values;
for lL=1:optsdef.NOOFSTARTPHASES
ShimStr.ValuesAll(lL) = quantify_phase_shim_TXfct(betaAll(:,lL),B1p.cxmap,ROI.masks);
end
%Plot the Results
optsdef.ROTATE = 180;
show_shim_prediction_TXfct(Shim.CurSet, B1p.cxmap, ROI.masks, optsdef);