1 /*=========================================================================
4 Module: $RCSfile: Dense2007ToDicom.cxx,v $
6 Date: $Date: 2008/03/28 15:36:57 $
7 Version: $Revision: 1.7 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
23 #if defined(__BORLANDC__)
28 #include "gdcmFileHelper.h"
29 #include "gdcmDebug.h"
30 #include "gdcmDirList.h"
32 #include "gdcmArgMgr.h"
36 * Converts the "Dense" ".txt" (2007 version) files into 16 bits Dicom Files,
37 * Hope they don't change soon!
40 void LoadPeakStrain(std::ifstream &from, std::string imageName, const char * patientname, std::string studyUID);
41 void LoadStrain(std::ifstream &from, std::string imageName, const char * patientname, bool createMultiFrame, std::string studyUID);
42 void MakeDicomImage(float *tabVal, float *X, float *Y, float *Z, int NP, std::string dcmImageName,
43 const char * patientname, int nbFrames, std::string studyUID, std::string serieUID);
47 int main(int argc, char *argv[])
50 " \n Dense2007ToDicom :\n ",
51 " Converts the '.txt' files into 16 bits Dicom Files, ",
53 " Dense2007ToDicom strain=...strain.txt peak_strain=...peak_strain.txt ",
54 " [patientname = Patient's name] ",
56 " [verbose] [debug] ",
58 " verbose : user wants to run the program in 'verbose mode' ",
59 " debug : *developer* wants to run the program in 'debug mode' ",
62 // ----- Initialize Arguments Manager ------
64 GDCM_NAME_SPACE::ArgMgr *am = new GDCM_NAME_SPACE::ArgMgr(argc, argv);
66 if (argc == 1 || am->ArgMgrDefined("usage"))
68 am->ArgMgrUsage(usage); // Display 'usage'
72 // Seems that ArgMgrWantString doesn't work on MacOS
73 if(!am->ArgMgrDefined("strain"))
75 std::cout << "strain is mandatory" << std::endl;
78 if(!am->ArgMgrDefined("peak_strain"))
80 std::cout << "peak_strain is mandatory" << std::endl;
84 const char *strain = am->ArgMgrWantString("strain",usage);
85 const char *peak_strain = am->ArgMgrWantString("peak_strain",usage);
87 const char *patientName = am->ArgMgrGetString("patientname");
89 bool createMultiFrame = (am->ArgMgrDefined("m") != 0);
91 if (am->ArgMgrDefined("debug"))
92 GDCM_NAME_SPACE::Debug::DebugOn();
94 verbose = ( 0 != am->ArgMgrDefined("verbose") );
96 // if unused Param we give up
97 if ( am->ArgMgrPrintUnusedLabels() )
99 am->ArgMgrUsage(usage);
103 delete am; // we don't need Argument Manager any longer
105 // ----- Begin Processing -----
107 std::ifstream fromPeakStrain( peak_strain );
108 if ( !fromPeakStrain )
110 std::cout << "Can't open file [" << peak_strain << "]" << std::endl;
114 std::ifstream fromStrain( strain );
117 std::cout << "Can't open file [" << strain << "]" << std::endl;
121 std::string strStudyUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
123 std::cout << "Success in open file [" << peak_strain << "]" << std::endl;
124 LoadPeakStrain(fromPeakStrain, peak_strain, patientName,strStudyUID);
125 fromPeakStrain.close();
127 std::cout << "Success in open file [" << strain << "]" << std::endl;
128 LoadStrain(fromStrain, strain, patientName, createMultiFrame, strStudyUID);
133 // =====================================================================================================================
135 void LoadPeakStrain(std::ifstream &from, std::string textFileName, const char * patientname,std::string studyUID)
137 // in sax_base_slice0_peak_strain.txt :
140 Number of material points (NP) = 181
141 Origin of (readout, phase enc, slice sel) coordinates in 3D = 87.3243 3.19392
143 Readout direction in 3D = -0.162314 -0.0771294 -0.983720
144 Phase Enc. direction in 3D = -0.540606 -0.827052 0.154046
145 Slice select direction in 3D = 0.825469 -0.556809 -0.0925458
146 The following are the (readout, phase enc, slice sel) coordinates (mm) of the grid points for which strains are calculated,
147 followed by their peak Ecc strain, an array of NP elements,
148 followed by their peak Err strain, an array of NP elements,
149 followed by their peak E11 strain, an array of NP elements,
150 followed by their Peak E22 strain, an array of NP elements,
151 42.0000 10.0000 0.000000
153 -0.154905 -0.0840482 -0.157350 -0.221403 -0.168118 -0.131331
154 -0.153781 -0.148481 -0.166602 -0.232858 -0.222650 -0.213712
164 //Number of material points (NP) = 181
173 std::cout << "NP : " << NP << std::endl;
175 //Origin of (readout, phase enc, slice sel) coordinates in 3D = 87.3243 3.19392 88.2381
188 float readout, phase_enc, slice_sel;
192 std::cout << " readout " << readout << " phase_enc " << phase_enc << " slice_sel " << slice_sel << std::endl;
194 // Readout direction in 3D = -0.162314 -0.0771294 -0.983720
202 float readoutX, readoutY, readoutZ;
206 std::cout << " readoutX " << readoutX << " readoutY " << readoutY << " readoutZ " << readoutZ << std::endl;
208 // Phase Enc. direction in 3D = -0.540606 -0.827052 0.154046
217 float phase_encX, phase_encY, phase_encZ;
221 std::cout << " phase_encX " << phase_encX << " phase_encY " << phase_encY << " phase_encZ " << phase_encZ << std::endl;
223 // Slice select direction in 3D = 0.825469 -0.556809 -0.0925458
231 float slice_selX, slice_selY, slice_selZ;
235 std::cout << " slice_selX " << slice_selX << " slice_selY " << slice_selY << " slice_selZ " << slice_selZ << std::endl;
240 The following are the (readout, phase enc, slice sel) coordinates (mm) of the grid points for which strains are calculated,
241 followed by their peak Ecc strain, an array of NP elements,
242 followed by their peak Err strain, an array of NP elements,
243 followed by their peak E11 strain, an array of NP elements,
244 followed by their Peak E22 strain, an array of NP elements,
247 std::cout << "------------start skipping 1 line---------------- " << std::endl;
248 std::getline(from, str1);
249 std::cout << "[" << str1 << "]" << std::endl;
250 std::cout << "------------start skipping 1 line---------------- " << std::endl;
251 std::getline(from, str1);
252 std::cout << "[" << str1 << "]" << std::endl;
253 std::cout << "------------start skipping 1 line---------------- " << std::endl;
254 std::getline(from, str1);
255 std::cout << "[" << str1 << "]" << std::endl;
256 std::cout << "------------start skipping 1 line---------------- " << std::endl;
257 std::getline(from, str1);
258 std::cout << "[" << str1 << "]" << std::endl;
259 std::cout << "------------start skipping 1 line---------------- " << std::endl;
260 std::getline(from, str1);
261 std::cout << "[" << str1 << "]" << std::endl;
262 std::cout << "------------start skipping 1 line---------------- " << std::endl;
263 std::getline(from, str1);
264 std::cout << "[" << str1 << "]" << std::endl;
265 std::cout << "------------stop skipping ---------------- " << std::endl;
267 float *X = new float[NP];
268 float *Y = new float[NP];
269 float *Z = new float[NP];
273 for (i=0; i<NP; i++) {
298 std::cout << "--------------- Ecc_strain ------------------" << std::endl;
299 float *ecc_strain = new float[NP];
300 for (i=0; i<NP; i++) {
301 from >> ecc_strain[i];
303 std::cout << ecc_strain[i] << std::endl;
307 std::cout << "--------------- Err_strain ------------------" << std::endl;
308 float *err_strain = new float[NP];
309 for (i=0; i<NP; i++) {
310 from >> err_strain[i];
312 std::cout << err_strain[i] << std::endl;
316 std::cout << "--------------- E11_strain ------------------" << std::endl;
317 float *e11_strain = new float[NP];
318 for (i=0; i<NP; i++) {
319 from >> e11_strain[i];
321 std::cout << e11_strain[i] << std::endl;
325 std::cout << "--------------- E22_strain ------------------" << std::endl;
326 float *e22_strain = new float[NP];
327 for (i=0; i<NP; i++) {
328 from >> e22_strain[i];
330 std::cout << e22_strain[i] << std::endl;
334 std::string dcmImageName;
335 std::string serieUID;
337 //followed by their peak Ecc strain, an array of NP elements,
338 serieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
339 dcmImageName = textFileName + "_peak_Ecc_strain.dcm";
340 MakeDicomImage(ecc_strain, X, Y, Z, NP, dcmImageName, patientname, 1, studyUID, serieUID);
342 //followed by their peak Err strain, an array of NP elements,
343 serieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
344 dcmImageName = textFileName + "_peak_Err_strain.dcm";
345 MakeDicomImage(err_strain, X, Y, Z, NP, dcmImageName, patientname, 1, studyUID, serieUID);
347 //followed by their peak E11 strain, an array of NP elements,
348 serieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
349 dcmImageName = textFileName + "_peak_E11_strain.dcm";
350 MakeDicomImage(e11_strain, X, Y, Z, NP, dcmImageName, patientname, 1, studyUID, serieUID);
352 //followed by their Peak E22 strain, an array of NP elements,
353 serieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
354 dcmImageName = textFileName + "_peak_E22_strain.dcm";
355 MakeDicomImage(e22_strain, X, Y, Z, NP, dcmImageName, patientname, 1, studyUID, serieUID);
358 // =====================================================================================================================
360 void LoadStrain(std::ifstream &from, std::string textFileName, const char * patientname, bool createMultiFrame, std::string studyUID)
363 // in sax_base_slice0_strain.txt :
365 Number of cine frames = 18
366 Temporal resolution = 32.0000 ms
367 First frame starts at 48.0000 ms
368 Number of material points (NP) = 181
369 Origin of (readout, phase enc, slice sel) coordinates in 3D = 87.324341 3.193918 88.238113
370 Readout direction in 3D = -0.162314 -0.0771294 -0.983720
371 Phase Enc. direction in 3D = -0.540606 -0.827052 0.154046
372 Slice select direction in 3D = 0.825469 -0.556809 -0.0925458
373 The following are the (readout, phase enc, slice sel) coordinates (mm) of the grid points for which strains are calculated,
374 followed by their Ecc strain, an array of dimensions(NP, number of cine frames),
375 followed by their Err strain, an array of dimensions(NP, number of cine frames),
376 followed by their E11 strain, an array of dimensions(NP, number of cine frames),
377 followed by their E22 strain, an array of dimensions(NP, number of cine frames),
378 Note that RV Err, E11 and E22 strains are not calculated due to the small thickness.
379 42.0000 10.0000 0.000000
380 44.0000 10.0000 0.000000
382 -0.0622793 -0.0840482 -0.157350 -0.196722 -0.105844 -0.131331
383 -0.153781 -0.00940573 -0.0542236 -0.100403 -0.0369671 -0.0696840
390 int NP; // Number of Points
391 int NCF; // Number of cine frames
392 float TR; // Temporal resolution
393 float FFS; // First frame starts
395 // Number of cine frames = 18
403 // Temporal resolution = 32.0000 ms
410 // First frame starts at 48.0000 ms
418 //Number of material points (NP) = 181
427 std::cout << "NP : " << NP << std::endl;
429 //Origin of (readout, phase enc, slice sel) coordinates in 3D = 87.324341 3.193918 88.238113
442 float readout, phase_enc, slice_sel;
446 std::cout << " readout " << readout << " phase_enc " << phase_enc << " slice_sel " << slice_sel << std::endl;
448 // Readout direction in 3D = -0.162314 -0.0771294 -0.983720
456 float readoutX, readoutY, readoutZ;
460 std::cout << " readoutX " << readoutX << " readoutY " << readoutY << " readoutZ " << readoutZ << std::endl;
462 // Phase Enc. direction in 3D = -0.540606 -0.827052 0.154046
471 float phase_encX, phase_encY, phase_encZ;
475 std::cout << " phase_encX " << phase_encX << " phase_encY " << phase_encY << " phase_encZ " << phase_encZ << std::endl;
477 // Slice select direction in 3D = 0.825469 -0.556809 -0.0925458
485 float slice_selX, slice_selY, slice_selZ;
489 std::cout << " slice_selX " << slice_selX << " slice_selY " << slice_selY << " slice_selZ " << slice_selZ << std::endl;
495 The following are the (readout, phase enc, slice sel) coordinates (mm) of the grid points for which strains are calculated,
496 followed by their Ecc strain, an array of dimensions(NP, number of cine frames),
497 followed by their Err strain, an array of dimensions(NP, number of cine frames),
498 followed by their E11 strain, an array of dimensions(NP, number of cine frames),
499 followed by their E22 strain, an array of dimensions(NP, number of cine frames),
500 Note that RV Err, E11 and E22 strains are not calculated due to the small thickness.
502 std::cout << "------------start skipping 1 line---------------- " << std::endl;
503 std::getline(from, str1);
504 std::cout << "[" << str1 << "]" << std::endl;
505 std::cout << "------------start skipping 1 line---------------- " << std::endl;
506 std::getline(from, str1);
507 std::cout << "[" << str1 << "]" << std::endl;
508 std::cout << "------------start skipping 1 line---------------- " << std::endl;
509 std::getline(from, str1);
510 std::cout << "[" << str1 << "]" << std::endl;
511 std::cout << "------------start skipping 1 line---------------- " << std::endl;
512 std::getline(from, str1);
513 std::cout << "[" << str1 << "]" << std::endl;
514 std::cout << "------------start skipping 1 line---------------- " << std::endl;
515 std::getline(from, str1);
516 std::cout << "[" << str1 << "]" << std::endl;
517 std::cout << "------------start skipping 1 line---------------- " << std::endl;
518 std::getline(from, str1);
519 std::cout << "[" << str1 << "]" << std::endl;
520 std::cout << "------------stop skipping ---------------- " << std::endl;
521 std::getline(from, str1);
522 std::cout << "[" << str1 << "]" << std::endl;
523 std::cout << "------------stop skipping ---------------- " << std::endl;
525 float *X = new float[NP];
526 float *Y = new float[NP];
527 float *Z = new float[NP];
531 for (i=0; i<NP; i++) {
555 std::string dcmImageName;
556 std::string serieUID;
558 std::cout << "=======================================================================================" << createMultiFrame << std::endl;
559 if(!createMultiFrame) { // One image per file here (single frame)
561 serieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
562 float *ecc_strain = new float[NP];
563 for (int nbr_of_frames=0; nbr_of_frames < NCF; nbr_of_frames++)
565 sprintf(frame, "_%d", nbr_of_frames);
567 std::cout << "--------------- Ecc_strain ------------------" << std::endl;
568 for (i=0; i<NP; i++) {
569 from >> ecc_strain[i];
571 std::cout << ecc_strain[i] << std::endl;
573 //followed by their Ecc strain, an array of NP elements,
574 dcmImageName = textFileName + frame + "_Ecc_strain.dcm";
575 std::cout << "Try to make image :[" << dcmImageName << "]" << std::endl;
576 MakeDicomImage(ecc_strain, X, Y, Z, NP, dcmImageName, patientname, 1, studyUID, serieUID);
577 }// end for nbr_of_frames
580 serieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
581 float *err_strain = new float[NP];
582 for (int nbr_of_frames=0; nbr_of_frames < NCF; nbr_of_frames++)
584 sprintf(frame, "_%d", nbr_of_frames);
585 std::cout << "--------------- Err_strain ------------------" << std::endl;
586 for (i=0; i<NP; i++) {
587 from >> err_strain[i];
589 std::cout << err_strain[i] << std::endl;
591 //followed by their Err strain, an array of NP elements,
592 dcmImageName = textFileName + frame + "_Err_strain.dcm";
593 std::cout << "Try to make image :[" << dcmImageName << "]" << std::endl;
594 MakeDicomImage(err_strain, X, Y, Z, NP, dcmImageName, patientname, 1, studyUID, serieUID);
595 }// end for nbr_of_frames
598 serieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
599 float *e11_strain = new float[NP];
600 for (int nbr_of_frames=0; nbr_of_frames < NCF; nbr_of_frames++)
602 sprintf(frame, "_%d", nbr_of_frames);
603 std::cout << "--------------- E11_strain ------------------" << std::endl;
604 for (i=0; i<NP; i++) {
605 from >> e11_strain[i];
607 std::cout << e11_strain[i] << std::endl;
609 //followed by their E11 strain, an array of NP elements,
610 dcmImageName = textFileName + frame + "_E11_strain.dcm";
611 std::cout << "Try to make image :[" << dcmImageName << "]" << std::endl;
612 MakeDicomImage(e11_strain, X, Y, Z, NP, dcmImageName, patientname, 1, studyUID, serieUID);
613 }// end for nbr_of_frames
616 serieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
617 float *e22_strain = new float[NP];
618 for (int nbr_of_frames=0; nbr_of_frames < NCF; nbr_of_frames++)
620 sprintf(frame, "_%d", nbr_of_frames);
621 std::cout << "--------------- E22_strain ------------------" << std::endl;
622 for (i=0; i<NP; i++) {
623 from >> e22_strain[i];
625 std::cout << e22_strain[i] << std::endl;
627 //followed by their E22 strain, an array of NP elements,
628 dcmImageName = textFileName + frame + "_E22_strain.dcm";
629 std::cout << "Try to make image :[" << dcmImageName << "]" << std::endl;
630 MakeDicomImage(e22_strain, X, Y, Z, NP, dcmImageName, patientname, 1, studyUID, serieUID);
631 } // end for nbr_of_frames
632 delete [] e22_strain;
634 } // end of single frame
637 else // generate Multiframe files
641 serieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID();
642 float *ecc_strain = new float[NP*NCF];
643 std::cout << "--------------- Ecc_strain ------------------" << std::endl;
644 for (i=0; i<NP*NCF; i++) {
645 from >> ecc_strain[i];
647 std::cout << ecc_strain[i] << std::endl;
649 //followed by their Ecc strain, an array of NP elements,
650 dcmImageName = textFileName + "_Ecc_strain.dcm";
651 std::cout << "Try to make image :[" << dcmImageName << "]" << std::endl;
652 MakeDicomImage(ecc_strain, X, Y, Z, NP, dcmImageName, patientname, NCF, studyUID, serieUID);
657 float *err_strain = new float[NP*NCF];
658 std::cout << "--------------- Err_strain ------------------" << std::endl;
659 for (i=0; i<NP*NCF; i++) {
660 from >> err_strain[i];
662 std::cout << err_strain[i] << std::endl;
664 //followed by their Ecc strain, an array of NP elements,
665 dcmImageName = textFileName + "_Err_strain.dcm";
666 std::cout << "Try to make image :[" << dcmImageName << "]" << std::endl;
667 MakeDicomImage(err_strain, X, Y, Z, NP, dcmImageName, patientname, NCF, studyUID, serieUID);
672 float *e11_strain = new float[NP*NCF];
673 std::cout << "--------------- E11_strain ------------------" << std::endl;
674 for (i=0; i<NP*NCF; i++) {
675 from >> e11_strain[i];
677 std::cout << e11_strain[i] << std::endl;
679 //followed by their Ecc strain, an array of NP elements,
680 dcmImageName = textFileName + "_E11_strain.dcm";
681 std::cout << "Try to make image :[" << dcmImageName << "]" << std::endl;
682 MakeDicomImage(e11_strain, X, Y, Z, NP, dcmImageName, patientname, NCF, studyUID, serieUID);
687 float *e22_strain = new float[NP*NCF];
688 std::cout << "--------------- E22_strain ------------------" << std::endl;
689 for (i=0; i<NP*NCF; i++) {
690 from >> e22_strain[i];
692 std::cout << e22_strain[i] << std::endl;
694 //followed by their Ecc strain, an array of NP elements,
695 dcmImageName = textFileName + "_E22_strain.dcm";
696 std::cout << "Try to make image :[" << dcmImageName << "]" << std::endl;
697 MakeDicomImage(e22_strain, X, Y, Z, NP, dcmImageName, patientname, NCF, studyUID, serieUID);
700 } // end of Multiframe
704 // =====================================================================================================================
707 void MakeDicomImage(float *tabVal, float *X, float *Y, float *Z, int NP, std::string dcmImageName, const char * patientName, int nbFrames, std::string studyUID, std::string serieUID)
710 std::cout << "=============================================================================="
711 << "enter MakeDicomImage [" << dcmImageName << "] [" << patientName << "]" << std::endl;
712 float minX = 99999., minY = 99999., minZ = 99999.;
713 float maxX = 0., maxY = 0., maxZ = 0.;
716 for (i=0; i<NP; i++) {
717 // std::cout << X[i] << " " << Y[i] << " " << Z[i] << std::endl;
732 std::cout << "Min X,Y,Z " << minX << " " << minY << " " << minZ << std::endl;
733 std::cout << "Max X,Y,Z " << maxX << " " << maxY << " " << maxZ << std::endl;
734 std::cout << "Size X,Y,Z " << maxX-minX << " " << maxY-minY << " " << maxZ-minZ << std::endl;
736 int lgrFrame = int(maxX*4.)*int(maxY*4.);
737 uint16_t *img = new uint16_t[lgrFrame*nbFrames ];
739 // Set whole image to 0
740 for(int i3=0; i3<lgrFrame*nbFrames; i3++)
743 for(int i4=0; i4<nbFrames; i4++)
744 for(int i2=0; i2<NP; i2++) {
745 int ordX = int(X[i2]*4.-30);
746 int ordY = int(maxY*4.) - int(Y[i2]*4.)+30;
747 img[ lgrFrame*i4 + ordX + ordY * int(maxX*4.) ] = int(tabVal[i2 + NP*i4]*100);
749 // Try to round up, just to see.
750 for(int iii=ordY-3; iii<ordY+4; iii++)
751 for(int jjj=ordX-3; jjj<ordX+4; jjj++)
752 img[ lgrFrame*i4 + jjj + iii * int(maxX*4.) ] = int(tabVal[i2 + NP*i4]*100);
755 std::cout << "===========sortie recup points" << std::endl;
756 // GDCM_NAME_SPACE::Debug::DebugOn();
758 std::ostringstream str;
760 GDCM_NAME_SPACE::File *file;
761 file = GDCM_NAME_SPACE::File::New();
763 // Set the image size
765 str << (int)(maxX*4.);
766 file->InsertEntryString(str.str(),0x0028,0x0011,"US"); // Columns
768 str << (int)(maxY*4.);
769 file->InsertEntryString(str.str(),0x0028,0x0010,"US"); // Rows
771 // Set the pixel type
773 file->InsertEntryString("16",0x0028,0x0100,"US"); // Bits Allocated
775 str << 16; // may be 12 or 16 if componentSize =16
776 file->InsertEntryString("16",0x0028,0x0101,"US"); // Bits Stored
777 file->InsertEntryString("15",0x0028,0x0102,"US"); // High Bit
779 // Set the pixel representation // 0/1 , 0=unsigned
780 file->InsertEntryString("1",0x0028,0x0103, "US"); // Pixel Representation
781 // Set the samples per pixel // 1:Grey level, 3:RGB
782 file->InsertEntryString("1",0x0028,0x0002, "US"); // Samples per Pixel
788 file->InsertEntryString(str.str(),0x0028,0x0008,"IS"); // Number of Frames
791 if (strlen(patientName) != 0)
792 file->InsertEntryString(patientName,0x0010,0x0010, "PN"); // Patient's Name
794 file->InsertEntryString(studyUID, 0x0020, 0x000d, "UI");
795 file->InsertEntryString(serieUID, 0x0020, 0x000e, "UI");
797 int pos = 0; // get the usefull part of the name
799 for(i=0, pos=0; pos<dcmImageName.size()-4; pos++, i++) {
800 if( dcmImageName[i]=='.' &&dcmImageName[i+1]=='t' && dcmImageName[i+2]=='x' && dcmImageName[i+3]=='t'
801 && dcmImageName[i+3]=='_') {
807 file->InsertEntryString(&(dcmImageName.c_str()[pos]),0x0008,0x103e, "LO"); // Series Description
809 // Set Rescale Intercept
812 file->InsertEntryString(str.str(),0x0028,0x1052,"DS");
817 file->InsertEntryString(str.str(),0x0028,0x1053,"DS");
820 GDCM_NAME_SPACE::FileHelper *fileH;
821 fileH = GDCM_NAME_SPACE::FileHelper::New(file);
822 // cast is just to avoid warnings (*no* conversion)
823 //fileH->SetImageData((uint8_t *)img,int(maxX*maxY)*sizeof(uint16_t)); // troubles when maxX, mayY are *actually* float!
825 fileH->SetImageData((uint8_t *)img,int(maxX*4.)*int(maxY*4.)*nbFrames*sizeof(uint16_t));
826 fileH->SetWriteModeToRaw();
827 fileH->SetWriteTypeToDcmExplVR();
829 if( !fileH->Write(dcmImageName))
830 std::cout << "Failed for [" << dcmImageName << "]\n"
831 << " File is unwrittable" << std::endl;