Thomas Shaw
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
1
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# TrainTrack Containers talk Steffen Bollmann and Thom Shaw ## Table of Contents [TOC] ## How to access course material --- https://github.com/thomshaw92/TrainTrack_containers_2020 ```gherkin= git clone https://github.com/thomshaw92/TrainTrack_containers_2020.git ``` ## Prerequisites - Please download and install Docker and Singularity if they are not available to you somewhere. - Python (Conda or Miniconda) - NeuroDocker (pip install neurodocker) - This dataset or your own dataset in BIDS format: - https://openneuro.org/datasets/ds000205/versions/00001 ## Course code --- :::info We will be using Docker for Windows and Singularity on Linux. This code may not work directly on your OS - so please ask the TAs or helpdesk if you run into issues. ::: ## 1) Build a simple docker container ### Docker pull and run First let's try the simplest example and pull the hello-world of docker: ```gherkin= docker pull hello-world ``` and then try running it: ```gherkin= docker run hello-world ``` (just docker run on its own would pull the image as well if it's not there yet) ### Images where are the Docker images located? ```gherkin= docker images ``` in windows all docker images are stored in a single hyper-v virtual machine disk at: C:\ProgramData\DockerDesktop\vm-data\DockerDesktop.vhdx ### Caching Find image ID of hello world remove the image ```gherkin= docker rmi ${image_id} ``` or if that doesn't work ```gherkin= docker rmi -f ${image_id} ``` ### fMRIprep example First let us check out our example dataset: The dataset is just a random Open Neuro dataset. Feel free to pull it via the web client or via AWS https://openneuro.org/datasets/ds000205/versions/00001 https://aws.amazon.com/cli/ ```gherkin= aws s3 sync --no-sign-request s3://openneuro.org/ds000205 ds000205-download/ ``` Then we pull fMRIPrep (this will take a while!) ```gherkin= docker pull poldracklab/fmriprep:latest ``` NB you can use the docker fmriprep wrapper but we will be interfacing directly with the Docker image. check in https://fmriprep.readthedocs.io/en/stable/docker.html https://hub.docker.com/r/poldracklab/fmriprep/tags for the latest versions of fmriprep Running fMRI prep container in Windows: (The data here is in ${HOME}/data - you may need to adjust yours) ```gherkin= docker run -ti --rm ` -v $HOME/data/BrainHackOHBM2020:/data:ro ` -v $HOME/data/derivatives:/out ` -v $HOME/data/work:/work ` poldracklab/fmriprep:latest /data /out/fmriprep-latest ` participant -w /work ``` :::info If you are on Linux: check fMRIPrep website https://fmriprep.readthedocs.io/en/stable/docker.html ! ::: ### Run Singularity on an HPC If your cluster supports running Singularity... First we need to set up singularity. Most HPCs will use lmod to manage software ```gherkin= module load singularity/3.5.0 ``` Then pull the same image from DockerHub. Singularity will handle the conversion from docker and you don't need root access to do this: ```gherkin= mkdir ${HOME}/images singularity build ${HOME}/images/fmriprep-latest.simg \ docker://poldracklab/fmriprep:latest ``` The command to run singularity is very similar to Docker. Check the fMRIPrep website for more details. ```gherkin= singularity run --cleanenv ${HOME}/images/fmriprep.simg \ path/to/data/dir path/to/output/dir \ participant \ --participant-label label ``` ## 2) Build a Docker file :::info Here is a Docker file to build an itksnap container ::: ```gherkin= FROM ubuntu:16.04 LABEL maintainer="Thom Shaw" LABEL org.label-schema.maintainer="Thom Shaw" ENV PATH="/opt/itksnap/bin/:${PATH}" ENV LD_LIBRARY_PATH=/opt/itksnap/lib/:${LD_LIBRARY_PATH} RUN apt-get update -y \ && apt-get install -y \ wget \ libglu1 \ libcurl4-openssl-dev \ libsm6 \ libxt6 \ libfreetype6 \ libxrender1 \ libfontconfig1 \ libglib2.0-0 \ libqt4-dev \ libgtk2.0-dev \ \ && wget -O itksnap.tar.gz 'https://sourceforge.net/projects/itk-snap/files/itk-snap/Nightly/itksnap-nightly-master-Linux-gcc64-qt4.tar.gz/download' \ \ && tar -zxf itksnap.tar.gz -C /opt/ \ && mv /opt/itksnap-*/ /opt/itksnap/ \ && rm itksnap.tar.gz \ && useradd -m -s /bin/bash itksnap USER itksnap COPY --chown=itksnap:itksnap UserPreferences.xml /home/itksnap/.itksnap.org/ITK-SNAP/ CMD ["itksnap"] ``` ### Build the image from Dockerfile :::info If you have Docker installed, you can try building this docker file now! Copy this file (or use the one from the github https://github.com/thomshaw92/TrainTrack_containers_2020/blob/master/2_build_itksnap_docker/Dockerfile) Save it as 'Dockerfile' in its own folder. ::: Run: ```=gherkin docker build ./folder ``` ### Use you new Docker image locally :::info This one is a little bit tricky because we are doing a graphical application. So I will show how it is done quickly and if you want to try it yourself ask the TAs or HelpDesk after this talk :) ::: Open Power Shell ```=gherkin docker run -it thomshaw92/itksnap bash export DISPLAY=(your display number) itksnap ``` ## 3) Using NeuroDocker :::info Sometimes, building your own docker container is too hard. So programs like NeuroDocker from the nice people at ReproNim can really help! We will be building this on HPC at UQ ::: ### Load the latest singularity ```=gherkin #!/usr/bin/env bash module load singularity/3.5.0 ``` ### Install neurodocker ```=gherkin pip install --user neurodocker pip install git+https://github.com/stebo85/neurodocker@add-itksnap ``` :::info We are using a pull request as our base install of neurodocker as it contains ITKSNAP ::: ### Define version and tool to be built ```=gherkin toolName='itksnap' toolVersion='3.8.0' buildDate=`date +%Y%m%d` imageName='itksnap' ``` ### Use NeuroDocker to generate singularity recipe ```=gherkin generate singularity \ --base ubuntu:16.04 \ --pkg-manager apt \ --${toolName} version=${toolVersion} \ --env DEPLOY_PATH=/opt/${toolName}-${toolVersion}/bin/ \ --entrypoint /opt/${toolName}-${toolVersion}/bin/itksnap \ --user=neuro \ > Singularity.itksnap ``` ### Build singularity container locally (WSL2) ```=gherkin sudo singularity build ${imageName}_${buildDate}.sif ./Singularity ``` OR if you don't have root access... ### Build Singularity remotely :::info Either go to https://github.com/singularityhub/singularityhub.github.io/wiki https://cloud.sylabs.io/builder ::: Or build online via the terminal ```=gherkin singularity remote login ``` :::info You will need to generate an API token, the instructions will appear on screen. ::: Then use ```=gherkin singularity build --remote ${imageName}_${buildDate}.sif ./Singularity.itksnap ``` ### Run your new Singularity image (in mobaxterm to use X11 server) ```=gherkin singularity exec itksnap_20200614.sif itksnap ``` ### Use software inside a container without changing your scripts https://github.com/thomshaw92/TrainTrack_containers_2020/blob/master/3_build_neurodocker/show_transparent_Singularity.md ## References and useful links Some useful websites: * Some useful resources for simple bash coding http://swcarpentry.github.io/shell-novice https://devhints.io/bash * BIDS data structure https://bids.neuroimaging.io/ * BIDSCoin for easy conversion of your DICOMs into BIDS format! https://github.com/Donders-Institute/bidscoin - We recommend using smux to compile and test code on compute nodes. - How to use smux: https://docs.massive.org.au/M3/slurm/interactive-jobs.html For more details, please see: https://docs.massive.org.au/M3/slurm/slurm-overview.html ## Shameless plug for our research > Longitudinal Automatic Segmentation of Hippocampus subfields using multi-contrast MRI :::info https://github.com/thomshaw92/LASHiS ::: ## FAQ and Feedback :::info **Need any help with a particular part?** Leave a comment! ::: ###### tags: `Docker` `Singularity` `Containers` `Data analysis` `OHBM` `BrainHack`

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully