diff --git a/src/x_to_nwb/hr_segments.py b/src/x_to_nwb/hr_segments.py index f172ace..a17a848 100644 --- a/src/x_to_nwb/hr_segments.py +++ b/src/x_to_nwb/hr_segments.py @@ -161,7 +161,11 @@ def calculateNumberOfPoints(self, duration): """ Return the number of points of this segment. """ - return math.trunc(duration / self.sampleInterval) + num_points = duration / self.sampleInterval + num_points_int = int(np.round(num_points)) + if not math.isclose(num_points, num_points_int): + raise ValueError(f"Segment duration {duration} is not divisible by sample interval {self.sampleInterval}") + return num_points_int def getAmplitude(self, channelRec, segmentRec): """