From 07ddced18f4f629035decbcc4a8cdd72671e5855 Mon Sep 17 00:00:00 2001 From: Stefano Moia Date: Tue, 7 Jul 2020 19:59:15 +0200 Subject: [PATCH 1/7] Correct chtrig extraction, add explanation in the docstring --- phys2bids/interfaces/acq.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/phys2bids/interfaces/acq.py b/phys2bids/interfaces/acq.py index fd6139892..6938cff8a 100644 --- a/phys2bids/interfaces/acq.py +++ b/phys2bids/interfaces/acq.py @@ -21,23 +21,29 @@ def populate_phys_input(filename, chtrig): filename: str path to the txt labchart file chtrig : int - index of trigger channel + index of trigger channel. + !!! ATTENTION: IT'S MEANT TO REPRESENT AN INDEX STARTING FROM 1 !!! Returns ------- BlueprintInput + Note + ---- + chtrig is not a python index - instead, it's human readable. + This is handy because when initialising the class, it gets initiliased + with a channel more at the beginning - that is already taken into account! + See Also -------- physio_obj.BlueprintInput """ - with warnings.catch_warnings(): warnings.filterwarnings('ignore', category=DeprecationWarning) data = read_file(filename).channels - freq = [data[chtrig].samples_per_second, ] - timeseries = [data[chtrig].time_index, ] + freq = [data[chtrig - 1].samples_per_second, ] + timeseries = [data[chtrig - 1].time_index, ] units = ['s', ] names = ['time', ] From 37673dca6ca3b26f74b31ffe847789d818afcebd Mon Sep 17 00:00:00 2001 From: Stefano Moia Date: Tue, 7 Jul 2020 22:05:41 +0200 Subject: [PATCH 2/7] Update phys2bids/interfaces/acq.py Co-authored-by: Taylor Salo --- phys2bids/interfaces/acq.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phys2bids/interfaces/acq.py b/phys2bids/interfaces/acq.py index 6938cff8a..1e840c1c0 100644 --- a/phys2bids/interfaces/acq.py +++ b/phys2bids/interfaces/acq.py @@ -30,9 +30,9 @@ def populate_phys_input(filename, chtrig): Note ---- - chtrig is not a python index - instead, it's human readable. - This is handy because when initialising the class, it gets initiliased - with a channel more at the beginning - that is already taken into account! + chtrig is not a 0-based Python index - instead, it's human readable (i.e., 1-based). + This is handy because, when initialising the class, a new channel corresponding + to time is added at the beginning - that is already taken into account! See Also -------- From 542a2716374920e1c8d08e155116c17eebe2cd20 Mon Sep 17 00:00:00 2001 From: Stefano Moia Date: Tue, 7 Jul 2020 22:05:52 +0200 Subject: [PATCH 3/7] Update phys2bids/interfaces/acq.py Co-authored-by: Taylor Salo --- phys2bids/interfaces/acq.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/interfaces/acq.py b/phys2bids/interfaces/acq.py index 1e840c1c0..5e57274f1 100644 --- a/phys2bids/interfaces/acq.py +++ b/phys2bids/interfaces/acq.py @@ -21,7 +21,7 @@ def populate_phys_input(filename, chtrig): filename: str path to the txt labchart file chtrig : int - index of trigger channel. + index of trigger channel. Must be a positive, non-zero integer. !!! ATTENTION: IT'S MEANT TO REPRESENT AN INDEX STARTING FROM 1 !!! Returns From be2a48586000ba023cb4f7bd5b6aaf1f822e2986 Mon Sep 17 00:00:00 2001 From: Stefano Moia Date: Tue, 7 Jul 2020 22:06:43 +0200 Subject: [PATCH 4/7] Revert docstring --- phys2bids/interfaces/acq.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/interfaces/acq.py b/phys2bids/interfaces/acq.py index 5e57274f1..1e840c1c0 100644 --- a/phys2bids/interfaces/acq.py +++ b/phys2bids/interfaces/acq.py @@ -21,7 +21,7 @@ def populate_phys_input(filename, chtrig): filename: str path to the txt labchart file chtrig : int - index of trigger channel. Must be a positive, non-zero integer. + index of trigger channel. !!! ATTENTION: IT'S MEANT TO REPRESENT AN INDEX STARTING FROM 1 !!! Returns From 2af654b5d950fc4b8c02deb0b153335161dc5584 Mon Sep 17 00:00:00 2001 From: Stefano Moia Date: Tue, 7 Jul 2020 22:30:52 +0200 Subject: [PATCH 5/7] Set default chtrig as 1 --- phys2bids/cli/run.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phys2bids/cli/run.py b/phys2bids/cli/run.py index 497eb4869..054bc4bfd 100644 --- a/phys2bids/cli/run.py +++ b/phys2bids/cli/run.py @@ -76,9 +76,9 @@ def _get_parser(): dest='chtrig', type=int, help='The column number of the trigger channel. ' - 'Channel numbering starts with 0. ' - 'Default is 0.', - default=0) + 'Channel numbering starts with 1. ' + 'Default is 1.', + default=1) optional.add_argument('-chsel', '--channel-selection', dest='chsel', nargs='*', From d227c37801ee22a3f9894f462a650ea935b89c1c Mon Sep 17 00:00:00 2001 From: Stefano Moia Date: Tue, 7 Jul 2020 22:35:51 +0200 Subject: [PATCH 6/7] Change default chtrig to 1, add check. --- phys2bids/phys2bids.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/phys2bids/phys2bids.py b/phys2bids/phys2bids.py index 1a4e316f0..76e26489f 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=0, chsel=None, num_timepoints_expected=None, + sub=None, ses=None, chtrig=1, 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,6 +191,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 < 1: + raise Exception('Wrong trigger cahnnel. Channel indexing starts with 1!') + filename, ftype = utils.check_input_type(filename, indir) From 528912b4e75a5187357013577598ed79922feecb Mon Sep 17 00:00:00 2001 From: Stefano Moia Date: Thu, 9 Jul 2020 16:08:30 +0200 Subject: [PATCH 7/7] Update phys2bids/phys2bids.py Co-authored-by: Taylor Salo --- phys2bids/phys2bids.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phys2bids/phys2bids.py b/phys2bids/phys2bids.py index 76e26489f..7f5bbe387 100644 --- a/phys2bids/phys2bids.py +++ b/phys2bids/phys2bids.py @@ -192,7 +192,7 @@ 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 < 1: - raise Exception('Wrong trigger cahnnel. Channel indexing starts with 1!') + raise Exception('Wrong trigger channel. Channel indexing starts with 1!') filename, ftype = utils.check_input_type(filename, indir)