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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7a1851d
start modifying the howto.rst file
vinferrer Mar 27, 2020
7e783d4
tutorial update
Mar 27, 2020
edbcdbc
Merge pull request #3 from RayStick/raystick/doc_trig_files
vinferrer Mar 28, 2020
835880b
new image
vinferrer Mar 28, 2020
36fcb30
modify tutorial to add not automatic case
vinferrer Mar 28, 2020
5da33a5
delete commas
vinferrer Mar 28, 2020
92bc844
add spaces
vinferrer Mar 28, 2020
2608c47
Merge branch 'master' of https://github.com/physiopy/phys2bids into d…
vinferrer Mar 30, 2020
d23c2ce
Edits to howto file, and clearer name for png
Mar 31, 2020
962c130
tweaks
Mar 31, 2020
be9893b
Merge pull request #4 from RayStick/raystick/doc_trig
vinferrer Apr 1, 2020
389b11f
delete old png output
Apr 1, 2020
0418426
Add new png output
Apr 1, 2020
981177e
Updated howto doc with middle trigger missing
Apr 1, 2020
dd4f588
Merge pull request #5 from RayStick/raystick/doc_trig_v2
vinferrer Apr 2, 2020
a989080
change message if thr is inputed
vinferrer Apr 2, 2020
d12c87c
change message if thr is inputed again
vinferrer Apr 2, 2020
147f61c
change message in docs
vinferrer Apr 2, 2020
e0c6e4e
ntp and thr needed
vinferrer Apr 2, 2020
e2699e3
Update docs/howto.rst
vinferrer Apr 2, 2020
f70f4e3
same thing
vinferrer Apr 2, 2020
11095e0
Merge branch 'doc_trig' of github.com:vinferrer/phys2bids into doc_trig
vinferrer Apr 2, 2020
83b1903
Update docs/howto.rst
vinferrer Apr 2, 2020
d74ce84
Update "skip trigger count" message in both script and documentation
Apr 2, 2020
2d9a767
Merge pull request #6 from smoia/doc_trig
vinferrer Apr 2, 2020
f3e06ef
Merge branch 'master' of https://github.com/physiopy/phys2bids into d…
vinferrer Apr 3, 2020
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/heuristic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Once you modified your heuristic file or created a new one, you can save it anyw

.. code-block:: shell

phys2bids -in tutorial_file.txt -chtrig 1 -outdir /home/arthurdent/physio_bids -ntp 158 -tr 1.2 -thr 0.735 -heur /home/arthurdent/git/phys2bids/phys2bids/heuristics/heur_tutorial.py -sub 006 -ses 01
phys2bids -in tutorial_file.txt -indir /home/arthurdent/git/phys2bids/phys2bids/tests/data/ -chtrig 1 -ntp 158 -tr 1.2 -outdir /home/arthurdent/physio -heur /home/arthurdent/git/phys2bids/phys2bids/heuristics/heur_tutorial.py -sub 006 -ses 01

Remember to **specify the full path** to the heuristic file. A copy of the heuristic file will be saved in the site folder.

Expand Down
213 changes: 116 additions & 97 deletions docs/howto.rst

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions phys2bids/phys2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ def phys2bids(filename, info=False, indir='.', outdir='.', heur_file=None,
viz.plot_trigger(phys_in.timeseries[0], phys_in.timeseries[chtrig],
plot_path, tr, phys_in.thr, num_timepoints_expected, filename)
else:
LGR.info('Not plotting trigger. If you want the trigger to be'
' plotted enter -tr or -ntp, preferably both.')
LGR.warning('Skipping trigger pulse count. If you want to run it, '
'call phys2bids using "-ntp" and "-tr" arguments')

# The next few lines remove the undesired channels from phys_in.
if chsel:
Expand Down
10 changes: 8 additions & 2 deletions phys2bids/physio_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,19 @@ def check_trigger_amount(self, chtrig=1, thr=None, num_timepoints_expected=0, tr
# Use the trigger channel to find the TRs,
# comparing it to a given threshold.
trigger = self.timeseries[chtrig]
flag = 0
if thr is None:
thr = np.mean(trigger) + 2 * np.std(trigger)
flag = 1
timepoints = trigger > thr
num_timepoints_found = len([is_true for is_true, _ in groupby(timepoints,
lambda x: x != 0) if is_true])
LGR.info(f'The number of timepoints according to the std_thr method '
f'is {num_timepoints_found}. The computed threshold is {thr}')
if flag == 1:
LGR.info(f'The number of timepoints according to the std_thr method '
f'is {num_timepoints_found}. The computed threshold is {thr}')
else:
LGR.info(f'The number of timepoints found with the manual threshold of {thr} '
f'is {num_timepoints_found}')
time_offset = self.timeseries[0][timepoints.argmax()]

if num_timepoints_expected:
Expand Down
Loading