diff --git a/.cirrus.yml b/.cirrus.yml index 7b64acd79..9a64032a8 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -39,7 +39,8 @@ Unittest_task: populate_script: - source activate $PWD/conda-env Running_unit_tests_script: - - apt-get install -y make curl + - apt-get update + - apt-get install -y build-essential curl - source activate $PWD/conda-env - make unittest - bash <(curl -s https://codecov.io/bash) @@ -62,7 +63,8 @@ Integration_task: populate_script: - source activate $PWD/conda-env Running_integration_tests_script: - - apt-get install -y make curl tree tar + - apt-get update + - apt-get install -y build-essential curl tree tar - source activate $PWD/conda-env - PATH=/home/test_user/.local/bin:$PATH - make integration @@ -84,7 +86,8 @@ Style_check_task: populate_script: - source activate $PWD/conda-env Lintin_script: - - apt-get install -y make + - apt-get update + - apt-get install -y build-essential - source activate $PWD/conda-env - make lint @@ -101,7 +104,8 @@ Build_docs_task: populate_script: - source activate $PWD/conda-env Build_documentation_script: - - apt-get install -y make tar + - apt-get update + - apt-get install -y build-essential tar - source activate $PWD/conda-env - make -C docs html docs_artifacts: @@ -121,6 +125,7 @@ Bids_validate_task: populate_script: - source activate $PWD/conda-env Generate_enviroment_script: + - apt-get update - apt-get install -yqq wget curl tree - curl -sL https://deb.nodesource.com/setup_15.x | bash - - apt-get install -yqq nodejs diff --git a/docs/howto.rst b/docs/howto.rst index cda369fd5..54c000eef 100644 --- a/docs/howto.rst +++ b/docs/howto.rst @@ -208,7 +208,7 @@ Now the output says: Tip: Time 0 is the time of first trigger ------------------------------------------------ -``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! +``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! 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. @@ -231,7 +231,7 @@ If for some reason ``-ntp`` and the number of timepoints found by ``phys2bids`` 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). .. note:: - ``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. + ``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. 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): diff --git a/phys2bids/physio_obj.py b/phys2bids/physio_obj.py index e6467fd06..e9e77127b 100644 --- a/phys2bids/physio_obj.py +++ b/phys2bids/physio_obj.py @@ -455,6 +455,7 @@ def check_trigger_amount(self, thr=None, num_timepoints_expected=0, tr=0): Outcome: self.thr: float Threshold used by the function to detect trigger points. + If no threshold is provided, value is the mean of the trigger channel. self.num_timepoints_found: int Property of the `BlueprintInput` class. Contains the number of timepoints found @@ -477,10 +478,14 @@ def check_trigger_amount(self, thr=None, num_timepoints_expected=0, tr=0): 'of time to find the starting time.') time = np.linspace(time[0], time[-1], len(trigger)) - # Check if thr was given, if not "guess" it. flag = 0 if thr is None: - thr = np.mean(trigger) + 2 * np.std(trigger) + # If trigger channels are binary + # (i.e., "on" is a higher value and "off" is a lower value) + # and each "on" and "off" are each always approzimately the same value + # then any value above the mean is "on" and every value below the mean + # is "off". + thr = np.mean(trigger) flag = 1 timepoints = trigger > thr num_timepoints_found = len([is_true for is_true, _ in groupby(timepoints,