@@ -83,10 +83,40 @@ def make_detection_bin(
8383 [expanded_detection_bin ])[0 ]
8484
8585
86+ @typing .overload
87+ def get_detection_efficiency (scanner : petsird .ScannerInformation ,
88+ type_of_module_pair : petsird .TypeOfModulePair ,
89+ detection_bin_1 : petsird .DetectionBin ,
90+ detection_bin_2 : petsird .DetectionBin ) -> float :
91+ """Compute the detection efficiency for a pair of detectors"""
92+ ...
93+
94+
95+ @typing .overload
8696def get_detection_efficiency (scanner : petsird .ScannerInformation ,
8797 type_of_module_pair : petsird .TypeOfModulePair ,
8898 event : petsird .CoincidenceEvent ) -> float :
8999 """Compute the detection efficiency for a coincidence event"""
100+ ...
101+
102+
103+ _DetectionBinUnannotated = typing .get_args (petsird .DetectionBin )[0 ]
104+
105+
106+ def get_detection_efficiency (
107+ scanner : petsird .ScannerInformation ,
108+ type_of_module_pair : petsird .TypeOfModulePair ,
109+ event_or_detection_bin_1 : typing .Union [petsird .CoincidenceEvent ,
110+ petsird .DetectionBin ],
111+ detection_bin_2 : petsird .DetectionBin = None ) -> float :
112+ """Compute the detection efficiency"""
113+ if isinstance (event_or_detection_bin_1 , _DetectionBinUnannotated ):
114+ detection_bin_1 = event_or_detection_bin_1
115+ assert detection_bin_2 is not None , "Second detection bin must be provided"
116+ else :
117+ detection_bin_1 , detection_bin_2 = event_or_detection_bin_1 .detection_bins [:
118+ 2 ]
119+
90120 if scanner .detection_efficiencies is None :
91121 # should never happen really, but this way, we don't crash.
92122 return 1.
@@ -100,8 +130,8 @@ def get_detection_efficiency(scanner: petsird.ScannerInformation,
100130 detection_bin_efficiencies [type_of_module_pair [0 ]])
101131 detection_bin_efficiencies1 = (
102132 detection_bin_efficiencies [type_of_module_pair [1 ]])
103- eff *= (detection_bin_efficiencies0 [event . detection_bins [ 0 ] ] *
104- detection_bin_efficiencies1 [event . detection_bins [ 1 ] ])
133+ eff *= (detection_bin_efficiencies0 [detection_bin_1 ] *
134+ detection_bin_efficiencies1 [detection_bin_2 ])
105135 if eff == 0 :
106136 return 0.
107137
@@ -113,10 +143,10 @@ def get_detection_efficiency(scanner: petsird.ScannerInformation,
113143 assert module_pair_SGID_LUT is not None
114144 expanded_det_bin0 = expand_detection_bin (scanner ,
115145 type_of_module_pair [0 ],
116- event . detection_bins [ 0 ] )
146+ detection_bin_1 )
117147 expanded_det_bin1 = expand_detection_bin (scanner ,
118148 type_of_module_pair [1 ],
119- event . detection_bins [ 1 ] )
149+ detection_bin_2 )
120150
121151 SGID = module_pair_SGID_LUT [type_of_module_pair [0 ]][
122152 type_of_module_pair [1 ]][expanded_det_bin0 .module_index ,
0 commit comments