Skip to content

Commit 1c27abf

Browse files
committed
add error message to alert user to frame mismatch
1 parent 5c65a98 commit 1c27abf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

petdeface/pet.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ def _run_interface(self, runtime):
5555
frames_duration = np.array(meta.outputs.out_dict["FrameDuration"])
5656

5757
mid_frames = frames_start + frames_duration / 2
58+
59+
# check to see if the json sidecar file has the correct number of frames
60+
if len(mid_frames) != data.shape[-1]:
61+
json_file = pet_file.replace(".gz", "").replace(".nii", ".json")
62+
raise ValueError(
63+
f"Number of frames in {pet_file} does not match the number of frames in the json sidecar file {json_file}"
64+
)
65+
5866
wavg = np.trapz(data, x=mid_frames) / (mid_frames[-1] - mid_frames[0])
5967

6068
_, base, ext = split_filename(pet_file)

0 commit comments

Comments
 (0)