From 975078e98c5630cf7268608c2c3e17e323a8e9b5 Mon Sep 17 00:00:00 2001 From: Christian O'Reilly Date: Mon, 11 Nov 2024 14:19:04 -0500 Subject: [PATCH 1/6] Fix bug issue #175 --- pylossless/bids.py | 2 +- pylossless/tests/test_bids.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 pylossless/tests/test_bids.py diff --git a/pylossless/bids.py b/pylossless/bids.py index 90ba861..f003e18 100644 --- a/pylossless/bids.py +++ b/pylossless/bids.py @@ -78,7 +78,7 @@ def convert_recording_to_bids( write_kwargs["allow_preload"] = True write_raw_bids( - raw, bids_path=bids_path, events_data=events, event_id=event_id, **write_kwargs + raw, bids_path=bids_path, events=events, event_id=event_id, **write_kwargs ) return bids_path diff --git a/pylossless/tests/test_bids.py b/pylossless/tests/test_bids.py new file mode 100644 index 0000000..1a0c995 --- /dev/null +++ b/pylossless/tests/test_bids.py @@ -0,0 +1,25 @@ +import pylossless as ll +import mne +import numpy as np +import pytest + + +@pytest.mark.filterwarnings("ignore:Converting data files to EDF format") +def test_find_breaks(): + """Make sure MNE's annotate_break function can run.""" + def edf_import_fct(path_in): + # read in a file + raw = mne.io.read_raw_edf(path_in, preload=True) + print(raw.annotations) + return raw, np.array([[0, 0, 0]]), {"test": 0, "T0": 1, "T1": 2, "T2": 3} + + testing_path = mne.datasets.testing.data_path() + fname = testing_path / "EDF" / "test_edf_overlapping_annotations.edf" + import_args = [{"path_in": fname}] + bids_path_args = [{'subject': '001', 'run': '01', 'session': '01', + "task": "test"}] + bids_paths = ll.bids.convert_dataset_to_bids(edf_import_fct, import_args, + bids_path_args, overwrite=True) + + print(bids_paths) + From 79f7cc3a8540b5a1020b56e5155ad84ccbb9c6f5 Mon Sep 17 00:00:00 2001 From: Christian O'Reilly Date: Mon, 11 Nov 2024 14:23:35 -0500 Subject: [PATCH 2/6] Code linting. --- pylossless/tests/test_bids.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylossless/tests/test_bids.py b/pylossless/tests/test_bids.py index 1a0c995..f046b78 100644 --- a/pylossless/tests/test_bids.py +++ b/pylossless/tests/test_bids.py @@ -4,7 +4,7 @@ import pytest -@pytest.mark.filterwarnings("ignore:Converting data files to EDF format") +@pytest.mark.filterwarnings("ignore:Converting data files to EDF format") def test_find_breaks(): """Make sure MNE's annotate_break function can run.""" def edf_import_fct(path_in): @@ -16,7 +16,7 @@ def edf_import_fct(path_in): testing_path = mne.datasets.testing.data_path() fname = testing_path / "EDF" / "test_edf_overlapping_annotations.edf" import_args = [{"path_in": fname}] - bids_path_args = [{'subject': '001', 'run': '01', 'session': '01', + bids_path_args = [{'subject': '001', 'run': '01', 'session': '01', "task": "test"}] bids_paths = ll.bids.convert_dataset_to_bids(edf_import_fct, import_args, bids_path_args, overwrite=True) From 70f179ef99884a1a6755b6cbf7b343baa7f15777 Mon Sep 17 00:00:00 2001 From: Christian O'Reilly Date: Mon, 11 Nov 2024 14:43:51 -0500 Subject: [PATCH 3/6] Update pylossless/tests/test_bids.py Co-authored-by: Scott Huberty <52462026+scott-huberty@users.noreply.github.com> --- pylossless/tests/test_bids.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylossless/tests/test_bids.py b/pylossless/tests/test_bids.py index f046b78..447b742 100644 --- a/pylossless/tests/test_bids.py +++ b/pylossless/tests/test_bids.py @@ -5,7 +5,7 @@ @pytest.mark.filterwarnings("ignore:Converting data files to EDF format") -def test_find_breaks(): +def test_find_breaks(tmp_path): """Make sure MNE's annotate_break function can run.""" def edf_import_fct(path_in): # read in a file From 79b926d990828bf7a11350c34e1340df03148e44 Mon Sep 17 00:00:00 2001 From: Christian O'Reilly Date: Mon, 11 Nov 2024 14:47:07 -0500 Subject: [PATCH 4/6] Update pylossless/tests/test_bids.py Co-authored-by: Scott Huberty <52462026+scott-huberty@users.noreply.github.com> --- pylossless/tests/test_bids.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pylossless/tests/test_bids.py b/pylossless/tests/test_bids.py index 447b742..08d89ed 100644 --- a/pylossless/tests/test_bids.py +++ b/pylossless/tests/test_bids.py @@ -18,7 +18,14 @@ def edf_import_fct(path_in): import_args = [{"path_in": fname}] bids_path_args = [{'subject': '001', 'run': '01', 'session': '01', "task": "test"}] - bids_paths = ll.bids.convert_dataset_to_bids(edf_import_fct, import_args, + bids_paths = ll.bids.convert_dataset_to_bids( + edf_import_fct, + import_args, + bids_path_args, + bids_root=tmp_path / "bids_dataset", + overwrite=True + ) + bids_path_args, overwrite=True) print(bids_paths) From a3f9ea71799d15f4cd112c1de0c6e0871dbd4d4a Mon Sep 17 00:00:00 2001 From: Christian O'Reilly Date: Mon, 11 Nov 2024 14:47:14 -0500 Subject: [PATCH 5/6] Update pylossless/tests/test_bids.py Co-authored-by: Scott Huberty <52462026+scott-huberty@users.noreply.github.com> --- pylossless/tests/test_bids.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pylossless/tests/test_bids.py b/pylossless/tests/test_bids.py index 08d89ed..8e4aa71 100644 --- a/pylossless/tests/test_bids.py +++ b/pylossless/tests/test_bids.py @@ -26,7 +26,6 @@ def edf_import_fct(path_in): overwrite=True ) - bids_path_args, overwrite=True) print(bids_paths) From 92b6b50222576a9da05c16983b22fa069deb99b2 Mon Sep 17 00:00:00 2001 From: Christian O'Reilly Date: Mon, 11 Nov 2024 15:00:43 -0500 Subject: [PATCH 6/6] Remove print, clean test files, rename test. --- pylossless/tests/test_bids.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pylossless/tests/test_bids.py b/pylossless/tests/test_bids.py index 8e4aa71..2293ba2 100644 --- a/pylossless/tests/test_bids.py +++ b/pylossless/tests/test_bids.py @@ -2,10 +2,11 @@ import mne import numpy as np import pytest +import shutil @pytest.mark.filterwarnings("ignore:Converting data files to EDF format") -def test_find_breaks(tmp_path): +def test_convert_dataset_to_bids(tmp_path): """Make sure MNE's annotate_break function can run.""" def edf_import_fct(path_in): # read in a file @@ -18,14 +19,11 @@ def edf_import_fct(path_in): import_args = [{"path_in": fname}] bids_path_args = [{'subject': '001', 'run': '01', 'session': '01', "task": "test"}] - bids_paths = ll.bids.convert_dataset_to_bids( + ll.bids.convert_dataset_to_bids( edf_import_fct, import_args, bids_path_args, bids_root=tmp_path / "bids_dataset", overwrite=True ) - - - print(bids_paths) - + shutil.rmtree(tmp_path / "bids_dataset")