diff --git a/phys2bids/phys2bids.py b/phys2bids/phys2bids.py index 7f5bbe387..1eac52e69 100644 --- a/phys2bids/phys2bids.py +++ b/phys2bids/phys2bids.py @@ -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. diff --git a/phys2bids/tests/test_integration.py b/phys2bids/tests/test_integration.py index 8b918cc03..63cbb2292 100644 --- a/phys2bids/tests/test_integration.py +++ b/phys2bids/tests/test_integration.py @@ -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) @@ -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) @@ -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) @@ -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)