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

BlueprintInput deepcopies inputs at initialization #358

Merged
merged 12 commits into from
Nov 30, 2020
2 changes: 1 addition & 1 deletion phys2bids/physio_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def check_trigger_amount(self, thr=None, num_timepoints_expected=0, tr=0):
# Use the trigger channel to find the TRs,
# comparing it to a given threshold.
trigger = self.timeseries[self.trigger_idx]
time = self.timeseries[0].copy()
time = self.timeseries[0]
LGR.info(f'The trigger is in channel {self.trigger_idx}')
# Check that trigger and time channels have the same length.
# If not, resample time to the length of the trigger
Expand Down
9 changes: 5 additions & 4 deletions phys2bids/tests/test_physio_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_BlueprintInput():
test_time = np.array([0, 1, 1, 2, 3, 5, 8, 13])
test_trigger = np.array([0, 1, 0, 0, 0, 0, 0, 0])
test_chocolate = np.array([1, 0, 0, 1, 0, 0, 1, 0])
test_timeseries = [test_time.copy(), test_trigger, test_chocolate]
test_timeseries = [test_time, test_trigger, test_chocolate]
test_freq = [42.0, 3.14, 20.0]
test_chn_name = ['time', 'trigger', 'chocolate']
test_units = ['s', 's', 'sweetness']
Expand All @@ -101,11 +101,12 @@ def test_BlueprintInput():

# Tests rename_channels
new_names = ['trigger', 'time', 'lindt']
blueprint_in.rename_channels(new_names.copy())
blueprint_in.rename_channels(new_names)
test_index = blueprint_in.return_index(1)
assert blueprint_in.ch_name == ['time', 'trigger', 'lindt']
assert test_index[0] is not test_trigger

# Tests return_index
test_index = blueprint_in.return_index(1)
assert (test_index[0] == test_trigger).all()
assert test_index[1] == len(test_timeseries)
assert test_index[2] == test_freq[1]
Expand Down Expand Up @@ -140,7 +141,7 @@ def test_cta_time_interp():
"""Test BlueprintInput.check_trigger_amount with time resampling."""
test_time = np.array([0, 7])
test_trigger = np.array([0, 1, 0, 0, 0, 0, 0, 0])
test_timeseries = [test_time.copy(), test_trigger]
test_timeseries = [test_time, test_trigger]
test_freq = [42.0, 3.14]
test_chn_name = ['time', 'trigger']
test_units = ['s', 's']
Expand Down