Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.9.0 #121

Merged
merged 20 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
# Name the job
name: Lint and Test
# Set the type of machine to run on
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
# Check out the latest commit from the current branch
- name: Checkout Current Branch
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.9.0] - 2024-03-26
### Added
- PNSSet class for parsing and writing `pnsSet.xml` files

### Fixed
- add ampSerialNumber and ampFirmwareVersion props to `FileInfo` class

## [0.8.0] - 2022-10-18
### Added
- coordinates and sensor layout XML files for the Geodesic Head Web
Expand Down Expand Up @@ -90,7 +97,8 @@ In `Reader.get_physical_samples_from_epoch()`:
- Parse key elements in categories.xml files with `mffpy.xml_files.Categories` class.
- Incorporate `cached_property` dependency into `mffpy` library.

[Unreleased]: https://github.com/bel-public/mffpy/compare/v0.8.0...HEAD
[Unreleased]: https://github.com/bel-public/mffpy/compare/v0.9.0...HEAD
[0.9.0]: https://github.com/bel-public/mffpy/compare/v0.8.0...v0.9.0
[0.8.0]: https://github.com/bel-public/mffpy/compare/v0.7.4...v0.8.0
[0.7.4]: https://github.com/bel-public/mffpy/compare/v0.7.3...v0.7.4
[0.7.3]: https://github.com/bel-public/mffpy/compare/v0.7.2...v0.7.3
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ $ pre-commit install
platform linux -- Python 3.6.7, pytest-7.0.1, pluggy-1.0.0
rootdir: /home/runner/work/mffpy/mffpy
plugins: cov-4.0.0
collected 122 items
collected 123 items

mffpy/tests/test_cached_property.py .. [ 1%]
mffpy/tests/test_devices.py ............. [ 12%]
mffpy/tests/test_dict2xml.py . [ 13%]
mffpy/tests/test_header_block.py .. [ 14%]
mffpy/tests/test_mffdir.py .... [ 18%]
mffpy/tests/test_mffdir.py .... [ 17%]
mffpy/tests/test_raw_bin_files.py .................. [ 32%]
mffpy/tests/test_reader.py ...................... [ 50%]
mffpy/tests/test_writer.py ........... [ 59%]
mffpy/tests/test_xml_files.py .......................................... [ 94%]
.. [ 95%]
mffpy/tests/test_xml_files.py .......................................... [ 93%]
... [ 95%]
mffpy/tests/test_zipfile.py ..... [100%]

----------- coverage: platform linux, python 3.6.7-final-0 -----------
Expand All @@ -68,23 +68,23 @@ mffpy/mffdir.py 92 7 92%
mffpy/raw_bin_files.py 113 0 100%
mffpy/reader.py 110 2 98%
mffpy/tests/__init__.py 0 0 100%
mffpy/tests/conftest.py 11 0 100%
mffpy/tests/conftest.py 15 0 100%
mffpy/tests/test_cached_property.py 33 0 100%
mffpy/tests/test_devices.py 12 0 100%
mffpy/tests/test_dict2xml.py 16 0 100%
mffpy/tests/test_header_block.py 33 0 100%
mffpy/tests/test_mffdir.py 30 0 100%
mffpy/tests/test_raw_bin_files.py 63 0 100%
mffpy/tests/test_reader.py 96 0 100%
mffpy/tests/test_writer.py 204 0 100%
mffpy/tests/test_xml_files.py 202 1 99%
mffpy/tests/test_writer.py 212 0 100%
mffpy/tests/test_xml_files.py 214 1 99%
mffpy/tests/test_zipfile.py 34 0 100%
mffpy/version.py 1 0 100%
mffpy/writer.py 71 0 100%
mffpy/xml_files.py 554 18 97%
mffpy/xml_files.py 607 22 96%
mffpy/zipfile.py 47 0 100%
-----------------------------------------------------------------
TOTAL 2023 40 98%
TOTAL 2100 44 98%


============================= 122 passed in 7.19s ==============================
Expand Down
3 changes: 3 additions & 0 deletions examples/example_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"mffVersion": "3",
"acquisitionVersion": "5.4.1.2 (r28337)",
"ampType": "NA400",
"ampFirmwareVersion": "1.6.23",
"ampSerialNumber": "M13010030",
"recordTime": "2019-05-01T10:58:31.236065-07:00"
},
"dataInfo": {
Expand Down Expand Up @@ -8112,6 +8114,7 @@
}
},
"dipoleSet": {},
"PNSSet": {},
"historyEntries": [
{
"name": "Noise_30Seconds",
Expand Down
47 changes: 47 additions & 0 deletions mffpy/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
ANY KIND, either express or implied.
"""

from typing import Any, Dict
from glob import glob
import os.path as op
from zipfile import ZipFile, ZIP_STORED
Expand All @@ -30,3 +31,49 @@ def ensure_mfz():
for content_filename in glob(op.join(fname[:-3] + 'mff', '*')):
arc_filename = op.basename(content_filename)
zf.write(content_filename, arcname=arc_filename)


@pytest.fixture
def sensors() -> Dict[int, Any]:
return {
0: {
'name': 'ECG',
'number': 0,
'unit': 'uV',
'psgType': 0,
'mapping': 1,
'samplingRate': 0,
'sensorType': 'ECG',
'highpass': 0.3000000119,
'lowpass': 70,
'notch': 60,
'groupNumber': 1,
'gain': 1,
'defaultDisplayAmplitude': 7.5,
'highpassDisplay': 0.3000000119,
'lowpassDisplay': 70,
'notchDisplay': 60,
'color': [0.0000, 0.0000, 0.0000, 1.0000],
'positiveUp': 'false',
},
1: {
'name': 'EMG',
'number': 1,
'unit': 'uV',
'psgType': 0,
'mapping': 2,
'samplingRate': 0,
'sensorType': 'EMG',
'highpass': 10,
'lowpass': 100,
'notch': 60,
'groupNumber': 1,
'gain': 1,
'defaultDisplayAmplitude': 7.5,
'highpassDisplay': 10,
'lowpassDisplay': 100,
'notchDisplay': 60,
'color': [0.0000, 0.0000, 0.0000, 1.0000],
'positiveUp': 'false',
}
}
18 changes: 16 additions & 2 deletions mffpy/tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_overwrite_mfz(tmpdir):
assert R2.startdatetime == time2


def test_writer_writes_multple_bins(tmpdir):
def test_writer_writes_multple_bins(tmpdir, sensors):
"""test that `mffpy.Writer` can write multiple binary files"""
dirname = join(str(tmpdir), 'multiple_bins.mff')
device = 'HydroCel GSN 256 1.0'
Expand All @@ -174,7 +174,7 @@ def test_writer_writes_multple_bins(tmpdir):
sampling_rate = 128
num_channels_dict = {
'EEG': 256,
'PNSData': 16
'PNSData': 2
}
data = {
dtype: np.random.randn(
Expand All @@ -192,6 +192,12 @@ def test_writer_writes_multple_bins(tmpdir):
startdatetime = datetime.strptime(
'1984-02-18T14:00:10.000000+0100', XML._time_format)
W.addxml('fileInfo', recordTime=startdatetime)
W.addxml(
'PNSSet',
name='Physio 16 set 60hz 1.0',
amp_series='400',
sensors=sensors,
)
W.add_coordinates_and_sensor_layout(device)
for b in bin_writers.values():
W.addbin(b)
Expand All @@ -212,6 +218,14 @@ def test_writer_writes_multple_bins(tmpdir):
layout = XML.from_file(layout)
assert layout.name == device

pns_set = R.directory.filepointer('pnsSet')
pns_set = XML.from_file(pns_set)
assert pns_set.name == 'Physio 16 set 60hz 1.0'
assert pns_set.amp_series == '400'
for key, val in pns_set.sensors.items():
for k, v in val.items():
assert v == sensors[key][k]


def test_write_multiple_blocks():
"""check that BinWriter correctly handles adding multiple blocks"""
Expand Down
15 changes: 15 additions & 0 deletions mffpy/tests/test_xml_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

examples_path = join(dirname(__file__), '..', '..', 'examples')
mff_path = join(examples_path, 'example_1.mff')
mffpath_3 = join(examples_path, 'example_3.mff')

"""
Here are several fixtures that parse example xml files
Expand Down Expand Up @@ -146,6 +147,8 @@ def test_FileInfo(file_info):
assert file_info.mffVersion == '3'
assert file_info.acquisitionVersion == '5.4.1.2 (r28337)'
assert file_info.ampType == 'NA400'
assert file_info.ampSerialNumber == 'M13010030'
assert file_info.ampFirmwareVersion == '1.6.23'
expected_rt = datetime.strptime(
'2019-05-01T10:58:31.236065-0700', "%Y-%m-%dT%H:%M:%S.%f%z")
assert file_info.recordTime == expected_rt, f"""
Expand Down Expand Up @@ -516,6 +519,18 @@ def test_dipoleSet_w_different_order(dipoleSet):
], dtype=np.float32))


def test_pnsSet(sensors):
"""test parsing of `pnsSet.xml`"""
filepath = join(mffpath_3, 'pnsSet.xml')
assert exists(filepath), f"Not found: '{filepath}'"
pns_set = XML.from_file(filepath)
assert pns_set.name == 'Physio 16 set 60hz 1.0'
assert pns_set.amp_series == '400'
for key, val in pns_set.sensors.items():
for k, v in val.items():
assert v == sensors[key][k]


@pytest.mark.parametrize("idx,expected", [
('name', 'Noise_30Seconds'),
('method', 'Segmentation'),
Expand Down
2 changes: 1 addition & 1 deletion mffpy/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.8.0"
__version__ = "0.9.0"
Loading
Loading