Skip to content

Commit

Permalink
Run pre-commits
Browse files Browse the repository at this point in the history
  • Loading branch information
smoia committed Apr 27, 2023
1 parent 83d245c commit fea0e0d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 33 deletions.
14 changes: 7 additions & 7 deletions phys2bids/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand All @@ -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)
22 changes: 5 additions & 17 deletions phys2bids/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
18 changes: 9 additions & 9 deletions phys2bids/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,33 +219,33 @@ 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):
chtrig = 5

# 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

0 comments on commit fea0e0d

Please sign in to comment.