Skip to content

Commit 06ba771

Browse files
authored
Merge pull request #440 from smoia/fix/trigger_idx_auto
Fix channel trigger variable type when the trigger is automatically detected
2 parents 18897d9 + 1032c09 commit 06ba771

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

phys2bids/physio_obj.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ def auto_trigger_selection(self):
590590
Automatically retrieved trigger index
591591
"""
592592
LGR.info('Running automatic trigger detection.')
593+
LGR.info('Matching channel names with known trigger names first.')
593594
joint_match = '§'.join(TRIGGER_NAMES)
594595
indexes = []
595596
for n, case in enumerate(self.ch_name):
@@ -604,10 +605,10 @@ def auto_trigger_selection(self):
604605
raise Exception('More than one possible trigger channel was automatically found. '
605606
'Please run phys2bids specifying the -chtrig argument.')
606607
else:
607-
self.trigger_idx = indexes[0]
608+
self.trigger_idx = int(indexes[0])
608609
else:
609610
# Time-domain automatic trigger detection
610-
611+
LGR.info('Find the trigger channel by measuring data distance from its value limits.')
611612
# Create numpy array with all channels (excluding time)
612613
channel_ts = np.array(self.timeseries[1:])
613614

@@ -621,7 +622,7 @@ def auto_trigger_selection(self):
621622
distance_mean = np.mean(distance, axis=1)
622623

623624
# Set the trigger as the channel with the smallest distance
624-
self.trigger_idx = np.nanargmin(distance_mean) + 1
625+
self.trigger_idx = int(np.nanargmin(distance_mean) + 1)
625626

626627
LGR.info(f'{self.ch_name[self.trigger_idx]} selected as trigger channel')
627628

0 commit comments

Comments
 (0)