From 62ec35ed0ed331021f5c04fae4205f501acdf7e0 Mon Sep 17 00:00:00 2001 From: vinferrer Date: Thu, 17 Sep 2020 16:13:52 +0200 Subject: [PATCH 01/66] default chtrig is 0 --- phys2bids/cli/run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phys2bids/cli/run.py b/phys2bids/cli/run.py index 054bc4bfd..ad386e0ce 100644 --- a/phys2bids/cli/run.py +++ b/phys2bids/cli/run.py @@ -77,8 +77,8 @@ def _get_parser(): type=int, help='The column number of the trigger channel. ' 'Channel numbering starts with 1. ' - 'Default is 1.', - default=1) + 'Default is 0.', + default=0) optional.add_argument('-chsel', '--channel-selection', dest='chsel', nargs='*', From 04bd62d53262a669ea96588e98efc1c18a5eaaa1 Mon Sep 17 00:00:00 2001 From: vinferrer Date: Thu, 17 Sep 2020 16:14:40 +0200 Subject: [PATCH 02/66] default chtrig is also 0 --- phys2bids/phys2bids.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phys2bids/phys2bids.py b/phys2bids/phys2bids.py index 006ce80ac..e1c0bb0c7 100644 --- a/phys2bids/phys2bids.py +++ b/phys2bids/phys2bids.py @@ -127,7 +127,7 @@ def print_json(outfile, samp_freq, time_offset, ch_name): description='The BIDS specification', cite_module=True) def phys2bids(filename, info=False, indir='.', outdir='.', heur_file=None, - sub=None, ses=None, chtrig=1, chsel=None, num_timepoints_expected=None, + sub=None, ses=None, chtrig=0, chsel=None, num_timepoints_expected=None, tr=None, thr=None, pad=9, ch_name=[], yml='', debug=False, quiet=False): """ Run main workflow of phys2bids. @@ -191,7 +191,7 @@ def phys2bids(filename, info=False, indir='.', outdir='.', heur_file=None, # Check options to make them internally coherent pt. II # #!# This can probably be done while parsing? indir = utils.check_input_dir(indir) - if chtrig < 1: + if chtrig < 0: raise Exception('Wrong trigger channel. Channel indexing starts with 1!') filename, ftype = utils.check_input_type(filename, From c30ac7512f44eec4eea79114dab54f4a21612657 Mon Sep 17 00:00:00 2001 From: vinferrer Date: Thu, 17 Sep 2020 16:40:07 +0200 Subject: [PATCH 03/66] add automatic recognition of a trigger channel by name --- phys2bids/physio_obj.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 24fb923b3..994bfb2df 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -228,6 +228,17 @@ class BlueprintInput(): def __init__(self, timeseries, freq, ch_name, units, trigger_idx, num_timepoints_found=None, thr=None, time_offset=0): """Initialise BlueprintInput (see class docstring).""" + trigger_names_list = ["trig", "trigger", "TRIGGER", "Trigger"] + if trigger_idx == 0: + name_not_found = True + LGR.warning('User did not input chtrig. Trying to find in auto mode by name') + for trig_name in trigger_names_list: + if trig_name in ch_name: + trigger_idx = ch_name.index(trig_name) + LGR.warning(f'Assigning chtrig to channel {trig_name}') + name_not_found = False + if name_not_found: + raise Exception('No trigger channel was automaticly found. Exiting program') self.timeseries = is_valid(timeseries, list, list_type=np.ndarray) self.freq = has_size(is_valid(freq, list, list_type=(int, float)), From bf37e1fbf77b3a164a0f0c981857dbb19c6614d8 Mon Sep 17 00:00:00 2001 From: vinferrer Date: Fri, 18 Sep 2020 14:24:08 +0200 Subject: [PATCH 04/66] add warking if trigger channel name doesn't match any alias --- phys2bids/physio_obj.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 994bfb2df..620e5b214 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -239,6 +239,10 @@ def __init__(self, timeseries, freq, ch_name, units, trigger_idx, name_not_found = False if name_not_found: raise Exception('No trigger channel was automaticly found. Exiting program') + else: + if ch_name[trigger_idx] not in trigger_names_list: + LGR.warning(f'Trigger channel name is not in our trigger channel name alias list.' + f'Please make sure you are choosing the proper channel') self.timeseries = is_valid(timeseries, list, list_type=np.ndarray) self.freq = has_size(is_valid(freq, list, list_type=(int, float)), From 23bf7f4b74b6d2c03439b6c16f2b1043af33d1f9 Mon Sep 17 00:00:00 2001 From: vinferrer Date: Fri, 18 Sep 2020 14:27:27 +0200 Subject: [PATCH 05/66] change 'Wrong trigger' chtrig to -1 --- phys2bids/tests/test_phys2bids.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phys2bids/tests/test_phys2bids.py b/phys2bids/tests/test_phys2bids.py index 3593a5828..128b9a6b0 100644 --- a/phys2bids/tests/test_phys2bids.py +++ b/phys2bids/tests/test_phys2bids.py @@ -48,7 +48,7 @@ def test_raise_exception(samefreq_full_acq_file): test_filename = 'input.txt' with raises(Exception) as errorinfo: - phys2bids.phys2bids(filename=test_filename, chtrig=0) + phys2bids.phys2bids(filename=test_filename, chtrig=-1) assert 'Wrong trigger' in str(errorinfo.value) test_path, test_filename = os.path.split(samefreq_full_acq_file) @@ -58,6 +58,6 @@ def test_raise_exception(samefreq_full_acq_file): assert "doesn't match" in str(errorinfo.value) with raises(Exception) as errorinfo: - phys2bids.phys2bids(filename=test_filename, num_timepoints_expected=[20, 300], chtrig=3, tr=1.5, - indir=test_path, outdir=test_path) + phys2bids.phys2bids(filename=test_filename, num_timepoints_expected=[20, 300], chtrig=3, + tr=1.5, indir=test_path, outdir=test_path) assert 'stop now' in str(errorinfo.value) From e43b51a30a2a66a567e731a65fa5b16341f8e561 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Fri, 18 Sep 2020 15:32:15 +0200 Subject: [PATCH 06/66] Update phys2bids/physio_obj.py Co-authored-by: Taylor Salo --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 620e5b214..2a094d65f 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -238,7 +238,7 @@ def __init__(self, timeseries, freq, ch_name, units, trigger_idx, LGR.warning(f'Assigning chtrig to channel {trig_name}') name_not_found = False if name_not_found: - raise Exception('No trigger channel was automaticly found. Exiting program') + raise Exception('No trigger channel was automatically found. Exiting program.') else: if ch_name[trigger_idx] not in trigger_names_list: LGR.warning(f'Trigger channel name is not in our trigger channel name alias list.' From a4dff3257d2c27ea1ba8c78b90b7db78fcbda072 Mon Sep 17 00:00:00 2001 From: vinferrer Date: Fri, 18 Sep 2020 15:34:08 +0200 Subject: [PATCH 07/66] edit warning messages --- phys2bids/physio_obj.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 620e5b214..d8dba086d 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -231,18 +231,18 @@ def __init__(self, timeseries, freq, ch_name, units, trigger_idx, trigger_names_list = ["trig", "trigger", "TRIGGER", "Trigger"] if trigger_idx == 0: name_not_found = True - LGR.warning('User did not input chtrig. Trying to find in auto mode by name') + LGR.warning('User did not input chtrig. Trying to find in auto mode by name.') for trig_name in trigger_names_list: if trig_name in ch_name: trigger_idx = ch_name.index(trig_name) - LGR.warning(f'Assigning chtrig to channel {trig_name}') + LGR.warning(f'Assigning chtrig to channel {trig_name}.') name_not_found = False if name_not_found: - raise Exception('No trigger channel was automaticly found. Exiting program') + raise Exception('No trigger channel was automaticly found. Exiting program.') else: if ch_name[trigger_idx] not in trigger_names_list: - LGR.warning(f'Trigger channel name is not in our trigger channel name alias list.' - f'Please make sure you are choosing the proper channel') + LGR.warning('Trigger channel name is not in our trigger channel name alias list. ' + 'Please make sure you are choosing the proper channel') self.timeseries = is_valid(timeseries, list, list_type=np.ndarray) self.freq = has_size(is_valid(freq, list, list_type=(int, float)), From bee4c71418e3a69e685aec305114ddc59ba1d3d2 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Fri, 18 Sep 2020 15:40:12 +0200 Subject: [PATCH 08/66] Update phys2bids/physio_obj.py Co-authored-by: Stefano Moia --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 6415ccb28..f1c73255d 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -238,7 +238,7 @@ def __init__(self, timeseries, freq, ch_name, units, trigger_idx, LGR.warning(f'Assigning chtrig to channel {trig_name}.') name_not_found = False if name_not_found: - raise Exception('No trigger channel was automatically found. Exiting program.') + raise Exception('No trigger channel was automatically found. Please run phys2bids specifying the -chtrig argument.') else: if ch_name[trigger_idx] not in trigger_names_list: LGR.warning('Trigger channel name is not in our trigger channel name alias list. ' From fd115b9ec435fa54044d1f2dabf60fb000df59a6 Mon Sep 17 00:00:00 2001 From: vinferrer Date: Fri, 18 Sep 2020 15:41:26 +0200 Subject: [PATCH 09/66] change assigning trigger phrase --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index f1c73255d..23708dbac 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -235,7 +235,7 @@ def __init__(self, timeseries, freq, ch_name, units, trigger_idx, for trig_name in trigger_names_list: if trig_name in ch_name: trigger_idx = ch_name.index(trig_name) - LGR.warning(f'Assigning chtrig to channel {trig_name}.') + LGR.warning(f'{trig_name} selected as trigger channel') name_not_found = False if name_not_found: raise Exception('No trigger channel was automatically found. Please run phys2bids specifying the -chtrig argument.') From 0529d79f82394668c976e7c70e62bd4fdee12548 Mon Sep 17 00:00:00 2001 From: vinferrer Date: Fri, 18 Sep 2020 16:07:25 +0200 Subject: [PATCH 10/66] solve lintin problem --- phys2bids/physio_obj.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 23708dbac..cd8b1a70b 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -238,7 +238,8 @@ def __init__(self, timeseries, freq, ch_name, units, trigger_idx, LGR.warning(f'{trig_name} selected as trigger channel') name_not_found = False if name_not_found: - raise Exception('No trigger channel was automatically found. Please run phys2bids specifying the -chtrig argument.') + raise Exception('No trigger channel was automatically found. Please run phys2bids' + 'specifying the -chtrig argument.') else: if ch_name[trigger_idx] not in trigger_names_list: LGR.warning('Trigger channel name is not in our trigger channel name alias list. ' From 2b75fd4fa027c05c40980fd7a49a9fcd7ea56b13 Mon Sep 17 00:00:00 2001 From: vinferrer Date: Mon, 21 Sep 2020 11:05:08 +0200 Subject: [PATCH 11/66] implement partial match --- phys2bids/physio_obj.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index cd8b1a70b..2c2a580b9 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -7,6 +7,7 @@ from itertools import groupby import numpy as np +import re LGR = logging.getLogger(__name__) @@ -228,16 +229,18 @@ class BlueprintInput(): def __init__(self, timeseries, freq, ch_name, units, trigger_idx, num_timepoints_found=None, thr=None, time_offset=0): """Initialise BlueprintInput (see class docstring).""" - trigger_names_list = ["trig", "trigger", "TRIGGER", "Trigger"] + trigger_names_list = ["trig", "trigger"] if trigger_idx == 0: - name_not_found = True LGR.warning('User did not input chtrig. Trying to find in auto mode by name.') - for trig_name in trigger_names_list: - if trig_name in ch_name: - trigger_idx = ch_name.index(trig_name) - LGR.warning(f'{trig_name} selected as trigger channel') - name_not_found = False - if name_not_found: + results = [re.search('|'.join(trigger_names_list), l, re.IGNORECASE) for l in ch_name] + indexes = [i for i, v in enumerate(results) if v] + if len(indexes) == 1: + trigger_idx = indexes[0] + LGR.warning(f'{ch_name[trigger_idx]} selected as trigger channel') + if len(indexes) > 1: + raise Exception('No trigger channel was automatically found. Please run phys2bids' + 'specifying the -chtrig argument.') + if len(indexes < 1): raise Exception('No trigger channel was automatically found. Please run phys2bids' 'specifying the -chtrig argument.') else: From c31a227d44381ea76da249096cb6888912caba71 Mon Sep 17 00:00:00 2001 From: vinferrer Date: Mon, 21 Sep 2020 11:14:05 +0200 Subject: [PATCH 12/66] correct error --- phys2bids/physio_obj.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 2c2a580b9..d668779cc 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -232,7 +232,8 @@ def __init__(self, timeseries, freq, ch_name, units, trigger_idx, trigger_names_list = ["trig", "trigger"] if trigger_idx == 0: LGR.warning('User did not input chtrig. Trying to find in auto mode by name.') - results = [re.search('|'.join(trigger_names_list), l, re.IGNORECASE) for l in ch_name] + results = [re.search('|'.join(trigger_names_list), + case, re.IGNORECASE) for case in ch_name] indexes = [i for i, v in enumerate(results) if v] if len(indexes) == 1: trigger_idx = indexes[0] @@ -240,7 +241,7 @@ def __init__(self, timeseries, freq, ch_name, units, trigger_idx, if len(indexes) > 1: raise Exception('No trigger channel was automatically found. Please run phys2bids' 'specifying the -chtrig argument.') - if len(indexes < 1): + if len(indexes) < 1: raise Exception('No trigger channel was automatically found. Please run phys2bids' 'specifying the -chtrig argument.') else: From cf839f97468b940eacd370e6b58d7a8c1f10bcca Mon Sep 17 00:00:00 2001 From: vinferrer Date: Mon, 21 Sep 2020 11:26:26 +0200 Subject: [PATCH 13/66] make the auto_chtrig a method inside phys_obj.py --- phys2bids/physio_obj.py | 42 ++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index d668779cc..cb3801b75 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -11,6 +11,8 @@ LGR = logging.getLogger(__name__) +trigger_names_list = ["trig", "trigger"] + def is_valid(var, var_type, list_type=None): """ @@ -229,25 +231,6 @@ class BlueprintInput(): def __init__(self, timeseries, freq, ch_name, units, trigger_idx, num_timepoints_found=None, thr=None, time_offset=0): """Initialise BlueprintInput (see class docstring).""" - trigger_names_list = ["trig", "trigger"] - if trigger_idx == 0: - LGR.warning('User did not input chtrig. Trying to find in auto mode by name.') - results = [re.search('|'.join(trigger_names_list), - case, re.IGNORECASE) for case in ch_name] - indexes = [i for i, v in enumerate(results) if v] - if len(indexes) == 1: - trigger_idx = indexes[0] - LGR.warning(f'{ch_name[trigger_idx]} selected as trigger channel') - if len(indexes) > 1: - raise Exception('No trigger channel was automatically found. Please run phys2bids' - 'specifying the -chtrig argument.') - if len(indexes) < 1: - raise Exception('No trigger channel was automatically found. Please run phys2bids' - 'specifying the -chtrig argument.') - else: - if ch_name[trigger_idx] not in trigger_names_list: - LGR.warning('Trigger channel name is not in our trigger channel name alias list. ' - 'Please make sure you are choosing the proper channel') self.timeseries = is_valid(timeseries, list, list_type=np.ndarray) self.freq = has_size(is_valid(freq, list, list_type=(int, float)), @@ -258,6 +241,12 @@ def __init__(self, timeseries, freq, ch_name, units, trigger_idx, self.num_timepoints_found = num_timepoints_found self.thr = thr self.time_offset = time_offset + if trigger_idx == 0: + self.auto_trigger_selection + else: + if ch_name[trigger_idx] not in trigger_names_list: + LGR.warning('Trigger channel name is not in our trigger channel name alias list. ' + 'Please make sure you are choosing the proper channel') @property def ch_amount(self): @@ -552,6 +541,21 @@ def print_info(self, filename): LGR.info(info) + def auto_trigger_selection(self): + LGR.warning('User did not input chtrig. Trying to find in auto mode by name.') + results = [re.search('|'.join(trigger_names_list), + case, re.IGNORECASE) for case in self.ch_name] + indexes = [i for i, v in enumerate(results) if v] + if len(indexes) == 1: + self.trigger_idx = indexes[0] + LGR.warning(f'{self.ch_name[self.trigger_idx]} selected as trigger channel') + if len(indexes) > 1: + raise Exception('No trigger channel was automatically found. Please run phys2bids' + 'specifying the -chtrig argument.') + if len(indexes) < 1: + raise Exception('No trigger channel was automatically found. Please run phys2bids' + 'specifying the -chtrig argument.') + class BlueprintOutput(): """ From 03cde910cde547eade796b1c56bb47de2286adfc Mon Sep 17 00:00:00 2001 From: vinferrer Date: Mon, 21 Sep 2020 11:34:17 +0200 Subject: [PATCH 14/66] add docstring --- phys2bids/physio_obj.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index cb3801b75..af47b6c80 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -542,6 +542,18 @@ def print_info(self, filename): LGR.info(info) def auto_trigger_selection(self): + """ + Finds a trigger index matching the channels with a regular expresion. + + Parameters + ---------- + self + + Notes + ----- + Outcome: + trigger_idx: + """ LGR.warning('User did not input chtrig. Trying to find in auto mode by name.') results = [re.search('|'.join(trigger_names_list), case, re.IGNORECASE) for case in self.ch_name] From 16629c5ee7de2e152bdd3711b9105d145f3f7fa6 Mon Sep 17 00:00:00 2001 From: vinferrer Date: Mon, 21 Sep 2020 11:52:46 +0200 Subject: [PATCH 15/66] use imperative mode --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index af47b6c80..8df3553a4 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -543,7 +543,7 @@ def print_info(self, filename): def auto_trigger_selection(self): """ - Finds a trigger index matching the channels with a regular expresion. + Find a trigger index matching the channels with a regular expresion. Parameters ---------- From f0d2212acfebe5c21c2c1099599e262fb80bfece Mon Sep 17 00:00:00 2001 From: vinferrer Date: Mon, 21 Sep 2020 12:24:57 +0200 Subject: [PATCH 16/66] now acq doesn't use chtrig --- phys2bids/interfaces/acq.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/phys2bids/interfaces/acq.py b/phys2bids/interfaces/acq.py index 1e840c1c0..0932d1fbc 100644 --- a/phys2bids/interfaces/acq.py +++ b/phys2bids/interfaces/acq.py @@ -41,9 +41,12 @@ def populate_phys_input(filename, chtrig): with warnings.catch_warnings(): warnings.filterwarnings('ignore', category=DeprecationWarning) data = read_file(filename).channels - - freq = [data[chtrig - 1].samples_per_second, ] - timeseries = [data[chtrig - 1].time_index, ] + # obtain time channel and time channel frequency from one of + # the channels with highest frequency + frequencies = [x.samples_per_second for x in data] + max_index = [i for i, j in enumerate(frequencies) if j == max(frequencies)][0] + freq = [data[max_index].samples_per_second, ] + timeseries = [data[max_index].time_index, ] units = ['s', ] names = ['time', ] From 37b604ad575990c0eca39faa6326afe718e13b0b Mon Sep 17 00:00:00 2001 From: vinferrer Date: Tue, 22 Sep 2020 14:29:39 +0200 Subject: [PATCH 17/66] add () so the function executes --- phys2bids/physio_obj.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 8df3553a4..47b8ee33b 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -242,7 +242,7 @@ def __init__(self, timeseries, freq, ch_name, units, trigger_idx, self.thr = thr self.time_offset = time_offset if trigger_idx == 0: - self.auto_trigger_selection + self.auto_trigger_selection() else: if ch_name[trigger_idx] not in trigger_names_list: LGR.warning('Trigger channel name is not in our trigger channel name alias list. ' @@ -562,7 +562,8 @@ def auto_trigger_selection(self): self.trigger_idx = indexes[0] LGR.warning(f'{self.ch_name[self.trigger_idx]} selected as trigger channel') if len(indexes) > 1: - raise Exception('No trigger channel was automatically found. Please run phys2bids' + raise Exception('More than one possible trigger channel was automatically found.' + 'Please run phys2bids' 'specifying the -chtrig argument.') if len(indexes) < 1: raise Exception('No trigger channel was automatically found. Please run phys2bids' From a0e8c02e38c5b2546ca5ae4db352dcae1e2610d8 Mon Sep 17 00:00:00 2001 From: vinferrer Date: Tue, 22 Sep 2020 14:47:00 +0200 Subject: [PATCH 18/66] add test_auto_trigger_selection unit test --- phys2bids/tests/test_physio_obj.py | 38 +++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/phys2bids/tests/test_physio_obj.py b/phys2bids/tests/test_physio_obj.py index cb9fe9a22..b51aa92a8 100644 --- a/phys2bids/tests/test_physio_obj.py +++ b/phys2bids/tests/test_physio_obj.py @@ -2,7 +2,7 @@ import numpy as np from pytest import raises - +import logging from phys2bids import physio_obj as po @@ -236,3 +236,39 @@ def test_BlueprintOutput(): # Test __eq__ assert blueprint_out == blueprint_out + + +def test_auto_trigger_selection(caplog): + """Test auto_trigger_selection.""" + test_time = np.array([0, 1, 2, 3, 4]) + test_trigger = np.array([0, 1, 2, 3, 4]) + test_half = np.array([0, 1, 2]) + test_twice = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) + test_timeseries = [test_time, test_trigger, test_half, test_twice] + test_freq = [1, 1, 0.5, 2] + test_chn_name = ['time', 'trigger', 'half', 'twice'] + test_units = ['s', 'V', 'V', 'V'] + + # test when trigger is not the name of the channel + test_chtrig = 2 + phys_in = po.BlueprintInput(test_timeseries, test_freq, test_chn_name, + test_units, test_chtrig) + assert 'Trigger channel name is not' in caplog.text + + # test when trigger is 0 and that the trigger channel is recognized by name: + test_chtrig = 0 + phys_in = po.BlueprintInput(test_timeseries, test_freq, test_chn_name, + test_units, test_chtrig) + assert phys_in.trigger_idx == 1 + # test when no trigger is found + test_chn_name = ['time', 'dummy', 'half', 'twice'] + with raises(Exception) as errorinfo: + phys_in = po.BlueprintInput(test_timeseries, test_freq, test_chn_name, + test_units, test_chtrig) + assert 'No trigger channel was automatically found' in str(errorinfo.value) + # test when no trigger is found + test_chn_name = ['time', 'trigger', 'TRIGGER', 'twice'] + with raises(Exception) as errorinfo: + phys_in = po.BlueprintInput(test_timeseries, test_freq, test_chn_name, + test_units, test_chtrig) + assert 'More than one possible trigger channel' in str(errorinfo.value) From 4ec2d10e0efe0e719bc3cf9a563f3f4f32d388bf Mon Sep 17 00:00:00 2001 From: vinferrer Date: Tue, 22 Sep 2020 14:49:48 +0200 Subject: [PATCH 19/66] delete unused import --- phys2bids/tests/test_physio_obj.py | 1 - 1 file changed, 1 deletion(-) diff --git a/phys2bids/tests/test_physio_obj.py b/phys2bids/tests/test_physio_obj.py index b51aa92a8..620bc659d 100644 --- a/phys2bids/tests/test_physio_obj.py +++ b/phys2bids/tests/test_physio_obj.py @@ -2,7 +2,6 @@ import numpy as np from pytest import raises -import logging from phys2bids import physio_obj as po From 59317b5948a69edbb062caf87c17e7398370ec88 Mon Sep 17 00:00:00 2001 From: vferrer Date: Thu, 15 Oct 2020 12:54:25 +0200 Subject: [PATCH 20/66] add chtrig=0 explanation --- phys2bids/cli/run.py | 3 ++- phys2bids/interfaces/txt.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/phys2bids/cli/run.py b/phys2bids/cli/run.py index ad386e0ce..5442481ed 100644 --- a/phys2bids/cli/run.py +++ b/phys2bids/cli/run.py @@ -77,7 +77,8 @@ def _get_parser(): type=int, help='The column number of the trigger channel. ' 'Channel numbering starts with 1. ' - 'Default is 0.', + 'Default is 0.if chtrig is left as zero the' + 'automic trigger channel search by name will be executed', default=0) optional.add_argument('-chsel', '--channel-selection', dest='chsel', diff --git a/phys2bids/interfaces/txt.py b/phys2bids/interfaces/txt.py index f126fecd9..2397bd27b 100644 --- a/phys2bids/interfaces/txt.py +++ b/phys2bids/interfaces/txt.py @@ -303,7 +303,8 @@ def populate_phys_input(filename, chtrig=0): filename: str path to the txt Labchart file chtrig : int - index of trigger channel, starting in 1 for human readability + index of trigger channel, starting in 1 for human readability, if chtrig is left as zero + the automic trigger channel search by name will be executed Returns ------- From 5f99e95168afe60aa5ae0228d54229d61d934c1a Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Wed, 25 Nov 2020 14:03:48 +0100 Subject: [PATCH 21/66] 0 isn't valid also --- phys2bids/phys2bids.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/phys2bids.py b/phys2bids/phys2bids.py index cc86a0f76..e6d087d62 100644 --- a/phys2bids/phys2bids.py +++ b/phys2bids/phys2bids.py @@ -191,7 +191,7 @@ def phys2bids(filename, info=False, indir='.', outdir='.', heur_file=None, # Check options to make them internally coherent pt. II # #!# This can probably be done while parsing? indir = utils.check_input_dir(indir) - if chtrig < 0: + if chtrig <= 0: raise Exception('Wrong trigger channel. Channel indexing starts with 1!') filename, ftype = utils.check_input_type(filename, From 77c46b86ddd2b2016d98c45eb73c6713d5841fa2 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Wed, 25 Nov 2020 14:04:06 +0100 Subject: [PATCH 22/66] add chtrig to the second call --- phys2bids/tests/test_phys2bids.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/tests/test_phys2bids.py b/phys2bids/tests/test_phys2bids.py index 5161e8e85..c37ee3f29 100644 --- a/phys2bids/tests/test_phys2bids.py +++ b/phys2bids/tests/test_phys2bids.py @@ -52,7 +52,7 @@ def test_raise_exception(samefreq_full_acq_file): with raises(Exception) as errorinfo: phys2bids.phys2bids(filename=test_filename, num_timepoints_expected=[70], tr=[1.3, 2], - indir=test_path, outdir=test_path) + indir=test_path, outdir=test_path, chtrig=3) assert "doesn't match" in str(errorinfo.value) with raises(Exception) as errorinfo: From 89d27db95cfc7667aa08459cd832bb9f82d5effc Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 08:55:54 +0100 Subject: [PATCH 23/66] Update phys2bids/cli/run.py Co-authored-by: Stefano Moia --- phys2bids/cli/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/cli/run.py b/phys2bids/cli/run.py index 5442481ed..d27f34adb 100644 --- a/phys2bids/cli/run.py +++ b/phys2bids/cli/run.py @@ -77,7 +77,7 @@ def _get_parser(): type=int, help='The column number of the trigger channel. ' 'Channel numbering starts with 1. ' - 'Default is 0.if chtrig is left as zero the' + 'Default is 0. If chtrig is left as zero phys2bids will ' 'automic trigger channel search by name will be executed', default=0) optional.add_argument('-chsel', '--channel-selection', From 2cdda8af6ffdcdaaabcef1eb1519f432f8753295 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 08:56:06 +0100 Subject: [PATCH 24/66] Update phys2bids/cli/run.py Co-authored-by: Stefano Moia --- phys2bids/cli/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/cli/run.py b/phys2bids/cli/run.py index d27f34adb..0527d6155 100644 --- a/phys2bids/cli/run.py +++ b/phys2bids/cli/run.py @@ -78,7 +78,7 @@ def _get_parser(): help='The column number of the trigger channel. ' 'Channel numbering starts with 1. ' 'Default is 0. If chtrig is left as zero phys2bids will ' - 'automic trigger channel search by name will be executed', + 'perform an automatic trigger channel search by channel names.', default=0) optional.add_argument('-chsel', '--channel-selection', dest='chsel', From cd27501175e944da6bdbba642aa38e923241085d Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 08:56:19 +0100 Subject: [PATCH 25/66] Update phys2bids/io.py Co-authored-by: Stefano Moia --- phys2bids/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/io.py b/phys2bids/io.py index 3efbf46c7..9df0a1e80 100644 --- a/phys2bids/io.py +++ b/phys2bids/io.py @@ -306,7 +306,7 @@ def load_txt_ext(filename, chtrig=0): path to the txt Labchart file chtrig : int index of trigger channel, starting in 1 for human readability, if chtrig is left as zero - the automic trigger channel search by name will be executed + perform an automatic trigger channel search by channel names. Returns ------- From 797e89ccfd009d7e8296675437a534b3a6fc8b45 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 08:56:33 +0100 Subject: [PATCH 26/66] Update phys2bids/physio_obj.py Co-authored-by: Stefano Moia --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 742bb1879..c405236a1 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -576,7 +576,7 @@ def auto_trigger_selection(self): 'Please run phys2bids' 'specifying the -chtrig argument.') if len(indexes) < 1: - raise Exception('No trigger channel was automatically found. Please run phys2bids' + raise Exception('No trigger channel automatically found. Please run phys2bids ' 'specifying the -chtrig argument.') From 00cf91ba513043c59829c16f0b440988bdc35d73 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 08:56:58 +0100 Subject: [PATCH 27/66] Update phys2bids/io.py Co-authored-by: Stefano Moia --- phys2bids/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/io.py b/phys2bids/io.py index 9df0a1e80..708f84d30 100644 --- a/phys2bids/io.py +++ b/phys2bids/io.py @@ -305,7 +305,7 @@ def load_txt_ext(filename, chtrig=0): filename: str path to the txt Labchart file chtrig : int - index of trigger channel, starting in 1 for human readability, if chtrig is left as zero + index of trigger channel, starting in 1 for human readability. If `chtrig == 0` perform an automatic trigger channel search by channel names. Returns From b39bddef9bf2f467af7320d19ffa23e9f11a8c27 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 08:57:25 +0100 Subject: [PATCH 28/66] Update phys2bids/phys2bids.py Co-authored-by: Stefano Moia --- phys2bids/phys2bids.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/phys2bids/phys2bids.py b/phys2bids/phys2bids.py index e6d087d62..5c49e6cee 100644 --- a/phys2bids/phys2bids.py +++ b/phys2bids/phys2bids.py @@ -192,7 +192,10 @@ def phys2bids(filename, info=False, indir='.', outdir='.', heur_file=None, # #!# This can probably be done while parsing? indir = utils.check_input_dir(indir) if chtrig <= 0: - raise Exception('Wrong trigger channel. Channel indexing starts with 1!') + raise Exception('Wrong trigger channel. Channel indexing cannot be negative!') + elif chtrig == 0: + LGR.warning('No trigger channel specified. phys2bids will run an automatic search based ' + 'on channel names.') filename, ftype = utils.check_input_type(filename, indir) From 3ce559cdce9aa2c7450a9301ad4e4a483e18ed86 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 08:57:54 +0100 Subject: [PATCH 29/66] Update phys2bids/physio_obj.py Co-authored-by: Stefano Moia --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index c405236a1..ee8476c94 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -11,7 +11,7 @@ LGR = logging.getLogger(__name__) -trigger_names_list = ["trig", "trigger"] +TRIGGER_NAMES = ["trig", "trigger"] def is_valid(var, var_type, list_type=None): From ae3256a376894fd852ddc1344723749eda4f1b62 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 08:58:10 +0100 Subject: [PATCH 30/66] Update phys2bids/tests/test_physio_obj.py Co-authored-by: Stefano Moia --- phys2bids/tests/test_physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/tests/test_physio_obj.py b/phys2bids/tests/test_physio_obj.py index 445f62ca1..ef1e11ff3 100644 --- a/phys2bids/tests/test_physio_obj.py +++ b/phys2bids/tests/test_physio_obj.py @@ -287,7 +287,7 @@ def test_auto_trigger_selection(caplog): with raises(Exception) as errorinfo: phys_in = po.BlueprintInput(test_timeseries, test_freq, test_chn_name, test_units, test_chtrig) - assert 'No trigger channel was automatically found' in str(errorinfo.value) + assert 'No trigger channel automatically found' in str(errorinfo.value) # test when no trigger is found test_chn_name = ['time', 'trigger', 'TRIGGER', 'twice'] with raises(Exception) as errorinfo: From aa66db2e7d3b867f054e702c30cfd4e7d2c1e483 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 08:58:41 +0100 Subject: [PATCH 31/66] Update phys2bids/physio_obj.py Co-authored-by: Stefano Moia --- phys2bids/physio_obj.py | 1 - 1 file changed, 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index ee8476c94..80f89009a 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -574,7 +574,6 @@ def auto_trigger_selection(self): if len(indexes) > 1: raise Exception('More than one possible trigger channel was automatically found.' 'Please run phys2bids' - 'specifying the -chtrig argument.') if len(indexes) < 1: raise Exception('No trigger channel automatically found. Please run phys2bids ' 'specifying the -chtrig argument.') From b03a07436aeeca4419d465729741ced9562ff1c8 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 08:59:11 +0100 Subject: [PATCH 32/66] Update phys2bids/physio_obj.py Co-authored-by: Stefano Moia --- phys2bids/physio_obj.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 80f89009a..3df023a74 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -562,7 +562,8 @@ def auto_trigger_selection(self): Notes ----- Outcome: - trigger_idx: + trigger_idx : int + Automatically retrieved trigger index """ LGR.warning('User did not input chtrig. Trying to find in auto mode by name.') results = [re.search('|'.join(trigger_names_list), From 6233068a0618058b5db553695d00ab812b88f4da Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 09:00:01 +0100 Subject: [PATCH 33/66] Update phys2bids/physio_obj.py Co-authored-by: Stefano Moia --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 3df023a74..2c3297eb1 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -565,7 +565,7 @@ def auto_trigger_selection(self): trigger_idx : int Automatically retrieved trigger index """ - LGR.warning('User did not input chtrig. Trying to find in auto mode by name.') + LGR.warning('Running automatic trigger detection.') results = [re.search('|'.join(trigger_names_list), case, re.IGNORECASE) for case in self.ch_name] indexes = [i for i, v in enumerate(results) if v] From c8d7a6366e48ec9e7927ae364358833d1311add8 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 09:00:30 +0100 Subject: [PATCH 34/66] Update phys2bids/physio_obj.py Co-authored-by: Stefano Moia --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 2c3297eb1..96ad895cc 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -566,7 +566,7 @@ def auto_trigger_selection(self): Automatically retrieved trigger index """ LGR.warning('Running automatic trigger detection.') - results = [re.search('|'.join(trigger_names_list), + results = [re.search('|'.join(TRIGGER_NAMES), case, re.IGNORECASE) for case in self.ch_name] indexes = [i for i, v in enumerate(results) if v] if len(indexes) == 1: From c9457f32b082283e320e19158bd3d12c9a22482e Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 09:00:48 +0100 Subject: [PATCH 35/66] Update phys2bids/physio_obj.py Co-authored-by: Stefano Moia --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 96ad895cc..fa5b6b4d9 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -573,7 +573,7 @@ def auto_trigger_selection(self): self.trigger_idx = indexes[0] LGR.warning(f'{self.ch_name[self.trigger_idx]} selected as trigger channel') if len(indexes) > 1: - raise Exception('More than one possible trigger channel was automatically found.' + raise Exception('More than one possible trigger channel was automatically found. ' 'Please run phys2bids' if len(indexes) < 1: raise Exception('No trigger channel automatically found. Please run phys2bids ' From 169b3ae2e768096a0b48d64d981732b1cb0a7281 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 09:01:09 +0100 Subject: [PATCH 36/66] Update phys2bids/physio_obj.py Co-authored-by: Stefano Moia --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index fa5b6b4d9..407bf1782 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -574,7 +574,7 @@ def auto_trigger_selection(self): LGR.warning(f'{self.ch_name[self.trigger_idx]} selected as trigger channel') if len(indexes) > 1: raise Exception('More than one possible trigger channel was automatically found. ' - 'Please run phys2bids' + 'Please run phys2bids specifying the -chtrig argument.') if len(indexes) < 1: raise Exception('No trigger channel automatically found. Please run phys2bids ' 'specifying the -chtrig argument.') From fc603a401f47f0769a0a9d4062bfeb2319c64c2a Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 09:05:28 +0100 Subject: [PATCH 37/66] conflict in docstring --- phys2bids/io.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/phys2bids/io.py b/phys2bids/io.py index 5e6a54fb5..e2a7c5ca9 100644 --- a/phys2bids/io.py +++ b/phys2bids/io.py @@ -216,18 +216,10 @@ def extract_header_items(channel_list, header=[]): Parameters ---------- -<<<<<<< HEAD - filename: str - path to the txt Labchart file - chtrig : int - index of trigger channel, starting in 1 for human readability. If `chtrig == 0` - perform an automatic trigger channel search by channel names. -======= channel_list : list of strings The channels of the recording header : list list that contains file header ->>>>>>> 52280e01ba7d2713f29dd391e2722df3f2ff690b Returns ------- From bbdbb532a37dd9d5ae270fad8111f1ab544f1132 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 09:06:41 +0100 Subject: [PATCH 38/66] TRIGGER_NAMES is a global variable --- phys2bids/physio_obj.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 407bf1782..93b032d97 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -4,15 +4,15 @@ """I/O objects for phys2bids.""" import logging +import re from itertools import groupby import numpy as np -import re - -LGR = logging.getLogger(__name__) TRIGGER_NAMES = ["trig", "trigger"] +LGR = logging.getLogger(__name__) + def is_valid(var, var_type, list_type=None): """ From 6389ca33d3079f629a1f584c3f92213056545d5e Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 09:09:00 +0100 Subject: [PATCH 39/66] rename trigger_name_list as TRIGGER_NAMES in one condition --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 93b032d97..9d894521e 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -244,7 +244,7 @@ def __init__(self, timeseries, freq, ch_name, units, trigger_idx, if trigger_idx == 0: self.auto_trigger_selection() else: - if ch_name[trigger_idx] not in trigger_names_list: + if ch_name[trigger_idx] not in TRIGGER_NAMES: LGR.warning('Trigger channel name is not in our trigger channel name alias list. ' 'Please make sure you are choosing the proper channel') From 7dfe63239ac59087356fc9b93b6286ac92175b9b Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 09:18:35 +0100 Subject: [PATCH 40/66] add raises to the docstring --- phys2bids/physio_obj.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 9d894521e..4d3483797 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -558,6 +558,10 @@ def auto_trigger_selection(self): Parameters ---------- self + Raises + ------ + Exception + More than one possible trigger channel was automatically found. Notes ----- From ed6f296a44ca7db1b8eecefa527433ef65d47821 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 09:18:46 +0100 Subject: [PATCH 41/66] add raises to the docstring --- phys2bids/physio_obj.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 4d3483797..fee988720 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -562,7 +562,8 @@ def auto_trigger_selection(self): ------ Exception More than one possible trigger channel was automatically found. - + Exception + No trigger channel automatically found Notes ----- Outcome: From ca3fe59b068c13a86e2322ee125135a42d73b1bf Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 09:28:23 +0100 Subject: [PATCH 42/66] change re expresion --- phys2bids/physio_obj.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index fee988720..36f613f60 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -571,8 +571,8 @@ def auto_trigger_selection(self): Automatically retrieved trigger index """ LGR.warning('Running automatic trigger detection.') - results = [re.search('|'.join(TRIGGER_NAMES), - case, re.IGNORECASE) for case in self.ch_name] + results = [re.search('|'.join(re.split('(\W+|\d|_)', case)), + '§'.join(TRIGGER_NAMES), re.IGNORECASE) for case in self.ch_name] indexes = [i for i, v in enumerate(results) if v] if len(indexes) == 1: self.trigger_idx = indexes[0] From fb285801d7a05a28ea3ae5089e229fcb14753464 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 09:44:29 +0100 Subject: [PATCH 43/66] add r to the re in results --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 36f613f60..71cb70e63 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -571,7 +571,7 @@ def auto_trigger_selection(self): Automatically retrieved trigger index """ LGR.warning('Running automatic trigger detection.') - results = [re.search('|'.join(re.split('(\W+|\d|_)', case)), + results = [re.search('|'.join(re.split(r'(\W+|\d|_)', case)), '§'.join(TRIGGER_NAMES), re.IGNORECASE) for case in self.ch_name] indexes = [i for i, v in enumerate(results) if v] if len(indexes) == 1: From a969cb4b34fe2a65a7aea0940da6ffd77af0a7d1 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 12:56:37 +0100 Subject: [PATCH 44/66] go back to the original re expresion --- phys2bids/physio_obj.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 71cb70e63..fee988720 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -571,8 +571,8 @@ def auto_trigger_selection(self): Automatically retrieved trigger index """ LGR.warning('Running automatic trigger detection.') - results = [re.search('|'.join(re.split(r'(\W+|\d|_)', case)), - '§'.join(TRIGGER_NAMES), re.IGNORECASE) for case in self.ch_name] + results = [re.search('|'.join(TRIGGER_NAMES), + case, re.IGNORECASE) for case in self.ch_name] indexes = [i for i, v in enumerate(results) if v] if len(indexes) == 1: self.trigger_idx = indexes[0] From 2beb6a1ddad9d65f7391032bfb35dd3aa378b708 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 13:01:01 +0100 Subject: [PATCH 45/66] name one of the channels CO2 so we see if a problem appears with the re --- phys2bids/tests/test_physio_obj.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phys2bids/tests/test_physio_obj.py b/phys2bids/tests/test_physio_obj.py index ef1e11ff3..3b24bde42 100644 --- a/phys2bids/tests/test_physio_obj.py +++ b/phys2bids/tests/test_physio_obj.py @@ -268,7 +268,7 @@ def test_auto_trigger_selection(caplog): test_twice = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) test_timeseries = [test_time, test_trigger, test_half, test_twice] test_freq = [1, 1, 0.5, 2] - test_chn_name = ['time', 'trigger', 'half', 'twice'] + test_chn_name = ['time', 'trigger', 'half', 'CO2'] test_units = ['s', 'V', 'V', 'V'] # test when trigger is not the name of the channel @@ -283,13 +283,13 @@ def test_auto_trigger_selection(caplog): test_units, test_chtrig) assert phys_in.trigger_idx == 1 # test when no trigger is found - test_chn_name = ['time', 'dummy', 'half', 'twice'] + test_chn_name = ['time', 'dummy', 'half', 'CO2'] with raises(Exception) as errorinfo: phys_in = po.BlueprintInput(test_timeseries, test_freq, test_chn_name, test_units, test_chtrig) assert 'No trigger channel automatically found' in str(errorinfo.value) # test when no trigger is found - test_chn_name = ['time', 'trigger', 'TRIGGER', 'twice'] + test_chn_name = ['time', 'trigger', 'TRIGGER', 'CO2'] with raises(Exception) as errorinfo: phys_in = po.BlueprintInput(test_timeseries, test_freq, test_chn_name, test_units, test_chtrig) From 320b5c81add176a38e1868a1b3914135b67ac9e6 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 21:35:35 +0100 Subject: [PATCH 46/66] Update phys2bids/physio_obj.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Eneko Uruñuela <13706448+eurunuela@users.noreply.github.com> --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index fee988720..562c9d7ed 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -246,7 +246,7 @@ def __init__(self, timeseries, freq, ch_name, units, trigger_idx, else: if ch_name[trigger_idx] not in TRIGGER_NAMES: LGR.warning('Trigger channel name is not in our trigger channel name alias list. ' - 'Please make sure you are choosing the proper channel') + 'Please make sure you choose the proper channel.') @property def ch_amount(self): From b652a3bdb447093063ac8ea4e99e7cb671ca94c9 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Mon, 30 Nov 2020 21:40:49 +0100 Subject: [PATCH 47/66] change warnings by infos --- phys2bids/physio_obj.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 625befd74..d42a10d18 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -565,13 +565,13 @@ def auto_trigger_selection(self): trigger_idx : int Automatically retrieved trigger index """ - LGR.warning('Running automatic trigger detection.') + LGR.info('Running automatic trigger detection.') results = [re.search('|'.join(TRIGGER_NAMES), case, re.IGNORECASE) for case in self.ch_name] indexes = [i for i, v in enumerate(results) if v] if len(indexes) == 1: self.trigger_idx = indexes[0] - LGR.warning(f'{self.ch_name[self.trigger_idx]} selected as trigger channel') + LGR.info(f'{self.ch_name[self.trigger_idx]} selected as trigger channel') if len(indexes) > 1: raise Exception('More than one possible trigger channel was automatically found. ' 'Please run phys2bids specifying the -chtrig argument.') From b5fdba67135d6742566e5d06a63bba787777698e Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Tue, 1 Dec 2020 08:55:01 +0100 Subject: [PATCH 48/66] add the if condition deleted when merging with main --- phys2bids/physio_obj.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index d42a10d18..0143d949a 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -242,6 +242,12 @@ def __init__(self, timeseries, freq, ch_name, units, trigger_idx, self.num_timepoints_found = deepcopy(num_timepoints_found) self.thr = deepcopy(thr) self.time_offset = deepcopy(time_offset) + if trigger_idx == 0: + self.auto_trigger_selection() + else: + if ch_name[trigger_idx] not in TRIGGER_NAMES: + LGR.warning('Trigger channel name is not in our trigger channel name alias list. ' + 'Please make sure you choose the proper channel.') @property def ch_amount(self): From 96af657da58fc8afccb076ad6d4bb7033ffa8962 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Tue, 1 Dec 2020 10:49:47 +0100 Subject: [PATCH 49/66] try stefano's solution but eliminate numbers frist from names --- phys2bids/physio_obj.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 0143d949a..ee92232f0 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -572,8 +572,9 @@ def auto_trigger_selection(self): Automatically retrieved trigger index """ LGR.info('Running automatic trigger detection.') - results = [re.search('|'.join(TRIGGER_NAMES), - case, re.IGNORECASE) for case in self.ch_name] + no_numbers = [re.sub(r'\d+', '', x) for x in self.ch_name] + results = [re.search('|'.join(re.split(r'(\W)', case)), + '§'.join(TRIGGER_NAMES), re.IGNORECASE) for case in no_numbers] indexes = [i for i, v in enumerate(results) if v] if len(indexes) == 1: self.trigger_idx = indexes[0] From a390bd6d28c517002d38bef780bf18d54da22479 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Thu, 17 Dec 2020 14:30:46 +0100 Subject: [PATCH 50/66] accept main incoming change --- phys2bids/phys2bids.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/phys2bids/phys2bids.py b/phys2bids/phys2bids.py index 267d73b79..0d11c1c6b 100644 --- a/phys2bids/phys2bids.py +++ b/phys2bids/phys2bids.py @@ -190,13 +190,9 @@ def phys2bids(filename, info=False, indir='.', outdir='.', heur_file=None, # Check options to make them internally coherent pt. II # #!# This can probably be done while parsing? - indir = utils.check_input_dir(indir) - if chtrig <= 0: - raise Exception('Wrong trigger channel. Channel indexing cannot be negative!') - elif chtrig == 0: - LGR.warning('No trigger channel specified. phys2bids will run an automatic search based ' - 'on channel names.') - + indir = os.path.abspath(indir) + if chtrig < 1: + raise Exception('Wrong trigger channel. Channel indexing starts with 1!') filename, ftype = utils.check_input_type(filename, indir) From 71225f56e63c55769ae6381f43d633c7d20b93e8 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Thu, 24 Dec 2020 12:02:16 +0100 Subject: [PATCH 51/66] adding cirrus CI with basic enviroment --- .cirrus.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .cirrus.yml diff --git a/.cirrus.yml b/.cirrus.yml new file mode 100644 index 000000000..1cd2e6957 --- /dev/null +++ b/.cirrus.yml @@ -0,0 +1,10 @@ +# global default +container: + image: continuumio/miniconda3 + +task: + makeenv_37: + folder: /tmp/src/phys2bids + env_script: + - git clone --branch=$CIRRUS_BRANCH + - pip install -e ".[test,doc]" \ No newline at end of file From 381f151b77d498044e3993e25e488ffd43e04deb Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Thu, 24 Dec 2020 12:03:22 +0100 Subject: [PATCH 52/66] wrong branch --- .cirrus.yml | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 .cirrus.yml diff --git a/.cirrus.yml b/.cirrus.yml deleted file mode 100644 index 1cd2e6957..000000000 --- a/.cirrus.yml +++ /dev/null @@ -1,10 +0,0 @@ -# global default -container: - image: continuumio/miniconda3 - -task: - makeenv_37: - folder: /tmp/src/phys2bids - env_script: - - git clone --branch=$CIRRUS_BRANCH - - pip install -e ".[test,doc]" \ No newline at end of file From c5a9285a45339b23952b984b1b4c4a26bea774a0 Mon Sep 17 00:00:00 2001 From: vinferrer Date: Sun, 31 Jan 2021 10:29:42 +0100 Subject: [PATCH 53/66] solve docstrings issues --- phys2bids/physio_obj.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index ee92232f0..15bc05e9a 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -552,6 +552,7 @@ def print_info(self, filename): LGR.info(info) + def auto_trigger_selection(self): """ Find a trigger index matching the channels with a regular expresion. @@ -559,12 +560,15 @@ def auto_trigger_selection(self): Parameters ---------- self - Raises + + Raises ------ Exception More than one possible trigger channel was automatically found. + Exception No trigger channel automatically found + Notes ----- Outcome: From 7fe9e784233af1f65f99a8de2d4090da90503e9a Mon Sep 17 00:00:00 2001 From: vinferrer Date: Sun, 31 Jan 2021 10:32:02 +0100 Subject: [PATCH 54/66] solve linting problems --- phys2bids/physio_obj.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 15bc05e9a..354b5d919 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -552,7 +552,6 @@ def print_info(self, filename): LGR.info(info) - def auto_trigger_selection(self): """ Find a trigger index matching the channels with a regular expresion. @@ -565,7 +564,7 @@ def auto_trigger_selection(self): ------ Exception More than one possible trigger channel was automatically found. - + Exception No trigger channel automatically found From d305f4de045c5cc04311807a406ac4c612aaef6c Mon Sep 17 00:00:00 2001 From: Stefano Moia Date: Tue, 16 Feb 2021 12:11:46 +0100 Subject: [PATCH 55/66] Propose less elegant but more specific comparison --- phys2bids/physio_obj.py | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 354b5d919..5c7719256 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -556,6 +556,9 @@ def auto_trigger_selection(self): """ Find a trigger index matching the channels with a regular expresion. + It compares the channel name with the the regular expressions stored + in TRIGGER_NAMES. + Parameters ---------- self @@ -575,17 +578,23 @@ def auto_trigger_selection(self): Automatically retrieved trigger index """ LGR.info('Running automatic trigger detection.') - no_numbers = [re.sub(r'\d+', '', x) for x in self.ch_name] - results = [re.search('|'.join(re.split(r'(\W)', case)), - '§'.join(TRIGGER_NAMES), re.IGNORECASE) for case in no_numbers] - indexes = [i for i, v in enumerate(results) if v] - if len(indexes) == 1: - self.trigger_idx = indexes[0] - LGR.info(f'{self.ch_name[self.trigger_idx]} selected as trigger channel') - if len(indexes) > 1: - raise Exception('More than one possible trigger channel was automatically found. ' - 'Please run phys2bids specifying the -chtrig argument.') - if len(indexes) < 1: + joint_match = '§'.join(TRIGGER_NAMES) + indexes = [] + for n, case in enumerate(self.ch_name): + name = re.split('(\W+|\d|_|\s)', case) + name = list(filter(None, name)) + + if re.search('|'.join(name), joint_match, re.IGNORECASE): + indexes = indexes + [n] + + if indexes: + if len(indexes) > 1: + raise Exception('More than one possible trigger channel was automatically found. ' + 'Please run phys2bids specifying the -chtrig argument.') + else: + self.trigger_idx = int(indexes) + LGR.info(f'{self.ch_name[self.trigger_idx]} selected as trigger channel') + else: raise Exception('No trigger channel automatically found. Please run phys2bids ' 'specifying the -chtrig argument.') From 99b6b3f36c5e34921500cc05adab8e855e7af070 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Tue, 16 Feb 2021 12:19:49 +0100 Subject: [PATCH 56/66] Update phys2bids/physio_obj.py Co-authored-by: Stefano Moia --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 354b5d919..b96fde952 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -246,7 +246,7 @@ def __init__(self, timeseries, freq, ch_name, units, trigger_idx, self.auto_trigger_selection() else: if ch_name[trigger_idx] not in TRIGGER_NAMES: - LGR.warning('Trigger channel name is not in our trigger channel name alias list. ' + LGR.info('Trigger channel name is not in our trigger channel name alias list. ' 'Please make sure you choose the proper channel.') @property From a001a008de5aedf1e414f5106b33ee7f89171952 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Tue, 16 Feb 2021 12:19:57 +0100 Subject: [PATCH 57/66] Update phys2bids/physio_obj.py Co-authored-by: Stefano Moia --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index b96fde952..bdbd55e18 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -582,7 +582,7 @@ def auto_trigger_selection(self): if len(indexes) == 1: self.trigger_idx = indexes[0] LGR.info(f'{self.ch_name[self.trigger_idx]} selected as trigger channel') - if len(indexes) > 1: + elif len(indexes) > 1: raise Exception('More than one possible trigger channel was automatically found. ' 'Please run phys2bids specifying the -chtrig argument.') if len(indexes) < 1: From 408c63db78fd633bc4fbeb789e947639023c5812 Mon Sep 17 00:00:00 2001 From: Vicente Ferrer Date: Tue, 16 Feb 2021 12:20:06 +0100 Subject: [PATCH 58/66] Update phys2bids/physio_obj.py Co-authored-by: Stefano Moia --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index bdbd55e18..f7adb5a77 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -585,7 +585,7 @@ def auto_trigger_selection(self): elif len(indexes) > 1: raise Exception('More than one possible trigger channel was automatically found. ' 'Please run phys2bids specifying the -chtrig argument.') - if len(indexes) < 1: + else: raise Exception('No trigger channel automatically found. Please run phys2bids ' 'specifying the -chtrig argument.') From 7479635aeb26486eb75cb49d2fa89a7f95af341e Mon Sep 17 00:00:00 2001 From: vinferrer Date: Tue, 16 Feb 2021 12:29:12 +0100 Subject: [PATCH 59/66] correct linting problem --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index f7adb5a77..ed9ceea6b 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -247,7 +247,7 @@ def __init__(self, timeseries, freq, ch_name, units, trigger_idx, else: if ch_name[trigger_idx] not in TRIGGER_NAMES: LGR.info('Trigger channel name is not in our trigger channel name alias list. ' - 'Please make sure you choose the proper channel.') + 'Please make sure you choose the proper channel.') @property def ch_amount(self): From d8169be6ffdef3d68970c5c097f276b1c7fa9222 Mon Sep 17 00:00:00 2001 From: Stefano Moia Date: Tue, 16 Feb 2021 12:29:22 +0100 Subject: [PATCH 60/66] Wrong way to get an int from a string! --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 5c7719256..ca0841646 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -592,7 +592,7 @@ def auto_trigger_selection(self): raise Exception('More than one possible trigger channel was automatically found. ' 'Please run phys2bids specifying the -chtrig argument.') else: - self.trigger_idx = int(indexes) + self.trigger_idx = indexes[0] LGR.info(f'{self.ch_name[self.trigger_idx]} selected as trigger channel') else: raise Exception('No trigger channel automatically found. Please run phys2bids ' From 82f21758150d6f76f148d38f52c515b09b64e082 Mon Sep 17 00:00:00 2001 From: Stefano Moia Date: Tue, 16 Feb 2021 12:29:29 +0100 Subject: [PATCH 61/66] Change warning to info --- phys2bids/physio_obj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index ca0841646..2aa5f7b81 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -246,7 +246,7 @@ def __init__(self, timeseries, freq, ch_name, units, trigger_idx, self.auto_trigger_selection() else: if ch_name[trigger_idx] not in TRIGGER_NAMES: - LGR.warning('Trigger channel name is not in our trigger channel name alias list. ' + LGR.info('Trigger channel name is not in our trigger channel name alias list. ' 'Please make sure you choose the proper channel.') @property From ce4e813dde0fb15944ec09b5a7e8275abc25954f Mon Sep 17 00:00:00 2001 From: Stefano Moia Date: Tue, 16 Feb 2021 12:37:23 +0100 Subject: [PATCH 62/66] Make linter happy --- phys2bids/physio_obj.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 2aa5f7b81..5a5ca8ed6 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -247,7 +247,7 @@ def __init__(self, timeseries, freq, ch_name, units, trigger_idx, else: if ch_name[trigger_idx] not in TRIGGER_NAMES: LGR.info('Trigger channel name is not in our trigger channel name alias list. ' - 'Please make sure you choose the proper channel.') + 'Please make sure you choose the proper channel.') @property def ch_amount(self): @@ -581,7 +581,7 @@ def auto_trigger_selection(self): joint_match = '§'.join(TRIGGER_NAMES) indexes = [] for n, case in enumerate(self.ch_name): - name = re.split('(\W+|\d|_|\s)', case) + name = re.split(r'(\W+|\d|_|\s)', case) name = list(filter(None, name)) if re.search('|'.join(name), joint_match, re.IGNORECASE): From 504dca485a53c2d0b4f3e112276dba0664cb1a9f Mon Sep 17 00:00:00 2001 From: vinferrer Date: Tue, 16 Feb 2021 13:09:26 +0100 Subject: [PATCH 63/66] increasing logger level to info --- phys2bids/phys2bids.py | 2 +- phys2bids/physio_obj.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phys2bids/phys2bids.py b/phys2bids/phys2bids.py index 0d11c1c6b..2dc6cbc94 100644 --- a/phys2bids/phys2bids.py +++ b/phys2bids/phys2bids.py @@ -44,7 +44,7 @@ from .due import due, Doi LGR = logging.getLogger(__name__) - +LGR.setLevel(logging.INFO) def print_summary(filename, ntp_expected, ntp_found, samp_freq, time_offset, outfile): """ diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index ed9ceea6b..3abc3cd52 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -13,7 +13,7 @@ TRIGGER_NAMES = ["trig", "trigger"] LGR = logging.getLogger(__name__) - +LGR.setLevel(logging.INFO) def is_valid(var, var_type, list_type=None): """ From 1511054fbd5c14afa041f5ea1f9b87c958495e61 Mon Sep 17 00:00:00 2001 From: vinferrer Date: Tue, 16 Feb 2021 13:14:41 +0100 Subject: [PATCH 64/66] add linting extra line --- phys2bids/phys2bids.py | 1 + phys2bids/physio_obj.py | 1 + 2 files changed, 2 insertions(+) diff --git a/phys2bids/phys2bids.py b/phys2bids/phys2bids.py index 2dc6cbc94..b31b6f70b 100644 --- a/phys2bids/phys2bids.py +++ b/phys2bids/phys2bids.py @@ -46,6 +46,7 @@ LGR = logging.getLogger(__name__) LGR.setLevel(logging.INFO) + def print_summary(filename, ntp_expected, ntp_found, samp_freq, time_offset, outfile): """ Print a summary onscreen and in file with informations on the files. diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index 3abc3cd52..c3ef78580 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -15,6 +15,7 @@ LGR = logging.getLogger(__name__) LGR.setLevel(logging.INFO) + def is_valid(var, var_type, list_type=None): """ Check that the var is of a certain type. From 52fa097c8e6a50923e7968bb804dc70c9366db9a Mon Sep 17 00:00:00 2001 From: Stefano Moia Date: Tue, 16 Feb 2021 15:22:26 +0100 Subject: [PATCH 65/66] Add a few trigger names to tests --- phys2bids/tests/test_physio_obj.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phys2bids/tests/test_physio_obj.py b/phys2bids/tests/test_physio_obj.py index 39adec222..a068a7d20 100644 --- a/phys2bids/tests/test_physio_obj.py +++ b/phys2bids/tests/test_physio_obj.py @@ -269,7 +269,7 @@ def test_auto_trigger_selection(caplog): test_twice = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) test_timeseries = [test_time, test_trigger, test_half, test_twice] test_freq = [1, 1, 0.5, 2] - test_chn_name = ['time', 'trigger', 'half', 'CO2'] + test_chn_name = ['time', 'trigger', 'half', 'CO2', 'CO 2', 'strigose'] test_units = ['s', 'V', 'V', 'V'] # test when trigger is not the name of the channel @@ -284,13 +284,13 @@ def test_auto_trigger_selection(caplog): test_units, test_chtrig) assert phys_in.trigger_idx == 1 # test when no trigger is found - test_chn_name = ['time', 'dummy', 'half', 'CO2'] + test_chn_name = ['time', 'dummy', 'half', 'CO2', 'CO 2', 'strigose', 'TRIGGAH'] with raises(Exception) as errorinfo: phys_in = po.BlueprintInput(test_timeseries, test_freq, test_chn_name, test_units, test_chtrig) assert 'No trigger channel automatically found' in str(errorinfo.value) # test when no trigger is found - test_chn_name = ['time', 'trigger', 'TRIGGER', 'CO2'] + test_chn_name = ['time', 'trigger', 'TRIGGER', 'CO2', 'CO 2', 'strigose'] with raises(Exception) as errorinfo: phys_in = po.BlueprintInput(test_timeseries, test_freq, test_chn_name, test_units, test_chtrig) From 7e79130b04fd06f3135258238f1a301e4b318add Mon Sep 17 00:00:00 2001 From: Stefano Moia Date: Tue, 16 Feb 2021 15:29:56 +0100 Subject: [PATCH 66/66] Match numbers --- phys2bids/tests/test_physio_obj.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phys2bids/tests/test_physio_obj.py b/phys2bids/tests/test_physio_obj.py index a068a7d20..fb6d61f53 100644 --- a/phys2bids/tests/test_physio_obj.py +++ b/phys2bids/tests/test_physio_obj.py @@ -267,10 +267,10 @@ def test_auto_trigger_selection(caplog): test_trigger = np.array([0, 1, 2, 3, 4]) test_half = np.array([0, 1, 2]) test_twice = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) - test_timeseries = [test_time, test_trigger, test_half, test_twice] - test_freq = [1, 1, 0.5, 2] + test_timeseries = [test_time, test_trigger, test_half, test_twice, test_twice, test_twice] + test_freq = [1, 1, 0.5, 2, 2, 2] test_chn_name = ['time', 'trigger', 'half', 'CO2', 'CO 2', 'strigose'] - test_units = ['s', 'V', 'V', 'V'] + test_units = ['s', 'V', 'V', 'V', 'V', 'V'] # test when trigger is not the name of the channel test_chtrig = 2 @@ -284,7 +284,7 @@ def test_auto_trigger_selection(caplog): test_units, test_chtrig) assert phys_in.trigger_idx == 1 # test when no trigger is found - test_chn_name = ['time', 'dummy', 'half', 'CO2', 'CO 2', 'strigose', 'TRIGGAH'] + test_chn_name = ['time', 'TRIGGAH', 'half', 'CO2', 'CO 2', 'strigose'] with raises(Exception) as errorinfo: phys_in = po.BlueprintInput(test_timeseries, test_freq, test_chn_name, test_units, test_chtrig)