-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* set up test notebooks * add tests and coverage * change path
- Loading branch information
Showing
24 changed files
with
694 additions
and
17,772 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
name: test notebook | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test_notebook: | ||
name: run notebooks | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
allow-prereleases: false | ||
- name: Install tox | ||
run: python -m pip install --upgrade tox | ||
- name: Run tests | ||
run: tox run -e test_notebook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
name: tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
tests: | ||
name: Test with ${{ matrix.py }} on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
py: ['3.12', '3.11', '3.10', '3.9', '3.8'] | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.py }} | ||
allow-prereleases: false | ||
- name: Install tox | ||
run: python -m pip install --upgrade tox | ||
- name: Run tests | ||
run: tox run -e tests | ||
- name: Upload coverage to CodeCov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
flags: ${{ matrix.os }}_${{ matrix.py }} | ||
if: success() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import neurodesign | ||
from neurodesign import generate | ||
|
||
# define experimental setup | ||
|
||
exp = neurodesign.experiment( | ||
TR=2, | ||
n_trials=20, | ||
P=[0.3, 0.3, 0.4], | ||
C=[[1, -1, 0], [0, 1, -1]], | ||
n_stimuli=3, | ||
rho=0.3, | ||
stim_duration=1, | ||
t_pre=0.5, | ||
t_post=2, | ||
ITImodel="exponential", | ||
ITImin=2, | ||
ITImax=4, | ||
ITImean=2.1, | ||
) | ||
|
||
# define first design with a fixed ITI | ||
|
||
design_1 = neurodesign.design( | ||
order=[0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1], | ||
ITI=[2] * 20, | ||
experiment=exp, | ||
) | ||
|
||
# expand to design matrix | ||
|
||
design_1.designmatrix() | ||
design_1.FCalc(weights=[0, 0.5, 0.25, 0.25]) | ||
design_1.FdCalc() | ||
design_1.FcCalc() | ||
design_1.FfCalc() | ||
design_1.FeCalc() | ||
|
||
# define second design | ||
|
||
design_2 = neurodesign.design( | ||
order=[0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 1], | ||
ITI=generate.iti(20, "exponential", min=1, mean=2, max=4, seed=1234)[0], | ||
experiment=exp, | ||
) | ||
|
||
design_2.designmatrix() | ||
design_2.FeCalc() | ||
design_2.FdCalc() | ||
design_2.FcCalc() | ||
design_2.FfCalc() | ||
|
||
# crossover to obtain design 3 and 4 | ||
|
||
design_3, design_4 = design_1.crossover(design_2, seed=2000) | ||
design_3.order | ||
design_4.order | ||
design_3.designmatrix() | ||
design_3.FeCalc() | ||
design_3.FdCalc() | ||
design_3.FcCalc() | ||
design_3.FfCalc() | ||
design_4.designmatrix() | ||
design_4.FeCalc() | ||
design_4.FdCalc() | ||
design_4.FcCalc() | ||
design_4.FfCalc() | ||
|
||
# mutate design | ||
DES5 = design_1.mutation(0.3, seed=2000) | ||
DES5.designmatrix() | ||
DES5.FeCalc() | ||
DES5.FdCalc() | ||
DES5.FcCalc() | ||
DES5.FfCalc() | ||
|
||
# compare detection power | ||
result = ( | ||
f" RESULTS \n ======= \n" | ||
f"DESIGN 1: Fd = {design_1.Fd} \n" | ||
f"DESIGN 2: Fd = {design_2.Fd} \n" | ||
f"DESIGN 3: Fd = {design_3.Fd} \n" | ||
f"DESIGN 4: Fd = {design_4.Fd} \n" | ||
f"DESIGN 5: Fd = {DES5.Fd} \n" | ||
) | ||
|
||
print(result) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.