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

Update trigger detection tutorial #191

Merged
merged 26 commits into from
Apr 3, 2020
Merged

Conversation

vinferrer
Copy link
Collaborator

Closes #190

Proposed Changes

  • Update howto.rst file so the trigger detection tutorial is updated
  • explain new automatic detection
  • Explain manual override
  • modify tutorial_file trigger so one of the triggers is not detected by the threshold

@vinferrer vinferrer added the Documentation This issue or PR is about the documentation label Mar 27, 2020
@vinferrer vinferrer requested review from smoia and RayStick March 27, 2020 11:49
@smoia
Copy link
Member

smoia commented Mar 27, 2020

@RayStick can you have a look at this PR and help @vinferrer with the tutorial update, please?

@codecov
Copy link

codecov bot commented Mar 27, 2020

Codecov Report

Merging #191 into master will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #191      +/-   ##
==========================================
+ Coverage   94.42%   94.46%   +0.03%     
==========================================
  Files           7        7              
  Lines         574      578       +4     
==========================================
+ Hits          542      546       +4     
  Misses         32       32              
Impacted Files Coverage Δ
phys2bids/phys2bids.py 90.44% <100.00%> (ø)
phys2bids/physio_obj.py 91.83% <100.00%> (+0.34%) ⬆️

@eurunuela
Copy link
Collaborator

Also, @vinferrer take #181 into account on your PR title! 😉

@vinferrer vinferrer changed the title start modifying the howto.rst file Update trigger detection tutorial Mar 27, 2020
@RayStick
Copy link
Member

I can review this soon.
@vinferrer I can try and adapt the tutorial file so that one of the triggers is not detected, if you like?

@vinferrer
Copy link
Collaborator Author

This is still a draft for the moment. So you don't have to review it yet. However if you wanna modifiy the tutorial_file please do so. I recommend you to run the new version with the atomatic threshold

@vinferrer
Copy link
Collaborator Author

This way you can lower down one of the triggers below that threshold.

@vinferrer
Copy link
Collaborator Author

Thanks in advance @RayStick

@RayStick
Copy link
Member

RayStick commented Mar 27, 2020

@vinferrer

I ran the latest phys2bids on the tutorial_file.txt (to check it works for me) and it works great (it automatically finds the threshold, and therefore the right number of time points). A really good improvement, thanks. I will use the threshold it finds to modify one of the triggers below that, and then see how the manual correction workflow can be implemented after that.

Let me know if there is anything else that would help you with this draft PR, before it is time to review.

@vinferrer
Copy link
Collaborator Author

The manual correction is already implemented. I want to modify the tutorial file just to make a tutorial where the user can see a case that this manual threshold is needed. Using the manual correction is pretty easy, you just have to enter a new threshold through -thr

@RayStick
Copy link
Member

Ah yes, I understand the idea. I just meant (1) I will make the new file with one trigger different and (2) check the manual correction then works (for me).

@vinferrer
Copy link
Collaborator Author

Oh sure, sorry for the missinterpretation

@vinferrer
Copy link
Collaborator Author

Please check it

@RayStick
Copy link
Member

I made a PR to your branch with two minor additions/changes:


(1) I have added a file called tutorial_file_v2.txt - the first trigger has been altered. Specifically, I changed lines 256-295 to 1.0475.
(2) Not related to changes you have made but relevant to the tutorial files - I have renamed the tutorial_file.json file because it is at risk of being overwritten when running phys2bids. This is because the default filename for the json file that phys2bids generates is filename.json.

When running
phys2bids -in ../tutorial_file_v2.txt -info

You get:

command1_tutorial_file_v2

When running
phys2bids -in ../tutorial_file_v2.txt -chtrig 1 -ntp 158 -tr 1.2

You get:
command2_tutorial_file_v2_trigger_time

When running:
phys2bids -in ../tutorial_file_v2.txt -chtrig 1 -ntp 158 -tr 1.2 -thr 1.04

You get:



command3_tutorial_file_v2_trigger_time

So all seems to be working as expected. :)

@vinferrer
Copy link
Collaborator Author

Do you get a warning in the log saying that the expected trigger amount is no the one founded?

@vinferrer
Copy link
Collaborator Author

I mean in the first case when the thr is done automaticly

@RayStick
Copy link
Member

Ah, sorry, should have included the output.

Running
phys2bids -in ../tutorial_file_v2.txt -chtrig 1 -ntp 158 -tr 1.2


Gives:

2020-03-27T17:24:42	phys2bids.phys2bids	INFO    	Currently running phys2bids version v1.3.0-beta+350.g7e783d4
2020-03-27T17:24:42	phys2bids.phys2bids	INFO    	Input file is ../tutorial_file_v2.txt
2020-03-27T17:24:42	phys2bids.utils	       INFO    	File extension is .txt
2020-03-27T17:24:42	phys2bids.utils	WARNING 	If both acq and txt files exist in the path, acq will be selected.
2020-03-27T17:24:42	phys2bids.phys2bids	INFO    	Reading the file ./../tutorial_file_v2.txt
2020-03-27T17:24:43	phys2bids.interfaces.txt	INFO    	phys2bids detected that your file is in Labchart format
2020-03-27T17:24:44	phys2bids.phys2bids	INFO    	Reading infos
2020-03-27T17:24:44	phys2bids.physio_obj	INFO    	
------------------------------------------------
File ../tutorial_file_v2.txt contains:
01. Trigger; sampled at 1000.0 Hz
02. CO2; sampled at 1000.0 Hz
03. O2; sampled at 1000.0 Hz
04. Pulse; sampled at 1000.0 Hz
------------------------------------------------

2020-03-27T17:24:44	phys2bids.physio_obj	INFO    	Counting trigger points
2020-03-27T17:24:44	phys2bids.physio_obj	INFO    	The number of timepoints according to the std_thr method is 157. The computed threshold is 1.1506977594943586
2020-03-27T17:24:44	phys2bids.physio_obj	INFO    	Checking number of timepoints
2020-03-27T17:24:44	phys2bids.physio_obj	WARNING 	Found 1 timepoints less than expected!
2020-03-27T17:24:44	phys2bids.physio_obj	WARNING 	Correcting time offset, assuming missing timepoints are at the beginning (try again with a more conservative thr)
2020-03-27T17:24:44	phys2bids.phys2bids	INFO    	Plot trigger
2020-03-27T17:24:45	phys2bids.phys2bids	INFO    	Preparing 1 output files.
2020-03-27T17:24:45	phys2bids.phys2bids	INFO    	Exporting files for freq 1000.0
2020-03-27T17:24:48	phys2bids.phys2bids	INFO    	
------------------------------------------------
Filename:            ../tutorial_file_v2.txt

Timepoints expected: 158
Timepoints found:    157
Sampling Frequency:  1000.0 Hz
Sampling started at: 0.2459999999998672 s
Tip: Time 0 is the time of first trigger
------------------------------------------------

@smoia
Copy link
Member

smoia commented Mar 27, 2020

Nice job people! Way to go!

@vinferrer
Copy link
Collaborator Author

I think we should have only one tutorial file so is more clear to the user. Therefore we can delete the previous one and leave @RayStick edited file. what do yo think?

@vinferrer vinferrer marked this pull request as ready for review March 30, 2020 10:42
@vinferrer
Copy link
Collaborator Author

Changes done

Copy link
Member

@smoia smoia left a comment

Choose a reason for hiding this comment

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

Ok, I think it flows very well, the changes make it clear, and if you can just add the two suggestion, I think we're ready to merge it in!

Good job guys!

docs/howto.rst Outdated Show resolved Hide resolved
docs/howto.rst Outdated Show resolved Hide resolved
docs/howto.rst Show resolved Hide resolved
docs/howto.rst Outdated Show resolved Hide resolved
@vinferrer
Copy link
Collaborator Author

I hope that's the last thing

@smoia
Copy link
Member

smoia commented Apr 2, 2020

@vinferrer I opened a PR to your branch with tiny things. As soon as you merge that in, we can merge this in!

@RayStick
Copy link
Member

RayStick commented Apr 2, 2020

Because it says "some checks haven't been completed yet" - do I wait until that is completed before merging?

@vinferrer
Copy link
Collaborator Author

dont merge

@vinferrer
Copy link
Collaborator Author

i need to add smoia changes

Update skip trigger count message in both script and documentation
@RayStick
Copy link
Member

RayStick commented Apr 2, 2020

Ah okay! As he had approved the PR, I thought you had already incorporated all his changes, sorry.

@smoia
Copy link
Member

smoia commented Apr 2, 2020

@vinferrer can you push an empty commit to restart the CI?

@vinferrer
Copy link
Collaborator Author

pushing

@vinferrer
Copy link
Collaborator Author

I think we can merge now

@vinferrer vinferrer merged commit c37bb87 into physiopy:master Apr 3, 2020
@vinferrer vinferrer deleted the doc_trig branch April 3, 2020 11:55
@RayStick
Copy link
Member

RayStick commented Apr 3, 2020

Great!

@smoia smoia added the released This issue/pull request has been released. label Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation This issue or PR is about the documentation released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tutorial documentation on trigger picture and ntp outdated
4 participants