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

Correct trigger channel indexing while reading AcqKnowledge files. #275

Merged
merged 7 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions phys2bids/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='*',
Expand Down
14 changes: 10 additions & 4 deletions phys2bids/interfaces/acq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
--------
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', ]

Expand Down
5 changes: 4 additions & 1 deletion phys2bids/phys2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 channel. Channel indexing starts with 1!')

filename, ftype = utils.check_input_type(filename,
indir)

Expand Down