diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml index b7ab6ff..339fc94 100644 --- a/.github/workflows/codespell.yml +++ b/.github/workflows/codespell.yml @@ -15,5 +15,5 @@ jobs: codespell: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 - uses: codespell-project/actions-codespell@master diff --git a/.github/workflows/miss_hit_quality.yml b/.github/workflows/miss_hit_quality.yml index 7fab7fd..2bfbc74 100644 --- a/.github/workflows/miss_hit_quality.yml +++ b/.github/workflows/miss_hit_quality.yml @@ -10,13 +10,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 with: submodules: true fetch-depth: 1 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.11 diff --git a/.github/workflows/miss_hit_style.yml b/.github/workflows/miss_hit_style.yml index 9a4ae4a..594b3c5 100644 --- a/.github/workflows/miss_hit_style.yml +++ b/.github/workflows/miss_hit_style.yml @@ -10,13 +10,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 with: submodules: true fetch-depth: 1 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: 3.11 diff --git a/.github/workflows/moxunit.yml b/.github/workflows/moxunit.yml index 81e395b..81fc93a 100644 --- a/.github/workflows/moxunit.yml +++ b/.github/workflows/moxunit.yml @@ -14,7 +14,7 @@ jobs: steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 with: submodules: true fetch-depth: 1 @@ -28,7 +28,7 @@ jobs: cover_xml_file: coverage.xml - name: Code coverage - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos file: coverage.xml # optional diff --git a/.github/workflows/update_submodules.yml b/.github/workflows/update_submodules.yml deleted file mode 100644 index 3c6ea53..0000000 --- a/.github/workflows/update_submodules.yml +++ /dev/null @@ -1,100 +0,0 @@ -name: update submodules - -# requires sudmodules URL to be "https..." (no ssh) -# -# requires submodule to be specified to follow a specific branch (stored in .gitmodules) -# -# clone them with: -# -# git submodule add -b branch_to_follow https://github.com/... submodule_path -# -# or specify it with: -# -# git config -f .gitmodules submodule.submodule_path.branch branch_to_follow -# - - # Uses the cron schedule for github actions - # - # https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#scheduled-events - # - # ┌───────────── minute (0 - 59) - # │ ┌───────────── hour (0 - 23) - # │ │ ┌───────────── day of the month (1 - 31) - # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) - # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) - # │ │ │ │ │ - # │ │ │ │ │ - # │ │ │ │ │ - # * * * * * - -on: - push: - branches: - - main - - master - - dev - schedule: - - cron: "0 0 1 * *" - - # to trigger update manually from the Action tab in github - workflow_dispatch: - inputs: - log: - description: "Log" - required: false - -env: - # to update all submodules - SUBMOD_TO_UPDATE: "*" - # otherwise use a space separated list of the relative paths of each submodule to update - # SUBMOD_TO_UPDATE: "lib/sub_3 lib/sub_1" - -defaults: - run: - shell: bash - -jobs: - update_submodules: - # only trigger update on upstream repo - if: github.repository_owner == 'cpp-lln-lab' - - runs-on: ubuntu-latest - - steps: - - - name: Clone repo - uses: actions/checkout@v3 - with: - submodules: true - - # check out the correct branch for each submodule and pull them all - # https://stackoverflow.com/questions/5828324/update-git-submodule-to-latest-commit-on-origin - - name: Update submodules - run: | - start_dir=$PWD - if [ "${SUBMOD_TO_UPDATE}" = "*" ]; then - submodules=$(git submodule | awk '{print $2}') - else - submodules=$(echo -e ${SUBMOD_TO_UPDATE} | sed "s/ /\n/g") - fi - nb_submod=$(echo "${submodules}" | wc -l) - echo -e "\nUPDATING ${nb_submod} SUBMODULES" - echo -e "${submodules}" - for i in $(seq 1 ${nb_submod}); do - path=$(echo -e ${submodules} | awk -v i=${i} '{print $i}') - branch=$(git config --get --file .gitmodules submodule.${path}.branch) - echo -e "\nswitching submodule ${path} to ${branch}" - cd "${path}" || exit - git checkout ${branch} - cd "${start_dir}" - done - git submodule update --remote --merge - - # if there have been changes, - # a PR is created using the checkout branch for this workflow - # https://github.com/peter-evans/create-pull-request - - name: Create Pull-Request - uses: peter-evans/create-pull-request@v4 - with: - commit-message: Update submodules - delete-branch: true diff --git a/README.md b/README.md index 598d19b..30de111 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,17 @@ [![](https://img.shields.io/badge/Octave-CI-blue?logo=Octave&logoColor=white)](https://github.com/cpp-lln-lab/template_PTB_experiment/actions) ![](https://github.com/Remi-gau/template_matlab_analysis/workflows/CI/badge.svg) [![codecov](https://codecov.io/gh/Remi-gau/template_matlab_analysis/branch/master/graph/badge.svg)](https://codecov.io/gh/cpp-lln-lab/template_PTB_experiment) -[![Build Status](https://travis-ci.com/Remi-gau/template_matlab_analysis.svg?branch=master)](https://travis-ci.com/cpp-lln-lab/template_PTB_experiment) -# Template repository for matlab analysis project +# Template repository for psycthoolbox experiment ## Content ```bash ├── .git -│ ├── COMMIT_EDITMSG -│ ├── FETCH_HEAD -│ ├── HEAD -│ ├── ORIG_HEAD -│ ├── branches -│ ├── config -│ ├── description -│ ├── hooks -│ │ ├── pre-commit.sample -│ │ └── pre-push.sample -│ ├── ... -│ └── ... ├── .github # where you put anything github related │ └── workflows # where you define your github actions │ └── moxunit.yml # a yaml file that defines a github action -├── lib # where you put the code from external libraries (mathworks website or other github repositories) +├── lib # external libraries (mathworks website or other github repositories) │ └── README.md ├── src # where you put your code │ ├── README.md @@ -32,39 +19,25 @@ ├── tests # where you put your unit tests | ├── README.md | └── miss_hit.cfg -├── .travis.yml # where you define the continuous integration done by Travis ├── LICENSE ├── README.md -├── requirements.txt # list of python packages used in this repo: to install `pip install -r requirements.txt` +├── requirements.txt # python packages used: to install `pip install -r requirements.txt` ├── miss_hit.cfg # configuration file for the matlab miss hit linter └── initEnv.m # a .m file to set up your project (adds the right folder to the path) ``` -## Keeping your code stylish: miss hit linter - -## Python environment - -More on this -[here](https://the-turing-way.netlify.app/reproducible-research/renv/renv-package.html) - -[Conda cheat sheet](https://docs.conda.io/projects/conda/en/4.6.0/_downloads/52a95608c49671267e40c689e0bc00ca/conda-cheatsheet.pdf) - -## Testing your code - -## Continuous integration - ## How to install and use this template By using the [template PTB experiment repository](https://github.com/cpp-lln-lab/template_PTB_experiment): -you can create a new repository on your github account with all the basic folders, -files and submodules already set up. You only have to then clone the repository -and you are good to go. - +you can create a new repository on your github account with all the basic +folders, files and submodules already set up. You only have to then clone the +repository and you are good to go. ## How to install and run Install + ``` git clone --recurse-submodules https://github.com/your_github_account/the_name_of_your_new_experiment.git ``` @@ -72,6 +45,7 @@ git clone --recurse-submodules https://github.com/your_github_account/the_name_o Set parameters in `setParameters.m` Run + ``` mainScript ``` diff --git a/initEnv.m b/initEnv.m index febf28a..10efd18 100644 --- a/initEnv.m +++ b/initEnv.m @@ -1,18 +1,45 @@ -% -% 1 - Check if version requirements -% are satisfied and the packages are -% are installed/loaded: -% Octave > 4 -% - image -% - optim -% - struct -% - statistics -% -% MATLAB >= R2015b -% -% 2 - Add project to the O/M path - -function initEnv +function initEnv(varargin) + % + % 1 - Check if version requirements are satisfied and the packages are are installed/loaded: + % Octave > 4 + % - image + % - optim + % - struct + % - statistics + % + % MATLAB >= R2015b + % + % 2 - Add project to the O/M path + % + % USAGE:: + % + % initEnv + % initEnv('init') + % initEnv('uninit') + % + % :param action: + % :type action: string + % + % :returns: - :action: (type) (dimension) + % + % Example:: + % + + % (C) Copyright 2022 CPP_BIDS developers + + p = inputParser; + + defaultAction = 'init'; + + addOptional(p, 'action', defaultAction, @ischar); + % addParameter(p, 'verbose', true); + + parse(p, varargin{:}); + + action = p.Results.action; + % verbose = p.Results.verbose; + + % Check Matlab and Octave version octaveVersion = '4.0.3'; matlabVersion = '8.6.0'; @@ -59,7 +86,7 @@ 'Try this in your terminal:', ... ' git submodule update --recursive ']); else - addDependencies(); + addDependencies(action); end disp('Correct matlab/octave versions and added to the path!'); @@ -96,13 +123,24 @@ function tryInstallFromForge(packageName) end -function addDependencies() +function addDependencies(action) pth = fileparts(mfilename('fullpath')); - addpath(fullfile(pth, 'lib', 'CPP_BIDS')); - addpath(genpath(fullfile(pth, 'lib', 'CPP_PTB', 'src'))); - addpath(fullfile(pth, 'subfun')); - checkCppBidsDependencies(); + switch lower(action) + + case 'init' + + run(fullfile(pth, 'lib', 'CPP_PTB', 'cpp_ptb')); + run(fullfile(pth, 'lib', 'CPP_BIDS', 'cpp_bids')); + addpath(genpath(fullfile(pth, 'src'))); + + case 'uninit' + + cpp_ptb('uninit'); + cpp_bids('uninit'); + rmpath(genpath(fullfile(pth, 'src'))); + + end end diff --git a/lib/CPP_BIDS b/lib/CPP_BIDS index f814264..8536d1c 160000 --- a/lib/CPP_BIDS +++ b/lib/CPP_BIDS @@ -1 +1 @@ -Subproject commit f814264af94fbfd5a4ef6644abd68f30f90883f2 +Subproject commit 8536d1cf4c6ca379a2b77feff5b35a94ed9dc317 diff --git a/lib/CPP_PTB b/lib/CPP_PTB index 0738579..b5dcdff 160000 --- a/lib/CPP_PTB +++ b/lib/CPP_PTB @@ -1 +1 @@ -Subproject commit 073857927bd9c9ebb35a0d0d9675239b135960b3 +Subproject commit b5dcdff754cfc77706f36f9f6416be09ef43f463 diff --git a/mainScript.m b/mainScript.m index 2f3fa11..6ab993a 100644 --- a/mainScript.m +++ b/mainScript.m @@ -11,7 +11,7 @@ end % make sure we got access to all the required functions and inputs -initEnv(); +initEnv('init'); % set and load all the parameters to run the experiment cfg = setParameters; @@ -125,6 +125,8 @@ cleanUp(); + initEnv('uninit'); + catch cleanUp(); diff --git a/notebooks/README.md b/notebooks/README.md deleted file mode 100644 index 1237a6d..0000000 --- a/notebooks/README.md +++ /dev/null @@ -1 +0,0 @@ -# Jupyter notebooks