Skip to content

Commit

Permalink
Merge pull request #209 from fanyuyen/master
Browse files Browse the repository at this point in the history
[bug] fix pmcx dettpsf overwrites input bug, close #208
  • Loading branch information
fangq authored Feb 23, 2024
2 parents e28fd4c + 90e2419 commit 79fda9c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pmcx/pmcx/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ def dettpsf(detp, detnum, prop, time):
output:
tpsf: caculated temporal point spread function curve of the specified detector
"""
detp = detp.copy()

# select the photon data of the specified detector
detp["ppath"] = detp["ppath"][detp["detid"] == detnum, :]
detp["detid"] = detp["detid"][detp["detid"] == detnum]
Expand Down Expand Up @@ -370,7 +372,9 @@ def detphoton(detp, medianum, savedetflag, issaveref=None, srcnum=None):
newdetp["detid"] = detp[0, :].astype(int).transpose()
if np.any(newdetp["detid"] > 65535):
newdetp["srcid"] = np.right_shift(newdetp["detid"], 16, dtype=np.int32)
newdetp["detid"] = np.bitwise_and(newdetp["detid"], 0xff, dtype=np.int32)
newdetp["detid"] = np.bitwise_and(
newdetp["detid"], 0xFF, dtype=np.int32

This comment has been minimized.

Copy link
@fangq

fangq Feb 23, 2024

Author Owner

@fanyuyen, I think there is a bug here: detid can be greater than 0xFF=255.

mcx can accommodate at most 4000 src+det+medium combined, see
https://github.com/fangq/mcx/blob/51003bc6d5540285be16d581f9abcb488852df24/src/mcx_const.h#L57C1-L58C1

if you look at the original matlab code, I used 0xFFFF

newdetp.detid = bitand(newdetp.detid, int32(hex2dec('ffff')));

can you submit another PR and fix this? (and double check to see if this appears elsewhere).

please also add [bug] and add #209 in your commit message so it will be linked here.

thanks

)
c0 = 1

length = medianum
Expand Down

0 comments on commit 79fda9c

Please sign in to comment.