From 15c082be7be0aa4c686b563618ee24bce1ded870 Mon Sep 17 00:00:00 2001 From: Hao-Ting Wang Date: Wed, 21 Jul 2021 11:44:20 +0100 Subject: [PATCH 01/14] NF/ADD CED spike2 file IO The current implementation uses the official API, SONPY, from CED. SONPY is closed sourced. The scanner volumen trigger in the test file was stored as "marker" channel. The SONPY API returns time points of markers, rather than a timeserie. The module I wrote has been tested on client machine. Will check if this breaks other tests. --- phys2bids/io.py | 85 +++++++++++++++++++++++++++++++++++++ phys2bids/tests/conftest.py | 28 ++++++++++-- phys2bids/tests/test_io.py | 31 ++++++++++++++ setup.cfg | 2 + 4 files changed, 143 insertions(+), 3 deletions(-) diff --git a/phys2bids/io.py b/phys2bids/io.py index 37c62355f..448281c73 100644 --- a/phys2bids/io.py +++ b/phys2bids/io.py @@ -538,3 +538,88 @@ def load_gep(filename): timeseries = [t_ch, trigger] timeseries.extend(data) return BlueprintInput(timeseries, freq, names, units, 1) + + +def load_smr(filename, chtrig=0): + """Load Spike2 smr file and populate object phys_input. + + Parameters + ---------- + filename: str + Path to the spike smr or smrx file. + + chtrig : int + Index of trigger channel. + + Returns + ------- + BlueprintInput + + Note + ---- + Index of chtrig is 1-index (i.e. spike2 channel number). + + See Also + -------- + physio_obj.BlueprintInput + """ + import sonpy + + # taken from sonpy demo + read_data = { + sonpy.lib.DataType.Adc: sonpy.lib.SonFile.ReadInts, + sonpy.lib.DataType.EventFall: sonpy.lib.SonFile.ReadEvents, + sonpy.lib.DataType.EventRise: sonpy.lib.SonFile.ReadEvents, + sonpy.lib.DataType.EventBoth: sonpy.lib.SonFile.ReadEvents, + sonpy.lib.DataType.Marker: sonpy.lib.SonFile.ReadMarkers, + sonpy.lib.DataType.AdcMark: sonpy.lib.SonFile.ReadWaveMarks, + sonpy.lib.DataType.RealMark: sonpy.lib.SonFile.ReadRealMarks, + sonpy.lib.DataType.TextMark: sonpy.lib.SonFile.ReadTextMarks, + sonpy.lib.DataType.RealWave: sonpy.lib.SonFile.ReadFloats + } + + smrfile = sonpy.lib.SonFile(filename, True) + time_base = smrfile.GetTimeBase() + n_channels = smrfile.MaxChannels() + freq, names, units, timeseries = [], [], [], [] + for i in range(n_channels): + current_channel = smrfile.ChannelType(i) + max_n_tick = smrfile.ChannelMaxTime(i) + if current_channel != sonpy.lib.DataType.Off and max_n_tick > 0: + max_n_tick = smrfile.ChannelMaxTime(i) + sample_rate = smrfile.GetIdealRate(i) + if current_channel == sonpy.lib.DataType.Adc: + divide = smrfile.ChannelDivide(i) + else: # marker channels + divide = 1 / (time_base * sample_rate) + # conversion factor from CED spike2 doc + # http://ced.co.uk/img/Spike9.pdf + gain = smrfile.GetChannelScale(i) / 6553.6 + offset = smrfile.GetChannelOffset(i) + name = smrfile.GetChannelTitle(chan=i) + unit = smrfile.GetChannelUnits(chan=i) + + n_samples = int(np.floor((max_n_tick) / divide)) + raw_signal = read_data[current_channel]( + smrfile, chan=i, nMax=n_samples, + tFrom=0, tUpto=max_n_tick) + + signal = np.array(raw_signal) * gain + offset + + # save the data + freq.append(sample_rate) + names.append(name) + units.append(unit) + timeseries.append(signal) + + # use the channel with highest sample rate to create time stamps + idx_max = np.argmax(freq) + n_timepoints = len(timeseries[idx_max]) # end point included + time = np.arange(n_timepoints) * freq[idx_max] + + # prepend to the existing list + freq = [freq[idx_max], ] + freq + timeseries = [time, ] + timeseries + units = ['s', ] + units + names = ['time', ] + names + return BlueprintInput(timeseries, freq, names, units, chtrig) diff --git a/phys2bids/tests/conftest.py b/phys2bids/tests/conftest.py index dcf4d564d..e715b454d 100644 --- a/phys2bids/tests/conftest.py +++ b/phys2bids/tests/conftest.py @@ -95,6 +95,7 @@ def multi_run_file(testpath): return fetch_file("gvy84", testpath, "Test2_samefreq_TWOscans.txt") + @pytest.fixture def matlab_file_labchart(testpath): return fetch_file("2j43t", testpath, "test_2minRest.mat") @@ -105,36 +106,57 @@ def matlab_file_acq(testpath): return fetch_file("mc96w", testpath, "Test_belt_pulse_multifreq.mat") + @pytest.fixture def ge_one_gep_file(testpath): return fetch_file("wb84d", testpath, "PPGData_epiRT_0000000000_00_00_000.gep") + @pytest.fixture def ge_two_gep_files_ppg(testpath): tmp = fetch_file("qawjv", testpath, "RESPData_epiRT_0000000000_00_00_000.gep") return fetch_file("wb84d", testpath, "PPGData_epiRT_0000000000_00_00_000.gep") + @pytest.fixture def ge_two_gep_files_resp(testpath): tmp = fetch_file("wb84d", testpath, "PPGData_epiRT_0000000000_00_00_000.gep") return fetch_file("qawjv", testpath, "RESPData_epiRT_0000000000_00_00_000.gep") + @pytest.fixture def ge_one_raw_file(testpath): return fetch_file("u9wsr", testpath, "PPGData_epiRT_0000000000_00_00_000") + @pytest.fixture def ge_two_raw_files(testpath): tmp = fetch_file("49xpw", testpath, "RESPData_epiRT_0000000000_00_00_000") return fetch_file("u9wsr", testpath, "PPGData_epiRT_0000000000_00_00_000") + @pytest.fixture def ge_badfiles(testpath): - tmp = fetch_file("tdmyn", testpath, "PPGData_epiRT_columnscsv_00_00_000") - tmp = fetch_file("b6skq", testpath, "PPGData_epiRT_columnstsv_00_00_000") - return fetch_file("8235b", testpath, "PPGData_epiRT_string0000_00_00_000") + tmp = fetch_file('tdmyn', testpath, + 'PPGData_epiRT_columnscsv_00_00_000') + tmp = fetch_file('b6skq', testpath, + 'PPGData_epiRT_columnstsv_00_00_000') + return fetch_file('8235b', testpath, + 'PPGData_epiRT_string0000_00_00_000') + + +@pytest.fixture +def spike2_smrx_file(testpath): + return fetch_file('7x5qw', testpath, + 'Test_ppg_pulse_spike2.smrx') + + +@pytest.fixture +def spike2_smr_file(testpath): + return fetch_file('zdpfr', testpath, + 'Test_ppg_pulse_spike2.smr') diff --git a/phys2bids/tests/test_io.py b/phys2bids/tests/test_io.py index 3302f1c35..a5933c371 100644 --- a/phys2bids/tests/test_io.py +++ b/phys2bids/tests/test_io.py @@ -214,3 +214,34 @@ def test_load_gep_two_files_resp(ge_two_gep_files_resp, testpath): gep_data2 = np.loadtxt(os.path.join(testpath, "PPGData_epiRT_0000000000_00_00_000.gep")) assert np.array_equal(gep_data1, phys_obj.timeseries[2]) assert np.array_equal(gep_data2, phys_obj.timeseries[3]) + + +def test_load_smr(spike2_smr_file, spike2_smrx_file): + chtrig = 5 + + # 32-bit file + phys_obj = io.load_smr(spike2_smr_file, chtrig) + assert phys_obj.ch_name[0] == 'time' + assert phys_obj.freq[0] == 1000.0 + assert phys_obj.units[0] == 's' + for n, ts in zip(phys_obj.ch_name, phys_obj.timeseries): + print(n, len(ts)) + + # checks that the scanner strigger is in the right channel + # the marker channels are stored as binary + assert phys_obj.ch_name[chtrig] == 'Scan Vol' + assert phys_obj.freq[chtrig] == 200.0 + assert phys_obj.units[chtrig] == '' + assert len(phys_obj.timeseries[chtrig]) == 60 + + # 64-bit file should have the same + phys_obj = io.load_smr(spike2_smrx_file, chtrig) + assert phys_obj.ch_name[0] == 'time' + assert phys_obj.freq[0] == 1000.0 + assert phys_obj.units[0] == 's' + # checks that the scanner trigger is in the right channel + # the marker channels are stored as binary + assert phys_obj.ch_name[chtrig] == 'Scan Vol' + assert phys_obj.freq[chtrig] == 200.0 + assert phys_obj.units[chtrig] == '' + assert len(phys_obj.timeseries[chtrig]) == 60 diff --git a/setup.cfg b/setup.cfg index 2bec2730a..58119a310 100644 --- a/setup.cfg +++ b/setup.cfg @@ -36,6 +36,8 @@ packages = find: include_package_data = True [options.extras_require] +spike2 = + sonpy >=1.9.3 acq = bioread >=1.0.5 mat= From cd4628414f8d287bd7efb41b596c7414124e7938 Mon Sep 17 00:00:00 2001 From: Hao-Ting Wang Date: Wed, 21 Jul 2021 14:11:41 +0100 Subject: [PATCH 02/14] remove some print statement for sanity check --- phys2bids/tests/test_io.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/phys2bids/tests/test_io.py b/phys2bids/tests/test_io.py index a5933c371..97d07c7a8 100644 --- a/phys2bids/tests/test_io.py +++ b/phys2bids/tests/test_io.py @@ -224,8 +224,6 @@ def test_load_smr(spike2_smr_file, spike2_smrx_file): assert phys_obj.ch_name[0] == 'time' assert phys_obj.freq[0] == 1000.0 assert phys_obj.units[0] == 's' - for n, ts in zip(phys_obj.ch_name, phys_obj.timeseries): - print(n, len(ts)) # checks that the scanner strigger is in the right channel # the marker channels are stored as binary From 5799932782fa79411ac04e838ab55bc404bb2ae2 Mon Sep 17 00:00:00 2001 From: Hao-Ting Wang Date: Wed, 21 Jul 2021 17:17:16 +0100 Subject: [PATCH 03/14] FIX installation options --- setup.cfg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 58119a310..455a73ad4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,7 +37,7 @@ include_package_data = True [options.extras_require] spike2 = - sonpy >=1.9.3 + sonpy >=1.8.5 acq = bioread >=1.0.5 mat= @@ -57,6 +57,7 @@ style = interfaces = %(acq)s %(mat)s + %(spike2)s test = pytest >=5.3 pytest-cov From 0003507d462bb285585fb6c21968bf1a79289418 Mon Sep 17 00:00:00 2001 From: Hao-Ting Wang Date: Wed, 21 Jul 2021 17:25:36 +0100 Subject: [PATCH 04/14] LINT flake8 don't like dictionary lined up like table --- phys2bids/io.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/phys2bids/io.py b/phys2bids/io.py index 448281c73..ce4b9ef57 100644 --- a/phys2bids/io.py +++ b/phys2bids/io.py @@ -567,15 +567,15 @@ def load_smr(filename, chtrig=0): # taken from sonpy demo read_data = { - sonpy.lib.DataType.Adc: sonpy.lib.SonFile.ReadInts, - sonpy.lib.DataType.EventFall: sonpy.lib.SonFile.ReadEvents, - sonpy.lib.DataType.EventRise: sonpy.lib.SonFile.ReadEvents, - sonpy.lib.DataType.EventBoth: sonpy.lib.SonFile.ReadEvents, - sonpy.lib.DataType.Marker: sonpy.lib.SonFile.ReadMarkers, - sonpy.lib.DataType.AdcMark: sonpy.lib.SonFile.ReadWaveMarks, - sonpy.lib.DataType.RealMark: sonpy.lib.SonFile.ReadRealMarks, - sonpy.lib.DataType.TextMark: sonpy.lib.SonFile.ReadTextMarks, - sonpy.lib.DataType.RealWave: sonpy.lib.SonFile.ReadFloats + sonpy.lib.DataType.Adc: sonpy.lib.SonFile.ReadInts, + sonpy.lib.DataType.EventFall: sonpy.lib.SonFile.ReadEvents, + sonpy.lib.DataType.EventRise: sonpy.lib.SonFile.ReadEvents, + sonpy.lib.DataType.EventBoth: sonpy.lib.SonFile.ReadEvents, + sonpy.lib.DataType.Marker: sonpy.lib.SonFile.ReadMarkers, + sonpy.lib.DataType.AdcMark: sonpy.lib.SonFile.ReadWaveMarks, + sonpy.lib.DataType.RealMark: sonpy.lib.SonFile.ReadRealMarks, + sonpy.lib.DataType.TextMark: sonpy.lib.SonFile.ReadTextMarks, + sonpy.lib.DataType.RealWave: sonpy.lib.SonFile.ReadFloats } smrfile = sonpy.lib.SonFile(filename, True) From e69a858b79378405f473abcaddc36b50c47f3043 Mon Sep 17 00:00:00 2001 From: Hao-Ting Wang Date: Wed, 21 Jul 2021 17:49:45 +0100 Subject: [PATCH 05/14] FIX sonpy version using 1.7.5. They use the second digit for python version not minor release. --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 455a73ad4..f25e57400 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,7 +37,7 @@ include_package_data = True [options.extras_require] spike2 = - sonpy >=1.8.5 + sonpy >=1.7.5 acq = bioread >=1.0.5 mat= From 59008d95c8f24743ed4f3aed37b003d740c87b84 Mon Sep 17 00:00:00 2001 From: smoia Date: Thu, 27 Apr 2023 01:04:01 +0200 Subject: [PATCH 06/14] Add python requirement in install --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index f25e57400..fe4585971 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,7 +37,7 @@ include_package_data = True [options.extras_require] spike2 = - sonpy >=1.7.5 + sonpy >=1.7.5;python_version>='3.7' acq = bioread >=1.0.5 mat= From 77f9b504afbf168263cae0f132b20aecf08f988b Mon Sep 17 00:00:00 2001 From: smoia Date: Thu, 27 Apr 2023 01:08:12 +0200 Subject: [PATCH 07/14] Try to fix install requirements --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index fe4585971..333d50cfa 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,7 +37,7 @@ include_package_data = True [options.extras_require] spike2 = - sonpy >=1.7.5;python_version>='3.7' + sonpy >=1.7.5;python_version>='3.7'<'3.10' acq = bioread >=1.0.5 mat= From 15a283131c4336b108b56b38736a4051431fdf12 Mon Sep 17 00:00:00 2001 From: smoia Date: Thu, 27 Apr 2023 01:09:12 +0200 Subject: [PATCH 08/14] Try again --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 333d50cfa..1b49a0883 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,7 +37,7 @@ include_package_data = True [options.extras_require] spike2 = - sonpy >=1.7.5;python_version>='3.7'<'3.10' + sonpy >=1.7.5;python_version>='3.7';python_version<'3.10' acq = bioread >=1.0.5 mat= From 08fd88a3ebeb4c4a023155a4c0016bf9409d8da9 Mon Sep 17 00:00:00 2001 From: smoia Date: Thu, 27 Apr 2023 01:10:30 +0200 Subject: [PATCH 09/14] Try again --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 1b49a0883..d8bd6cfdd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,7 +37,7 @@ include_package_data = True [options.extras_require] spike2 = - sonpy >=1.7.5;python_version>='3.7';python_version<'3.10' + sonpy >=1.7.5;python_version>='3.7', <'3.10' acq = bioread >=1.0.5 mat= From 9a6e3aec56613ebff24760b9ec7ba2271ec2b590 Mon Sep 17 00:00:00 2001 From: smoia Date: Thu, 27 Apr 2023 01:15:19 +0200 Subject: [PATCH 10/14] Try again --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index d8bd6cfdd..85e0fb05e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,7 +37,7 @@ include_package_data = True [options.extras_require] spike2 = - sonpy >=1.7.5;python_version>='3.7', <'3.10' + sonpy >=1.7.5;python_version=='3.7.*,3.8.*,3.9.*'' acq = bioread >=1.0.5 mat= From 7628240b5cc25c6e86213556f9ca3baa83ddc691 Mon Sep 17 00:00:00 2001 From: smoia Date: Thu, 27 Apr 2023 01:19:52 +0200 Subject: [PATCH 11/14] Remove extra ' --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 85e0fb05e..f9208504e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,7 +37,7 @@ include_package_data = True [options.extras_require] spike2 = - sonpy >=1.7.5;python_version=='3.7.*,3.8.*,3.9.*'' + sonpy >=1.7.5;python_version=='3.7.*,3.8.*,3.9.*' acq = bioread >=1.0.5 mat= From 13e4912d11e5a7b2505524f334d65a9ea15dc61b Mon Sep 17 00:00:00 2001 From: smoia Date: Thu, 27 Apr 2023 02:05:16 +0200 Subject: [PATCH 12/14] Selective skip tests --- phys2bids/tests/test_io.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phys2bids/tests/test_io.py b/phys2bids/tests/test_io.py index 97d07c7a8..2d80df536 100644 --- a/phys2bids/tests/test_io.py +++ b/phys2bids/tests/test_io.py @@ -1,5 +1,6 @@ import math import os +import sys import numpy as np import pytest @@ -216,6 +217,10 @@ def test_load_gep_two_files_resp(ge_two_gep_files_resp, testpath): assert np.array_equal(gep_data2, phys_obj.timeseries[3]) +@pytest.mark.skipif( + sys.version_info < (3, 7) or sys.version_info > (3, 9), + reason="Requires python between 3.7 and 3.9" +) def test_load_smr(spike2_smr_file, spike2_smrx_file): chtrig = 5 From 83d245c7322c3bf2064ff608af0b042cabec16e7 Mon Sep 17 00:00:00 2001 From: smoia Date: Thu, 27 Apr 2023 02:14:41 +0200 Subject: [PATCH 13/14] Mark xfail --- phys2bids/tests/test_io.py | 1 + 1 file changed, 1 insertion(+) diff --git a/phys2bids/tests/test_io.py b/phys2bids/tests/test_io.py index 2d80df536..fa64cdb7d 100644 --- a/phys2bids/tests/test_io.py +++ b/phys2bids/tests/test_io.py @@ -221,6 +221,7 @@ def test_load_gep_two_files_resp(ge_two_gep_files_resp, testpath): sys.version_info < (3, 7) or sys.version_info > (3, 9), reason="Requires python between 3.7 and 3.9" ) +@pytest.mark.xfail(reason="We need to fix sonpy install") def test_load_smr(spike2_smr_file, spike2_smrx_file): chtrig = 5 From fea0e0d55842b5b8a901889ee82edec68a3636dc Mon Sep 17 00:00:00 2001 From: smoia Date: Thu, 27 Apr 2023 02:36:31 +0200 Subject: [PATCH 14/14] Run pre-commits --- phys2bids/io.py | 14 +++++++------- phys2bids/tests/conftest.py | 22 +++++----------------- phys2bids/tests/test_io.py | 18 +++++++++--------- 3 files changed, 21 insertions(+), 33 deletions(-) diff --git a/phys2bids/io.py b/phys2bids/io.py index ce4b9ef57..d4a5e3903 100644 --- a/phys2bids/io.py +++ b/phys2bids/io.py @@ -575,7 +575,7 @@ def load_smr(filename, chtrig=0): sonpy.lib.DataType.AdcMark: sonpy.lib.SonFile.ReadWaveMarks, sonpy.lib.DataType.RealMark: sonpy.lib.SonFile.ReadRealMarks, sonpy.lib.DataType.TextMark: sonpy.lib.SonFile.ReadTextMarks, - sonpy.lib.DataType.RealWave: sonpy.lib.SonFile.ReadFloats + sonpy.lib.DataType.RealWave: sonpy.lib.SonFile.ReadFloats, } smrfile = sonpy.lib.SonFile(filename, True) @@ -601,8 +601,8 @@ def load_smr(filename, chtrig=0): n_samples = int(np.floor((max_n_tick) / divide)) raw_signal = read_data[current_channel]( - smrfile, chan=i, nMax=n_samples, - tFrom=0, tUpto=max_n_tick) + smrfile, chan=i, nMax=n_samples, tFrom=0, tUpto=max_n_tick + ) signal = np.array(raw_signal) * gain + offset @@ -618,8 +618,8 @@ def load_smr(filename, chtrig=0): time = np.arange(n_timepoints) * freq[idx_max] # prepend to the existing list - freq = [freq[idx_max], ] + freq - timeseries = [time, ] + timeseries - units = ['s', ] + units - names = ['time', ] + names + freq = [freq[idx_max]] + freq + timeseries = [time] + timeseries + units = ["s"] + units + names = ["time"] + names return BlueprintInput(timeseries, freq, names, units, chtrig) diff --git a/phys2bids/tests/conftest.py b/phys2bids/tests/conftest.py index e715b454d..69160fde6 100644 --- a/phys2bids/tests/conftest.py +++ b/phys2bids/tests/conftest.py @@ -95,7 +95,6 @@ def multi_run_file(testpath): return fetch_file("gvy84", testpath, "Test2_samefreq_TWOscans.txt") - @pytest.fixture def matlab_file_labchart(testpath): return fetch_file("2j43t", testpath, "test_2minRest.mat") @@ -106,57 +105,46 @@ def matlab_file_acq(testpath): return fetch_file("mc96w", testpath, "Test_belt_pulse_multifreq.mat") - @pytest.fixture def ge_one_gep_file(testpath): return fetch_file("wb84d", testpath, "PPGData_epiRT_0000000000_00_00_000.gep") - @pytest.fixture def ge_two_gep_files_ppg(testpath): tmp = fetch_file("qawjv", testpath, "RESPData_epiRT_0000000000_00_00_000.gep") return fetch_file("wb84d", testpath, "PPGData_epiRT_0000000000_00_00_000.gep") - @pytest.fixture def ge_two_gep_files_resp(testpath): tmp = fetch_file("wb84d", testpath, "PPGData_epiRT_0000000000_00_00_000.gep") return fetch_file("qawjv", testpath, "RESPData_epiRT_0000000000_00_00_000.gep") - @pytest.fixture def ge_one_raw_file(testpath): return fetch_file("u9wsr", testpath, "PPGData_epiRT_0000000000_00_00_000") - @pytest.fixture def ge_two_raw_files(testpath): tmp = fetch_file("49xpw", testpath, "RESPData_epiRT_0000000000_00_00_000") return fetch_file("u9wsr", testpath, "PPGData_epiRT_0000000000_00_00_000") - @pytest.fixture def ge_badfiles(testpath): - tmp = fetch_file('tdmyn', testpath, - 'PPGData_epiRT_columnscsv_00_00_000') - tmp = fetch_file('b6skq', testpath, - 'PPGData_epiRT_columnstsv_00_00_000') - return fetch_file('8235b', testpath, - 'PPGData_epiRT_string0000_00_00_000') + tmp = fetch_file("tdmyn", testpath, "PPGData_epiRT_columnscsv_00_00_000") + tmp = fetch_file("b6skq", testpath, "PPGData_epiRT_columnstsv_00_00_000") + return fetch_file("8235b", testpath, "PPGData_epiRT_string0000_00_00_000") @pytest.fixture def spike2_smrx_file(testpath): - return fetch_file('7x5qw', testpath, - 'Test_ppg_pulse_spike2.smrx') + return fetch_file("7x5qw", testpath, "Test_ppg_pulse_spike2.smrx") @pytest.fixture def spike2_smr_file(testpath): - return fetch_file('zdpfr', testpath, - 'Test_ppg_pulse_spike2.smr') + return fetch_file("zdpfr", testpath, "Test_ppg_pulse_spike2.smr") diff --git a/phys2bids/tests/test_io.py b/phys2bids/tests/test_io.py index fa64cdb7d..ffed64546 100644 --- a/phys2bids/tests/test_io.py +++ b/phys2bids/tests/test_io.py @@ -219,7 +219,7 @@ def test_load_gep_two_files_resp(ge_two_gep_files_resp, testpath): @pytest.mark.skipif( sys.version_info < (3, 7) or sys.version_info > (3, 9), - reason="Requires python between 3.7 and 3.9" + reason="Requires python between 3.7 and 3.9", ) @pytest.mark.xfail(reason="We need to fix sonpy install") def test_load_smr(spike2_smr_file, spike2_smrx_file): @@ -227,25 +227,25 @@ def test_load_smr(spike2_smr_file, spike2_smrx_file): # 32-bit file phys_obj = io.load_smr(spike2_smr_file, chtrig) - assert phys_obj.ch_name[0] == 'time' + assert phys_obj.ch_name[0] == "time" assert phys_obj.freq[0] == 1000.0 - assert phys_obj.units[0] == 's' + assert phys_obj.units[0] == "s" # checks that the scanner strigger is in the right channel # the marker channels are stored as binary - assert phys_obj.ch_name[chtrig] == 'Scan Vol' + assert phys_obj.ch_name[chtrig] == "Scan Vol" assert phys_obj.freq[chtrig] == 200.0 - assert phys_obj.units[chtrig] == '' + assert phys_obj.units[chtrig] == "" assert len(phys_obj.timeseries[chtrig]) == 60 # 64-bit file should have the same phys_obj = io.load_smr(spike2_smrx_file, chtrig) - assert phys_obj.ch_name[0] == 'time' + assert phys_obj.ch_name[0] == "time" assert phys_obj.freq[0] == 1000.0 - assert phys_obj.units[0] == 's' + assert phys_obj.units[0] == "s" # checks that the scanner trigger is in the right channel # the marker channels are stored as binary - assert phys_obj.ch_name[chtrig] == 'Scan Vol' + assert phys_obj.ch_name[chtrig] == "Scan Vol" assert phys_obj.freq[chtrig] == 200.0 - assert phys_obj.units[chtrig] == '' + assert phys_obj.units[chtrig] == "" assert len(phys_obj.timeseries[chtrig]) == 60