@@ -65,6 +65,17 @@ read_float(const H5::H5File& file, const std::string& dataset)
65
65
return tmp;
66
66
}
67
67
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
+
68
79
bool
69
80
GEHDF5Wrapper::check_GE_signature (const std::string& filename)
70
81
{
@@ -90,13 +101,7 @@ GEHDF5Wrapper::check_GE_signature(H5::H5File& file)
90
101
if (file.getId () == -1 )
91
102
error (" File is not open. Aborting" );
92
103
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" );
100
105
101
106
if (read_str_manufacturer == " GE MEDICAL SYSTEMS" )
102
107
{
@@ -277,14 +282,7 @@ GEHDF5Wrapper::open(const std::string& filename)
277
282
shared_ptr<Scanner>
278
283
GEHDF5Wrapper::get_scanner_from_HDF5 ()
279
284
{
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" );
288
286
float effective_ring_diameter;
289
287
int num_transaxial_blocks_per_bucket = 0 ;
290
288
int num_axial_blocks_per_bucket = 0 ;
@@ -425,6 +423,11 @@ GEHDF5Wrapper::initialise_proj_data_info_from_HDF5()
425
423
{
426
424
shared_ptr<Scanner> scanner_sptr = get_scanner_from_HDF5 ();
427
425
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
+
428
431
this ->proj_data_info_sptr
429
432
= ProjDataInfo::construct_proj_data_info (scanner_sptr,
430
433
/* span*/ 2 ,
@@ -654,11 +657,20 @@ GEHDF5Wrapper::initialise_proj_data(const unsigned int view_num)
654
657
if (view_num == 0 || view_num > static_cast <unsigned >(this ->get_scanner_sptr ()->get_num_detectors_per_ring () / 2 ))
655
658
error (" internal error in GE HDF5 code: view number " + std::to_string (view_num) + " is incorrect" );
656
659
660
+ const auto num_tof_bins = read_dataset_uint32 (" /HeaderData/Sorter/numTOF_bins" );
661
+
657
662
if (rdf_ver == 9 )
658
663
{
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
+ }
662
674
m_dataspace = m_dataset_sptr->getSpace ();
663
675
// Create an array to host the size of the dimensions
664
676
const int rank = m_dataspace.getSimpleExtentNdims ();
@@ -673,13 +685,7 @@ GEHDF5Wrapper::initialise_proj_data(const unsigned int view_num)
673
685
// AB for signa, these where [1981,27,357] and [45,448,357]
674
686
m_NX_SUB = dims[0 ]; // hyperslab dimensions
675
687
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 ;
683
689
}
684
690
else
685
691
return Succeeded::no;
@@ -831,7 +837,6 @@ GEHDF5Wrapper::read_sinogram(Array<3, unsigned char>& output,
831
837
}
832
838
}
833
839
}
834
- output.release_data_ptr ();
835
840
}
836
841
837
842
return Succeeded::yes;
0 commit comments