Stephan Heunis ("Atlantis" slot)
@fMRwhy jsheunis Psychoinformatics lab Institute of Neuroscience and Medicine, Brain & Behavior (INM-7) |
|
Şeyma Bayrak ("Rising Sun" slot)
sheyma Otto Hahn Group Cognitive Neurogenetics |
|
You've just published a paper that calculated the cortical thickness for a group of research participants. You've run some statistical tests and visualized the results.
Soon after, a researcher in your field sends you an email:
Our goal for this hands-on session is to guide you through the use of several tools for creating a reproducible workflow so that you can go...
from reacting like this: |
to reacting like this: |
There are many routes to follow, and many tools to help you on your way. We are going to take a step-wise, "Galaxy brain" approach:
By the end of this session, you should be able to do the following STEPS:
1. | The required packages | requirements.txt |
2. | The Python version | virtual environment |
3. | Instructions for how to use these to successfully run the script | README |
4. | Data and code and all of the above in an accessible location | GitHub |
code
and data
directories to your repositorycode
and data
directories to your repository
#!/bin/bash
ROOTDIR=[where-you-want-to-save-the-repo]
REPOURL=[insert-your-repo-URL]
REPONAME=[insert-your-repo-name]
CONTENTDIR=[insert-path-to-paper_data_and_code-directory]
cd $ROOTDIR
git clone $REPOURL
cd $REPONAME
cp -R $CONTENTDIR/* .
git add --all
git commit -m "add data and code to repo"
git push origin main
git
#!/bin/bash
# After editing and saving the README file
# Make sure you are located in the repo's root directory
git add README.md
git commit -m "add description to readme"
git push origin main
We have not yet specified the software or package requirements and we have not explained how to set up a virtual environment. We'll address these as our next main step in the hands-on session.
1. | The required packages | requirements.txt | ? |
2. | The Python version | virtual environment | ? |
3. | Instructions for how to use these to successfully run the script | README | ✅ |
4. | Data and code and all of the above in an accessible location | GitHub | ✅ |
pip
:
pip install -r requirements.txt
matplotlib==3.2.2
numpy>=1.16.5
pandas
nibabel
nilearn>=0.7.1
sklearn
brainspace
requirements.txt
file and add it to your GitHub repo
(either in your browser or via git
).
pip
and a requirements.txt
file might not be sufficient:
git clone https://github.com/MICA-MNI/BrainStat.git
cd BrainStat
python3 setup.py build
python3 setup.py install
|
|
#!/bin/bash
pip install virtualenv #install the package
virtualenv --python=python3 mypythonenv #create a new virtual environment
source mypythonenv/bin/activate #activate the virtual environment
# now install your packages with pip and do the analysis
deactivate #deactivate the virtual environment
#!/bin/bash
# install miniconda using install files via link
conda create -n mypythonenv python=3.6
conda activate mypythonenv
# now install your packages with conda and/or pip and do the analysis
conda deactivate #deactivate the virtual environment
requirements.txt
1. | The required packages | requirements.txt | ✅ |
2. | The Python version | virtual environment | ✅ |
3. | Instructions for how to use these to successfully run the script | README | ✅ |
4. | Data and code and all of the above in an accessible location | GitHub | ✅ |
environment.yml
for conda ❓requirements.txt
for Python/PIP ✅apt.txt
for Unix-based software ❓postBuild
❓requirements.txt
file with most packagesapt.txt
:
libgl1-mesa-dev
xvfb
postBuild
:
#!/bin/bash
git clone https://github.com/MICA-MNI/BrainStat.git
cd BrainStat
python3 setup.py build
python3 setup.py install
cd ..
export DISPLAY=:99.0
which Xvfb
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
sleep 3
exec "$@"
environment.yml
instead of requirements.txt
to specify the configuration is also possible.
It all depends on which packages are available via which distribution service. For an example of setting up our repository using
environment.yml
, see the conda-env branch of the repo. For a variety of options for configuration files
see the Binder documentation.
postBuild
✅postBuild
✅conda
and pip
conda install -c conda-forge notebook
pip install notebook
From this: | To this: |
datalad-container
datalad-containers run
$ datalad clone ///openneuro/ds000001
[INFO ] Cloning http://datasets.datalad.org/openneuro/ds000001 [1 other candidates] into '/tmp/ds000001'
[INFO ] access to 1 dataset sibling s3-PRIVATE not auto-enabled, enable with:
| datalad siblings -d "/tmp/ds000001" enable -s s3-PRIVATE
install(ok): /tmp/ds000001 (dataset)
$ cd ds000001
$ ls sub-01/*
sub-01/anat:
sub-01_inplaneT2.nii.gz sub-01_T1w.nii.gz
sub-01/func:
sub-01_task-balloonanalogrisktask_run-01_bold.nii.gz
sub-01_task-balloonanalogrisktask_run-01_events.tsv
sub-01_task-balloonanalogrisktask_run-02_bold.nii.gz
sub-01_task-balloonanalogrisktask_run-02_events.tsv
sub-01_task-balloonanalogrisktask_run-03_bold.nii.gz
sub-01_task-balloonanalogrisktask_run-03_events.tsv
This is what you can do now!