-
Notifications
You must be signed in to change notification settings - Fork 1
/
mrecon_kt.m
610 lines (464 loc) · 20.5 KB
/
mrecon_kt.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
function mrecon_kt( rawDataFilePath, varargin )
%MRECON_KT k-t SENSE reconstruction using ReconFrame
%
% MRECON_KT( rawDataFilePath, 'senseref', senseRefFilePath, 'coilsurvey', coilSurveyFilePath )
%
% MRECON_KT( ..., 'outputdir', outputDirPath )
%
% MRECON_KT( ..., 'outptname', outFilePrefix )
%
% MRECON_KT( ..., 'patchversion', 'PIH1' )
%
% MRECON_KT( ..., 'reconoptionpairs', opts )
%
% MRECON_KT( ..., 'reconktsense', false )
%
% MRECON_KT( ..., 'ktregstrength', 0.014 )
%
% MRECON_KT( ..., 'ktregstrengthroi', 0.00014 )
%
% MRECON_KT( ..., 'mask', mask )
%
% MRECON_KT( ..., 'exportpdf', true )
%
% MRECON_KT( ..., 'exportjson', true )
%
% MRECON_KT( ..., 'exportgoalc', true )
%
% MRECON_KT( ..., 'verbose', true )
%
% NOTE: senseref and coilsurvey currently required to estimate
% sensitivity maps; requirement may be removed in future with
% implementation of autocalibrated sensitivity maps
% jfpva (joshua.vanamerom@kcl.ac.uk)
%% Optional Input Argument Default Values
default.senseRefFilePath = '';
default.coilSurveyFilePath = '';
default.outputDirPath = pwd;
default.outFilePrefix = '';
default.reconOpts = {};
default.isReconKtSense = true;
default.ktRegStrength = 0.0014;
default.ktRegStrengthROI = default.ktRegStrength / 100;
default.mask = [];
default.patchVersion = '';
default.isExportPdf = true;
default.isExportJson = true;
default.isExportGoalc = true;
default.isVerbose = false;
%% Parse Input
p = inputParser;
if verLessThan('matlab','8.2')
add_param_fn = @( parseobj, argname, defaultval, validator ) addParamValue( parseobj, argname, defaultval, validator );
else
add_param_fn = @( parseobj, argname, defaultval, validator ) addParameter( parseobj, argname, defaultval, validator );
end
addRequired( p, 'rawDataFilePath', ...
@(x) validateattributes( x, {'char'}, {'vector'}, mfilename) );
add_param_fn( p, 'senseref', default.senseRefFilePath, ...
@(x) validateattributes( x, {'char'}, {'vector'}, mfilename) );
add_param_fn( p, 'coilsurvey', default.coilSurveyFilePath, ...
@(x) validateattributes( x, {'char'}, {'vector'}, mfilename) );
add_param_fn( p, 'outputdir', default.outputDirPath, ...
@(x) validateattributes( x, {'char'}, {'nonempty','vector'}, mfilename) );
add_param_fn( p, 'outputname', default.outFilePrefix, ...
@(x) validateattributes( x, {'char'}, {'nonempty','vector'}, mfilename) );
add_param_fn( p, 'reconoptionpairs', default.reconOpts, ...
@(x) validateattributes( x, {'cell'}, {}, mfilename) );
add_param_fn( p, 'reconktsense', default.isReconKtSense, ...
@(x) validateattributes( x, {'logical'}, {'scalar'}, mfilename) );
add_param_fn( p, 'ktregstrength', default.ktRegStrength, ...
@(x) validateattributes( x, {'numeric'}, {'positive','scalar'}, mfilename) );
add_param_fn( p, 'ktregstrengthroi', default.ktRegStrengthROI, ...
@(x) validateattributes( x, {'numeric'}, {'positive','scalar'}, mfilename) );
add_param_fn( p, 'mask', default.mask, ...
@(x) validateattributes( x, {'logical'}, {}, mfilename) );
add_param_fn( p, 'patchversion', default.patchVersion, ...
@(x) validateattributes( x, {'char'}, {'vector'}, mfilename) );
add_param_fn( p, 'exportpdf', default.isExportPdf, ...
@(x) validateattributes( x, {'logical'}, {'scalar'}, mfilename) );
add_param_fn( p, 'exportjson', default.isExportJson, ...
@(x) validateattributes( x, {'logical'}, {'scalar'}, mfilename) );
add_param_fn( p, 'exportgoalc', default.isExportGoalc, ...
@(x) validateattributes( x, {'logical'}, {'scalar'}, mfilename) );
add_param_fn( p, 'verbose', default.isVerbose, ...
@(x) validateattributes( x, {'logical'}, {'scalar'}, mfilename) );
parse( p, rawDataFilePath, varargin{:} );
senseRefFilePath = p.Results.senseref;
coilSurveyFilePath = p.Results.coilsurvey;
outputDirPath = p.Results.outputdir;
outFilePrefix = p.Results.outputname;
reconOpts = p.Results.reconoptionpairs;
isReconKtSense = p.Results.reconktsense;
ktRegStrength = p.Results.ktregstrength;
ktRegStrengthROI = p.Results.ktregstrengthroi;
mask = p.Results.mask;
patchVersion = p.Results.patchversion;
isExportPdf = p.Results.exportpdf;
isExportJson = p.Results.exportjson;
isExportGoalc = p.Results.exportgoalc;
isVerbose = p.Results.verbose;
%% Add Dependencies
origDepPath = path;
resetDepPath = onCleanup( @()path(origDepPath) );
codeDirPath = fileparts( which( mfilename ) );
addpath( genpath( fullfile( codeDirPath, 'lib' ) ) )
addpath( genpath( fullfile( codeDirPath, 'mrecon' ) ) )
addpath( genpath( fullfile( codeDirPath, 'recon' ) ) )
addpath( genpath( fullfile( codeDirPath, 'util' ) ) )
if isempty( which( 'MRecon' ) )
error( 'Require ReconFrame library in Matlab path.' )
end
%% Anonymous Functions
% Swap dimensions to/from ReconFrame
% ReconFrame:
% 1-2-3-4----5---6----7----8----9---10----11----12
% x?y-z?chan?dyn-card?echo?loca?mix?extr1?extr2?aver
% Otherwise:
% x-y-dyn-chan-loca-z-card-echo-mix-extr1-extr12-aver
dim.x = 1;
dim.y = 2;
dim.z = 3;
dim.chan = 4;
dim.dyn = 5;
dim.card = 6;
dim.echo = 7;
dim.loca = 8;
dim.mix = 9;
dim.extr1 = 10;
dim.extr2 = 11;
dim.aver = 12;
ind_reconframe_to_xydcl = [ dim.x dim.y dim.dyn dim.chan dim.loca dim.z dim.card dim.echo dim.mix dim.extr1 dim.extr2 dim.aver ];
[~,ind_xydcl_to_reconframe] = sort( ind_reconframe_to_xydcl );
swap_dim_reconframe_to_xydcl = @( data ) permute( data, ind_reconframe_to_xydcl );
swap_dim_xydcl_to_reconframe = @( data ) permute( data, ind_xydcl_to_reconframe );
% Verbose Messages
disp_start_step_msg = @( descStr ) fprintf( '%-70s ', strcat( descStr, ' ...' ) );
disp_time_elapsed_msg = @( t ) fprintf( '... %6gs elapsed\n', round(t) );
disp_write_file_msg = @( fileStr ) fprintf( ' saved to %s\n', fileStr );
%% Setup
% Output Filename Prefix
if isempty( outFilePrefix )
[~,outFilePrefix] = fileparts( rawDataFilePath );
end
% Coil Sensitivity Map Calculation Method
csmCalcMethod = '';
if ~isempty( senseRefFilePath ) && ~isempty( coilSurveyFilePath )
if exist( senseRefFilePath, 'file' ) && exist( coilSurveyFilePath, 'file' )
csmCalcMethod = 'prescan';
else
if ~exist( senseRefFilePath, 'file' )
warning( 'SENSE reference file does not exist: %s', senseRefFilePath )
end
if ~exist( coilSurveyFilePath, 'file' )
warning( 'Coil survey file does not exist: %s', coilSurveyFilePath )
end
end
end
if ~strcmp( csmCalcMethod, 'prescan' )
error( 'Only CSM calculation method ''prescan'' currently valid' )
end
%% Start
tic, % start timer
fprintf( '\n%s() started %s\n\n', mfilename, datestr(now) );
%% Load Data
% Undersampled Data
disp_start_step_msg( 'Loading and preprocessing undersampled data' )
ACQ = MRecon( rawDataFilePath );
ACQ.Parameter.Parameter2Read.typ = 1;
ACQ.Parameter.Parameter2Read.mix = 0;
ACQ.Parameter.Parameter2Read.Update;
ACQ.ReadData;
mrecon_setreconparam( ACQ, 'optionpairs', reconOpts );
mrecon_preprocess( ACQ );
disp_time_elapsed_msg( toc )
% Training Data
disp_start_step_msg( 'Loading and preprocessing training data' )
TRN = MRecon( rawDataFilePath );
TRN.Parameter.Parameter2Read.typ = 1;
TRN.Parameter.Parameter2Read.mix = 1;
TRN.Parameter.Parameter2Read.Update;
TRN.ReadData;
mrecon_setreconparam( TRN, 'optionpairs', reconOpts );
mrecon_preprocess( TRN );
disp_time_elapsed_msg( toc )
% Noise
disp_start_step_msg( 'Loading and preprocessing noise data' )
NOISE = MRecon( rawDataFilePath );
NOISE.Parameter.Parameter2Read.typ = 5;
NOISE.Parameter.Parameter2Read.mix = 0;
NOISE.Parameter.Parameter2Read.Update;
NOISE.ReadData;
mrecon_setreconparam( NOISE, 'optionpairs', reconOpts );
mrecon_preprocess( NOISE );
disp_time_elapsed_msg( toc )
% Save Data
disp_start_step_msg( 'Saving k-space data' )
ktAcq = swap_dim_reconframe_to_xydcl( ACQ.Data );
ktTrn = swap_dim_reconframe_to_xydcl( TRN.Data );
ktNoise = swap_dim_reconframe_to_xydcl( NOISE.Data );
kspaceMatFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_kspace.mat' ) );
save( kspaceMatFilePath, 'ktAcq', 'ktTrn', 'ktNoise', '-v7.3' );
clear ktAcq ktTrn ktNoise
disp_time_elapsed_msg( toc )
disp_write_file_msg( kspaceMatFilePath )
%% Calculate Coil Sensitivity Maps
switch csmCalcMethod
case 'prescan'
% Sense Reference
disp_start_step_msg( 'Loading SENSE reference data' ),
SREF = MRecon( senseRefFilePath );
disp_time_elapsed_msg( toc ),
% Coil Survey
disp_start_step_msg( 'Loading coil survey data' ),
COIL = MRecon( coilSurveyFilePath );
disp_time_elapsed_msg( toc ),
% Target
TGT = MRecon( rawDataFilePath );
TGT.Parameter.Parameter2Read.typ = 1;
TGT.Parameter.Parameter2Read.mix = 0;
TGT.Parameter.Recon.RemoveMOversampling = 'No';
% Calculate Coil Sensitivity Maps
disp_start_step_msg( 'Calculating coil sensitivity maps' )
% Create SENSE object
SENS = MRsense( SREF, TGT, COIL );
% Calculate sensitivity maps
SENS.CalculateSensitivity = 1;
SENS.Mask = 1;
SENS.Smooth = 1;
SENS.Extrapolate = 1;
SENS.MatchTargetSize = 1;
SENS.RemoveMOversampling = 0;
SENS.OutputSizeSensitivity = [ size(ACQ.Data,dim.x), size(ACQ.Data,dim.y), size(ACQ.Data,dim.loca) ];
SENS.OutputSizeReformated = SENS.OutputSizeSensitivity;
SENS.Perform;
% Extract data from MRsense object
csm = swap_dim_reconframe_to_xydcl( SENS.Sensitivity ); % coil sensitivity maps
imBody = swap_dim_reconframe_to_xydcl( SENS.ReformatedBodycoilData ); % body coil image
imCoil = swap_dim_reconframe_to_xydcl( SENS.ReformatedCoilData ); % array coil images
psiSens = SENS.Psi; % array coil noise covariance
csmMatFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_csm.mat' ) );
save( csmMatFilePath, 'csm', 'imBody', 'imCoil', 'psiSens', '-v7.3' );
disp_time_elapsed_msg( toc )
disp_write_file_msg( csmMatFilePath )
otherwise
error( 'Unrecognised CSM calculation method: %s', csmCalcMethod ),
end
% Add Sensitivity Maps to Undersampled and Training Data MRecon Objects
ACQ.Parameter.Recon.Sensitivities = SENS;
TRN.Parameter.Recon.Sensitivities = SENS;
%% Baseline Recon
% Display Start Message
disp_start_step_msg( 'Reconstructing baseline images' ),
% Copy MRecon Object
BLN = ACQ.Copy;
BLN.Parameter.Recon.SENSE = 'Yes'; % CLEAR coil combination
% Get Data from MRecon Object
ktAcq = swap_dim_reconframe_to_xydcl( BLN.Data );
% Sampling Pattern
ktSmp = single( sum( sum( ktAcq, 4 ), 1 ) ~= 0 );
% Get Baseline
ktBln = bsxfun( @rdivide, sum( ktAcq, 3 ), sum( ktSmp, 3 ) );
% Put Data in Back in MRecon Object
BLN.Data = swap_dim_xydcl_to_reconframe( ktBln );
% Transform to Image Space
mrecon_k2i( BLN );
% Image Space Postprocessing
mrecon_postprocess( BLN );
% Write to NIfTI
blnAbNiiFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_bln_ab' ) );
blnAbNiiFilePath = mrecon_writenifti( BLN, blnAbNiiFilePath, 'datatype', 'magnitude' );
blnReNiiFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_bln_re' ) );
blnReNiiFilePath = mrecon_writenifti( BLN, blnReNiiFilePath, 'datatype', 'real' );
blnImNiiFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_bln_im' ) );
blnImNiiFilePath = mrecon_writenifti( BLN, blnImNiiFilePath, 'datatype', 'imaginary' );
% Save as .mat
xtBln = BLN.Data;
blnMatFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_bln_recon.mat' ) );
save( blnMatFilePath, 'xtBln', '-v7.3' );
clear xtBln
% Display Time Elapsed Message
disp_time_elapsed_msg( toc )
disp_write_file_msg( blnAbNiiFilePath )
disp_write_file_msg( blnReNiiFilePath )
disp_write_file_msg( blnImNiiFilePath )
disp_write_file_msg( blnMatFilePath )
%% Sliding Window Recon
% Display Start Message
disp_start_step_msg( 'Computing sliding window reconstruction of undersampled data' ),
% Sliding Window Reconstruction MRecon Object
SLW = ACQ.Copy;
SLW.Parameter.Recon.SENSE = 'Yes'; % CLEAR coil combination
% Get Data from MRecon Object
ktSlw = swap_dim_reconframe_to_xydcl( SLW.Data );
% Fill k-Space Using Sliding Window for Each Slice
for iSlice = 1:size(SLW.Data,dim.loca)
ktSlw(:,:,:,:,iSlice) = kt_sliding_window( ktSlw(:,:,:,:,iSlice) );
end
% Put Data in Back in MRecon Object
SLW.Data = swap_dim_xydcl_to_reconframe( ktSlw );
% Recon Images
mrecon_k2i( SLW )
% Postprocessing
mrecon_postprocess( SLW );
% Get Timing
frameDuration = mrecon_calc_frame_duration( SLW );
% Save as NIfTI
slwNiiFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_slw_ab' ) );
slwNiiFilePath = mrecon_writenifti( SLW, slwNiiFilePath, 'frameduration', frameDuration );
% Display Time Elapsed Message
disp_time_elapsed_msg( toc ),
disp_write_file_msg( slwNiiFilePath )
%% k-t SENSE Reconstruction
if ( isReconKtSense )
% Display Start Message
fprintf( 'Performing k-t SENSE reconstruction \n' ),
% k-t SENSE Reconstruction MRecon Object
RCN = ACQ.Copy;
RCN.Data = sum (RCN.Data, dim.chan );
% k-t SENSE Prior MRecon Object
PRI = TRN.Copy;
PRI.Parameter.Recon.SENSE = 'Yes'; % CLEAR coil combination
% DC/Baseline MRecon Object
DC = ACQ.Copy;
DC.Data = sum( sum( DC.Data, dim.chan ), dim.dyn );
% Process Slice-by-Slice
numSlice = size( RCN.Data, dim.loca );
for iSlice = 1:numSlice
% Display Start Message
disp_start_step_msg( sprintf( ' slice %3i', iSlice ) )
% Get Data from MRecon Objects
ktAcq = swap_dim_reconframe_to_xydcl( ACQ.Data(:,:,:,:,:,:,:,iSlice,:,:,:,:) );
ktTrn = swap_dim_reconframe_to_xydcl( TRN.Data(:,:,:,:,:,:,:,iSlice,:,:,:,:) );
csm = swap_dim_reconframe_to_xydcl( ACQ.Parameter.Recon.Sensitivities.Sensitivity(:,:,:,:,:,:,:,iSlice,:,:,:,:) );
noiseCov = SENS.Psi;
% k-t SENSE Reconstruction
if isempty( mask )
[ ktRcn, ktDc ] = recon_ktsense( ktAcq, ktTrn, csm, 'noisecov', noiseCov, 'lambda0', ktRegStrength );
else
[ ktRcn, ktDc ] = recon_ktsense( ktAcq, ktTrn, csm, 'noisecov', noiseCov, 'lambda0', ktRegStrength, 'mask', mask(:,:,iSlice), 'lambdaroi', ktRegStrengthROI );
end
% TODO: compare recon using available noise covariance estimates:
% 1) estimated from k-t undersampled data,
% 2) calculated using noise samples in MRecon object NOISE, and
% 3) calculated in sensitivity maps MRecon object SENS
% Put Data in Back in MRecon Objects
RCN.Data(:,:,:,:,:,:,:,iSlice,:,:,:,:) = swap_dim_xydcl_to_reconframe( ktRcn );
DC.Data(:,:,:,:,:,:,:,iSlice,:,:,:,:) = swap_dim_xydcl_to_reconframe( ktDc );
% Save Reconstructed Data
reconMatFilePath = fullfile( outputDirPath, sprintf( '%s_slice%02i_recon.mat', outFilePrefix, iSlice ) );
save( reconMatFilePath, 'ktRcn', 'ktDc', '-v7.3' );
clear ktRcn ktDc
% Display Time Elapsed Message
disp_time_elapsed_msg( toc ),
disp_write_file_msg( reconMatFilePath ),
end
% Display Start Message
disp_start_step_msg( 'Finalising k-t SENSE reconstruction' ),
% Recon Images
mrecon_k2i( RCN )
mrecon_k2i( PRI )
mrecon_k2i( DC )
% Postprocessing
mrecon_postprocess( RCN );
mrecon_postprocess( PRI );
mrecon_postprocess( DC );
% Get Timing
frameDuration = mrecon_calc_frame_duration( RCN );
% Write Real-Time as NIfTI
rltAbNiiFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_rlt_ab' ) );
rltAbNiiFilePath = mrecon_writenifti( RCN, rltAbNiiFilePath, 'frameduration', frameDuration, 'datatype', 'magnitude' );
rltReNiiFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_rlt_re' ) );
rltReNiiFilePath = mrecon_writenifti( RCN, rltReNiiFilePath, 'frameduration', frameDuration, 'datatype', 'real' );
rltImNiiFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_rlt_im' ) );
rltImNiiFilePath = mrecon_writenifti( RCN, rltImNiiFilePath, 'frameduration', frameDuration, 'datatype', 'imaginary' );
% Write Training as NIfTI
priAbNiiFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_trn_ab' ) );
priAbNiiFilePath = mrecon_writenifti( PRI, priAbNiiFilePath, 'frameduration', frameDuration, 'datatype', 'magnitude' );
priReNiiFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_trn_re' ) );
priReNiiFilePath = mrecon_writenifti( PRI, priReNiiFilePath, 'frameduration', frameDuration, 'datatype', 'real' );
priImNiiFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_trn_im' ) );
priImNiiFilePath = mrecon_writenifti( PRI, priImNiiFilePath, 'frameduration', frameDuration, 'datatype', 'imaginary' );
% Write DC as NIfTI
dcAbNiiFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_dc_ab' ) );
dcAbNiiFilePath = mrecon_writenifti( DC, dcAbNiiFilePath, 'datatype', 'magnitude' );
dcReNiiFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_dc_re' ) );
dcReNiiFilePath = mrecon_writenifti( DC, dcReNiiFilePath, 'datatype', 'real' );
dcImNiiFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_dc_im' ) );
dcImNiiFilePath = mrecon_writenifti( DC, dcImNiiFilePath, 'datatype', 'imaginary' );
% Save as .mat
xtRcn = RCN.Data;
rltMatFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_rlt_recon.mat' ) );
save( rltMatFilePath, 'xtRcn', '-v7.3' );
clear xtRcn
xtPri = PRI.Data;
priMatFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_pri_recon.mat' ) );
save( priMatFilePath, 'xtPri', '-v7.3' );
clear xtPri
xtDc = DC.Data;
dcMatFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_dc_recon.mat' ) );
save( dcMatFilePath, 'xtDc', '-v7.3' );
clear xtDc
% Save Parameters
PARAM = mrecon_getparameters( RCN );
PARAM.Timing = mrecon_getslicetiming( RCN, 'patchversion', patchVersion );
rltParamMatFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_rlt_parameters.mat' ) );
save( rltParamMatFilePath, 'PARAM', '-v7.3' );
% Display Time Elapsed Message
disp_time_elapsed_msg( toc ),
disp_write_file_msg( rltAbNiiFilePath )
disp_write_file_msg( rltReNiiFilePath )
disp_write_file_msg( rltImNiiFilePath )
disp_write_file_msg( rltParamMatFilePath )
disp_write_file_msg( rltMatFilePath )
disp_write_file_msg( priAbNiiFilePath )
disp_write_file_msg( priReNiiFilePath )
disp_write_file_msg( priImNiiFilePath )
disp_write_file_msg( priMatFilePath )
disp_write_file_msg( dcAbNiiFilePath )
disp_write_file_msg( dcReNiiFilePath )
disp_write_file_msg( dcImNiiFilePath )
disp_write_file_msg( dcMatFilePath )
else
fprintf( 'Skipping k-t SENSE reconstruction \n' ),
end
%% Save GVE PDF
if ( isExportPdf )
% Display Start Message
disp_start_step_msg( 'Generating protocol definition file' ),
% Save GVE
gvepdfFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_pdf.gve' ) );
ACQ.Parameter.ExtractPDFFile( gvepdfFilePath );
% Display Time Elapsed Message
disp_time_elapsed_msg( toc ),
disp_write_file_msg( gvepdfFilePath )
end
%% Export JSON
if ( isExportJson )
% Display Start Message
disp_start_step_msg( 'Generating JSON parameter file' ),
% Export JSON
jsonFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '.json' ) );
if ( isReconKtSense )
RCN.Parameter.Export2Json( jsonFilePath );
else
ACQ.Parameter.Export2Json( jsonFilePath );
end
% Display Time Elapsed Message
disp_time_elapsed_msg( toc ),
disp_write_file_msg( jsonFilePath )
end
%% Export GoalC
if ( isExportGoalc )
% Display Start Message
disp_start_step_msg( 'Exporting GoalC information file' ),
% Export GoalC
goalcFilePath = fullfile( outputDirPath, strcat( outFilePrefix, '_goalc.txt' ) );
mrecon_writegoalc2txt( ACQ, goalcFilePath );
% Display Time Elapsed Message
disp_time_elapsed_msg( toc ),
disp_write_file_msg( goalcFilePath )
end
%% End
fprintf( '\n%s() finished %s\n\n', mfilename, datestr(now) );
end % mrecon_kt(...)