├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ ├── help-.md │ ├── installation-issue.md │ └── plugin-review.md └── workflows │ ├── cd-build.yml │ ├── check-docs.yml │ └── ci-build.yml ├── .gitignore ├── .readthedocs.yml ├── AUTHOR ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── MANIFEST.in ├── README.rst ├── apt.txt ├── develop.txt ├── docs ├── _templates │ ├── module.rst_t │ ├── package.rst_t │ └── toc.rst_t ├── binder │ ├── README.md │ ├── apt.txt │ ├── environment.yml │ └── requirements.txt ├── images │ ├── banner-astro.jpg │ ├── banner-etomo.jpg │ ├── banner-mri.jpg │ ├── cosmostat_logo.jpg │ ├── logo.png │ ├── logo.svg │ ├── logo_no_background.png │ ├── neurospin_logo.png │ └── schema.jpg ├── requirements.txt └── source │ ├── _static │ └── custom.css │ ├── about.rst │ ├── citing.rst │ ├── conf.py │ ├── contributing.rst │ ├── dependencies.rst │ ├── index.rst │ ├── installation.rst │ ├── my_ref.bib │ ├── quickstart.rst │ ├── refs.bib │ ├── toc.rst │ └── z_ref.rst ├── environment.yml ├── examples ├── README.txt └── pysap │ ├── README.txt │ └── plot_basics.py ├── plugins.txt ├── pysap ├── __init__.py ├── apps │ ├── __init__.py │ ├── pypipe_config.json │ ├── pysapview │ └── pysapview3 ├── base │ ├── __init__.py │ ├── exceptions.py │ ├── image.py │ ├── io.py │ ├── loaders │ │ ├── __init__.py │ │ ├── fits.py │ │ ├── loader_base.py │ │ ├── mat.py │ │ ├── nifti.py │ │ ├── numpy_binary.py │ │ └── tif.py │ ├── observable.py │ ├── plugins.py │ ├── transform.py │ └── utils.py ├── configure.py ├── data.py ├── extensions │ ├── __init__.py │ ├── formating.py │ ├── sparse2d.py │ ├── tools.py │ ├── transform.py │ └── wrapper.py ├── info.py ├── plotting │ ├── __init__.py │ ├── image.py │ ├── transform.py │ └── utils.py ├── plugins │ └── __init__.py ├── test │ ├── errors.json │ ├── test_binding.py │ └── test_examples.py └── utils.py ├── setup.cfg ├── setup.py └── sparse2d └── python ├── CMakeLists.txt └── cmake └── Modules └── BuildSparse2D.cmake /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: If you discover a bug while using PySAP please provide the following information 4 | to help us resolve the issue. 5 | title: "[BUG]" 6 | labels: bug 7 | assignees: '' 8 | 9 | --- 10 | 11 | **System setup** 12 | OS: [e.g] macOS v10.14.1 13 | Python version: [e.g.] v3.6.7 14 | Python environment (if any): [e.g.] conda v4.5.11 15 | 16 | **Describe the bug** 17 | A clear and concise description of what the bug is. 18 | 19 | **To Reproduce** 20 | List the exact steps you followed that lead to the bug you encountered so that we can attempt to recreate the conditions. 21 | 22 | **Expected behavior** 23 | A clear and concise description of what you expected to happen. 24 | 25 | **Screenshots** 26 | If applicable, add screenshots to help explain your problem. 27 | 28 | **Module and lines involved** 29 | If you are aware of the source of the bug we would very much appreciate if you could provide the module(s) and line number(s) affected. This will enable us to more rapidly fix the problem. 30 | 31 | **Are you planning to submit a Pull Request?** 32 | - [ ] Yes 33 | - [X] No 34 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: If you believe PySAP could be improved with the addition of extra functionality 4 | or features feel free to let us know. 5 | title: "[NEW FEATURE]" 6 | labels: enhancement 7 | assignees: '' 8 | 9 | --- 10 | 11 | **Is your feature request related to a problem? Please describe.** 12 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 13 | 14 | **Describe the solution you'd like** 15 | In order to increase your chances of having a feature included, be sure to be as clear and specific as possible as to the properties this feature should have. 16 | 17 | **Describe alternatives you've considered** 18 | A clear and concise description of any alternative solutions or features you've considered. 19 | 20 | **Are you planning to submit a Pull Request?** 21 | - [ ] Yes 22 | - [X] No 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/help-.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Help! 3 | about: Users are welcome to ask any question relating to PySAP and we will endeavour 4 | to reply as soon as possible. 5 | title: "[HELP]" 6 | labels: help wanted 7 | assignees: '' 8 | 9 | --- 10 | 11 | Let us know how we can help. 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/installation-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Installation issue 3 | about: If you encounter difficulties installing PySAP be sure to re-read the installation 4 | instructions provided before submitting an issue. 5 | title: "[INSTALLATION ERROR]" 6 | labels: installation 7 | assignees: '' 8 | 9 | --- 10 | 11 | **System setup** 12 | OS: [e.g] macOS v10.14.1 13 | Python version: [e.g.] v3.6.7 14 | Python environment (if any): [e.g.] conda v4.5.11 15 | 16 | **Describe the bug** 17 | A clear and concise description of what the problem is. 18 | 19 | **To Reproduce** 20 | List the exact steps you followed that lead to the problem you encountered so that we can attempt to recreate the conditions. 21 | 22 | **Screenshots** 23 | If applicable, add screenshots to help explain your problem. 24 | 25 | **Are you planning to submit a Pull Request?** 26 | - [ ] Yes 27 | - [X] No 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/plugin-review.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Plugin review 3 | about: If you have a new or existing PySAP plugin that you want reviewed please provide 4 | the following information. 5 | title: "[PLUGIN REVIEW]" 6 | labels: pugin review 7 | assignees: '' 8 | 9 | --- 10 | 11 | **Which type of plugin do you want reviewed?** 12 | - [ ] A new plugin that is not hosted on CEA-COSMIC 13 | - [X] An existing plugin that is hosted on CEA-COSMIC 14 | 15 | **New plugin details** 16 | - Repository URL: *e.g.* https://github.com/MY_ACCOUNT/pysap-MYPLUGIN 17 | - Where is example data hosted: *e.g.* ftp://MYFTP.com 18 | - What is the purpose of this plugin? What is the application? 19 | 20 | **Existing plugin details** 21 | - Plugin name: *e.g.* pysap-mri 22 | - Brief description of changes since last review. 23 | -------------------------------------------------------------------------------- /.github/workflows/cd-build.yml: -------------------------------------------------------------------------------- 1 | name: CD 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - main 8 | 9 | jobs: 10 | 11 | coverage: 12 | name: Deploy Coverage Results 13 | runs-on: ubuntu-latest 14 | 15 | 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v3 19 | 20 | - name: Set up Python ${{ matrix.python-version }} 21 | uses: actions/setup-python@v4 22 | with: 23 | python-version: "3.10" 24 | 25 | - name: Check Python Version 26 | run: python --version 27 | 28 | - name: Install Package Dependencies 29 | run: | 30 | python -m pip install --upgrade pip 31 | python -m pip install git+https://github.com/cea-cosmic/modopt@develop # Workaround, to be removed 32 | python -m pip install -r develop.txt 33 | 34 | - name: Install PySAP 35 | run: python -m pip install . 36 | 37 | - name: Run Tests 38 | run: python -m pytest 39 | 40 | - name: Upload coverage to Codecov 41 | uses: codecov/codecov-action@v1 42 | with: 43 | token: ${{ secrets.CODECOV_TOKEN }} 44 | file: coverage.xml 45 | flags: unittests 46 | 47 | 48 | 49 | 50 | 51 | api_deploy: 52 | name: Deploy API Documentation 53 | needs: coverage 54 | runs-on: self-hosted 55 | if: success() 56 | 57 | env: 58 | gh_root: https://github.com/CEA-COSMIC/ 59 | tag_path: /archive/refs/tags/ 60 | gh_download: https://codeload.github.com/CEA-COSMIC/ 61 | develop_path: /tar.gz/refs/heads/develop 62 | sphinx_opts: -t docs/_templates -feTMo docs/source 63 | 64 | steps: 65 | - name: Checkout 66 | uses: actions/checkout@v2 67 | 68 | - name: Set up Python 3.10 69 | uses: actions/setup-python@v5 70 | with: 71 | python-version: "3.10.12" 72 | 73 | - name: Check Python Version 74 | run: python --version 75 | 76 | - name: Install dependencies 77 | run: | 78 | python -m pip install --upgrade pip 79 | python -m pip install pandoc 80 | python -m pip install -r docs/requirements.txt 81 | python -m pip install . 82 | 83 | - name: Download plug-ins 84 | run: | 85 | while read _plugin; do 86 | plugin_name="$(echo ${_plugin} | awk -F== '{print $1}')" 87 | plugin_version="$(echo ${_plugin} | awk -F== '{print $2}')" 88 | wget ${gh_download}${plugin_name}${develop_path} -O ${plugin_name}.tar.gz 89 | done < plugins.txt 90 | for file in *.tar.gz; do 91 | tar xzf "$file"; 92 | python -m pip install "$file" 93 | done 94 | rm *.tar.gz 95 | 96 | - name: Extract plug-in examples 97 | run: | 98 | while read _plugin; do 99 | plugin_name="$(echo ${_plugin} | awk -F== '{print $1}')" 100 | cp -r ${plugin_name}-*/examples examples/${plugin_name} || echo "Warning: no examples found for ${plugin_name}" 101 | done < plugins.txt 102 | 103 | - name: Build PySAP source files 104 | run: sphinx-apidoc ${sphinx_opts} pysap 105 | 106 | - name: Build plug-in source files 107 | run: | 108 | while read _plugin; do 109 | plugin_name="$(echo ${_plugin} | awk -F== '{print $1}')" 110 | package_name="$(echo ${plugin_name} | awk -F- '{print $2}')" 111 | sphinx-apidoc ${sphinx_opts} ${plugin_name}-*/${package_name} 112 | done < plugins.txt 113 | 114 | - name: Install GPU specific requirements 115 | run: | 116 | python -m pip install -r pysap-mri-*/gpu_requirements.txt 117 | 118 | - name: Build API documentation 119 | run: sphinx-build -E docs/source docs/_build 120 | 121 | - name: Deploy API documentation 122 | uses: peaceiris/actions-gh-pages@v3.5.9 123 | with: 124 | github_token: ${{ secrets.GITHUB_TOKEN }} 125 | publish_dir: docs/_build 126 | -------------------------------------------------------------------------------- /.github/workflows/check-docs.yml: -------------------------------------------------------------------------------- 1 | name: Check Docs Manually 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | build_plugins: 7 | description: 'Build API Docs with Plug-Ins' 8 | required: true 9 | default: true 10 | type: boolean 11 | build_examples: 12 | description: 'Build API Docs with Examples' 13 | required: true 14 | default: true 15 | type: boolean 16 | 17 | jobs: 18 | 19 | api: 20 | name: Check API Documentation 21 | runs-on: self-hosted 22 | 23 | env: 24 | gh_root: https://github.com/CEA-COSMIC/ 25 | tag_path: /archive/refs/tags/ 26 | gh_download: https://codeload.github.com/CEA-COSMIC/ 27 | develop_path: /tar.gz/refs/heads/develop 28 | sphinx_opts: -t docs/_templates -feTMo docs/source 29 | 30 | steps: 31 | - name: Checkout 32 | uses: actions/checkout@v2 33 | 34 | - name: Set up Python 3.10 35 | uses: actions/setup-python@v5 36 | with: 37 | python-version: "3.10.12" 38 | 39 | - name: Check Python Version 40 | run: python --version 41 | 42 | - name: Install dependencies 43 | run: | 44 | python -m pip install --upgrade pip 45 | python -m pip install pandoc 46 | python -m pip install git+https://github.com/cea-cosmic/modopt@develop # Workaround, to be removed 47 | python -m pip install -r docs/requirements.txt 48 | python -m pip install . 49 | 50 | - name: Download plug-ins 51 | if: ${{ inputs.build_plugins }} 52 | run: | 53 | while read _plugin; do 54 | plugin_name="$(echo ${_plugin} | awk -F== '{print $1}')" 55 | plugin_version="$(echo ${_plugin} | awk -F== '{print $2}')" 56 | wget ${gh_download}${plugin_name}${develop_path} -O ${plugin_name}.tar.gz 57 | done < plugins.txt 58 | for file in *.tar.gz; do 59 | tar xzf "$file"; 60 | python -m pip install "$file" 61 | done 62 | rm *.tar.gz 63 | 64 | - name: Extract plug-in examples 65 | if: ${{ inputs.build_examples }} 66 | run: | 67 | while read _plugin; do 68 | plugin_name="$(echo ${_plugin} | awk -F== '{print $1}')" 69 | cp -r ${plugin_name}-*/examples examples/${plugin_name} || echo "Warning: no examples found for ${plugin_name}" 70 | done < plugins.txt 71 | 72 | - name: Build PySAP source files 73 | run: sphinx-apidoc ${sphinx_opts} pysap 74 | 75 | - name: Build plug-in source files 76 | if: ${{ inputs.build_plugins }} 77 | run: | 78 | while read _plugin; do 79 | plugin_name="$(echo ${_plugin} | awk -F== '{print $1}')" 80 | package_name="$(echo ${plugin_name} | awk -F- '{print $2}')" 81 | sphinx-apidoc ${sphinx_opts} ${plugin_name}-*/${package_name} 82 | done < plugins.txt 83 | 84 | - name: Install GPU specific requirements 85 | run: | 86 | python -m pip install -r pysap-mri-*/gpu_requirements.txt 87 | 88 | - name: Build API documentation 89 | run: sphinx-build -E docs/source docs/_build 90 | 91 | - name: Archive API build 92 | uses: actions/upload-artifact@v2 93 | with: 94 | name: api-docs 95 | retention-days: 14 96 | path: docs/_build 97 | -------------------------------------------------------------------------------- /.github/workflows/ci-build.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - develop 7 | - master 8 | - main 9 | 10 | jobs: 11 | test-full: 12 | name: Full Test Suite 13 | runs-on: ${{ matrix.os }} 14 | 15 | strategy: 16 | fail-fast: false 17 | matrix: 18 | os: [ubuntu-latest, macos-latest] 19 | python-version: ["3.10"] 20 | 21 | steps: 22 | - name: Checkout 23 | uses: actions/checkout@v3 24 | 25 | - name: Set up Python ${{ matrix.python-version }} 26 | uses: actions/setup-python@v4 27 | with: 28 | python-version: ${{ matrix.python-version }} 29 | 30 | - name: Check Python Version 31 | run: python --version 32 | 33 | - name: Install macOS Dependencies 34 | if: runner.os == 'macOS' 35 | run: | 36 | brew tap sfarrens/sf 37 | brew install bigmac libomp 38 | 39 | - name: Install Package Dependencies 40 | run: | 41 | python -m pip install --upgrade pip 42 | python -m pip install -r develop.txt 43 | python -m pip install twine 44 | 45 | - name: Install PySAP 46 | run: python -m pip install . 47 | 48 | - name: Check PySAP Installation 49 | run: | 50 | python -c "import pysparse" 51 | python -c "import pysap; print(pysap.info())" 52 | 53 | - name: Run Tests 54 | run: python -m pytest 55 | 56 | - name: Save Test Results 57 | if: always() 58 | uses: actions/upload-artifact@v2 59 | with: 60 | name: unit-test-results-${{ matrix.os }}-${{ matrix.python-version }} 61 | path: pytest.xml 62 | 63 | - name: Run Examples 64 | continue-on-error: true 65 | run: python pysap/test/test_examples.py 66 | 67 | - name: Check Distribution 68 | run: | 69 | python setup.py sdist 70 | twine check dist/* 71 | 72 | - name: Upload Coverage to Codecov 73 | uses: codecov/codecov-action@v1 74 | with: 75 | token: ${{ secrets.CODECOV_TOKEN }} 76 | file: coverage.xml 77 | flags: unittests 78 | 79 | test-basic: 80 | name: Basic Test Suite 81 | runs-on: ${{ matrix.os }} 82 | 83 | strategy: 84 | fail-fast: false 85 | matrix: 86 | os: [ubuntu-latest, macos-latest] 87 | python-version: ["3.7", "3.8", "3.9"] 88 | 89 | steps: 90 | - name: Checkout 91 | uses: actions/checkout@v2 92 | 93 | - name: Set up Python ${{ matrix.python-version }} 94 | uses: actions/setup-python@v4 95 | with: 96 | python-version: ${{ matrix.python-version }} 97 | 98 | - name: Check Python Version 99 | run: python --version 100 | 101 | - name: Install macOS Dependencies 102 | if: runner.os == 'macOS' 103 | run: | 104 | brew tap sfarrens/sf 105 | brew install bigmac libomp 106 | 107 | - name: Install Package Dependencies 108 | run: | 109 | python --version 110 | python -m pip install --upgrade pip 111 | python -m pip install -r develop.txt 112 | 113 | - name: Install PySAP 114 | run: python -m pip install . 115 | 116 | - name: Check PySAP Installation 117 | run: | 118 | python -c "import pysparse" 119 | python -c "import pysap; print(pysap.info())" 120 | 121 | - name: Run Tests 122 | run: python -m pytest 123 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | share/python-wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | MANIFEST 28 | 29 | # PyInstaller 30 | # Usually these files are written by a python script from a template 31 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 32 | *.manifest 33 | *.spec 34 | 35 | # Installer logs 36 | pip-log.txt 37 | pip-delete-this-directory.txt 38 | 39 | # Unit test / coverage reports 40 | htmlcov/ 41 | .tox/ 42 | .nox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *.cover 49 | *.py,cover 50 | .hypothesis/ 51 | .pytest_cache/ 52 | cover/ 53 | pytest.xml 54 | 55 | # Translations 56 | *.mo 57 | *.pot 58 | 59 | # Django stuff: 60 | *.log 61 | local_settings.py 62 | db.sqlite3 63 | db.sqlite3-journal 64 | 65 | # Flask stuff: 66 | instance/ 67 | .webassets-cache 68 | 69 | # Scrapy stuff: 70 | .scrapy 71 | 72 | # Sphinx documentation 73 | docs/_build/ 74 | docs/source/auto_examples 75 | docs/source/fortuna.* 76 | docs/source/scripts.* 77 | docs/source/*.nblink 78 | docs/source/*astro* 79 | docs/source/*etomo* 80 | docs/source/*mri* 81 | docs/source/*pysap* 82 | pysap-astro* 83 | pysap-etomo* 84 | pysap-mri* 85 | 86 | # PyBuilder 87 | .pybuilder/ 88 | target/ 89 | 90 | # Jupyter Notebook 91 | .ipynb_checkpoints 92 | 93 | # IPython 94 | profile_default/ 95 | ipython_config.py 96 | 97 | # pyenv 98 | # For a library or package, you might want to ignore these files since the code is 99 | # intended to run in multiple environments; otherwise, check them in: 100 | # .python-version 101 | 102 | # pipenv 103 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 104 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 105 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 106 | # install all needed dependencies. 107 | #Pipfile.lock 108 | 109 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 110 | __pypackages__/ 111 | 112 | # Celery stuff 113 | celerybeat-schedule 114 | celerybeat.pid 115 | 116 | # SageMath parsed files 117 | *.sage.py 118 | 119 | # Environments 120 | .env 121 | .venv 122 | env/ 123 | venv/ 124 | ENV/ 125 | env.bak/ 126 | venv.bak/ 127 | 128 | # Spyder project settings 129 | .spyderproject 130 | .spyproject 131 | 132 | # Rope project settings 133 | .ropeproject 134 | 135 | # mkdocs documentation 136 | /site 137 | 138 | # mypy 139 | .mypy_cache/ 140 | .dmypy.json 141 | dmypy.json 142 | 143 | # Pyre type checker 144 | .pyre/ 145 | 146 | # pytype static type analyzer 147 | .pytype/ 148 | 149 | # Cython debug symbols 150 | cython_debug/ 151 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | 6 | version: 2 7 | 8 | sphinx: 9 | builder: html 10 | configuration: doc/source/conf.py 11 | fail_on_warning: true 12 | 13 | formats: [] 14 | 15 | conda: 16 | environment: environment.yml 17 | -------------------------------------------------------------------------------- /AUTHOR: -------------------------------------------------------------------------------- 1 | Antoine Grigis 2 | Samuel Farrens 3 | Jean-Luc Starck 4 | Philippe Ciuciu 5 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | education, socio-economic status, nationality, personal appearance, race, 10 | religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at 59 | [samuel.farrens@cea.fr](mailto:samuel.farrens@cea.fr). 60 | All complaints will be reviewed and investigated and will result in a response that 61 | is deemed necessary and appropriate to the circumstances. The project team is 62 | obligated to maintain confidentiality with regard to the reporter of an incident. 63 | Further details of specific enforcement policies may be posted separately. 64 | 65 | Project maintainers who do not follow or enforce the Code of Conduct in good 66 | faith may face temporary or permanent repercussions as determined by other 67 | members of the project's leadership. 68 | 69 | ## Attribution 70 | 71 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 72 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 73 | 74 | [homepage]: https://www.contributor-covenant.org 75 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to PySAP 2 | 3 | PySAP is a package for sparsity with applications in astrophysics and MRI. 4 | This package has been developed in collaboration between [CosmoStat](http://www.cosmostat.org/) and [NeuroSpin](http://joliot.cea.fr/drf/joliot/Pages/Entites_de_recherche/NeuroSpin.aspx) via the [COSMIC](http://cosmic.cosmostat.org/) project. 5 | 6 | ## Contents 7 | 8 | 1. [Introduction](#introduction) 9 | 2. [Issues](#issues) 10 | a. [Asking Questions](#asking-questions) 11 | b. [Installation Issues](#installation-issues) 12 | c. [Reporting Bugs](#reporting-bugs) 13 | d. [Requesting Features](#requesting-features) 14 | 3. [Pull Requests](#pull-requests) 15 | a. [Before Making a PR](#before-making-a-pr) 16 | b. [Making a PR](#making-a-pr) 17 | c. [After Making a PR](#after-making-a-pr) 18 | d. [Content](#content) 19 | e. [CI Tests](#ci-tests) 20 | f. [Coverage](#coverage) 21 | g. [Style Guide](#style-guide) 22 | 23 | ## Introduction 24 | 25 | PySAP is fully open-source and as such users are welcome to fork, clone and/or reuse the software freely. Users wishing to contribute to the development of this package, however, are kindly requested to adhere to the following guidelines and the [code of conduct](./CODE_OF_CONDUCT.md). 26 | 27 | ## Issues 28 | 29 | The easiest way to contribute to PySAP is by raising a "New issue". This will give you the opportunity to ask questions, report bugs or even request new features. 30 | 31 | Remember to use clear and descriptive titles for issues. This will help other users that encounter similar problems find quick solutions. We also ask that you read the available documentation and browse existing issues on similar topics before raising a new issue in order to avoid repetition. 32 | 33 | ### Asking Questions 34 | 35 | Users are of course welcome to ask any question relating to PySAP and we will endeavour to reply as soon as possible. 36 | 37 | These issues should include the `help wanted` label. 38 | 39 | ### Installation Issues 40 | 41 | If you encounter difficulties installing PySAP be sure to re-read the installation instructions provided. If you are still unable to install the package please remember to include the following details in the issue you raise: 42 | 43 | * your operating system and the corresponding version (*e.g.* macOS v10.14.1, Ubuntu v16.04.1, *etc.*), 44 | * the version of Python you are using (*e.g* v3.6.7, *etc.*), 45 | * the python environment you are using (if any) and the corresponding version (*e.g.* virtualenv v16.1.0, conda v4.5.11, *etc.*), 46 | * the exact steps followed while attempting to install PySAP 47 | * and the error message printed or a screen capture of the terminal output. 48 | 49 | These issues should include the `installation` label. 50 | 51 | ### Reporting Bugs 52 | 53 | If you discover a bug while using PySAP please provide the same information requested for installation issues. Be sure to list the exact steps you followed that lead to the bug you encountered so that we can attempt to recreate the conditions. 54 | 55 | If you are aware of the source of the bug we would very much appreciate if you could provide the module(s) and line number(s) affected. This will enable us to more rapidly fix the problem. 56 | 57 | These issues should include the `bug` label. 58 | 59 | ### Requesting Features 60 | 61 | If you believe PySAP could be improved with the addition of extra functionality or features feel free to let us know. We cannot guarantee that we will include these features, but we will certainly take your suggestions into consideration. 62 | 63 | In order to increase your chances of having a feature included, be sure to be as clear and specific as possible as to the properties this feature should have. 64 | 65 | These issues should include the `enhancement` label. 66 | 67 | ## Pull Requests 68 | 69 | If you would like to take a more active roll in the development of PySAP you can do so by submitting a "Pull request". A Pull Requests (PR) is a way by which a user can submit modifications or additions to the PySAP package directly. PRs need to be reviewed by the package moderators and if accepted are merged into the master branch of the repository. 70 | 71 | Before making a PR, be sure to carefully read the following guidelines. 72 | 73 | ### Before Making a PR 74 | 75 | The following steps should be followed before making a pull request: 76 | 77 | 1. Log into your GitHub account or create an account if you do not already have one. 78 | 79 | 1. Go to the main PySAP repository page: [https://github.com/CEA-COSMIC/pysap](https://github.com/CEA-COSMIC/pysap) 80 | 81 | 1. Fork the repository, *i.e.* press the button on the top right with this symbol . This will create an independent copy of the repository on your account. 82 | 83 | 1. Clone your fork of PySAP. 84 | 85 | ```bash 86 | git clone https://github.com/YOUR_USERNAME/pysap 87 | ``` 88 | 89 | 5. Add the original repository (*upstream*) to remote. 90 | 91 | ```bash 92 | git remote add upstream https://github.com/CEA-COSMIC/pysap 93 | ``` 94 | 95 | ### Making a PR 96 | 97 | The following steps should be followed to make a pull request: 98 | 99 | 1. Pull the latest updates to the original repository. 100 | 101 | ```bash 102 | git pull upstream master 103 | ``` 104 | 105 | 2. Create a new branch for your modifications. 106 | 107 | ```bash 108 | git checkout -b BRANCH_NAME 109 | ``` 110 | 111 | 3. Make the desired modifications to the relevant modules. 112 | 113 | 4. Add the modified files to the staging area. 114 | 115 | ```bash 116 | git add . 117 | ``` 118 | 119 | 5. Make sure all of the appropriate files have been staged. Note that all files listed in green will be included in the following commit. 120 | 121 | ```bash 122 | git status 123 | ``` 124 | 125 | 6. Commit the changes with an appropriate description. 126 | 127 | ```bash 128 | git commit -m "Description of commit" 129 | ``` 130 | 131 | 7. Push the commits to a branch on your fork of PySAP. 132 | 133 | ```bash 134 | git push origin BRANCH_NAME 135 | ``` 136 | 137 | 8. Make a pull request for your branch with a clear description of what has been done, why and what issues this relates to. 138 | 139 | 9. Wait for feedback and repeat steps 3 through 7 if necessary. 140 | 141 | ### After Making a PR 142 | 143 | If your PR is accepted and merged it is recommended that the following steps be followed to keep your fork up to date. 144 | 145 | 1. Make sure you switch back to your local master branch. 146 | 147 | ```bash 148 | git checkout master 149 | ``` 150 | 151 | 2. Delete the local branch you used for the PR. 152 | 153 | ```bash 154 | git branch -d BRANCH_NAME 155 | ``` 156 | 157 | 3. Pull the latest updates to the original repository, which include your PR changes. 158 | 159 | ```bash 160 | git pull upstream master 161 | ``` 162 | 163 | 4. Push the commits to your fork. 164 | 165 | ```bash 166 | git push origin master 167 | ``` 168 | 169 | ### Content 170 | 171 | Every PR should correspond to a bug fix or new feature issue that has already be raised. When you make a PR be sure to tag the issue that it resolves (*e.g.* this PR relates to issue #1). This way the issue can be closed once the PR has been merged. 172 | 173 | The content of a given PR should be as concise as possible. To that end, aim to restrict modifications to those needed to resolve a single issue. Additional bug fixes or features should be made as separate PRs. 174 | 175 | ### CI Tests 176 | 177 | Continuous Integration (CI) tests are implemented via [Travis CI](https://travis-ci.org/). All PRs must pass the CI tests before being merged. Your PR may not be reviewed by a moderator until all CI test are passed. Therefore, try to resolve any issues in your PR that may cause the tests to fail. 178 | 179 | In some cases it may be necessary to modify the unit tests, but this should be clearly justified in the PR description. 180 | 181 | ### Coverage 182 | 183 | Coverage tests are implemented via [Codecov](https://about.codecov.io/). These tests will fail if the coverage, *i.e.* the number of lines of code covered by unit tests, decreases. When submitting new code in a PR, contributors should aim to write appropriate unit tests. If the coverage drops significantly moderators may request unit tests be added before the PR is merged. 184 | 185 | ### Style Guide 186 | 187 | All contributions should adhere to the following style guides currently implemented in PySAP: 188 | 189 | 1. All code should be compatible with the Python versions listed in `README.rst`. 190 | 191 | 1. All code should adhere to [PEP8](https://www.python.org/dev/peps/pep-0008/) standards. 192 | 193 | 1. Docstrings need to be provided for all new modules, methods and classes. These should adhere to [numpydoc](https://numpydoc.readthedocs.io/en/latest/format.html) standards. 194 | 195 | 1. When in doubt look at the existing code for inspiration. 196 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM continuumio/miniconda3 2 | 3 | LABEL Description="PySAP Docker Image" 4 | WORKDIR /home 5 | ENV SHELL /bin/bash 6 | 7 | ARG DEBIAN_FRONTEND=noninteractive 8 | ARG CC=gcc-10 9 | ARG CXX=g++-10 10 | 11 | RUN apt-get update && \ 12 | apt-get install -y gcc-10 g++-10 && \ 13 | apt-get install -y libgl1 && \ 14 | apt-get install -y libnfft3-dev && \ 15 | apt-get install -y cmake && \ 16 | apt-get clean 17 | 18 | RUN git clone https://github.com/CEA-COSMIC/pysap.git 19 | 20 | RUN cd pysap && \ 21 | conda env create -f environment.yml 22 | 23 | ENV PATH /opt/conda/envs/pysap/bin:$PATH 24 | 25 | RUN echo "path: $PATH" && \ 26 | cd pysap && \ 27 | python -m pip install . 28 | 29 | CMD ["jupyter", "notebook", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"] 30 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include AUTHOR LICENSE MANIFEST.in setup.py README.rst 2 | # documentation 3 | recursive-include doc/source * 4 | recursive-exclude doc/source *.*~ 5 | prune doc/source/*/generated 6 | # ISAP binding 7 | recursive-include sparse2d/python * 8 | recursive-exclude sparse2d/python *.*~ 9 | prune sparse2d/python/test 10 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | 2 | |CI|_ |Codecov|_ |Python36|_ |Python37|_ |Python38|_ |Python39|_ |PyPi|_ |Doc|_ |Docker|_ 3 | 4 | .. |CI| image:: https://github.com/CEA-COSMIC/pysap/workflows/CI/badge.svg 5 | .. _CI: https://github.com/CEA-COSMIC/pysap/actions?query=workflow%3ACI 6 | 7 | .. |Codecov| image:: https://codecov.io/gh/CEA-COSMIC/pysap/branch/master/graph/badge.svg?token=XHJIQXV7AX 8 | .. _Codecov: https://codecov.io/gh/CEA-COSMIC/pysap 9 | 10 | .. |Python36| image:: https://img.shields.io/badge/python-3.6-blue.svg 11 | .. _Python36: https://badge.fury.io/py/python-pySAP 12 | 13 | .. |Python37| image:: https://img.shields.io/badge/python-3.7-blue.svg 14 | .. _Python37: https://badge.fury.io/py/python-pySAP 15 | 16 | .. |Python38| image:: https://img.shields.io/badge/python-3.8-blue.svg 17 | .. _Python38: https://badge.fury.io/py/python-pySAP 18 | 19 | .. |Python39| image:: https://img.shields.io/badge/python-3.9-blue.svg 20 | .. _Python39: https://badge.fury.io/py/python-pySAP 21 | 22 | .. |PyPi| image:: https://badge.fury.io/py/python-pySAP.svg 23 | .. _PyPi: https://badge.fury.io/py/python-pySAP 24 | 25 | .. |Doc| image:: https://readthedocs.org/projects/python-pysap/badge/?version=latest 26 | .. _Doc: https://python-pysap.readthedocs.io/en/latest/?badge=latest 27 | 28 | .. |Docker| image:: https://img.shields.io/docker/cloud/build/ceacosmic/pysap 29 | .. _Docker: https://hub.docker.com/r/ceacosmic/pysap 30 | 31 | PySAP 32 | ====== 33 | 34 | PySAP (Python Sparse data Analysis Package) is a Python module for **sparse data analysis** that offers: 35 | 36 | * A common API for astronomical and neuroimaging datasets. 37 | * Access to |link-to-sparse2d| executables with both wrappers and bindings. 38 | * Access to application specific plug-ins. 39 | * A graphical user interface to play with the provided functions. 40 | 41 | .. |link-to-sparse2d| raw:: html 42 | 43 | Sparse2D 45 | 46 | .. raw:: html 47 | 48 | 49 | 50 | This package is the result of the |link-to-cosmic| project, which is a collaboration between 51 | the CEA Neurospin UNATI and CEA CosmoStat laboratories. 52 | 53 | .. |link-to-cosmic| raw:: html 54 | 55 | COSMIC 57 | 58 | Important links 59 | =============== 60 | 61 | - Official source code repo: https://github.com/cea-cosmic/pysap 62 | - API documentation (last stable release): https://python-pysap.readthedocs.io/ 63 | - PySAP paper: https://arxiv.org/abs/1910.08465 64 | 65 | Dependencies 66 | ============ 67 | 68 | PySAP will automatically install all of the required dependencies, however 69 | issues may arise on some operating systems. If you encounter any problems please 70 | ensure that you have all of the following dependencies installed before opening a 71 | new issue. 72 | 73 | 1. PySAP requires that the COSMIC package |link-to-modopt| be installed. 74 | 75 | .. |link-to-modopt| raw:: html 76 | 77 | ModOpt 79 | 80 | 2. PySAP also requires the installation of the following third party software packages: 81 | 82 | * scipy [>=1.5.4] 83 | * numpy [>=1.19.5] 84 | * matplotlib [>=3.3.4] 85 | * astropy [>=4.1] 86 | * nibabel [>=3.2.1] 87 | * pyqtgraph [>=0.11.1] 88 | * progressbar2 [>=3.53.1] 89 | * scikit-learn [>=0.24.1] 90 | * pybind11 [==2.6.2] 91 | * pyqt5 [==5.15.4] 92 | * PyWavelets [>=1.1.1] 93 | 94 | Plug-Ins 95 | ======== 96 | 97 | PySAP currently supports the following plug-ins: 98 | 99 | * |link-to-pysap-astro| [==0.0.1] 100 | * |link-to-pysap-etomo| [==0.0.1] 101 | * |link-to-pysap-mri| [==0.4.0] 102 | 103 | .. |link-to-pysap-astro| raw:: html 104 | 105 | PySAP-Astro 107 | 108 | .. |link-to-pysap-etomo| raw:: html 109 | 110 | PySAP-ETomo 112 | 113 | .. |link-to-pysap-mri| raw:: html 114 | 115 | PySAP-MRI 117 | 118 | Installation 119 | ============ 120 | 121 | The installation of PySAP has been extensively tested on Ubuntu and macOS, however 122 | we cannot guarantee it will work on every operating system. A Docker 123 | image is available (see below) for those unable to install PySAP directly. 124 | 125 | If you encounter any installation issues be sure to go through the following steps before opening a new issue: 126 | 127 | 1. Check that that all the dependencies listed above have been correctly installed. 128 | 2. Read through all of the documentation provided, including the troubleshooting suggestions. 129 | 3. Check if your problem has already been addressed in a previous issue. 130 | 131 | Further instructions are available |link-to-install|. 132 | 133 | .. |link-to-install| raw:: html 134 | 135 | here 137 | 138 | From PyPi 139 | --------- 140 | 141 | To install PySAP simply run: 142 | 143 | .. code-block:: bash 144 | 145 | $ pip install python-pysap 146 | 147 | Depending on your Python setup you may need to provide the ``--user`` option. 148 | 149 | .. code-block:: bash 150 | 151 | $ pip install --user python-pysap 152 | 153 | Locally 154 | ------- 155 | 156 | To build PySAP locally, clone the repository: 157 | 158 | .. code-block:: bash 159 | 160 | $ git clone https://github.com/CEA-COSMIC/pysap.git 161 | 162 | and run: 163 | 164 | .. code-block:: bash 165 | 166 | $ pip install . 167 | 168 | or: 169 | 170 | .. code-block:: bash 171 | 172 | $ python setup.py install 173 | 174 | As before, use the ``--user`` option if needed. 175 | 176 | Custom Installation 177 | ------------------- 178 | 179 | The following options can be passed when running ``python setup.py install``: 180 | 181 | * ``--noplugins`` : Install PySAP without any plug-ins 182 | * ``--only=`` : Install PySAP with only the specified plug-in names (comma separated) 183 | * ``--nosparse2d`` : Install PySAP without building Sparse2D 184 | 185 | For example, to install PySAP with only the Etomo plug-in and without Sparse2D 186 | you would run the following. 187 | 188 | .. code-block:: bash 189 | 190 | $ python setup.py install --nosparse2d --only=pysap-etomo 191 | 192 | Note that these options can also be invoked when installing with ``pip`` using 193 | the ``--install-option="