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

Add additional automatic detection of the trigger based on time-domain analysis #391

Merged
merged 11 commits into from
May 12, 2021

Conversation

drombas
Copy link
Contributor

@drombas drombas commented Mar 10, 2021

Related to #204 and #386.

This implements a time-domain detection of the trigger when the text-matching detection fails.

Proposed Changes

  • Added a time-domain detection of the trigger
    The implementation computes a metric measuring how much each channel differs from a binary signal. The metric is computed as the average distance from each point to the closest limit of the signal (min or max).
    More "binary-like" signals like the trigger should have most of the points closer to either signal limit resulting on a smaller metric. Assuming this, the trigger is detected as the channel that minimizes the metric.

Changes regarding the chtrig=0 are part of #390 (hope it is not confusing).

Change Type

  • bugfix (+0.0.1)
  • minor (+0.1.0)
  • major (+1.0.0)
  • refactoring (no version update)
  • test (no version update)
  • infrastructure (no version update)
  • documentation (no version update)
  • other

Checklist before review

  • I added everything I wanted to add to this PR.
  • [Code or tests only] I wrote/updated the necessary docstrings.
  • [Code or tests only] I ran and passed tests locally.
  • [Documentation only] I built the docs locally.
  • My contribution is harmonious with the rest of the code: I'm not introducing repetitions.
  • My code respects the adopted style, especially linting conventions.
  • The title of this PR is explanatory on its own, enough to be understood as part of a changelog.
  • I added or indicated the right labels.
  • I added information regarding the timeline of completion for this PR.
  • Please, comment on my PR while it's a draft and give me feedback on the development!

@drombas drombas changed the title Implement basic automatic channel detection ENH: Implement time-domain detection of the trigger Apr 7, 2021
@codecov
Copy link

codecov bot commented Apr 7, 2021

Codecov Report

Merging #391 (e860c5d) into master (3b4ec90) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #391      +/-   ##
==========================================
+ Coverage   94.77%   94.81%   +0.03%     
==========================================
  Files           8        8              
  Lines         862      868       +6     
==========================================
+ Hits          817      823       +6     
  Misses         45       45              
Impacted Files Coverage Δ
phys2bids/phys2bids.py 88.13% <100.00%> (ø)
phys2bids/physio_obj.py 93.92% <100.00%> (+0.17%) ⬆️

@drombas drombas marked this pull request as ready for review April 7, 2021 09:43
@smoia smoia added the Minormod This PR generally closes an `Enhancement` issue. It increments the minor version (0.+1.0) label Apr 11, 2021
@eurunuela eurunuela self-requested a review April 15, 2021 15:17
Copy link
Collaborator

@eurunuela eurunuela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @drombas ! This is great and definitely makes phys2bids more robust.

I would like to have a couple of tiny changes made before approving this PR though.

phys2bids/physio_obj.py Outdated Show resolved Hide resolved
@drombas drombas requested a review from eurunuela April 16, 2021 17:36
Copy link
Collaborator

@eurunuela eurunuela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks great. Thanks @drombas !

phys2bids/physio_obj.py Outdated Show resolved Hide resolved
Copy link

@rzlim08 rzlim08 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great!

Copy link
Collaborator

@eurunuela eurunuela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Hopefully the failing test will pass when merged into master.

@smoia
Copy link
Member

smoia commented May 12, 2021

LGTM! Hopefully the failing test will pass when merged into master.

But please check them out before merging!

@eurunuela
Copy link
Collaborator

But please check them out before merging!

I will! I'm reading the guidelines too because I have completely forgotten about how we name PRs lol.

@smoia smoia changed the title ENH: Implement time-domain detection of the trigger Implement time-domain detection of the trigger May 12, 2021
@smoia smoia changed the title Implement time-domain detection of the trigger Add additional automatic detection of the trigger based on time-domain analysis May 12, 2021
@smoia
Copy link
Member

smoia commented May 12, 2021

But please check them out before merging!

I will! I'm reading the guidelines too because I have completely forgotten about how we name PRs lol.

Is it ok?

@eurunuela
Copy link
Collaborator

Is it ok?

Yeah, that looks good. Thanks!

@smoia
Copy link
Member

smoia commented May 12, 2021

Ok, apparently the readthedocs fail is not related to the PR (other PR have the same issue and none of them is touching documentation). We'll need to have a look at readthedocs and understand what changed.

@eurunuela
Copy link
Collaborator

Ok, apparently the readthedocs fail is not related to the PR (other PR have the same issue and none of them is touching documentation). We'll need to have a look at readthedocs and understand what changed.

Thanks for looking into it. I'm really busy today. I'll merge then.

@eurunuela eurunuela merged commit 586d7ae into physiopy:master May 12, 2021
@smoia
Copy link
Member

smoia commented May 12, 2021

🚀 PR was released in 2.5.0 🚀

@smoia smoia added the released This issue/pull request has been released. label May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Minormod This PR generally closes an `Enhancement` issue. It increments the minor version (0.+1.0) released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants