diff --git a/cpp/petsird_generator.cpp b/cpp/petsird_generator.cpp index 9b5beef..c47fbcf 100644 --- a/cpp/petsird_generator.cpp +++ b/cpp/petsird_generator.cpp @@ -28,7 +28,7 @@ constexpr uint32_t NUMBER_OF_ENERGY_BINS = 3; constexpr uint32_t NUMBER_OF_TOF_BINS = 300; constexpr float RADIUS = 400.F; constexpr std::array CRYSTAL_LENGTH{ 20.F, 4.F, 4.F }; -constexpr std::array NUM_CRYSTALS_PER_MODULE{ 2, 4, 5 }; +constexpr std::array NUM_CRYSTALS_PER_MODULE{ 2, 4, 7 }; constexpr uint32_t NUM_MODULES_ALONG_RING{ 20 }; constexpr uint32_t NUM_MODULES_ALONG_AXIS{ 2 }; constexpr float MODULE_AXIS_SPACING{ (NUM_CRYSTALS_PER_MODULE[2] + 4) * CRYSTAL_LENGTH[2] }; @@ -64,6 +64,7 @@ get_detector_module() constexpr auto N0 = NUM_CRYSTALS_PER_MODULE[0]; constexpr auto N1 = NUM_CRYSTALS_PER_MODULE[1]; constexpr auto N2 = NUM_CRYSTALS_PER_MODULE[2]; + unsigned id = 0; for (int rep0 = 0; rep0 < N0; ++rep0) for (int rep1 = 0; rep1 < N1; ++rep1) for (int rep2 = 0; rep2 < N2; ++rep2) @@ -72,7 +73,7 @@ get_detector_module() { 0.0, 1.0, 0.0, (rep1 - N1 / 2) * CRYSTAL_LENGTH[1] }, { 0.0, 0.0, 1.0, (rep2 - N2 / 2) * CRYSTAL_LENGTH[2] } } }; rep_volume.transforms.push_back(transform); - rep_volume.ids.push_back(rep0 + N0 * (rep1 + N1 * rep2)); + rep_volume.ids.push_back(id++); } } diff --git a/python/petsird_generator.py b/python/petsird_generator.py index 2536a7a..b86fb3d 100644 --- a/python/petsird_generator.py +++ b/python/petsird_generator.py @@ -18,7 +18,7 @@ RADIUS = 400 CRYSTAL_LENGTH = (20, 4, 4) # num crystals in a module -NUM_CRYSTALS_PER_MODULE = (2, 4,5) +NUM_CRYSTALS_PER_MODULE = (2, 4, 7) NUM_MODULES_ALONG_RING = 20 NUM_MODULES_ALONG_AXIS = 2 MODULE_AXIS_SPACING = (NUM_CRYSTALS_PER_MODULE[2] + 4) * CRYSTAL_LENGTH[2] @@ -55,6 +55,7 @@ def get_detector_module() -> petsird.DetectorModule: N0 = NUM_CRYSTALS_PER_MODULE[0] N1 = NUM_CRYSTALS_PER_MODULE[1] N2 = NUM_CRYSTALS_PER_MODULE[2] + id = 0 for rep0 in range(N0): for rep1 in range(N1): for rep2 in range(N2): @@ -69,7 +70,8 @@ def get_detector_module() -> petsird.DetectorModule: ) ) rep_volume.transforms.append(transform) - rep_volume.ids.append(rep0 + N0 * (rep1 + N1 * rep2)) + rep_volume.ids.append(id) + id += 1 return petsird.DetectorModule( detecting_elements=[rep_volume], detecting_element_ids=[0] diff --git a/python/petsird_helpers.py b/python/petsird_helpers.py index 69183ab..31fbaf6 100644 --- a/python/petsird_helpers.py +++ b/python/petsird_helpers.py @@ -40,9 +40,12 @@ def get_module_and_element( assert len(scanner_geometry.replicated_modules) == 1 rep_module = scanner_geometry.replicated_modules[0] assert len(rep_module.object.detecting_elements) == 1 - num_modules = len(rep_module.transforms) + num_el_per_module = len( + rep_module.object.detecting_elements[0].ids + ) + return [ - ModuleAndElement(module=det % num_modules, el=det // num_modules) + ModuleAndElement(module=det // num_el_per_module, el=det % num_el_per_module) for det in scanner_det_ids ]