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 | /*!
* \file Tomato.h
* \author Konrad Werys
* \date 2018/08/14
*/
#ifndef Tomato_Tomato_EXPORT_HXX
#define Tomato_Tomato_EXPORT_HXX
#include "CmakeConfigForTomato.h"
#ifdef USE_ITK
namespace Ox {
template< typename IType, typename EType >
class CastPixelAccessor
{
public:
typedef IType InternalType;
typedef EType ExternalType;
static void Set(InternalType & output, const ExternalType & input)
{
output = static_cast<InternalType>( input );
}
static ExternalType Get( const InternalType & input )
{
return static_cast<ExternalType>( input );
}
};
template< typename MeasureType >
int
Tomato<MeasureType>
::exportToDicom(){
if (_opts->dir_output_map.empty()){
printf("No DICOM export, dir_output_map not given.\n");
return EXIT_FAILURE;
}
// OxColorbarImageFilter
typedef itk::Colorbar2DImageFilter< ImageType2D > OxColorbarImageFilterType;
typename OxColorbarImageFilterType::Pointer OxColorbarFilter = OxColorbarImageFilterType::New();
OxColorbarFilter->SetInput(_imageCalculatorItk->GetT1Image());
// get the dictionary ready before export
//typedef itk::MetaDataDictionary DictionaryType;
//DictionaryType & _dictionaryInput = reader->GetDicomIO()->GetMetaDataDictionary();
// T1 map with color
DictionaryType dictionaryOutput_T1Color(_dictionaryInput);
// UIDs
gdcm::UIDGenerator sopuid;
std::string sopInstanceUID_T1Color = sopuid.Generate();
gdcm::UIDGenerator suid;
std::string seriesUID_T1 = suid.Generate();
// seriesNumber
std::string seriesNumber, newSeriesNumber_T1;
itk::ExposeMetaData<std::string>(_dictionaryInput, "0020|0011", seriesNumber);
if (_opts->output_map_series_number == 0){
newSeriesNumber_T1 = KWUtil::NumberToString(KWUtil::StringToNumber<int>(seriesNumber) + 10002);
// newSeriesNumber_T1 = std::to_string( stoi(seriesNumber) + 10002 ); // C++11 needed to do this
} else {
newSeriesNumber_T1 = KWUtil::NumberToString(_opts->output_map_series_number);
}
// dicom tags dependent on the MagneticFieldStrength
std::string MagneticFieldStrength;
itk::ExposeMetaData<std::string>(_dictionaryInput, "0018|0087", MagneticFieldStrength);
std::string ImageCommentsT1mapWithColormap, clutRedString, clutGreenString, clutBlueString;
if (MagneticFieldStrength.find("1.5") != std::string::npos){
ImageCommentsT1mapWithColormap = ImageCommentsT1mapWithColormap.append("ShMOLLI color 980SD265ms");
clutRedString = getEncodedSting(getShmolliColormapRed15TArray());
clutGreenString = getEncodedSting(getShmolliColormapGreen15TArray());
clutBlueString = getEncodedSting(getShmolliColormapBlue15TArray());
printf("Colormap for MagneticFieldStrength 1.5T is used.\n");
} else if (MagneticFieldStrength.find("3") != std::string::npos){
ImageCommentsT1mapWithColormap = ImageCommentsT1mapWithColormap.append("ShMOLLI color 1198SD175ms");
clutRedString = getEncodedSting(getShmolliColormapRed3TArray());
clutGreenString = getEncodedSting(getShmolliColormapGreen3TArray());
clutBlueString = getEncodedSting(getShmolliColormapBlue3TArray());
printf("Colormap for MagneticFieldStrength 3T is used.\n");
} else {
printf("MagneticFieldStrength not detected, colormap will not be used.\n");
}
// PaletteColorLookupTableUID
std::string PaletteColorLookupTableUID;
itk::ExposeMetaData<std::string>(_dictionaryInput, "0028|1199", PaletteColorLookupTableUID);
//std::cout << "PaletteColorLookupTableUID: " << PaletteColorLookupTableUID << std::endl;
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1Color, std::string("0008|0018"), sopInstanceUID_T1Color);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1Color, std::string("0002|0003"), sopInstanceUID_T1Color);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1Color, std::string("0020|000e"), seriesUID_T1);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1Color, std::string("0028|1199"), PaletteColorLookupTableUID); // color look up table UID
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1Color, std::string("0020|0011"), newSeriesNumber_T1); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1Color, std::string("0020|4000"), ImageCommentsT1mapWithColormap); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1Color, std::string("0020|0013"), std::string("1")); // instance number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1Color, std::string("0028|0106"), std::string("0")); // smallest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1Color, std::string("0028|0107"), std::string("4096")); // largest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1Color, std::string("0028|1050"), std::string("2048")); // window center
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1Color, std::string("0028|1051"), std::string("4096")); // window width
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1Color, std::string("0028|1101"), std::string("4096\\0\\16")); // red color look up table descriptor
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1Color, std::string("0028|1102"), std::string("4096\\0\\16")); // green color look up table descriptor
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1Color, std::string("0028|1103"), std::string("4096\\0\\16")); // blue color look up table descriptor
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1Color, std::string("0028|1201"), clutRedString);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1Color, std::string("0028|1202"), clutGreenString);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1Color, std::string("0028|1203"), clutBlueString);
// T1 map no color
DictionaryType dictionaryOutput_T1(_dictionaryInput);
std::string sopInstanceUID_T1 = sopuid.Generate();
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1, std::string("0008|0018"), sopInstanceUID_T1);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1, std::string("0002|0003"), sopInstanceUID_T1);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1, std::string("0020|000e"), seriesUID_T1);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1, std::string("0020|0011"), newSeriesNumber_T1); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1, std::string("0020|4000"), std::string("ShMOLLI T1 map")); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1, std::string("0020|0013"), std::string("2")); // instance number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1, std::string("0028|0106"), std::string("0")); // smallest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1, std::string("0028|0107"), std::string("4096")); // largest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1, std::string("0028|1050"), std::string("2048")); // window center
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1, std::string("0028|1051"), std::string("4096")); // window width
// R2 map
DictionaryType dictionaryOutput_R2(_dictionaryInput);
std::string sopInstanceUID_R2 = sopuid.Generate();
std::string seriesUID_R2 = suid.Generate();
std::string newSeriesNumber_R2;
itk::ExposeMetaData<std::string>(_dictionaryInput, "0020|0011", seriesNumber);
if (_opts->output_fitparams_series_number == 0) {
newSeriesNumber_R2 = KWUtil::NumberToString(KWUtil::StringToNumber<int>(seriesNumber) + 10003);
//newSeriesNumber_R2 = std::to_string( std::stoi(seriesNumber) + 10003 ); // C++11
} else {
newSeriesNumber_R2 = KWUtil::NumberToString(_opts->output_fitparams_series_number);
}
itk::EncapsulateMetaData<std::string>( dictionaryOutput_R2, std::string("0008|0018"), sopInstanceUID_R2);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_R2, std::string("0002|0003"), sopInstanceUID_R2);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_R2, std::string("0020|000e"), seriesUID_R2);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_R2, std::string("0020|0011"), newSeriesNumber_R2); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_R2, std::string("0020|4000"), std::string("Rsquare*4000 Map")); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_R2, std::string("0020|0013"), std::string("3")); // instance number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_R2, std::string("0028|0106"), std::string("0")); // smallest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_R2, std::string("0028|0107"), std::string("4096")); // largest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_R2, std::string("0028|1050"), std::string("3900")); // window center
itk::EncapsulateMetaData<std::string>( dictionaryOutput_R2, std::string("0028|1051"), std::string("200")); // window width
// A map
DictionaryType dictionaryOutput_A(_dictionaryInput);
std::string sopInstanceUID_A = sopuid.Generate();
itk::EncapsulateMetaData<std::string>( dictionaryOutput_A, std::string("0008|0018"), sopInstanceUID_A);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_A, std::string("0002|0003"), sopInstanceUID_A);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_A, std::string("0020|000e"), seriesUID_R2);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_A, std::string("0028|1199"), PaletteColorLookupTableUID); // color look up table UID
itk::EncapsulateMetaData<std::string>( dictionaryOutput_A, std::string("0020|0011"), newSeriesNumber_R2); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_A, std::string("0020|4000"), std::string("Signal(TI)=[___AMap___]-B*exp(-TI/T1star)")); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_A, std::string("0020|0013"), std::string("4")); // instance number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_A, std::string("0028|0106"), std::string("0")); // smallest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_A, std::string("0028|0107"), std::string("4096")); // largest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_A, std::string("0028|1050"), std::string("2000")); // window center
itk::EncapsulateMetaData<std::string>( dictionaryOutput_A, std::string("0028|1051"), std::string("4000")); // window width
// B map
DictionaryType dictionaryOutput_B(_dictionaryInput);
std::string sopInstanceUID_B = sopuid.Generate();
itk::EncapsulateMetaData<std::string>( dictionaryOutput_B, std::string("0008|0018"), sopInstanceUID_B);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_B, std::string("0002|0003"), sopInstanceUID_B);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_B, std::string("0020|000e"), seriesUID_R2);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_B, std::string("0020|0011"), newSeriesNumber_R2); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_B, std::string("0020|4000"), std::string("Signal(TI)=A-[___BMap___]*exp(-TI/T1star)")); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_B, std::string("0020|0013"), std::string("5")); // instance number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_B, std::string("0028|0106"), std::string("0")); // smallest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_B, std::string("0028|0107"), std::string("4096")); // largest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_B, std::string("0028|1050"), std::string("2000")); // window center
itk::EncapsulateMetaData<std::string>( dictionaryOutput_B, std::string("0028|1051"), std::string("4000")); // window width
// T1star map
DictionaryType dictionaryOutput_T1star(_dictionaryInput);
std::string sopInstanceUID_T1star = sopuid.Generate();
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1star, std::string("0008|0018"), sopInstanceUID_T1star);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1star, std::string("0002|0003"), sopInstanceUID_T1star);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1star, std::string("0020|000e"), seriesUID_R2);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1star, std::string("0020|0011"), newSeriesNumber_R2); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1star, std::string("0020|4000"), std::string("Signal(TI)=A-B*exp(-TI/[___T1starMap___])")); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1star, std::string("0020|0013"), std::string("6")); // instance number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1star, std::string("0028|0106"), std::string("0")); // smallest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1star, std::string("0028|0107"), std::string("4096")); // largest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1star, std::string("0028|1050"), std::string("2000")); // window center
itk::EncapsulateMetaData<std::string>( dictionaryOutput_T1star, std::string("0028|1051"), std::string("4000")); // window width
// _ShMOLLIT1range map
DictionaryType dictionaryOutput_ShMolliT1Range(_dictionaryInput);
std::string sopInstanceUID_ShMolliT1Range = sopuid.Generate();
itk::EncapsulateMetaData<std::string>( dictionaryOutput_ShMolliT1Range, std::string("0008|0018"), sopInstanceUID_ShMolliT1Range);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_ShMolliT1Range, std::string("0002|0003"), sopInstanceUID_ShMolliT1Range);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_ShMolliT1Range, std::string("0020|000e"), seriesUID_R2);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_ShMolliT1Range, std::string("0020|0011"), newSeriesNumber_R2); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_ShMolliT1Range, std::string("0020|4000"), std::string("_ShMOLLIT1range")); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_ShMolliT1Range, std::string("0020|0013"), std::string("7")); // instance number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_ShMolliT1Range, std::string("0028|0106"), std::string("0")); // smallest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_ShMolliT1Range, std::string("0028|0107"), std::string("4096")); // largest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_ShMolliT1Range, std::string("0028|1050"), std::string("1500")); // window center
itk::EncapsulateMetaData<std::string>( dictionaryOutput_ShMolliT1Range, std::string("0028|1051"), std::string("3000")); // window width
// _nAmebaCallFinal map
DictionaryType dictionaryOutput_nAmebaCallFinal(_dictionaryInput);
std::string sopInstanceUID_nAmebaCallFinal = sopuid.Generate();
itk::EncapsulateMetaData<std::string>( dictionaryOutput_nAmebaCallFinal, std::string("0008|0018"), sopInstanceUID_nAmebaCallFinal);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_nAmebaCallFinal, std::string("0002|0003"), sopInstanceUID_nAmebaCallFinal);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_nAmebaCallFinal, std::string("0020|000e"), seriesUID_R2);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_nAmebaCallFinal, std::string("0020|0011"), newSeriesNumber_R2); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_nAmebaCallFinal, std::string("0020|4000"), std::string("_nAmebaCallFinal")); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_nAmebaCallFinal, std::string("0020|0013"), std::string("8")); // instance number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_nAmebaCallFinal, std::string("0028|0106"), std::string("0")); // smallest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_nAmebaCallFinal, std::string("0028|0107"), std::string("4096")); // largest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_nAmebaCallFinal, std::string("0028|1050"), std::string("2000")); // window center
itk::EncapsulateMetaData<std::string>( dictionaryOutput_nAmebaCallFinal, std::string("0028|1051"), std::string("4000")); // window width
// _RelSNRFinal map
DictionaryType dictionaryOutput_RelSNRFinal(_dictionaryInput);
std::string sopInstanceUID_RelSNRFinal = sopuid.Generate();
itk::EncapsulateMetaData<std::string>( dictionaryOutput_RelSNRFinal, std::string("0008|0018"), sopInstanceUID_RelSNRFinal);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_RelSNRFinal, std::string("0002|0003"), sopInstanceUID_RelSNRFinal);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_RelSNRFinal, std::string("0020|000e"), seriesUID_R2);
itk::EncapsulateMetaData<std::string>( dictionaryOutput_RelSNRFinal, std::string("0020|0011"), newSeriesNumber_R2); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_RelSNRFinal, std::string("0020|4000"), std::string("_RelSNRFinal")); // series number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_RelSNRFinal, std::string("0020|0013"), std::string("9")); // instance number
itk::EncapsulateMetaData<std::string>( dictionaryOutput_RelSNRFinal, std::string("0028|0106"), std::string("0")); // smallest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_RelSNRFinal, std::string("0028|0107"), std::string("4096")); // largest pixel
itk::EncapsulateMetaData<std::string>( dictionaryOutput_RelSNRFinal, std::string("0028|1050"), std::string("2000")); // window center
itk::EncapsulateMetaData<std::string>( dictionaryOutput_RelSNRFinal, std::string("0028|1051"), std::string("4000")); // window width
// get GDCMImageIO ready before export
typedef itk::GDCMImageIO ImageIOType;
ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
gdcmImageIO->KeepOriginalUIDOn();
// to cast
typedef itk::AdaptImageFilter < ImageType2D, OutputImageType, CastPixelAccessor< InputPixelType, OutputPixelType > > ImageAdaptorType;
typename ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
// get the writer ready before export
typedef itk::ImageFileWriter<OutputImageType> WriterType;
typename WriterType::Pointer writer = WriterType::New();
writer->SetUseInputMetaDataDictionary(false);
// maybe this? http://www.cplusplus.com/reference/string/string/find_last_of/
if (!_opts->dir_output_map.empty()) {
printf("Saving to: %s ", _opts->dir_output_map.c_str());
//std::cout << "Saving to: " << _opts->dir_output_map << std::flush;
itk::FileTools::CreateDirectory(_opts->dir_output_map);
// export T1 color
gdcmImageIO->SetMetaDataDictionary(dictionaryOutput_T1Color);
// export to dicom
adaptor->SetInput(OxColorbarFilter->GetOutput());
writer->SetFileName(_opts->dir_output_map + KWUtil::PathSeparator() + newSeriesNumber_T1 + "_T1color.dcm");
writer->SetInput(adaptor->GetOutput());
writer->SetImageIO(gdcmImageIO);
try {
writer->Update();
} catch (itk::ExceptionObject &e) {
std::cerr << "Exception in file writer " << std::endl;
std::cerr << e << std::endl;
}
// export T1 color
gdcmImageIO->SetMetaDataDictionary(dictionaryOutput_T1);
// export to dicom
adaptor->SetInput(OxColorbarFilter->GetOutput());
writer->SetFileName( _opts->dir_output_map + KWUtil::PathSeparator() + newSeriesNumber_T1 + "_T1.dcm");
writer->SetInput(adaptor->GetOutput());
writer->SetImageIO(gdcmImageIO);
try {
writer->Update();
} catch (itk::ExceptionObject &e) {
std::cerr << "Exception in file writer " << std::endl;
std::cerr << e << std::endl;
}
std::cout << " Saved!" << std::endl;
}
if (!_opts->dir_output_fitparams.empty()) {
printf("Saving to: %s ", _opts->dir_output_fitparams.c_str());
//std::cout << "Saving to: " << _opts->dir_output_fitparams << std::flush;
// scaling R2 * 4000
typedef itk::MultiplyImageFilter< ImageType2D, ImageType2D, ImageType2D > MultiplyImageFilterType;
typename MultiplyImageFilterType::Pointer multiplyFilter = MultiplyImageFilterType::New();
multiplyFilter->SetInput( _imageCalculatorItk->GetR2Image() );
multiplyFilter->SetConstant( 4000 );
OxColorbarFilter->SetInput(multiplyFilter->GetOutput());
OxColorbarFilter->SetZerosInsteadOfColorbar(true);
// mkdir
itk::FileTools::CreateDirectory(_opts->dir_output_fitparams);
// export R2
gdcmImageIO->SetMetaDataDictionary(dictionaryOutput_R2);
// export to dicom
adaptor->SetInput(OxColorbarFilter->GetOutput());
writer->SetFileName(_opts->dir_output_fitparams + KWUtil::PathSeparator() + newSeriesNumber_R2 + "_R2.dcm");
writer->SetInput(adaptor->GetOutput());
writer->SetImageIO(gdcmImageIO);
try {
writer->Update();
} catch (itk::ExceptionObject &e) {
std::cerr << "Exception in file writer " << std::endl;
std::cerr << e << std::endl;
}
// export A
gdcmImageIO->SetMetaDataDictionary(dictionaryOutput_A);
OxColorbarFilter->SetInput(_imageCalculatorItk->GetAImage());
OxColorbarFilter->SetZerosInsteadOfColorbar(true);
// export to dicom
adaptor->SetInput(OxColorbarFilter->GetOutput());
writer->SetFileName(_opts->dir_output_fitparams + KWUtil::PathSeparator() + newSeriesNumber_R2 + "_A.dcm");
writer->SetInput(adaptor->GetOutput());
writer->SetImageIO(gdcmImageIO);
try {
writer->Update();
} catch (itk::ExceptionObject &e) {
std::cerr << "Exception in file writer " << std::endl;
std::cerr << e << std::endl;
}
// export B
gdcmImageIO->SetMetaDataDictionary(dictionaryOutput_B);
OxColorbarFilter->SetInput(_imageCalculatorItk->GetBImage());
OxColorbarFilter->SetZerosInsteadOfColorbar(true);
// export to dicom
adaptor->SetInput(OxColorbarFilter->GetOutput());
writer->SetFileName(_opts->dir_output_fitparams + KWUtil::PathSeparator() + newSeriesNumber_R2 + "_B.dcm");
writer->SetInput(adaptor->GetOutput());
writer->SetImageIO(gdcmImageIO);
try {
writer->Update();
} catch (itk::ExceptionObject &e) {
std::cerr << "Exception in file writer " << std::endl;
std::cerr << e << std::endl;
}
// export T1star
gdcmImageIO->SetMetaDataDictionary(dictionaryOutput_T1star);
OxColorbarFilter->SetInput(_imageCalculatorItk->GetT1starImage());
OxColorbarFilter->SetZerosInsteadOfColorbar(true);
// export to dicom
adaptor->SetInput(OxColorbarFilter->GetOutput());
writer->SetFileName(_opts->dir_output_fitparams + KWUtil::PathSeparator() + newSeriesNumber_R2 + "_T1star.dcm");
writer->SetInput(adaptor->GetOutput());
writer->SetImageIO(gdcmImageIO);
try {
writer->Update();
} catch (itk::ExceptionObject &e) {
std::cerr << "Exception in file writer " << std::endl;
std::cerr << e << std::endl;
}
// export ShMolliRange
gdcmImageIO->SetMetaDataDictionary(dictionaryOutput_ShMolliT1Range);
typedef itk::NShmolliSamplesUsedTo123ImageFilter <ImageType2D> nShmolliSamplesUsedTo123FilterType;
typename nShmolliSamplesUsedTo123FilterType::Pointer nShmolliSamplesUsedTo123Filter = nShmolliSamplesUsedTo123FilterType::New();
nShmolliSamplesUsedTo123Filter->SetInput(_imageCalculatorItk->GetNShmolliSamplesUsedImage());
OxColorbarFilter->SetInput(nShmolliSamplesUsedTo123Filter->GetOutput());
OxColorbarFilter->SetZerosInsteadOfColorbar(true);
// export to dicom
adaptor->SetInput(OxColorbarFilter->GetOutput());
writer->SetFileName(_opts->dir_output_fitparams + KWUtil::PathSeparator() + newSeriesNumber_R2 + "_ShMolliRange.dcm");
writer->SetInput(adaptor->GetOutput());
writer->SetImageIO(gdcmImageIO);
try {
writer->Update();
} catch (itk::ExceptionObject &e) {
std::cerr << "Exception in file writer " << std::endl;
std::cerr << e << std::endl;
}
// TODO: change chisquare to final call value
// export nAmebaCalls
gdcmImageIO->SetMetaDataDictionary(dictionaryOutput_nAmebaCallFinal);
OxColorbarFilter->SetInput(_imageCalculatorItk->GetChiSqrtImage());
OxColorbarFilter->SetZerosInsteadOfColorbar(true);
// export to dicom
adaptor->SetInput(OxColorbarFilter->GetOutput());
writer->SetFileName(_opts->dir_output_fitparams + KWUtil::PathSeparator() + newSeriesNumber_R2 + "_nAmebaCallFinal.dcm");
writer->SetInput(adaptor->GetOutput());
writer->SetImageIO(gdcmImageIO);
try {
writer->Update();
} catch (itk::ExceptionObject &e) {
std::cerr << "Exception in file writer " << std::endl;
std::cerr << e << std::endl;
}
// TODO: check, values seem a little low
// export RelSNRFinal
gdcmImageIO->SetMetaDataDictionary(dictionaryOutput_RelSNRFinal);
OxColorbarFilter->SetInput(_imageCalculatorItk->GetSNRImage());
OxColorbarFilter->SetZerosInsteadOfColorbar(true);
// export to dicom
adaptor->SetInput(OxColorbarFilter->GetOutput());
writer->SetFileName(_opts->dir_output_fitparams + KWUtil::PathSeparator() + newSeriesNumber_R2 + "_RelSNRFinal.dcm");
writer->SetInput(adaptor->GetOutput());
writer->SetImageIO(gdcmImageIO);
try {
writer->Update();
} catch (itk::ExceptionObject &e) {
std::cerr << "Exception in file writer " << std::endl;
std::cerr << e << std::endl;
}
std::cout << " Saved!" << std::endl;
}
return 0; // EXIT_SUCCESS
}
} // namespace Ox
#endif
#endif //Tomato_Tomato_EXPORT_HXX
|