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

Start of sampling time is now the same for all frequencies #283

Merged
merged 11 commits into from
Aug 19, 2020
7 changes: 7 additions & 0 deletions phys2bids/phys2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,13 @@ def phys2bids(filename, info=False, indir='.', outdir='.', heur_file=None,
# Also create a BlueprintOutput object for each unique frequency found.
# Populate it with the corresponding blueprint input and replace it
# in the dictionary.
# Add time channel in the proper frequency.
if uniq_freq != phys_in[run].freq[0]:
phys_out[key].ch_name.insert(0, phys_in[run].ch_name[0])
phys_out[key].units.insert(0, phys_in[run].units[0])
phys_out[key].timeseries.insert(0, np.linspace(phys_in[run].timeseries[0][0],
phys_in[run].timeseries[0][-1],
num=phys_out[key].timeseries[0].shape[0]))
phys_out[key] = BlueprintOutput.init_from_blueprint(phys_out[key])

# Preparing output parameters: name and folder.
Expand Down
12 changes: 6 additions & 6 deletions phys2bids/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def test_integration_heuristic(skip_integration, multifreq_lab_file):
# Check sampling frequency
assert check_string(log_info, 'Sampling Frequency', '40.0')
# Check sampling started
assert check_string(log_info, 'Sampling started', '-157.8535')
assert check_string(log_info, 'Sampling started', '3.6960')
# Check first trigger
assert check_string(log_info, 'first trigger', 'Time 0', is_num=False)

Expand All @@ -167,8 +167,8 @@ def test_integration_heuristic(skip_integration, multifreq_lab_file):

# Compares values in json file with ground truth
assert math.isclose(json_data['SamplingFrequency'], 40.0,)
assert math.isclose(json_data['StartTime'], -157.8535,)
assert json_data['Columns'] == ['O2']
assert math.isclose(json_data['StartTime'], 3.6960,)
assert json_data['Columns'] == ['time', 'O2']

# ##### Checks for 100 Hz files
# Read log file (note that this file is not the logger file)
Expand All @@ -183,7 +183,7 @@ def test_integration_heuristic(skip_integration, multifreq_lab_file):
# Check sampling frequency
assert check_string(log_info, 'Sampling Frequency', '100.0')
# Check sampling started
assert check_string(log_info, 'Sampling started', '-0.3057')
assert check_string(log_info, 'Sampling started', '3.6960')
# Check first trigger
assert check_string(log_info, 'first trigger', 'Time 0', is_num=False)

Expand All @@ -194,8 +194,8 @@ def test_integration_heuristic(skip_integration, multifreq_lab_file):

# Compares values in json file with ground truth
assert math.isclose(json_data['SamplingFrequency'], 100.0,)
assert math.isclose(json_data['StartTime'], -0.3057,)
assert json_data['Columns'] == ['CO2']
assert math.isclose(json_data['StartTime'], 3.6960,)
assert json_data['Columns'] == ['time', 'CO2']

# Remove generated files
shutil.rmtree(test_path_output)
Expand Down