Skip to content

Commit

Permalink
Add implementation of PhysioLog.data attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrosss committed Jan 23, 2024
1 parent 64c284b commit 7c72e65
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/fmri_physio_log/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def _body(self) -> None:
self.rate = self.params[2] if self.n_params == 4 else self.params[3]
self.info = self._visitor._info[:]
self.ts = self._visitor._data[self.n_params :]
self.data = self._visitor._data.copy()

def _footer(self) -> None:
"""Interpret the physio footer (everything after the '5003' tag)
Expand Down
18 changes: 18 additions & 0 deletions tests/fmri_physio_log_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ def test_physio_log_simple_1():
assert log.params == (1, 2, 40, 280)
assert log.info == []

assert len(log.data) == log.n_params + len(log.ts)
assert log.data == [*log.params, *log.ts]

assert log.ecg == fpl.MeasurementSummary(0, 0, 0, 0, 0, 0)
assert log.puls == fpl.MeasurementSummary(75, 790, 211, 1055, 530, 47)
assert log.resp == fpl.MeasurementSummary(11, 5400, 4400, 5600, 5000, 81)
Expand Down Expand Up @@ -103,6 +106,9 @@ def test_physio_log_simple_2():
assert log.params == (1, 8, 20, 2)
assert log.info == []

assert len(log.data) == log.n_params + len(log.ts)
assert log.data == [*log.params, *log.ts]

assert log.ecg == fpl.MeasurementSummary(0, 0, 0, 0, 0, 0)
assert log.puls == fpl.MeasurementSummary(72, 823, 355, 1646, 795, 5)
assert log.resp == fpl.MeasurementSummary(0, 0, 0, 0, 0, 0)
Expand Down Expand Up @@ -144,6 +150,9 @@ def test_physio_log_with_info():
assert log.params == (1, 1, 2, 40, 280)
assert len(log.info) == 5

assert len(log.data) == log.n_params + len(log.ts)
assert log.data == [*log.params, *log.ts]

assert log.ecg == fpl.MeasurementSummary(0, 0, 0, 0, 0, 0)
assert log.puls == fpl.MeasurementSummary(148, 405, 180, 1142, 498, 17)
assert log.resp == fpl.MeasurementSummary(12, 4660, 4400, 5740, 4973, 44)
Expand Down Expand Up @@ -187,6 +196,9 @@ def test_physio_log_with_multiline_body():
assert log.params == (1, 2, 40, 280)
assert len(log.info) == 2

assert len(log.data) == log.n_params + len(log.ts)
assert log.data == [*log.params, *log.ts]

assert log.ecg == fpl.MeasurementSummary(0, 0, 0, 0, 0, 0)
assert log.puls == fpl.MeasurementSummary(66, 906, 731, 1113, 914, 1)
assert log.resp == fpl.MeasurementSummary(18, 3260, 3080, 4540, 3779, 73)
Expand All @@ -208,6 +220,9 @@ def test_physio_log_from_filename_basic(sample_basic_puls_file: Path):
assert log.rate == 20
assert log.params == (1, 8, 20, 2)

assert len(log.data) == log.n_params + len(log.ts)
assert log.data == [*log.params, *log.ts]

assert log.ecg == fpl.MeasurementSummary(
freq=0,
per=0,
Expand Down Expand Up @@ -280,6 +295,9 @@ def test_physio_log_from_filename_with_ext2(sample_with_ext2_file: Path):
assert log.rate == 40
assert log.params == (1, 2, 40, 280)

assert len(log.data) == log.n_params + len(log.ts)
assert log.data == [*log.params, *log.ts]

assert log.ecg == fpl.MeasurementSummary(
freq=0,
per=0,
Expand Down

0 comments on commit 7c72e65

Please sign in to comment.