Skip to content

Commit a54e85c

Browse files
author
Stefano Moia
committed
Merge branch 'master' into read-spike
2 parents 65289d2 + 7369827 commit a54e85c

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

.cirrus.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ Unittest_task:
3939
populate_script:
4040
- source activate $PWD/conda-env
4141
Running_unit_tests_script:
42-
- apt-get install -y make curl
42+
- apt-get update
43+
- apt-get install -y build-essential curl
4344
- source activate $PWD/conda-env
4445
- make unittest
4546
- bash <(curl -s https://codecov.io/bash)
@@ -62,7 +63,8 @@ Integration_task:
6263
populate_script:
6364
- source activate $PWD/conda-env
6465
Running_integration_tests_script:
65-
- apt-get install -y make curl tree tar
66+
- apt-get update
67+
- apt-get install -y build-essential curl tree tar
6668
- source activate $PWD/conda-env
6769
- PATH=/home/test_user/.local/bin:$PATH
6870
- make integration
@@ -84,7 +86,8 @@ Style_check_task:
8486
populate_script:
8587
- source activate $PWD/conda-env
8688
Lintin_script:
87-
- apt-get install -y make
89+
- apt-get update
90+
- apt-get install -y build-essential
8891
- source activate $PWD/conda-env
8992
- make lint
9093

@@ -101,7 +104,8 @@ Build_docs_task:
101104
populate_script:
102105
- source activate $PWD/conda-env
103106
Build_documentation_script:
104-
- apt-get install -y make tar
107+
- apt-get update
108+
- apt-get install -y build-essential tar
105109
- source activate $PWD/conda-env
106110
- make -C docs html
107111
docs_artifacts:
@@ -121,6 +125,7 @@ Bids_validate_task:
121125
populate_script:
122126
- source activate $PWD/conda-env
123127
Generate_enviroment_script:
128+
- apt-get update
124129
- apt-get install -yqq wget curl tree
125130
- curl -sL https://deb.nodesource.com/setup_15.x | bash -
126131
- apt-get install -yqq nodejs

docs/howto.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ Now the output says:
208208
Tip: Time 0 is the time of first trigger
209209
------------------------------------------------
210210
211-
``phys2bids`` has an automatic way of finding the right threshold, in order to find the correct number of timepoints, by using the mean and standard deviation of the trigger channel. If "Found just the right amount of timepoints!" appears everything should be working properly!
211+
``phys2bids`` has an automatic way of finding the right threshold, in order to find the correct number of timepoints, by using the mean of the trigger channel. If "Found just the right amount of timepoints!" appears everything should be working properly!
212212

213213
Alright, so now we have some outputs that make sense! We have 158 timepoints expected (as inputted with ``-ntp``) and found. The output also tells us that the fMRI sampling started around 0.25 seconds later than the start of this physiological sampling.
214214

@@ -231,7 +231,7 @@ If for some reason ``-ntp`` and the number of timepoints found by ``phys2bids``
231231
3. The file doesn't have all the trigger pulses you expect because the recording started later than the MRI recording (e.g. by mistake).
232232

233233
.. note::
234-
``phys2bids`` was created to deal with little sampling errors - such as distracted researchers that started sampling a bit too late than expected. For this reason, if it finds less trigger pulses than the amount specified, it will assume that the missing ones are at the beginning and anticipate the starting time consequently.
234+
``phys2bids`` was created to deal with little sampling errors - such as distracted researchers that started sampling a bit too late than expected. For this reason, if it finds fewer trigger pulses than the amount specified, it will assume that the missing ones are at the beginning and anticipate the starting time consequently.
235235

236236

237237
Let's go through an example where the number of timepoints automatically found is not correct. For that, will we use tutorial_file_v2.txt (in the same location as tutorial_file.txt):

phys2bids/physio_obj.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ def check_trigger_amount(self, thr=None, num_timepoints_expected=0, tr=0):
455455
Outcome:
456456
self.thr: float
457457
Threshold used by the function to detect trigger points.
458+
If no threshold is provided, value is the mean of the trigger channel.
458459
self.num_timepoints_found: int
459460
Property of the `BlueprintInput` class.
460461
Contains the number of timepoints found
@@ -477,10 +478,14 @@ def check_trigger_amount(self, thr=None, num_timepoints_expected=0, tr=0):
477478
'of time to find the starting time.')
478479
time = np.linspace(time[0], time[-1], len(trigger))
479480

480-
# Check if thr was given, if not "guess" it.
481481
flag = 0
482482
if thr is None:
483-
thr = np.mean(trigger) + 2 * np.std(trigger)
483+
# If trigger channels are binary
484+
# (i.e., "on" is a higher value and "off" is a lower value)
485+
# and each "on" and "off" are each always approzimately the same value
486+
# then any value above the mean is "on" and every value below the mean
487+
# is "off".
488+
thr = np.mean(trigger)
484489
flag = 1
485490
timepoints = trigger > thr
486491
num_timepoints_found = len([is_true for is_true, _ in groupby(timepoints,

0 commit comments

Comments
 (0)