@@ -65,6 +65,17 @@ read_float(const H5::H5File& file, const std::string& dataset)
6565 return tmp;
6666}
6767
68+ static std::string
69+ read_string (const H5::H5File& file, const std::string& dataset)
70+ {
71+ H5::DataSet ds = file.openDataSet (dataset.c_str ());
72+ H5::StrType datatype = ds.getStrType ();
73+
74+ std::string value;
75+ ds.read (value, datatype);
76+ return value;
77+ }
78+
6879bool
6980GEHDF5Wrapper::check_GE_signature (const std::string& filename)
7081{
@@ -90,13 +101,7 @@ GEHDF5Wrapper::check_GE_signature(H5::H5File& file)
90101 if (file.getId () == -1 )
91102 error (" File is not open. Aborting" );
92103
93- H5::StrType vlst (
94- 0 ,
95- 37 ); // 37 here is the length of the string (PW got it from the text file generated by list2txt with the LIST000_decomp.BLF
96- std::string read_str_manufacturer;
97-
98- H5::DataSet dataset2 = file.openDataSet (" /HeaderData/ExamData/manufacturer" );
99- dataset2.read (read_str_manufacturer, vlst);
104+ std::string read_str_manufacturer = read_string (file, " /HeaderData/ExamData/manufacturer" );
100105
101106 if (read_str_manufacturer == " GE MEDICAL SYSTEMS" )
102107 {
@@ -277,14 +282,7 @@ GEHDF5Wrapper::open(const std::string& filename)
277282shared_ptr<Scanner>
278283GEHDF5Wrapper::get_scanner_from_HDF5 ()
279284{
280- std::string read_str_scanner;
281- H5::StrType vlst (
282- 0 ,
283- 37 ); // 37 here is the length of the string (PW got it from the text file generated by list2txt with the LIST000_decomp.BLF
284-
285- H5::DataSet dataset = file.openDataSet (" /HeaderData/ExamData/scannerDesc" );
286- dataset.read (read_str_scanner, vlst);
287-
285+ std::string read_str_scanner = read_string (this ->file , " /HeaderData/ExamData/scannerDesc" );
288286 float effective_ring_diameter;
289287 int num_transaxial_blocks_per_bucket = 0 ;
290288 int num_axial_blocks_per_bucket = 0 ;
@@ -425,6 +423,11 @@ GEHDF5Wrapper::initialise_proj_data_info_from_HDF5()
425423{
426424 shared_ptr<Scanner> scanner_sptr = get_scanner_from_HDF5 ();
427425
426+ // TODO get TOF mashing when reading sinos as TOF
427+ const auto num_tof_bins = read_dataset_uint32 (" /HeaderData/Sorter/numTOF_bins" );
428+ if (num_tof_bins > 1 )
429+ warning (" GE RDF data currently still read as non-TOF" );
430+
428431 this ->proj_data_info_sptr
429432 = ProjDataInfo::construct_proj_data_info (scanner_sptr,
430433 /* span*/ 2 ,
@@ -654,11 +657,20 @@ GEHDF5Wrapper::initialise_proj_data(const unsigned int view_num)
654657 if (view_num == 0 || view_num > static_cast <unsigned >(this ->get_scanner_sptr ()->get_num_detectors_per_ring () / 2 ))
655658 error (" internal error in GE HDF5 code: view number " + std::to_string (view_num) + " is incorrect" );
656659
660+ const auto num_tof_bins = read_dataset_uint32 (" /HeaderData/Sorter/numTOF_bins" );
661+
657662 if (rdf_ver == 9 )
658663 {
659- m_address = " /SegmentData/Segment2/3D_TOF_Sinogram/view" + std::to_string (view_num);
660-
661- m_dataset_sptr.reset (new H5::DataSet (file.openDataSet (m_address)));
664+ if (num_tof_bins > 1 )
665+ {
666+ m_address = " /SegmentData/Segment2/3D_TOF_Sinogram/view" + std::to_string (view_num);
667+ m_dataset_sptr.reset (new H5::DataSet (file.openDataSet (m_address)));
668+ }
669+ else
670+ {
671+ m_address = " /SegmentData/Segment2/3D_Sinogram/view" + std::to_string (view_num);
672+ m_dataset_sptr.reset (new H5::DataSet (file.openDataSet (m_address)));
673+ }
662674 m_dataspace = m_dataset_sptr->getSpace ();
663675 // Create an array to host the size of the dimensions
664676 const int rank = m_dataspace.getSimpleExtentNdims ();
@@ -673,13 +685,7 @@ GEHDF5Wrapper::initialise_proj_data(const unsigned int view_num)
673685 // AB for signa, these where [1981,27,357] and [45,448,357]
674686 m_NX_SUB = dims[0 ]; // hyperslab dimensions
675687 m_NY_SUB = dims[1 ];
676- m_NZ_SUB = dims[2 ];
677- #if 0
678- // AB todo: ??? why are these different?
679- m_NX = 45; // output buffer dimensions
680- m_NY = 448;
681- m_NZ = 357;
682- #endif
688+ m_NZ_SUB = rank > 2 ? dims[2 ] : 1 ;
683689 }
684690 else
685691 return Succeeded::no;
@@ -831,7 +837,6 @@ GEHDF5Wrapper::read_sinogram(Array<3, unsigned char>& output,
831837 }
832838 }
833839 }
834- output.release_data_ptr ();
835840 }
836841
837842 return Succeeded::yes;
0 commit comments