├── 120908_nipype ├── Task 1.ipynb ├── Task 2.ipynb ├── Task 3.ipynb ├── Task 3.py └── talknotebooks │ ├── DataGrabber.ipynb │ ├── Task 1.ipynb │ ├── Untitled0.ipynb │ ├── Untitled1.ipynb │ └── Untitled2.ipynb ├── 170327-nipype ├── README.md ├── docker │ ├── Dockerfile.all │ ├── Dockerfile.base │ ├── Dockerfile.complete │ ├── Dockerfile.mindboggle │ └── Dockerfile.nofsspm ├── notebooks │ ├── basic-bids │ │ └── basic_data_input_bids.ipynb │ ├── intro-nipype │ │ └── hello-world.ipynb │ ├── new-workflows-and-interfaces │ │ ├── .gitignore │ │ ├── .solution_workflow │ │ ├── advanced_interfaces.ipynb │ │ ├── advanced_workflows.ipynb │ │ └── files │ │ │ ├── brainvolume.m │ │ │ ├── smoothflow_detailed.png │ │ │ └── transform.tfm │ ├── nibabel_nilearn │ │ ├── nibabel_nilearn.ipynb │ │ ├── plot-surfs.ipynb │ │ └── prep.ipynb │ ├── nipype_101_tasks │ │ └── Day4.ipynb │ ├── numpy-advanced │ │ ├── Makefile │ │ ├── css │ │ │ ├── exercises.css │ │ │ └── notebook.css │ │ ├── images │ │ │ ├── array_dtype.png │ │ │ ├── array_flat.png │ │ │ ├── array_flat.svg │ │ │ ├── array_flat_extended.png │ │ │ ├── array_flat_extended.svg │ │ │ ├── array_memory_dtype.png │ │ │ ├── array_memory_dtype.svg │ │ │ ├── array_memory_dtype_small.png │ │ │ ├── array_memory_presentation.png │ │ │ ├── array_memory_presentation.svg │ │ │ ├── array_memory_strides.png │ │ │ ├── array_memory_strides.svg │ │ │ ├── array_memory_strides_transpose.png │ │ │ ├── array_memory_strides_transpose.svg │ │ │ ├── array_reshape.png │ │ │ ├── array_reshape.svg │ │ │ ├── array_reshape_nd.png │ │ │ ├── array_reshape_nd.svg │ │ │ ├── array_transpose_question.png │ │ │ ├── array_transpose_question.svg │ │ │ ├── broadcast_1D.png │ │ │ ├── broadcast_2D.png │ │ │ ├── broadcast_3D.png │ │ │ ├── jack.png │ │ │ ├── ndarray_struct.png │ │ │ ├── ndarray_struct.svg │ │ │ ├── numpy.png │ │ │ ├── numpy.svg │ │ │ ├── overview.png │ │ │ └── radar_struct.png │ │ ├── load_style.py │ │ ├── numpy_advanced_py3.ipynb │ │ └── numpy_advanced_py3.slides.html │ ├── scientific-python │ │ ├── Titanic.csv │ │ └── scientific_python.ipynb │ └── testing │ │ ├── pytest_mark_solutions │ │ ├── maxima.py │ │ ├── random_numbers.py │ │ ├── sector_area.py │ │ ├── test_maxima_pytest.py │ │ ├── test_random_numbers.py │ │ └── test_sector_area_pytest.py │ │ ├── pytest_solutions │ │ ├── maxima.py │ │ ├── random_numbers.py │ │ ├── sector_area.py │ │ ├── test_maxima.py │ │ ├── test_random_numbers.py │ │ └── test_sector_area.py │ │ └── solutions │ │ ├── asserts.ipynb │ │ ├── maxima.ipynb │ │ ├── random_numbers.ipynb │ │ ├── sector_area.ipynb │ │ └── sector_area_general.ipynb └── startup.ipynb └── README.md /120908_nipype/Task 2.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "name": "Task 2" 4 | }, 5 | "nbformat": 3, 6 | "nbformat_minor": 0, 7 | "worksheets": [ 8 | { 9 | "cells": [ 10 | { 11 | "cell_type": "code", 12 | "collapsed": false, 13 | "input": [ 14 | "%pylab inline" 15 | ], 16 | "language": "python", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "output_type": "stream", 21 | "stream": "stdout", 22 | "text": [ 23 | "\n", 24 | "Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].\n", 25 | "For more information, type 'help(pylab)'.\n" 26 | ] 27 | } 28 | ], 29 | "prompt_number": 1 30 | }, 31 | { 32 | "cell_type": "code", 33 | "collapsed": false, 34 | "input": [ 35 | "from glob import glob\n", 36 | "from nipype.interfaces.dcm2nii import Dcm2nii\n", 37 | "from nipype.interfaces.fsl import BET\n", 38 | "\n", 39 | "import nipype.pipeline.engine as pe" 40 | ], 41 | "language": "python", 42 | "metadata": {}, 43 | "outputs": [], 44 | "prompt_number": 2 45 | }, 46 | { 47 | "cell_type": "code", 48 | "collapsed": false, 49 | "input": [ 50 | "convert = pe.Node(Dcm2nii(), name='convert_dicom')\n", 51 | "skull_stripper = pe.Node(BET(), name = 'skull_stripper')\n", 52 | "\n", 53 | "convert_flow = pe.Workflow(name = 'convert_and_strip')\n", 54 | "convert_flow.connect(convert, 'converted_files', skull_stripper, 'in_file')" 55 | ], 56 | "language": "python", 57 | "metadata": {}, 58 | "outputs": [], 59 | "prompt_number": 3 60 | }, 61 | { 62 | "cell_type": "code", 63 | "collapsed": false, 64 | "input": [ 65 | "fl = glob('/opt/data/NIPYPE_DATA/NKI.archive.1-5.007.LiteDICOM/3466763/session_1/MPRAGE_1/*.dcm')\n", 66 | "convert_flow.inputs.convert_dicom.source_names = fl[0] # or fl\n", 67 | "convert_flow.base_dir = '/mnt/mydir/'" 68 | ], 69 | "language": "python", 70 | "metadata": {}, 71 | "outputs": [], 72 | "prompt_number": 4 73 | }, 74 | { 75 | "cell_type": "code", 76 | "collapsed": false, 77 | "input": [ 78 | "convert_flow.run()" 79 | ], 80 | "language": "python", 81 | "metadata": {}, 82 | "outputs": [ 83 | { 84 | "output_type": "stream", 85 | "stream": "stdout", 86 | "text": [ 87 | "120909-06:56:28,132 workflow INFO:\n", 88 | "\t ['check', 'execution', 'logging']\n" 89 | ] 90 | }, 91 | { 92 | "output_type": "stream", 93 | "stream": "stdout", 94 | "text": [ 95 | "120909-06:56:28,136 workflow INFO:\n", 96 | "\t Running serially.\n" 97 | ] 98 | }, 99 | { 100 | "output_type": "stream", 101 | "stream": "stdout", 102 | "text": [ 103 | "120909-06:56:28,138 workflow INFO:\n", 104 | "\t Executing node convert_dicom in dir: /mnt/mydir/convert_and_strip/convert_dicom\n" 105 | ] 106 | }, 107 | { 108 | "output_type": "stream", 109 | "stream": "stdout", 110 | "text": [ 111 | "120909-06:56:28,151 workflow INFO:\n", 112 | "\t Running: dcm2nii -g n -n y -i n -o /mnt/mydir/convert_and_strip/convert_dicom -b config.ini /opt/data/NIPYPE_DATA/NKI.archive.1-5.007.LiteDICOM/3466763/session_1/MPRAGE_1/m000-s0155-defaced_MPRAGE.nii.dcm\n" 113 | ] 114 | }, 115 | { 116 | "output_type": "stream", 117 | "stream": "stdout", 118 | "text": [ 119 | "120909-06:56:28,192 interface INFO:\n", 120 | "\t stdout 2012-09-09T06:56:28.191981:Chris Rorden's dcm2nii :: 2 November 2010 (Debian)\n" 121 | ] 122 | }, 123 | { 124 | "output_type": "stream", 125 | "stream": "stdout", 126 | "text": [ 127 | "120909-06:56:28,194 interface INFO:\n", 128 | "\t stdout 2012-09-09T06:56:28.191981:reading preferences file /home/nipype_user/.dcm2nii/dcm2nii.ini\n" 129 | ] 130 | }, 131 | { 132 | "output_type": "stream", 133 | "stream": "stdout", 134 | "text": [ 135 | "120909-06:56:28,195 interface INFO:\n", 136 | "\t stdout 2012-09-09T06:56:28.191981:reading preferences file config.ini\n" 137 | ] 138 | }, 139 | { 140 | "output_type": "stream", 141 | "stream": "stdout", 142 | "text": [ 143 | "120909-06:56:28,196 interface INFO:\n", 144 | "\t stdout 2012-09-09T06:56:28.191981:Data will be exported to /mnt/mydir/convert_and_strip/convert_dicom/\n" 145 | ] 146 | }, 147 | { 148 | "output_type": "stream", 149 | "stream": "stdout", 150 | "text": [ 151 | "120909-06:56:29,45 interface INFO:\n", 152 | "\t stdout 2012-09-09T06:56:29.044975:Validating 384 potential DICOM images.\n" 153 | ] 154 | }, 155 | { 156 | "output_type": "stream", 157 | "stream": "stdout", 158 | "text": [ 159 | "120909-06:56:29,45 interface INFO:\n", 160 | "\t stdout 2012-09-09T06:56:29.044975:Found 192 DICOM images.\n" 161 | ] 162 | }, 163 | { 164 | "output_type": "stream", 165 | "stream": "stdout", 166 | "text": [ 167 | "120909-06:56:29,46 interface INFO:\n", 168 | "\t stdout 2012-09-09T06:56:29.044975:Converting 192/192 1\n" 169 | ] 170 | }, 171 | { 172 | "output_type": "stream", 173 | "stream": "stdout", 174 | "text": [ 175 | "120909-06:56:29,46 interface INFO:\n", 176 | "\t stdout 2012-09-09T06:56:29.044975:m000-s0001-defaced_MPRAGE.nii.dcm->18991230_010000MPRAGEs011a1001.nii\n" 177 | ] 178 | }, 179 | { 180 | "output_type": "stream", 181 | "stream": "stdout", 182 | "text": [ 183 | "120909-06:56:29,47 interface INFO:\n", 184 | "\t stdout 2012-09-09T06:56:29.044975:Saving /mnt/mydir/convert_and_strip/convert_dicom/18991230_010000MPRAGEs011a1001.nii\n" 185 | ] 186 | }, 187 | { 188 | "output_type": "stream", 189 | "stream": "stdout", 190 | "text": [ 191 | "120909-06:56:29,633 interface INFO:\n", 192 | "\t stdout 2012-09-09T06:56:29.633844:Reorienting as /mnt/mydir/convert_and_strip/convert_dicom/o18991230_010000MPRAGEs011a1001.nii\n" 193 | ] 194 | }, 195 | { 196 | "output_type": "stream", 197 | "stream": "stdout", 198 | "text": [ 199 | "120909-06:56:29,634 interface INFO:\n", 200 | "\t stdout 2012-09-09T06:56:29.633844:Saving /mnt/mydir/convert_and_strip/convert_dicom/o18991230_010000MPRAGEs011a1001.nii\n" 201 | ] 202 | }, 203 | { 204 | "output_type": "stream", 205 | "stream": "stdout", 206 | "text": [ 207 | "120909-06:56:29,635 interface INFO:\n", 208 | "\t stdout 2012-09-09T06:56:29.633844:Cropping NIfTI/Analyze image /mnt/mydir/convert_and_strip/convert_dicom/o18991230_010000MPRAGEs011a1001.nii\n" 209 | ] 210 | }, 211 | { 212 | "output_type": "stream", 213 | "stream": "stdout", 214 | "text": [ 215 | "120909-06:56:29,668 interface INFO:\n", 216 | "\t stdout 2012-09-09T06:56:29.668688:Saving /mnt/mydir/convert_and_strip/convert_dicom/co18991230_010000MPRAGEs011a1001.nii\n" 217 | ] 218 | }, 219 | { 220 | "output_type": "stream", 221 | "stream": "stdout", 222 | "text": [ 223 | "120909-06:56:29,711 workflow INFO:\n", 224 | "\t Executing node skull_stripper in dir: /mnt/mydir/convert_and_strip/skull_stripper\n" 225 | ] 226 | }, 227 | { 228 | "output_type": "stream", 229 | "stream": "stdout", 230 | "text": [ 231 | "120909-06:56:29,718 workflow INFO:\n", 232 | "\t Running: bet /mnt/mydir/convert_and_strip/convert_dicom/18991230_010000MPRAGEs011a1001.nii /mnt/mydir/convert_and_strip/skull_stripper/18991230_010000MPRAGEs011a1001_brain.nii.gz\n" 233 | ] 234 | }, 235 | { 236 | "output_type": "pyout", 237 | "prompt_number": 5, 238 | "text": [ 239 | "" 240 | ] 241 | } 242 | ], 243 | "prompt_number": 5 244 | }, 245 | { 246 | "cell_type": "code", 247 | "collapsed": false, 248 | "input": [], 249 | "language": "python", 250 | "metadata": {}, 251 | "outputs": [], 252 | "prompt_number": 5 253 | } 254 | ], 255 | "metadata": {} 256 | } 257 | ] 258 | } -------------------------------------------------------------------------------- /120908_nipype/Task 3.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3.0 3 | 4 | # 5 | 6 | # ## Convert two DTI images and run DTIFit 7 | 8 | # 9 | 10 | from glob import glob 11 | from nipype.interfaces.dcm2nii import Dcm2nii 12 | from nipype.interfaces.fsl import DTIFit, BET 13 | 14 | import nipype.pipeline.engine as pe 15 | 16 | # 17 | 18 | 19 | # ### Version 2: Mapnodes 20 | 21 | # 22 | 23 | convert = pe.MapNode(Dcm2nii(), name='convert_dicom', iterfield=['source_names']) 24 | skull_stripper = pe.MapNode(BET(mask=True), name = 'skull_stripper', iterfield=['in_file']) 25 | dtifit = pe.MapNode(DTIFit(), name = 'dtifit', iterfield=['dwi','bvals', 'bvecs','mask']) 26 | 27 | convert_flow = pe.Workflow(name = 'convert_and_fit_mapnode') 28 | convert_flow.connect([(convert, dtifit, [('converted_files', 'dwi'), 29 | ('bvals', 'bvals'), 30 | ('bvecs', 'bvecs')]), 31 | (convert, skull_stripper, [('converted_files', 'in_file')]), 32 | (skull_stripper, dtifit, [('mask_file', 'mask')]) 33 | ]) 34 | 35 | # 36 | 37 | fl = glob('/opt/data/NIPYPE_DATA/2475376/session*/DTI_mx_137/*-0001.dcm') 38 | convert_flow.inputs.convert_dicom.source_names = fl 39 | convert_flow.base_dir = '/mnt/mydir/' 40 | 41 | # 42 | 43 | from nipype.interfaces.io import DataGrabber, DataSink 44 | 45 | # 46 | 47 | dg = pe.Node(DataGrabber(infields=['subject_id', 'session'], outfields=['diffusion']), 48 | name = 'datasource') 49 | dg.inputs.base_directory = '/opt/data/NIPYPE_DATA/' 50 | dg.inputs.template = '%s/session%d/DTI*/*-0001.dcm' 51 | dg.inputs.subject_id = '2475376' 52 | dg.inputs.session = [1, 2] 53 | 54 | # 55 | 56 | convert_flow.connect(dg, 'diffusion', convert, 'source_names') 57 | 58 | # 59 | 60 | ds = pe.Node(DataSink(), name='sinker') 61 | ds.inputs.base_directory = '/mnt/mydir/outputs' 62 | convert_flow.connect(skull_stripper, 'mask_file', ds, 'mask') 63 | convert_flow.connect(dtifit, 'FA', ds, 'dti.@FA') 64 | convert_flow.connect(dtifit, 'MD', ds, 'dti.@MD') 65 | 66 | # 67 | 68 | dg.iterables = ('subject_id', ['2475376', '3313349', '9630905']) 69 | 70 | # 71 | 72 | eg = convert_flow.run(plugin='MultiProc', plugin_args={'n_procs': 2}) 73 | 74 | # 75 | 76 | 77 | -------------------------------------------------------------------------------- /120908_nipype/talknotebooks/DataGrabber.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "name": "DataGrabber" 4 | }, 5 | "nbformat": 3, 6 | "nbformat_minor": 0, 7 | "worksheets": [ 8 | { 9 | "cells": [ 10 | { 11 | "cell_type": "code", 12 | "collapsed": false, 13 | "input": [ 14 | "%pylab inline" 15 | ], 16 | "language": "python", 17 | "metadata": {}, 18 | "outputs": [ 19 | { 20 | "output_type": "stream", 21 | "stream": "stdout", 22 | "text": [ 23 | "\n", 24 | "Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].\n", 25 | "For more information, type 'help(pylab)'.\n" 26 | ] 27 | } 28 | ], 29 | "prompt_number": 1 30 | }, 31 | { 32 | "cell_type": "code", 33 | "collapsed": false, 34 | "input": [ 35 | "from nipype.interfaces.io import DataGrabber" 36 | ], 37 | "language": "python", 38 | "metadata": {}, 39 | "outputs": [], 40 | "prompt_number": 2 41 | }, 42 | { 43 | "cell_type": "code", 44 | "collapsed": false, 45 | "input": [ 46 | "DataGrabber.help()" 47 | ], 48 | "language": "python", 49 | "metadata": {}, 50 | "outputs": [ 51 | { 52 | "output_type": "stream", 53 | "stream": "stdout", 54 | "text": [ 55 | "Generic datagrabber module that wraps around glob in an\n", 56 | "intelligent way for neuroimaging tasks to grab files\n", 57 | "\n", 58 | "\n", 59 | ".. attention::\n", 60 | "\n", 61 | " Doesn't support directories currently\n", 62 | "\n", 63 | "Examples\n", 64 | "--------\n", 65 | "\n", 66 | ">>> from nipype.interfaces.io import DataGrabber\n", 67 | "\n", 68 | "Pick all files from current directory\n", 69 | "\n", 70 | ">>> dg = DataGrabber()\n", 71 | ">>> dg.inputs.template = '*'\n", 72 | "\n", 73 | "Pick file foo/foo.nii from current directory\n", 74 | "\n", 75 | ">>> dg.inputs.template = '%s/%s.dcm'\n", 76 | ">>> dg.inputs.template_args['outfiles']=[['dicomdir','123456-1-1.dcm']]\n", 77 | "\n", 78 | "Same thing but with dynamically created fields\n", 79 | "\n", 80 | ">>> dg = DataGrabber(infields=['arg1','arg2'])\n", 81 | ">>> dg.inputs.template = '%s/%s.nii'\n", 82 | ">>> dg.inputs.arg1 = 'foo'\n", 83 | ">>> dg.inputs.arg2 = 'foo'\n", 84 | "\n", 85 | "however this latter form can be used with iterables and iterfield in a\n", 86 | "pipeline.\n", 87 | "\n", 88 | "Dynamically created, user-defined input and output fields\n", 89 | "\n", 90 | ">>> dg = DataGrabber(infields=['sid'], outfields=['func','struct','ref'])\n", 91 | ">>> dg.inputs.base_directory = '.'\n", 92 | ">>> dg.inputs.template = '%s/%s.nii'\n", 93 | ">>> dg.inputs.template_args['func'] = [['sid',['f3','f5']]]\n", 94 | ">>> dg.inputs.template_args['struct'] = [['sid',['struct']]]\n", 95 | ">>> dg.inputs.template_args['ref'] = [['sid','ref']]\n", 96 | ">>> dg.inputs.sid = 's1'\n", 97 | "\n", 98 | "Change the template only for output field struct. The rest use the\n", 99 | "general template\n", 100 | "\n", 101 | ">>> dg.inputs.field_template = dict(struct='%s/struct.nii')\n", 102 | ">>> dg.inputs.template_args['struct'] = [['sid']]\n", 103 | "\n", 104 | "Inputs::\n", 105 | "\n", 106 | "\t[Mandatory]\n", 107 | "\ttemplate: (a string)\n", 108 | "\t\tLayout used to get files. relative to base directory if defined\n", 109 | "\n", 110 | "\t[Optional]\n", 111 | "\tbase_directory: (an existing directory name)\n", 112 | "\t\tPath to the base directory consisting of subject data.\n", 113 | "\tignore_exception: (a boolean, nipype default value: False)\n", 114 | "\t\tPrint an error message instead of throwing an exception in case the interface fails to\n", 115 | "\t\trun\n", 116 | "\traise_on_empty: (a boolean, nipype default value: True)\n", 117 | "\t\tGenerate exception if list is empty for a given field\n", 118 | "\tsort_filelist: (a boolean, nipype default value: False)\n", 119 | "\t\tSort the filelist that matches the template\n", 120 | "\ttemplate_args: (a dictionary with keys which are a string and with values which are a\n", 121 | "\t\t list of items which are a list of items which are any value)\n", 122 | "\t\tInformation to plug into template\n", 123 | "\n", 124 | "Outputs::\n", 125 | "\n", 126 | "\tNone\n", 127 | "\n" 128 | ] 129 | } 130 | ], 131 | "prompt_number": 4 132 | }, 133 | { 134 | "cell_type": "code", 135 | "collapsed": false, 136 | "input": [], 137 | "language": "python", 138 | "metadata": {}, 139 | "outputs": [] 140 | } 141 | ], 142 | "metadata": {} 143 | } 144 | ] 145 | } -------------------------------------------------------------------------------- /120908_nipype/talknotebooks/Untitled0.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "metadata": { 3 | "name": "Untitled0" 4 | }, 5 | "nbformat": 3, 6 | "nbformat_minor": 0, 7 | "worksheets": [] 8 | } -------------------------------------------------------------------------------- /170327-nipype/README.md: -------------------------------------------------------------------------------- 1 | ## Executable pieces (notebooks, scripts, etc.,.) 2 | 3 | Use this directory to store any notebooks or other scripts needed for lessons. Recommend creating a directory per lesson. Simply give your lesson a meaningful name: 4 | `lesson-git`, `lesson-nibabel`, `lesson-container` 5 | 6 | ## Presentations 7 | 8 | Send a pull-request to the [gh-pages branch](https://github.com/nipy/workshops/tree/gh-pages). We will use a few simple markdown templates for web pages and slides. You can also render your jupyter notebooks as slides to include in the workshop documentation. 9 | -------------------------------------------------------------------------------- /170327-nipype/docker/Dockerfile.all: -------------------------------------------------------------------------------- 1 | FROM nipype/workshops:latest-base 2 | MAINTAINER Satrajit Ghosh 3 | 4 | #----------------------------------- 5 | # Install octave FSL from repository 6 | #----------------------------------- 7 | USER root 8 | RUN apt-get update -qq && apt-get install -yq --no-install-recommends \ 9 | octave \ 10 | fsl-core fsl-mni152-templates fsl-atlases fsl-5.0-eddy-nonfree && \ 11 | apt-get clean && \ 12 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ 13 | ln -s /usr/bin/octave /usr/bin/matlab && \ 14 | chown $NB_USER /opt 15 | ENV FSLDIR=/usr/share/fsl/5.0 \ 16 | FSLOUTPUTTYPE=NIFTI_GZ \ 17 | FSLMULTIFILEQUIT=TRUE \ 18 | POSSUMDIR=/usr/share/fsl/5.0 \ 19 | LD_LIBRARY_PATH=/usr/lib/fsl/5.0:$LD_LIBRARY_PATH \ 20 | FSLTCLSH=/usr/bin/tclsh \ 21 | FSLWISH=/usr/bin/wish \ 22 | PATH=/usr/lib/fsl/5.0:$PATH 23 | 24 | #----------------- 25 | # Install dcm2niix 26 | #----------------- 27 | USER root 28 | RUN apt-get update -qq && apt-get install -yq --no-install-recommends \ 29 | build-essential && \ 30 | apt-get clean && \ 31 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 32 | USER $NB_USER 33 | WORKDIR /tmp 34 | RUN git clone https://github.com/neurolabusc/dcm2niix.git && \ 35 | cd dcm2niix/console/ && \ 36 | git checkout b3c146bc49e1bcb1bd91f786523b7bd5740787fc && \ 37 | g++ -O3 -I. main_console.cpp nii_dicom.cpp jpg_0XC3.cpp ujpeg.cpp \ 38 | nifti1_io_core.cpp nii_ortho.cpp nii_dicom_batch.cpp \ 39 | -o dcm2niix -DmyDisableOpenJPEG -DmyDisableJasper && \ 40 | mkdir -p /opt/bin && cp dcm2niix /opt/bin/ && \ 41 | cd /tmp && rm -rf dcm2niix 42 | 43 | #------------- 44 | # Install ANTS 45 | #------------- 46 | # USER root 47 | # RUN apt-get update -qq && apt-get install -yq --no-install-recommends \ 48 | # build-essential && \ 49 | # apt-get clean && \ 50 | # rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 51 | # USER $NB_USER 52 | # WORKDIR /tmp 53 | # RUN git clone https://github.com/stnava/ANTs.git && \ 54 | # cd ANTs && \ 55 | # git checkout 767f756bc0e423cd503a24c806b6578aaeb5b82f && \ 56 | # mkdir build && cd build && cmake .. && make && \ 57 | # mkdir -p /opt/ants && \ 58 | # cp bin/* /opt/ants && cp ../Scripts/* /opt/ants && \ 59 | # cd /tmp && rm -rf ANTs 60 | RUN curl -sSL https://dl.dropbox.com/s/btep51gtglp7kwh/ants.tgz?dl=0 | tar zx -C / 61 | ENV ANTSPATH=/opt/ants/ \ 62 | PATH=/opt/ants:$PATH 63 | 64 | #------------ 65 | # Install c3d 66 | #------------ 67 | RUN mkdir -p /opt/c3d && \ 68 | curl -sSL "http://downloads.sourceforge.net/project/c3d/c3d/1.0.0/c3d-1.0.0-Linux-x86_64.tar.gz" \ 69 | | tar -xzC /opt/c3d --strip-components 1 70 | ENV C3DPATH=/opt/c3d \ 71 | PATH=/opt/c3d/bin:$PATH 72 | 73 | #------------------- 74 | # Install FreeSurfer 75 | #------------------- 76 | RUN curl -sSL https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.0/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tar.gz | tar zx -C /opt \ 77 | --exclude='freesurfer/trctrain' \ 78 | --exclude='freesurfer/subjects/fsaverage_sym' \ 79 | --exclude='freesurfer/subjects/fsaverage3' \ 80 | --exclude='freesurfer/subjects/fsaverage4' \ 81 | --exclude='freesurfer/subjects/fsaverage5' \ 82 | --exclude='freesurfer/subjects/fsaverage6' \ 83 | --exclude='freesurfer/subjects/cvs_avg35' \ 84 | --exclude='freesurfer/subjects/cvs_avg35_inMNI152' \ 85 | --exclude='freesurfer/subjects/bert' \ 86 | --exclude='freesurfer/subjects/V1_average' \ 87 | --exclude='freesurfer/average/mult-comp-cor' \ 88 | --exclude='freesurfer/lib/cuda' \ 89 | --exclude='freesurfer/lib/qt' && \ 90 | ( echo "cHJpbnRmICJrcnp5c3p0b2YuZ29yZ29sZXdza2lAZ21haWwuY29tXG41MTcyXG4gKkN2dW12RVYzelRmZ1xuRlM1Si8yYzFhZ2c0RVxuIiA+IC9vcHQvZnJlZXN1cmZlci9saWNlbnNlLnR4dAo=" | base64 -d | sh ) 91 | ENV FSL_DIR=/usr/share/fsl/5.0 \ 92 | OS=Linux \ 93 | FS_OVERRIDE=0 \ 94 | FIX_VERTEX_AREA= \ 95 | FSF_OUTPUT_FORMAT=nii.gz \ 96 | FREESURFER_HOME=/opt/freesurfer 97 | ENV SUBJECTS_DIR=$FREESURFER_HOME/subjects \ 98 | FUNCTIONALS_DIR=$FREESURFER_HOME/sessions \ 99 | MNI_DIR=$FREESURFER_HOME/mni \ 100 | LOCAL_DIR=$FREESURFER_HOME/local \ 101 | FSFAST_HOME=$FREESURFER_HOME/fsfast \ 102 | MINC_BIN_DIR=$FREESURFER_HOME/mni/bin \ 103 | MINC_LIB_DIR=$FREESURFER_HOME/mni/lib \ 104 | MNI_DATAPATH=$FREESURFER_HOME/mni/data \ 105 | FMRI_ANALYSIS_DIR=$FREESURFER_HOME/fsfast 106 | ENV PERL5LIB=$MINC_LIB_DIR/perl5/5.8.5 \ 107 | MNI_PERL5LIB=$MINC_LIB_DIR/perl5/5.8.5 \ 108 | PATH=$FREESURFER_HOME/bin:$FSFAST_HOME/bin:$FREESURFER_HOME/tktools:$MINC_BIN_DIR:$PATH 109 | 110 | #------------------- 111 | # Install Matlab MCR 112 | #------------------- 113 | USER root 114 | WORKDIR /opt 115 | RUN echo "destinationFolder=/opt/mcr" > mcr_options.txt && \ 116 | echo "agreeToLicense=yes" >> mcr_options.txt && \ 117 | echo "outputFile=/tmp/matlabinstall_log" >> mcr_options.txt && \ 118 | echo "mode=silent" >> mcr_options.txt && \ 119 | mkdir -p matlab_installer && \ 120 | curl -sSL https://www.mathworks.com/supportfiles/downloads/R2017a/deployment_files/R2017a/installers/glnxa64/MCR_R2017a_glnxa64_installer.zip \ 121 | -o matlab_installer/installer.zip && \ 122 | unzip matlab_installer/installer.zip -d matlab_installer/ && \ 123 | matlab_installer/install -inputFile /opt/mcr_options.txt && \ 124 | rm -rf matlab_installer mcr_options.txt 125 | 126 | #------------ 127 | # Install SPM 128 | #------------ 129 | user $NB_USER 130 | RUN curl -sSL http://www.fil.ion.ucl.ac.uk/spm/download/restricted/utopia/dev/spm12_latest_Linux_R2017a.zip -o spm12.zip && \ 131 | unzip spm12.zip && \ 132 | rm -rf spm12.zip 133 | 134 | ENV MATLABCMD="/opt/mcr/v92/toolbox/matlab" \ 135 | SPMMCRCMD="/opt/spm12/run_spm12.sh /opt/mcr/v92/ script" \ 136 | FORCE_SPMMCR=1 \ 137 | LD_LIBRARY_PATH=/opt/mcr/v92/runtime/glnxa64:/opt/mcr/v92/bin/glnxa64:/opt/mcr/v92/sys/os/glnxa64:$LD_LIBRARY_PATH 138 | 139 | #------------- 140 | # Install afni 141 | #------------- 142 | USER root 143 | RUN apt-get update -qq && apt-get install -yq --no-install-recommends \ 144 | libxp6 && \ 145 | apt-get clean && \ 146 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 147 | USER $NB_USER 148 | WORKDIR /opt 149 | RUN curl -sSLO https://afni.nimh.nih.gov/pub/dist/tgz/linux_openmp_64.tgz && \ 150 | tar zxf linux_openmp_64.tgz && rm linux_openmp_64.tgz && \ 151 | mv linux_openmp_64 afni 152 | ENV AFNI_MODELPATH=/opt/afni/ \ 153 | AFNI_IMSAVE_WARNINGS=NO \ 154 | AFNI_TTATLAS_DATASET=/opt/afni \ 155 | AFNI_PLUGINPATH=/opt/afni \ 156 | PATH=/opt/afni:$PATH 157 | 158 | #------------------- 159 | # Install mindboggle 160 | #------------------- 161 | USER root 162 | RUN apt-get update -qq && apt-get install -yq --no-install-recommends \ 163 | build-essential libsm-dev libx11-dev libxt-dev libxext-dev && \ 164 | apt-get clean && \ 165 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 166 | USER $NB_USER 167 | RUN conda install --quiet --yes cmake && \ 168 | conda clean -tipsy 169 | WORKDIR /tmp 170 | RUN git clone https://github.com/nipy/mindboggle && \ 171 | cd mindboggle && git checkout cb37b8fa3b2bd1b272cb932e7f15c3ec110cb5d7 && \ 172 | python setup.py install && \ 173 | mkdir /opt/mindboggle && mkdir /opt/mindboggle/vtk_cpp_tools && \ 174 | cd /opt/mindboggle/vtk_cpp_tools && \ 175 | cmake /tmp/mindboggle/vtk_cpp_tools -DCMAKE_EXE_LINKER_FLAGS="-L /opt/conda/lib" && \ 176 | make && cd .. && rm -rf /tmp/mindboggle && \ 177 | curl -sSL https://osf.io/rh9km/?action=download\&version=2 -o templates.zip && \ 178 | unzip templates.zip && rm -rf templates.zip __MACOSX 179 | ENV vtk_cpp_tools=/opt/mindboggle/vtk_cpp_tools 180 | 181 | #------------- 182 | # Install PALM 183 | #------------- 184 | WORKDIR /opt 185 | RUN git clone https://github.com/andersonwinkler/PALM.git && \ 186 | chmod +x /opt/PALM/palm 187 | ENV PATH=/opt/PALM:$PATH 188 | 189 | #---------------------------------------- 190 | # Clear apt cache and other empty folders 191 | #---------------------------------------- 192 | USER root 193 | RUN apt-get clean && apt-get autoremove -y && \ 194 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /boot /media /mnt /srv && \ 195 | chmod a+w /tmp 196 | 197 | WORKDIR /home/$NB_USER/work 198 | USER $NB_USER 199 | -------------------------------------------------------------------------------- /170327-nipype/docker/Dockerfile.base: -------------------------------------------------------------------------------- 1 | # This Dockerfile was based off: https://github.com/miykael/nipype_env/level0 2 | # Changes include working with Python 3 and updates to base package layer 3 | 4 | FROM jupyter/base-notebook 5 | MAINTAINER Satrajit Ghosh 6 | 7 | #--------------------------------------------- 8 | # Update OS dependencies and setup neurodebian 9 | #--------------------------------------------- 10 | USER root 11 | RUN apt-get update -qq && apt-get install -yq --no-install-recommends bzip2 \ 12 | ca-certificates \ 13 | curl \ 14 | tree \ 15 | unzip \ 16 | wget \ 17 | xvfb \ 18 | zip \ 19 | vim \ 20 | emacs-nox \ 21 | graphviz \ 22 | less && \ 23 | apt-get clean && \ 24 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 25 | 26 | ENV NEURODEBIAN_URL http://neuro.debian.net/lists/jessie.de-md.full 27 | RUN curl -sSL $NEURODEBIAN_URL | sudo tee /etc/apt/sources.list.d/neurodebian.sources.list && \ 28 | ( apt-key adv --recv-keys --keyserver pgp.mit.edu 2649A5A9 || \ 29 | { wget -q -O- http://neuro.debian.net/_static/neuro.debian.net.asc | apt-key add -; } ) && \ 30 | apt-get update -qq && apt-get install -yq --no-install-recommends \ 31 | git-annex-standalone && \ 32 | apt-get clean && \ 33 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 34 | 35 | 36 | #------------------------------------------------- 37 | # Update and install conda dependencies for nipype 38 | #------------------------------------------------- 39 | USER $NB_USER 40 | 41 | # Make sure that necessary packages are installed 42 | RUN conda install --quiet --yes -c clinicalgraphics vtk=7.1.0 && \ 43 | conda install --quiet --yes nomkl \ 44 | matplotlib \ 45 | pandas \ 46 | pip \ 47 | scikit-image \ 48 | seaborn \ 49 | cython \ 50 | dipy \ 51 | nilearn \ 52 | reprozip \ 53 | reprounzip \ 54 | prov \ 55 | pycrypto \ 56 | cryptography \ 57 | boto \ 58 | pytest \ 59 | pythreejs \ 60 | bqplot \ 61 | mayavi \ 62 | docutils \ 63 | xvfbwrapper && \ 64 | conda update --quiet --yes icu && \ 65 | conda clean -tipsy && \ 66 | jupyter nbextension enable --py --sys-prefix widgetsnbextension && \ 67 | jupyter nbextension enable --py --sys-prefix pythreejs && \ 68 | jupyter nbextension enable --py --sys-prefix bqplot 69 | 70 | # Import matplotlib the first time to build the font cache. 71 | ENV XDG_CACHE_HOME /home/$NB_USER/.cache/ 72 | RUN MPLBACKEND=Agg $CONDA_DIR/bin/python -c "import matplotlib.pyplot" 73 | 74 | #------------------------------------------------------------------- 75 | # Update pip, nibabel (for Cifti) and nilearn (for surface plotting) 76 | #------------------------------------------------------------------- 77 | RUN pip install --upgrade --quiet pip && \ 78 | pip install --upgrade --quiet nipy && \ 79 | pip install --upgrade --quiet pydicom && \ 80 | pip install --quiet datalad pybids==0.1 && \ 81 | pip install --upgrade --quiet matplotlib --upgrade-strategy only-if-needed && \ 82 | pip install --quiet https://github.com/nipy/nibabel/archive/ca977abeb77f95ed3a40b7b89c310b286b9885b7.zip \ 83 | https://github.com/nilearn/nilearn/archive/87c12efe14c005f1c916f76358639b55a306fb06.zip && \ 84 | rm -rf ~/.cache/pip 85 | 86 | #--------------------------------------------- 87 | # Install newest version of nipype from Github 88 | #--------------------------------------------- 89 | RUN pip install --quiet https://github.com/nipy/nipype/archive/master.zip && \ 90 | rm -rf ~/.cache/pip 91 | 92 | #---------------------------------------- 93 | # Clear apt cache and other empty folders 94 | #---------------------------------------- 95 | USER root 96 | RUN apt-get clean && \ 97 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /boot /media /mnt /srv && \ 98 | chmod a+w /tmp && ln -s /home/$NB_USER/work/data /data 99 | 100 | USER $NB_USER 101 | -------------------------------------------------------------------------------- /170327-nipype/docker/Dockerfile.complete: -------------------------------------------------------------------------------- 1 | FROM nipype/workshops:latest-nofsspm 2 | MAINTAINER Satrajit Ghosh 3 | 4 | #------------------- 5 | # Install FreeSurfer 6 | #------------------- 7 | RUN curl -sSL https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.0/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tar.gz | tar zx -C /opt \ 8 | --exclude='freesurfer/trctrain' \ 9 | --exclude='freesurfer/subjects/fsaverage_sym' \ 10 | --exclude='freesurfer/subjects/fsaverage3' \ 11 | --exclude='freesurfer/subjects/fsaverage4' \ 12 | --exclude='freesurfer/subjects/fsaverage5' \ 13 | --exclude='freesurfer/subjects/fsaverage6' \ 14 | --exclude='freesurfer/subjects/cvs_avg35' \ 15 | --exclude='freesurfer/subjects/cvs_avg35_inMNI152' \ 16 | --exclude='freesurfer/subjects/bert' \ 17 | --exclude='freesurfer/subjects/V1_average' \ 18 | --exclude='freesurfer/average/mult-comp-cor' \ 19 | --exclude='freesurfer/lib/cuda' \ 20 | --exclude='freesurfer/lib/qt' && \ 21 | ( echo "cHJpbnRmICJrcnp5c3p0b2YuZ29yZ29sZXdza2lAZ21haWwuY29tXG41MTcyXG4gKkN2dW12RVYzelRmZ1xuRlM1Si8yYzFhZ2c0RVxuIiA+IC9vcHQvZnJlZXN1cmZlci9saWNlbnNlLnR4dAo=" | base64 -d | sh ) 22 | ENV FSL_DIR=/usr/share/fsl/5.0 \ 23 | OS=Linux \ 24 | FS_OVERRIDE=0 \ 25 | FIX_VERTEX_AREA= \ 26 | FSF_OUTPUT_FORMAT=nii.gz \ 27 | FREESURFER_HOME=/opt/freesurfer 28 | ENV SUBJECTS_DIR=$FREESURFER_HOME/subjects \ 29 | FUNCTIONALS_DIR=$FREESURFER_HOME/sessions \ 30 | MNI_DIR=$FREESURFER_HOME/mni \ 31 | LOCAL_DIR=$FREESURFER_HOME/local \ 32 | FSFAST_HOME=$FREESURFER_HOME/fsfast \ 33 | MINC_BIN_DIR=$FREESURFER_HOME/mni/bin \ 34 | MINC_LIB_DIR=$FREESURFER_HOME/mni/lib \ 35 | MNI_DATAPATH=$FREESURFER_HOME/mni/data \ 36 | FMRI_ANALYSIS_DIR=$FREESURFER_HOME/fsfast 37 | ENV PERL5LIB=$MINC_LIB_DIR/perl5/5.8.5 \ 38 | MNI_PERL5LIB=$MINC_LIB_DIR/perl5/5.8.5 \ 39 | PATH=$FREESURFER_HOME/bin:$FSFAST_HOME/bin:$FREESURFER_HOME/tktools:$MINC_BIN_DIR:$PATH 40 | 41 | #------------------- 42 | # Install Matlab MCR 43 | #------------------- 44 | USER root 45 | WORKDIR /opt 46 | RUN echo "destinationFolder=/opt/mcr" > mcr_options.txt && \ 47 | echo "agreeToLicense=yes" >> mcr_options.txt && \ 48 | echo "outputFile=/tmp/matlabinstall_log" >> mcr_options.txt && \ 49 | echo "mode=silent" >> mcr_options.txt && \ 50 | mkdir -p matlab_installer && \ 51 | curl -sSL https://www.mathworks.com/supportfiles/downloads/R2017a/deployment_files/R2017a/installers/glnxa64/MCR_R2017a_glnxa64_installer.zip \ 52 | -o matlab_installer/installer.zip && \ 53 | unzip matlab_installer/installer.zip -d matlab_installer/ && \ 54 | matlab_installer/install -inputFile /opt/mcr_options.txt && \ 55 | rm -rf matlab_installer mcr_options.txt 56 | 57 | #------------ 58 | # Install SPM 59 | #------------ 60 | user $NB_USER 61 | RUN curl -sSL http://www.fil.ion.ucl.ac.uk/spm/download/restricted/utopia/dev/spm12_latest_Linux_R2017a.zip -o spm12.zip && \ 62 | unzip spm12.zip && \ 63 | rm -rf spm12.zip 64 | 65 | ENV MATLABCMD="/opt/mcr/v92/toolbox/matlab" \ 66 | SPMMCRCMD="/opt/spm12/run_spm12.sh /opt/mcr/v92/ script" \ 67 | FORCE_SPMMCR=1 \ 68 | LD_LIBRARY_PATH=/opt/mcr/v92/runtime/glnxa64:/opt/mcr/v92/bin/glnxa64:/opt/mcr/v92/sys/os/glnxa64:$LD_LIBRARY_PATH 69 | 70 | #---------------------------------------- 71 | # Clear apt cache and other empty folders 72 | #---------------------------------------- 73 | USER root 74 | RUN apt-get update -qq && apt-get install -yq --no-install-recommends \ 75 | man && \ 76 | apt-get clean && apt-get autoremove -y && \ 77 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /boot /media /mnt /srv && \ 78 | chmod a+w /tmp 79 | 80 | WORKDIR /home/$NB_USER/work 81 | USER $NB_USER 82 | -------------------------------------------------------------------------------- /170327-nipype/docker/Dockerfile.mindboggle: -------------------------------------------------------------------------------- 1 | FROM jupyter/base-notebook 2 | MAINTAINER Satrajit Ghosh 3 | 4 | #--------------------------------------------- 5 | # Update OS dependencies and setup neurodebian 6 | #--------------------------------------------- 7 | USER root 8 | RUN apt-get update -qq && apt-get install -yq --no-install-recommends bzip2 \ 9 | ca-certificates \ 10 | curl \ 11 | tree \ 12 | unzip \ 13 | wget \ 14 | xvfb \ 15 | zip \ 16 | vim \ 17 | emacs-nox \ 18 | graphviz \ 19 | less \ 20 | git && \ 21 | apt-get clean && \ 22 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 23 | 24 | #------------------------------------------------- 25 | # Update and install conda dependencies for nipype 26 | #------------------------------------------------- 27 | USER $NB_USER 28 | 29 | # Make sure that necessary packages are installed 30 | RUN conda install --quiet --yes nomkl \ 31 | matplotlib \ 32 | pandas \ 33 | pip \ 34 | seaborn \ 35 | reprozip \ 36 | reprounzip \ 37 | prov \ 38 | pytest \ 39 | pythreejs \ 40 | traits \ 41 | docutils \ 42 | xvfbwrapper && \ 43 | conda install --quiet --yes -c clinicalgraphics vtk=7.1.0 && \ 44 | conda clean -tipsy && \ 45 | jupyter nbextension enable --py --sys-prefix widgetsnbextension && \ 46 | jupyter nbextension enable --py --sys-prefix pythreejs 47 | 48 | # Import matplotlib the first time to build the font cache. 49 | ENV XDG_CACHE_HOME /home/$NB_USER/.cache/ 50 | RUN MPLBACKEND=Agg $CONDA_DIR/bin/python -c "import matplotlib.pyplot" 51 | 52 | #------------------------------------------------------------------- 53 | # Update pip, nibabel (for Cifti) and nilearn (for surface plotting) 54 | #------------------------------------------------------------------- 55 | RUN pip install --upgrade --quiet pip && \ 56 | pip install --quiet pybids==0.1 && \ 57 | pip install --upgrade --quiet matplotlib --upgrade-strategy only-if-needed && \ 58 | pip install --quiet https://github.com/nipy/nibabel/archive/ca977abeb77f95ed3a40b7b89c310b286b9885b7.zip && \ 59 | rm -rf ~/.cache/pip 60 | 61 | #--------------------------------------------- 62 | # Install newest version of nipype from Github 63 | #--------------------------------------------- 64 | RUN pip install --quiet https://github.com/nipy/nipype/archive/master.zip && \ 65 | rm -rf ~/.cache/pip 66 | 67 | #------------------- 68 | # Install mindboggle 69 | #------------------- 70 | USER root 71 | RUN apt-get update -qq && apt-get install -yq --no-install-recommends \ 72 | build-essential libsm-dev libx11-dev libxt-dev libxext-dev && \ 73 | apt-get clean && \ 74 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 75 | RUN chown $NB_USER /opt 76 | USER $NB_USER 77 | RUN conda install --quiet --yes cmake && \ 78 | conda clean -tipsy 79 | WORKDIR /tmp 80 | RUN git clone https://github.com/nipy/mindboggle && \ 81 | cd mindboggle && \ 82 | git checkout cb37b8fa3b2bd1b272cb932e7f15c3ec110cb5d7 && \ 83 | python setup.py install && \ 84 | mkdir /opt/mindboggle && mkdir /opt/mindboggle/vtk_cpp_tools && \ 85 | cd /opt/mindboggle/vtk_cpp_tools 86 | RUN cmake /tmp/mindboggle/vtk_cpp_tools -DCMAKE_EXE_LINKER_FLAGS="-L /opt/conda/lib" && \ 87 | make && cd .. && rm -rf /tmp/mindboggle && \ 88 | curl -sSL https://osf.io/rh9km/?action=download\&version=2 -o templates.zip && \ 89 | unzip templates.zip && rm -rf templates.zip __MACOSX 90 | ENV vtk_cpp_tools=/opt/mindboggle/vtk_cpp_tools 91 | 92 | #---------------------------------------- 93 | # Clear apt cache and other empty folders 94 | #---------------------------------------- 95 | USER root 96 | RUN apt-get clean && apt-get autoremove -y && \ 97 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /boot /media /mnt /srv && \ 98 | chmod a+w /tmp 99 | 100 | WORKDIR /home/$NB_USER/work 101 | USER $NB_USER 102 | -------------------------------------------------------------------------------- /170327-nipype/docker/Dockerfile.nofsspm: -------------------------------------------------------------------------------- 1 | FROM nipype/workshops:latest-base 2 | MAINTAINER Satrajit Ghosh 3 | 4 | #----------------------------------- 5 | # Install octave FSL from repository 6 | #----------------------------------- 7 | USER root 8 | RUN apt-get update -qq && apt-get install -yq --no-install-recommends \ 9 | octave \ 10 | fsl-core fsl-mni152-templates fsl-atlases fsl-5.0-eddy-nonfree && \ 11 | apt-get clean && \ 12 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \ 13 | ln -s /usr/bin/octave /usr/bin/matlab && \ 14 | chown $NB_USER /opt 15 | ENV FSLDIR=/usr/share/fsl/5.0 \ 16 | FSLOUTPUTTYPE=NIFTI_GZ \ 17 | FSLMULTIFILEQUIT=TRUE \ 18 | POSSUMDIR=/usr/share/fsl/5.0 \ 19 | LD_LIBRARY_PATH=/usr/lib/fsl/5.0:$LD_LIBRARY_PATH \ 20 | FSLTCLSH=/usr/bin/tclsh \ 21 | FSLWISH=/usr/bin/wish \ 22 | PATH=/usr/lib/fsl/5.0:$PATH 23 | 24 | #----------------- 25 | # Install dcm2niix 26 | #----------------- 27 | USER root 28 | RUN apt-get update -qq && apt-get install -yq --no-install-recommends \ 29 | build-essential && \ 30 | apt-get clean && \ 31 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 32 | USER $NB_USER 33 | WORKDIR /tmp 34 | RUN git clone https://github.com/neurolabusc/dcm2niix.git && \ 35 | cd dcm2niix/console/ && \ 36 | git checkout b3c146bc49e1bcb1bd91f786523b7bd5740787fc && \ 37 | g++ -O3 -I. main_console.cpp nii_dicom.cpp jpg_0XC3.cpp ujpeg.cpp \ 38 | nifti1_io_core.cpp nii_ortho.cpp nii_dicom_batch.cpp \ 39 | -o dcm2niix -DmyDisableOpenJPEG -DmyDisableJasper && \ 40 | mkdir -p /opt/bin && cp dcm2niix /opt/bin/ && \ 41 | cd /tmp && rm -rf dcm2niix 42 | 43 | #------------- 44 | # Install ANTS 45 | #------------- 46 | # USER root 47 | # RUN apt-get update -qq && apt-get install -yq --no-install-recommends \ 48 | # build-essential && \ 49 | # apt-get clean && \ 50 | # rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 51 | # USER $NB_USER 52 | # WORKDIR /tmp 53 | # RUN git clone https://github.com/stnava/ANTs.git && \ 54 | # cd ANTs && \ 55 | # git checkout 767f756bc0e423cd503a24c806b6578aaeb5b82f && \ 56 | # mkdir build && cd build && cmake .. && make && \ 57 | # mkdir -p /opt/ants && \ 58 | # cp bin/* /opt/ants && cp ../Scripts/* /opt/ants && \ 59 | # cd /tmp && rm -rf ANTs 60 | RUN curl -sSL https://dl.dropbox.com/s/btep51gtglp7kwh/ants.tgz?dl=0 | tar zx -C / 61 | ENV ANTSPATH=/opt/ants/ \ 62 | PATH=/opt/ants:$PATH 63 | 64 | #------------ 65 | # Install c3d 66 | #------------ 67 | RUN mkdir -p /opt/c3d && \ 68 | curl -sSL "http://downloads.sourceforge.net/project/c3d/c3d/1.0.0/c3d-1.0.0-Linux-x86_64.tar.gz" \ 69 | | tar -xzC /opt/c3d --strip-components 1 70 | ENV C3DPATH=/opt/c3d \ 71 | PATH=/opt/c3d/bin:$PATH 72 | 73 | #------------- 74 | # Install afni 75 | #------------- 76 | USER root 77 | RUN apt-get update -qq && apt-get install -yq --no-install-recommends \ 78 | libxp6 && \ 79 | apt-get clean && \ 80 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 81 | USER $NB_USER 82 | WORKDIR /opt 83 | RUN curl -sSLO https://afni.nimh.nih.gov/pub/dist/tgz/linux_openmp_64.tgz && \ 84 | tar zxf linux_openmp_64.tgz && rm linux_openmp_64.tgz && \ 85 | mv linux_openmp_64 afni 86 | ENV AFNI_MODELPATH=/opt/afni/ \ 87 | AFNI_IMSAVE_WARNINGS=NO \ 88 | AFNI_TTATLAS_DATASET=/opt/afni \ 89 | AFNI_PLUGINPATH=/opt/afni \ 90 | PATH=/opt/afni:$PATH 91 | 92 | #------------------- 93 | # Install mindboggle 94 | #------------------- 95 | USER root 96 | RUN apt-get update -qq && apt-get install -yq --no-install-recommends \ 97 | build-essential libsm-dev libx11-dev libxt-dev libxext-dev && \ 98 | apt-get clean && \ 99 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 100 | USER $NB_USER 101 | RUN conda install --quiet --yes cmake && \ 102 | conda clean -tipsy 103 | WORKDIR /tmp 104 | RUN git clone https://github.com/nipy/mindboggle && \ 105 | cd mindboggle && git checkout cb37b8fa3b2bd1b272cb932e7f15c3ec110cb5d7 && \ 106 | python setup.py install && \ 107 | mkdir /opt/mindboggle && mkdir /opt/mindboggle/vtk_cpp_tools && \ 108 | cd /opt/mindboggle/vtk_cpp_tools && \ 109 | cmake /tmp/mindboggle/vtk_cpp_tools -DCMAKE_EXE_LINKER_FLAGS="-L /opt/conda/lib" && \ 110 | make && cd .. && rm -rf /tmp/mindboggle && \ 111 | curl -sSL https://osf.io/rh9km/?action=download\&version=2 -o templates.zip && \ 112 | unzip templates.zip && rm -rf templates.zip __MACOSX 113 | ENV vtk_cpp_tools=/opt/mindboggle/vtk_cpp_tools 114 | 115 | #------------- 116 | # Install PALM 117 | #------------- 118 | WORKDIR /opt 119 | RUN git clone https://github.com/andersonwinkler/PALM.git && \ 120 | chmod +x /opt/PALM/palm 121 | ENV PATH=/opt/PALM:$PATH 122 | 123 | #---------------------------------------- 124 | # Clear apt cache and other empty folders 125 | #---------------------------------------- 126 | USER root 127 | RUN apt-get clean && apt-get autoremove -y && \ 128 | rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /boot /media /mnt /srv && \ 129 | chmod a+w /tmp 130 | 131 | WORKDIR /home/$NB_USER/work 132 | USER $NB_USER 133 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/intro-nipype/hello-world.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 3, 6 | "metadata": { 7 | "collapsed": true, 8 | "deletable": true, 9 | "editable": true 10 | }, 11 | "outputs": [], 12 | "source": [ 13 | "import os\n", 14 | "from nipype import Workflow, Node, Function, MapNode, JoinNode, config\n", 15 | "config.enable_provenance()" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": 4, 21 | "metadata": { 22 | "collapsed": true, 23 | "deletable": true, 24 | "editable": true 25 | }, 26 | "outputs": [], 27 | "source": [ 28 | "def sum(a,b):\n", 29 | " return a + b\n", 30 | "\n", 31 | "def concat(a, b):\n", 32 | " return [a, b]\n", 33 | "\n", 34 | "def plus_one(a):\n", 35 | " return a + 1\n", 36 | "\n", 37 | "def merge_and_scale_data(data2):\n", 38 | " import numpy as np\n", 39 | " return (np.array(data2) * 1000).tolist()" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": 5, 45 | "metadata": { 46 | "collapsed": false, 47 | "deletable": true, 48 | "editable": true 49 | }, 50 | "outputs": [], 51 | "source": [ 52 | "wf = Workflow('hello-world')" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": 6, 58 | "metadata": { 59 | "collapsed": false, 60 | "deletable": true, 61 | "editable": true 62 | }, 63 | "outputs": [], 64 | "source": [ 65 | "adder = Node(Function(input_names=['a', 'b'],\n", 66 | " output_names=['sum'],\n", 67 | " function=sum), name='a_plus_b')\n", 68 | "\n", 69 | "'''\n", 70 | "concater = Node(Function(input_names=['a', 'b'],\n", 71 | " output_names=['some_list'],\n", 72 | " function=concat), name='concat_a_b')\n", 73 | "\n", 74 | "plusone = MapNode(Function(input_names=['a'],\n", 75 | " output_names=['out'],\n", 76 | " function=plus_one), \n", 77 | " iterfield=['a'],\n", 78 | " name='add_1')\n", 79 | "'''\n", 80 | "\n", 81 | "\n", 82 | "joiner = JoinNode(Function(input_names=['data2'],\n", 83 | " output_names=['data_scaled'],\n", 84 | " function=merge_and_scale_data),\n", 85 | " name='join_scale_data',\n", 86 | " joinsource=adder,\n", 87 | " joinfield=['data2'])" 88 | ] 89 | }, 90 | { 91 | "cell_type": "code", 92 | "execution_count": 7, 93 | "metadata": { 94 | "collapsed": false, 95 | "deletable": true, 96 | "editable": true 97 | }, 98 | "outputs": [], 99 | "source": [ 100 | "adder.iterables = ('a', [1, 2])\n", 101 | "adder.inputs.b = 2\n", 102 | "\n", 103 | "'''\n", 104 | "wf.connect(adder, 'sum', concater, 'a')\n", 105 | "concater.inputs.b = 3\n", 106 | "\n", 107 | "wf.connect(concater, 'some_list', plusone, 'a')\n", 108 | "'''\n", 109 | "\n", 110 | "wf.connect(adder, 'sum', joiner, 'data2')" 111 | ] 112 | }, 113 | { 114 | "cell_type": "code", 115 | "execution_count": 8, 116 | "metadata": { 117 | "collapsed": true, 118 | "deletable": true, 119 | "editable": true 120 | }, 121 | "outputs": [], 122 | "source": [ 123 | "# wf.add_nodes([adder])" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": 9, 129 | "metadata": { 130 | "collapsed": false, 131 | "deletable": true, 132 | "editable": true 133 | }, 134 | "outputs": [], 135 | "source": [ 136 | "wf.base_dir = os.getcwd()\n", 137 | "eg = wf.run(plugin='MultiProc', plugin_args={'n_procs': 2})" 138 | ] 139 | }, 140 | { 141 | "cell_type": "code", 142 | "execution_count": 10, 143 | "metadata": { 144 | "collapsed": false, 145 | "deletable": true, 146 | "editable": true 147 | }, 148 | "outputs": [ 149 | { 150 | "data": { 151 | "text/plain": [ 152 | "[hello-world.a_plus_b.aI.a0,\n", 153 | " hello-world.a_plus_b.aI.a1,\n", 154 | " hello-world.join_scale_data]" 155 | ] 156 | }, 157 | "execution_count": 10, 158 | "metadata": {}, 159 | "output_type": "execute_result" 160 | } 161 | ], 162 | "source": [ 163 | "eg.nodes()" 164 | ] 165 | }, 166 | { 167 | "cell_type": "code", 168 | "execution_count": 11, 169 | "metadata": { 170 | "collapsed": false, 171 | "deletable": true, 172 | "editable": true 173 | }, 174 | "outputs": [ 175 | { 176 | "name": "stdout", 177 | "output_type": "stream", 178 | "text": [ 179 | "01_download.ipynb\t hello-world\r\n", 180 | "02_inferfaces.ipynb\t hello-world.ipynb\r\n", 181 | "03_nodes.ipynb\t\t index.ipynb\r\n", 182 | "04_workflows.ipynb\t workflow_provenance_20160724T023217.provn\r\n", 183 | "05_load_save_data.ipynb workflow_provenance_20160724T023248.provn\r\n", 184 | "06_iterables.ipynb\t workflow_provenance_20160724T023448.provn\r\n", 185 | "data\t\t\t workflow_provenance_20160724T023448.trig\r\n" 186 | ] 187 | } 188 | ], 189 | "source": [ 190 | "!ls" 191 | ] 192 | }, 193 | { 194 | "cell_type": "code", 195 | "execution_count": 43, 196 | "metadata": { 197 | "collapsed": false, 198 | "deletable": true, 199 | "editable": true 200 | }, 201 | "outputs": [ 202 | { 203 | "name": "stdout", 204 | "output_type": "stream", 205 | "text": [ 206 | "\r\n", 207 | "\r\n", 208 | "File: crash-20160724-011821-main-add_1-3c81a7f7-d8f3-415f-bbf0-8a66e236de15.pklz\r\n", 209 | "Node: hello-world.add_1\r\n", 210 | "Working directory: /home/main/notebooks/notebooks/hello-world/add_1\r\n", 211 | "\r\n", 212 | "\r\n", 213 | "Node inputs:\r\n", 214 | "\r\n", 215 | "a = [3, 3]\r\n", 216 | "function_str = def plus_one(a):\r\n", 217 | " return a + 1\r\n", 218 | "\r\n", 219 | "ignore_exception = False\r\n", 220 | "\r\n", 221 | "\r\n", 222 | "\r\n", 223 | "Traceback: \r\n", 224 | "Traceback (most recent call last):\r\n", 225 | " File \"/home/main/anaconda2/lib/python2.7/site-packages/nipype/pipeline/plugins/linear.py\", line 39, in run\r\n", 226 | " node.run(updatehash=updatehash)\r\n", 227 | " File \"/home/main/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py\", line 394, in run\r\n", 228 | " self._run_interface()\r\n", 229 | " File \"/home/main/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py\", line 504, in _run_interface\r\n", 230 | " self._result = self._run_command(execute)\r\n", 231 | " File \"/home/main/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/nodes.py\", line 630, in _run_command\r\n", 232 | " result = self._interface.run()\r\n", 233 | " File \"/home/main/anaconda2/lib/python2.7/site-packages/nipype/interfaces/base.py\", line 1034, in run\r\n", 234 | " runtime = self._run_wrapper(runtime)\r\n", 235 | " File \"/home/main/anaconda2/lib/python2.7/site-packages/nipype/interfaces/base.py\", line 991, in _run_wrapper\r\n", 236 | " runtime = self._run_interface(runtime)\r\n", 237 | " File \"/home/main/anaconda2/lib/python2.7/site-packages/nipype/interfaces/utility.py\", line 496, in _run_interface\r\n", 238 | " raise out\r\n", 239 | "TypeError: can only concatenate list (not \"int\") to list\r\n", 240 | "Interface Function failed to run. \r\n", 241 | "\r\n", 242 | "\r\n", 243 | "\r\n" 244 | ] 245 | } 246 | ], 247 | "source": [ 248 | "!nipype_display_crash crash-20160724-011821-main-add_1-3c81a7f7-d8f3-415f-bbf0-8a66e236de15.pklz" 249 | ] 250 | }, 251 | { 252 | "cell_type": "code", 253 | "execution_count": 13, 254 | "metadata": { 255 | "collapsed": false, 256 | "deletable": true, 257 | "editable": true 258 | }, 259 | "outputs": [ 260 | { 261 | "data": { 262 | "text/plain": [ 263 | ")>" 264 | ] 265 | }, 266 | "execution_count": 13, 267 | "metadata": {}, 268 | "output_type": "execute_result" 269 | } 270 | ], 271 | "source": [ 272 | "import rdflib as rl\n", 273 | "g = rl.ConjunctiveGraph()\n", 274 | "g.parse('workflow_provenance_20160724T023448.trig', format='trig')" 275 | ] 276 | }, 277 | { 278 | "cell_type": "code", 279 | "execution_count": 14, 280 | "metadata": { 281 | "collapsed": true, 282 | "deletable": true, 283 | "editable": true 284 | }, 285 | "outputs": [], 286 | "source": [ 287 | "query = \"\"\"\n", 288 | "PREFIX prov: \n", 289 | "PREFIX niiri: \n", 290 | "PREFIX nipype: \n", 291 | "\n", 292 | "# Find all activities that were involved in producing a file\n", 293 | "SELECT ?alabel ?a_id ?blabel ?b_id\n", 294 | "WHERE {\n", 295 | "\n", 296 | " ?a prov:qualifiedStart [ prov:starter ?b] .\n", 297 | " ?a_id a prov:Bundle;\n", 298 | " prov:wasGeneratedBy ?a .\n", 299 | " ?b_id a prov:Bundle;\n", 300 | " prov:wasGeneratedBy ?b .\n", 301 | " ?a rdfs:label ?alabel .\n", 302 | " ?b rdfs:label ?blabel .\n", 303 | "}\n", 304 | "\"\"\"" 305 | ] 306 | }, 307 | { 308 | "cell_type": "code", 309 | "execution_count": 15, 310 | "metadata": { 311 | "collapsed": false, 312 | "deletable": true, 313 | "editable": true 314 | }, 315 | "outputs": [ 316 | { 317 | "name": "stdout", 318 | "output_type": "stream", 319 | "text": [ 320 | "alabel,a_id,blabel,b_id\r\n", 321 | "Function_join_scale_data,http://iri.nidash.org/30d0a36c514711e6ac830a580af40a0b,Function_a_plus_b,http://iri.nidash.org/30cda05e514711e6ac830a580af40a0b\r\n", 322 | "Function_join_scale_data,http://iri.nidash.org/30d0a36c514711e6ac830a580af40a0b,Function_a_plus_b,http://iri.nidash.org/30cf1be6514711e6ac830a580af40a0b\r\n", 323 | "\n" 324 | ] 325 | } 326 | ], 327 | "source": [ 328 | "res = g.query(query)\n", 329 | "print(res.serialize(format='csv'))" 330 | ] 331 | }, 332 | { 333 | "cell_type": "code", 334 | "execution_count": 16, 335 | "metadata": { 336 | "collapsed": false, 337 | "deletable": true, 338 | "editable": true 339 | }, 340 | "outputs": [ 341 | { 342 | "data": { 343 | "text/plain": [ 344 | "{'http://iri.nidash.org/30cda05e514711e6ac830a580af40a0b': [],\n", 345 | " 'http://iri.nidash.org/30cf1be6514711e6ac830a580af40a0b': [],\n", 346 | " 'http://iri.nidash.org/30d0a36c514711e6ac830a580af40a0b': ['http://iri.nidash.org/30cda05e514711e6ac830a580af40a0b',\n", 347 | " 'http://iri.nidash.org/30cf1be6514711e6ac830a580af40a0b']}" 348 | ] 349 | }, 350 | "execution_count": 16, 351 | "metadata": {}, 352 | "output_type": "execute_result" 353 | } 354 | ], 355 | "source": [ 356 | "graph_list = {}\n", 357 | "for item in res.bindings:\n", 358 | " b_id = str(item['b_id'])\n", 359 | " a_id = str(item['a_id'])\n", 360 | " if a_id not in graph_list:\n", 361 | " graph_list[a_id] = []\n", 362 | " if b_id not in graph_list:\n", 363 | " graph_list[b_id] = []\n", 364 | " if b_id not in graph_list[a_id]:\n", 365 | " graph_list[a_id].append(b_id)\n", 366 | "graph_list" 367 | ] 368 | }, 369 | { 370 | "cell_type": "code", 371 | "execution_count": 17, 372 | "metadata": { 373 | "collapsed": true, 374 | "deletable": true, 375 | "editable": true 376 | }, 377 | "outputs": [], 378 | "source": [ 379 | "input_query = \"\"\"\n", 380 | "PREFIX prov: \n", 381 | "PREFIX niiri: \n", 382 | "PREFIX nipype: \n", 383 | "\n", 384 | "# Find all activities that were involved in producing a file\n", 385 | "SELECT ?in_port ?val ?in\n", 386 | "WHERE {\n", 387 | " GRAPH <%s>\n", 388 | " {\n", 389 | " \n", 390 | " ?ic a nipype:Inputs;\n", 391 | " prov:hadMember ?in .\n", 392 | " ?in prov:value ?val .\n", 393 | " ?act prov:qualifiedUsage ?qual .\n", 394 | " ?qual nipype:inPort ?in_port; \n", 395 | " prov:entity ?in .\n", 396 | " } .\n", 397 | "}\n", 398 | "\"\"\"" 399 | ] 400 | }, 401 | { 402 | "cell_type": "code", 403 | "execution_count": 18, 404 | "metadata": { 405 | "collapsed": false, 406 | "deletable": true, 407 | "editable": true 408 | }, 409 | "outputs": [ 410 | { 411 | "name": "stdout", 412 | "output_type": "stream", 413 | "text": [ 414 | "in_port,val,in\r\n", 415 | "ignore_exception,0,http://iri.nidash.org/9ec227a6f740d9ba54614c67f6f65e89\r\n", 416 | "b,2,http://iri.nidash.org/f2674a4bd5d68a3c564b887c54369ff2\r\n", 417 | "a,2,http://iri.nidash.org/f2674a4bd5d68a3c564b887c54369ff2\r\n", 418 | "function_str,\"def sum(a,b):\n", 419 | " return a + b\n", 420 | "\",http://iri.nidash.org/6e9ca8e35b79884a37bcefe4402e222a\r\n", 421 | "\n" 422 | ] 423 | } 424 | ], 425 | "source": [ 426 | "res = g.query(input_query % graph_list.keys()[0])\n", 427 | "print(res.serialize(format='csv'))" 428 | ] 429 | }, 430 | { 431 | "cell_type": "code", 432 | "execution_count": 19, 433 | "metadata": { 434 | "collapsed": true, 435 | "deletable": true, 436 | "editable": true 437 | }, 438 | "outputs": [], 439 | "source": [ 440 | "output_query = \"\"\"\n", 441 | "PREFIX prov: \n", 442 | "PREFIX niiri: \n", 443 | "PREFIX nipype: \n", 444 | "\n", 445 | "# Find all activities that were involved in producing a file\n", 446 | "SELECT ?out_port ?val ?out\n", 447 | "WHERE {\n", 448 | " GRAPH <%s>\n", 449 | " {\n", 450 | " \n", 451 | " ?oc a nipype:Outputs;\n", 452 | " prov:hadMember ?out;\n", 453 | " prov:wasGeneratedBy ?act .\n", 454 | " ?out prov:value ?val .\n", 455 | " ?out prov:qualifiedGeneration ?qual .\n", 456 | " ?qual nipype:outPort ?out_port; \n", 457 | " prov:activity ?act .\n", 458 | " } .\n", 459 | "}\n", 460 | "\"\"\"" 461 | ] 462 | }, 463 | { 464 | "cell_type": "code", 465 | "execution_count": 20, 466 | "metadata": { 467 | "collapsed": false, 468 | "deletable": true, 469 | "editable": true 470 | }, 471 | "outputs": [ 472 | { 473 | "name": "stdout", 474 | "output_type": "stream", 475 | "text": [ 476 | "out_port,val,out\r\n", 477 | "sum,4,http://iri.nidash.org/5a554bd80b84b2a803d081008e96be30\r\n", 478 | "\n" 479 | ] 480 | } 481 | ], 482 | "source": [ 483 | "res = g.query(output_query % graph_list.keys()[0])\n", 484 | "print(res.serialize(format='csv'))" 485 | ] 486 | }, 487 | { 488 | "cell_type": "code", 489 | "execution_count": 21, 490 | "metadata": { 491 | "collapsed": false, 492 | "deletable": true, 493 | "editable": true 494 | }, 495 | "outputs": [ 496 | { 497 | "name": "stdout", 498 | "output_type": "stream", 499 | "text": [ 500 | "Node id: http://iri.nidash.org/30cf1be6514711e6ac830a580af40a0b\n", 501 | "Inputs\n", 502 | "in_port,val,in\r\n", 503 | "ignore_exception,0,http://iri.nidash.org/9ec227a6f740d9ba54614c67f6f65e89\r\n", 504 | "b,2,http://iri.nidash.org/f2674a4bd5d68a3c564b887c54369ff2\r\n", 505 | "a,2,http://iri.nidash.org/f2674a4bd5d68a3c564b887c54369ff2\r\n", 506 | "function_str,\"def sum(a,b):\n", 507 | " return a + b\n", 508 | "\",http://iri.nidash.org/6e9ca8e35b79884a37bcefe4402e222a\r\n", 509 | "\n", 510 | "Outputs\n", 511 | "out_port,val,out\r\n", 512 | "sum,4,http://iri.nidash.org/5a554bd80b84b2a803d081008e96be30\r\n", 513 | "\n", 514 | "Node id: http://iri.nidash.org/30cda05e514711e6ac830a580af40a0b\n", 515 | "Inputs\n", 516 | "in_port,val,in\r\n", 517 | "function_str,\"def sum(a,b):\n", 518 | " return a + b\n", 519 | "\",http://iri.nidash.org/6e9ca8e35b79884a37bcefe4402e222a\r\n", 520 | "b,2,http://iri.nidash.org/f2674a4bd5d68a3c564b887c54369ff2\r\n", 521 | "ignore_exception,0,http://iri.nidash.org/9ec227a6f740d9ba54614c67f6f65e89\r\n", 522 | "a,1,http://iri.nidash.org/e5692843450c8e664dfe4b40a35647de\r\n", 523 | "\n", 524 | "Outputs\n", 525 | "out_port,val,out\r\n", 526 | "sum,4,http://iri.nidash.org/5a554bd80b84b2a803d081008e96be30\r\n", 527 | "\n", 528 | "Node id: http://iri.nidash.org/30d0a36c514711e6ac830a580af40a0b\n", 529 | "Inputs\n", 530 | "in_port,val,in\r\n", 531 | "data2,\"[3, 4]\",http://iri.nidash.org/f66428b68d6f34c423ce9ca417b3e33b\r\n", 532 | "ignore_exception,0,http://iri.nidash.org/9ec227a6f740d9ba54614c67f6f65e89\r\n", 533 | "function_str,\"def merge_and_scale_data(data2):\n", 534 | " import numpy as np\n", 535 | " return (np.array(data2) * 1000).tolist()\n", 536 | "\",http://iri.nidash.org/7f972116128031b2a38ae957dfc29f7d\r\n", 537 | "\n", 538 | "Outputs\n", 539 | "out_port,val,out\r\n", 540 | "sum,4,http://iri.nidash.org/5a554bd80b84b2a803d081008e96be30\r\n", 541 | "\n" 542 | ] 543 | } 544 | ], 545 | "source": [ 546 | "for graph in graph_list:\n", 547 | " print(\"Node id: %s\" % graph)\n", 548 | " print('Inputs')\n", 549 | " res = g.query(input_query % graph)\n", 550 | " print(res.serialize(format='csv'))\n", 551 | " print('Outputs')\n", 552 | " res = g.query(output_query % graph_list.keys()[0])\n", 553 | " print(res.serialize(format='csv'))" 554 | ] 555 | }, 556 | { 557 | "cell_type": "code", 558 | "execution_count": null, 559 | "metadata": { 560 | "collapsed": true, 561 | "deletable": true, 562 | "editable": true 563 | }, 564 | "outputs": [], 565 | "source": [] 566 | } 567 | ], 568 | "metadata": { 569 | "kernelspec": { 570 | "display_name": "Python 3", 571 | "language": "python", 572 | "name": "python3" 573 | }, 574 | "language_info": { 575 | "codemirror_mode": { 576 | "name": "ipython", 577 | "version": 3 578 | }, 579 | "file_extension": ".py", 580 | "mimetype": "text/x-python", 581 | "name": "python", 582 | "nbconvert_exporter": "python", 583 | "pygments_lexer": "ipython3", 584 | "version": "3.5.2" 585 | } 586 | }, 587 | "nbformat": 4, 588 | "nbformat_minor": 0 589 | } 590 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/new-workflows-and-interfaces/.gitignore: -------------------------------------------------------------------------------- 1 | .ipynb_checkpoints/ 2 | data/ 3 | working_dir/ 4 | run_docker.sh 5 | example_metaflow.ipynb 6 | basic_workflow.ipynb 7 | 8 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/new-workflows-and-interfaces/.solution_workflow: -------------------------------------------------------------------------------- 1 | wf.connect([ 2 | (node_smooth, node_mask, [('out_file', 'in_file')]), 3 | (node_bet, node_mask, [('mask_file', 'mask_file')]) 4 | ]) 5 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/new-workflows-and-interfaces/files/brainvolume.m: -------------------------------------------------------------------------------- 1 | load input_image.mat; 2 | total = sum(data(:) > 0) -------------------------------------------------------------------------------- /170327-nipype/notebooks/new-workflows-and-interfaces/files/smoothflow_detailed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/new-workflows-and-interfaces/files/smoothflow_detailed.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/new-workflows-and-interfaces/files/transform.tfm: -------------------------------------------------------------------------------- 1 | #Insight Transform File V1.0 2 | #Transform 0 3 | Transform: AffineTransform_double_3_3 4 | Parameters: 1.02009654 -0.00984231 0.00283729 -0.24555664 0.91639648 0.32458515 -0.01980156 -0.00296066 0.98863359 1.79024059 -13.02945168 -1.34438656 5 | FixedParameters: -3.37801369 17.43375029 8.46811160 6 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/nibabel_nilearn/prep.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Prepare Haxby Dataset" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": null, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "import nilearn.datasets\n", 17 | "\n", 18 | "haxby_dataset = nilearn.datasets.fetch_haxby(data_dir='/home/jovyan/work/data')" 19 | ] 20 | } 21 | ], 22 | "metadata": { 23 | "kernelspec": { 24 | "display_name": "Python 3", 25 | "language": "python", 26 | "name": "python3" 27 | }, 28 | "language_info": { 29 | "codemirror_mode": { 30 | "name": "ipython", 31 | "version": 3 32 | }, 33 | "file_extension": ".py", 34 | "mimetype": "text/x-python", 35 | "name": "python", 36 | "nbconvert_exporter": "python", 37 | "pygments_lexer": "ipython3", 38 | "version": "3.5.2" 39 | } 40 | }, 41 | "nbformat": 4, 42 | "nbformat_minor": 2 43 | } 44 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: slides 2 | 3 | slides: 4 | ipython nbconvert numpy_advanced.ipynb \ 5 | --to slides --reveal-prefix ../reveal.js 6 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/css/exercises.css: -------------------------------------------------------------------------------- 1 | .rendered_html { 2 | font-family: Georgia, serif; 3 | font-size: 110%; 4 | line-height: 1.5; 5 | } 6 | 7 | .input { 8 | width: 930px; 9 | } 10 | 11 | .inner_cell { 12 | width: 800px; 13 | } 14 | 15 | .code_cell { 16 | width: 800px; 17 | } 18 | 19 | .CodeMirror-sizer { 20 | } 21 | 22 | hr { 23 | border: 1px solid #DDD; 24 | } 25 | 26 | .rendered_html h1 { 27 | margin: 0.25em 0em 0.5em; 28 | font-family: sans-serif; 29 | color: #015C9C; 30 | text-align: center; 31 | line-height: 1.2; 32 | page-break-before: always; 33 | } 34 | 35 | .rendered_html h2 { 36 | margin: 1.1em 0em 0.5em; 37 | font-family: sans-serif; 38 | color: #26465D; 39 | line-height: 1.2; 40 | } 41 | 42 | .rendered_html h3 { 43 | font-family: sans-serif; 44 | margin: 1.1em 0em 0.5em; 45 | color: #002845; 46 | line-height: 1.2; 47 | } 48 | 49 | .rendered_html li { 50 | line-height: 1.5; 51 | } 52 | 53 | .CodeMirror-lines { 54 | font-size: 110%; 55 | line-height: 1.4em; 56 | font-family: DejaVu Sans Mono, Consolas, Ubuntu, monospace; 57 | } 58 | 59 | h1.bigtitle { 60 | margin: 4cm 1cm 4cm 1cm; 61 | font-size: 300%; 62 | } 63 | 64 | h3.point { 65 | font-size: 200%; 66 | text-align: center; 67 | margin: 2em 0em 2em 0em; 68 | #26465D 69 | } 70 | 71 | .logo { 72 | margin: 20px 0 20px 0; 73 | } 74 | 75 | a.anchor-link { 76 | display: none; 77 | } 78 | 79 | h1.title { 80 | font-size: 250%; 81 | } 82 | 83 | .exercize { 84 | color: #738; 85 | } 86 | 87 | h2 .exercize { 88 | font-style: italic; 89 | } 90 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/css/notebook.css: -------------------------------------------------------------------------------- 1 | .rendered_html { 2 | font-family: Georgia, serif; 3 | font-size: 130%; 4 | line-height: 1.5; 5 | } 6 | 7 | .input { 8 | width: 930px; 9 | } 10 | 11 | .inner_cell { 12 | width: 800px; 13 | } 14 | 15 | .code_cell { 16 | width: 800px; 17 | } 18 | 19 | .CodeMirror-sizer { 20 | } 21 | 22 | hr { 23 | border: 1px solid #DDD; 24 | } 25 | 26 | .rendered_html h1 { 27 | margin: 0.25em 0em 0.5em; 28 | font-family: sans-serif; 29 | color: #015C9C; 30 | text-align: center; 31 | line-height: 1.2; 32 | page-break-before: always; 33 | } 34 | 35 | .rendered_html h2 { 36 | margin: 1.1em 0em 0.5em; 37 | font-family: sans-serif; 38 | color: #26465D; 39 | line-height: 1.2; 40 | } 41 | 42 | .rendered_html h3 { 43 | font-family: sans-serif; 44 | margin: 1.1em 0em 0.5em; 45 | color: #002845; 46 | line-height: 1.2; 47 | } 48 | 49 | .rendered_html li { 50 | line-height: 1.5; 51 | } 52 | 53 | .CodeMirror-lines { 54 | font-size: 110%; 55 | line-height: 1.4em; 56 | font-family: DejaVu Sans Mono, Consolas, Ubuntu, monospace; 57 | } 58 | 59 | h1.bigtitle { 60 | margin: 4cm 1cm 4cm 1cm; 61 | font-size: 300%; 62 | } 63 | 64 | h3.point { 65 | font-size: 200%; 66 | text-align: center; 67 | margin: 2em 0em 2em 0em; 68 | #26465D 69 | } 70 | 71 | .logo { 72 | margin: 20px 0 20px 0; 73 | } 74 | 75 | a.anchor-link { 76 | display: none; 77 | } 78 | 79 | h1.title { 80 | font-size: 250%; 81 | } 82 | 83 | .exercize { 84 | color: #738; 85 | } 86 | 87 | h2 .exercize { 88 | font-style: italic; 89 | } 90 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/array_dtype.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/array_dtype.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/array_flat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/array_flat.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/array_flat.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 38 | 40 | 41 | 43 | image/svg+xml 44 | 46 | 47 | 48 | 49 | 50 | 54 | 62 | 70 | 78 | 86 | 94 | 102 | 110 | 118 | 0 129 | 1 140 | 2 151 | 3 162 | 4 173 | 5 184 | 6 195 | 7 206 | 214 | 8 225 | 226 | 227 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/array_flat_extended.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/array_flat_extended.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/array_flat_extended.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 38 | 40 | 41 | 43 | image/svg+xml 44 | 46 | 47 | 48 | 49 | 50 | 54 | 62 | 70 | 78 | 86 | 94 | 102 | 110 | 118 | 0 129 | 1 140 | 2 151 | 3 162 | 4 173 | 5 184 | 6 195 | 7 206 | 214 | 8 225 | 233 | 9 244 | 246 | 254 | 10 265 | 266 | 269 | 277 | ... 288 | 289 | 290 | 291 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/array_memory_dtype.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/array_memory_dtype.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/array_memory_dtype_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/array_memory_dtype_small.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/array_memory_presentation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/array_memory_presentation.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/array_memory_presentation.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 38 | 40 | 41 | 43 | image/svg+xml 44 | 46 | 47 | 48 | 49 | 50 | 54 | 57 | 65 | 73 | 81 | 89 | 97 | 105 | 113 | 121 | 0 132 | 1 143 | 2 154 | 3 165 | 4 176 | 5 187 | 6 198 | 7 209 | 217 | 8 228 | 229 | 232 | 235 | 243 | 251 | 259 | 0 270 | 1 281 | 2 292 | 293 | 296 | 304 | 312 | 320 | 3 331 | 4 342 | 5 353 | 354 | 357 | 365 | 373 | 6 384 | 7 395 | 403 | 8 414 | 415 | 416 | Memory 427 | User view 438 | 446 | ? 457 | 465 | ... 476 | 484 | ... 495 | 503 | ? 514 | 515 | 516 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/array_memory_strides.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/array_memory_strides.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/array_memory_strides.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 21 | 23 | 30 | 35 | 36 | 43 | 48 | 49 | 56 | 61 | 62 | 69 | 74 | 75 | 76 | 94 | 96 | 97 | 99 | image/svg+xml 100 | 102 | 103 | 104 | 105 | 106 | 110 | 113 | 121 | 129 | 137 | 145 | 153 | 161 | 169 | 177 | 0 188 | 1 199 | 2 210 | 3 221 | 4 232 | 5 243 | 6 254 | 7 265 | 273 | 8 284 | 285 | 288 | 291 | 299 | 307 | 315 | 0 326 | 1 337 | 2 348 | 349 | 352 | 360 | 368 | 376 | 3 387 | 4 398 | 5 409 | 410 | 413 | 421 | 429 | 6 440 | 7 451 | 459 | 8 470 | 471 | 472 | Memory 483 | User view 494 | 502 | ? 513 | 521 | ... 532 | 540 | ... 551 | 559 | ? 570 | 578 | data: 43616176shape: (3, 3)strides: (3, 1) 597 | 603 | 43616176 614 | 620 | 626 | 632 | 638 | 639 | 640 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/array_memory_strides_transpose.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/array_memory_strides_transpose.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/array_reshape.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/array_reshape.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/array_reshape.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 21 | 23 | 30 | 35 | 36 | 37 | 55 | 57 | 58 | 60 | image/svg+xml 61 | 63 | 64 | 65 | 66 | 67 | 71 | 74 | 82 | 90 | 98 | 0 109 | 1 120 | 2 131 | 132 | 135 | 143 | 151 | 159 | 3 170 | 4 181 | 5 192 | 193 | 196 | 204 | 212 | 6 223 | 7 234 | 242 | 8 253 | 254 | 259 | Shape: (3, 3) 270 | 271 | 272 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/array_reshape_nd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/array_reshape_nd.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/array_reshape_nd.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 21 | 23 | 30 | 35 | 36 | 37 | 55 | 57 | 58 | 60 | image/svg+xml 61 | 63 | 64 | 65 | 66 | 67 | 71 | 73 | 76 | 84 | 92 | 100 | 0 111 | 1 122 | 2 133 | 134 | 137 | 145 | 153 | 161 | 3 172 | 4 183 | 5 194 | 195 | 198 | 206 | 214 | 6 225 | 7 236 | 244 | 8 255 | 256 | 257 | 260 | 263 | 271 | 279 | 287 | 0 298 | 1 309 | 2 320 | 321 | 324 | 332 | 340 | 348 | 3 359 | 4 370 | 5 381 | 382 | 385 | 393 | 401 | 6 412 | 7 423 | 431 | 8 442 | 443 | 444 | 447 | 450 | 458 | 466 | 474 | 0 485 | 1 496 | 2 507 | 508 | 511 | 519 | 527 | 535 | 3 546 | 4 557 | 5 568 | 569 | 572 | 580 | 588 | 6 599 | 7 610 | 618 | 8 629 | 630 | 631 | 636 | Shape: (3, 3, 3) 647 | 648 | 649 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/array_transpose_question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/array_transpose_question.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/broadcast_1D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/broadcast_1D.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/broadcast_2D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/broadcast_2D.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/broadcast_3D.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/broadcast_3D.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/jack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/jack.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/ndarray_struct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/ndarray_struct.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/ndarray_struct.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 27 | 33 | 34 | 41 | 47 | 48 | 55 | 61 | 62 | 69 | 75 | 76 | 77 | 99 | 101 | 102 | 104 | image/svg+xml 105 | 107 | 108 | 109 | 110 | 111 | 116 | 118 | 120 | 127 | 0 139 | 140 | 141 | 144 | 147 | 154 | 1 166 | 167 | 168 | 171 | 174 | 181 | 2 193 | 194 | 195 | 198 | 201 | 208 | 3 220 | 221 | 222 | 225 | 228 | 235 | 4 247 | 248 | 249 | 252 | 255 | 262 | 5 274 | 275 | 276 | 278 | 280 | 283 | 290 | 6 302 | 303 | 304 | 305 | 311 | 319 | FlagsBase 346 | ShapeData typeStrides 368 | 369 | 370 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/numpy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/numpy.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/overview.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/images/radar_struct.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nipy/workshops/09cdc5ebe1ffe31608756e79c6cb1848742e6969/170327-nipype/notebooks/numpy-advanced/images/radar_struct.png -------------------------------------------------------------------------------- /170327-nipype/notebooks/numpy-advanced/load_style.py: -------------------------------------------------------------------------------- 1 | from IPython.display import display, HTML 2 | import requests 3 | 4 | def load_style(s): 5 | """Load a CSS stylesheet in the notebook by URL or filename. 6 | 7 | Examples:: 8 | 9 | %load_style mystyle.css 10 | %load_style http://ipynbstyles.com/otherstyle.css 11 | """ 12 | if s.startswith('http'): 13 | r =requests.get(s) 14 | style = r.text 15 | else: 16 | with open(s, 'r') as f: 17 | style = f.read() 18 | s = ''.format(style=style) 19 | display(HTML(s)) 20 | 21 | def load_ipython_extension(ip): 22 | """Load the extension in IPython.""" 23 | ip.register_magic_function(load_style) -------------------------------------------------------------------------------- /170327-nipype/notebooks/testing/pytest_mark_solutions/maxima.py: -------------------------------------------------------------------------------- 1 | def find_maxima(list_of_numbers): 2 | maxima = [] 3 | if list_of_numbers[0] > list_of_numbers[1]: 4 | maxima.append(0) 5 | for i in range(1, len(list_of_numbers)-1): 6 | if list_of_numbers[i-1] < list_of_numbers[i] > list_of_numbers[i+1]: 7 | maxima.append(i) 8 | if list_of_numbers[-1] > list_of_numbers[-2]: 9 | maxima.append(len(list_of_numbers)-1) 10 | return maxima 11 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/testing/pytest_mark_solutions/random_numbers.py: -------------------------------------------------------------------------------- 1 | import random 2 | import numpy as np 3 | 4 | 5 | def mean_random_numbers(): 6 | a = random.sample(range(-100, 100), 10) 7 | mean = np.absolute(a).mean() 8 | return mean 9 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/testing/pytest_mark_solutions/sector_area.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def sector_area(radius1, radius2, angle_deg): 4 | angle_rad = (2 * math.pi / 360) * angle_deg # changing degrees to radians 5 | area = 0.5 * (radius1**2 - radius2**2) * angle_rad 6 | return area 7 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/testing/pytest_mark_solutions/test_maxima_pytest.py: -------------------------------------------------------------------------------- 1 | from maxima import find_maxima 2 | import pytest 3 | 4 | @pytest.mark.parametrize("input, expected_maxima", [ 5 | ([1, 2, 1, 0], [1] ), 6 | ([-1, 2, 1, 3, 2], [1, 3]), 7 | ([4, 3, 4, 3], [0, 2]), 8 | ([1, 2, 3], [2] ) 9 | ]) 10 | def test_maxima(input, expected_maxima): 11 | assert find_maxima(input) == expected_maxima 12 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/testing/pytest_mark_solutions/test_random_numbers.py: -------------------------------------------------------------------------------- 1 | import random 2 | import numpy as np 3 | from random_numbers import mean_random_numbers 4 | import pytest, sys 5 | 6 | @pytest.mark.xfail(sys.version_info < (3,0), 7 | reason="random api is different in python2") 8 | def test_random_numbers(): 9 | random.seed(3) 10 | np.testing.assert_almost_equal(mean_random_numbers(), 47) 11 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/testing/pytest_mark_solutions/test_sector_area_pytest.py: -------------------------------------------------------------------------------- 1 | import math 2 | from sector_area import sector_area 3 | 4 | import pytest 5 | 6 | 7 | @pytest.mark.parametrize("rad1, rad2, ang", [(2, 1, 30), (10, 5, 270)]) 8 | def test_gt0(rad1, rad2, ang): 9 | assert sector_area(rad1, rad2, ang) > 0 10 | 11 | @pytest.mark.parametrize("inputs, expected", [ 12 | ([5, 1, 0], 0 ), 13 | ([5, 0, 360], math.pi * 25) 14 | ]) 15 | def test_expected(inputs, expected): 16 | assert sector_area(*inputs) == expected 17 | 18 | @pytest.mark.xfail(reason="my function doesn't rise an exception - TODO") 19 | @pytest.mark.parametrize("inputs", [[5, 1, -30], [5, 7, 360]]) 20 | def test_exception(inputs, expected): 21 | with pytest.raises.Exception: 22 | assert sector_area(*inputs) 23 | 24 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/testing/pytest_solutions/maxima.py: -------------------------------------------------------------------------------- 1 | def find_maxima(list_of_numbers): 2 | maxima = [] 3 | if list_of_numbers[0] > list_of_numbers[1]: 4 | maxima.append(0) 5 | for i in range(1, len(list_of_numbers)-1): 6 | if list_of_numbers[i-1] < list_of_numbers[i] > list_of_numbers[i+1]: 7 | maxima.append(i) 8 | if list_of_numbers[-1] > list_of_numbers[-2]: 9 | maxima.append(len(list_of_numbers)-1) 10 | return maxima 11 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/testing/pytest_solutions/random_numbers.py: -------------------------------------------------------------------------------- 1 | import random 2 | import numpy as np 3 | 4 | 5 | def mean_random_numbers(): 6 | a = random.sample(range(-100, 100), 10) 7 | mean = np.absolute(a).mean() 8 | return mean 9 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/testing/pytest_solutions/sector_area.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | def sector_area(radius1, radius2, angle_deg): 4 | angle_rad = (2 * math.pi / 360) * angle_deg # changing degrees to radians 5 | area = 0.5 * (radius1**2 - radius2**2) * angle_rad 6 | return area 7 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/testing/pytest_solutions/test_maxima.py: -------------------------------------------------------------------------------- 1 | from maxima import find_maxima 2 | 3 | def test_maxima(): 4 | inputs = [[1, 2, 1, 0], [-1, 2, 1, 3, 2], [4, 3, 4, 3], [1, 2, 3]] 5 | expected_maxima = [[1], [1, 3], [0, 2], [2]] 6 | for i in range(len(inputs)): 7 | assert find_maxima(inputs[i]) == expected_maxima[i] 8 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/testing/pytest_solutions/test_random_numbers.py: -------------------------------------------------------------------------------- 1 | import random 2 | import numpy as np 3 | from random_numbers import mean_random_numbers 4 | 5 | 6 | def test_random_numbers(): 7 | random.seed(3) 8 | np.testing.assert_almost_equal(mean_random_numbers(), 47) 9 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/testing/pytest_solutions/test_sector_area.py: -------------------------------------------------------------------------------- 1 | import math 2 | from sector_area import sector_area 3 | 4 | def test_gt0(): 5 | for rad1, rad2, ang in [(2, 1, 30), (10, 5, 270)]: 6 | assert sector_area(rad1, rad2, ang) > 0 7 | 8 | 9 | def test_angle0(): 10 | assert sector_area(5, 1, 0) == 0 11 | 12 | 13 | def test_full(): 14 | assert sector_area(5, 0, 360) == math.pi * 25 15 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/testing/solutions/asserts.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true, 8 | "deletable": true, 9 | "editable": true 10 | }, 11 | "outputs": [], 12 | "source": [ 13 | "assert True" 14 | ] 15 | }, 16 | { 17 | "cell_type": "code", 18 | "execution_count": null, 19 | "metadata": { 20 | "collapsed": false, 21 | "deletable": true, 22 | "editable": true 23 | }, 24 | "outputs": [], 25 | "source": [ 26 | "assert False" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": null, 32 | "metadata": { 33 | "collapsed": true, 34 | "deletable": true, 35 | "editable": true 36 | }, 37 | "outputs": [], 38 | "source": [ 39 | "assert 1 + 2 == 3" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": null, 45 | "metadata": { 46 | "collapsed": true, 47 | "deletable": true, 48 | "editable": true 49 | }, 50 | "outputs": [], 51 | "source": [ 52 | "assert 2**0.5 < 1.5" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": null, 58 | "metadata": { 59 | "collapsed": true, 60 | "deletable": true, 61 | "editable": true 62 | }, 63 | "outputs": [], 64 | "source": [ 65 | "k = 10\n", 66 | "assert k != 0" 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": null, 72 | "metadata": { 73 | "collapsed": false, 74 | "deletable": true, 75 | "editable": true 76 | }, 77 | "outputs": [], 78 | "source": [ 79 | "import math\n", 80 | "assert math.pi == 3.14" 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": null, 86 | "metadata": { 87 | "collapsed": true, 88 | "deletable": true, 89 | "editable": true 90 | }, 91 | "outputs": [], 92 | "source": [ 93 | "assert abs(math.pi - 3.14) < 0.5 * 10**(-2)" 94 | ] 95 | }, 96 | { 97 | "cell_type": "code", 98 | "execution_count": null, 99 | "metadata": { 100 | "collapsed": false, 101 | "deletable": true, 102 | "editable": true 103 | }, 104 | "outputs": [], 105 | "source": [ 106 | "import numpy.testing as npt\n", 107 | "npt.assert_almost_equal(math.pi, 3.14, decimal=2)\n", 108 | "#npt.assert_allclose(math.pi, 3.14, atol=0.01)" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": null, 114 | "metadata": { 115 | "collapsed": true, 116 | "deletable": true, 117 | "editable": true 118 | }, 119 | "outputs": [], 120 | "source": [ 121 | "assert \"var1\" in [\"var1\", \"var3\"]" 122 | ] 123 | }, 124 | { 125 | "cell_type": "code", 126 | "execution_count": null, 127 | "metadata": { 128 | "collapsed": false, 129 | "deletable": true, 130 | "editable": true 131 | }, 132 | "outputs": [], 133 | "source": [ 134 | "assert \"var1\" not in [\"var1\", \"var3\"]" 135 | ] 136 | }, 137 | { 138 | "cell_type": "code", 139 | "execution_count": null, 140 | "metadata": { 141 | "collapsed": false, 142 | "deletable": true, 143 | "editable": true 144 | }, 145 | "outputs": [], 146 | "source": [ 147 | "a = 2\n", 148 | "assert type(a) is int" 149 | ] 150 | }, 151 | { 152 | "cell_type": "code", 153 | "execution_count": null, 154 | "metadata": { 155 | "collapsed": false, 156 | "deletable": true, 157 | "editable": true 158 | }, 159 | "outputs": [], 160 | "source": [ 161 | "b = 4/2\n", 162 | "assert type(b) is int" 163 | ] 164 | }, 165 | { 166 | "cell_type": "code", 167 | "execution_count": null, 168 | "metadata": { 169 | "collapsed": true, 170 | "deletable": true, 171 | "editable": true 172 | }, 173 | "outputs": [], 174 | "source": [ 175 | "assert type(b) == float" 176 | ] 177 | }, 178 | { 179 | "cell_type": "code", 180 | "execution_count": null, 181 | "metadata": { 182 | "collapsed": false, 183 | "deletable": true, 184 | "editable": true 185 | }, 186 | "outputs": [], 187 | "source": [ 188 | "l = [3,4,5]" 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": null, 194 | "metadata": { 195 | "collapsed": false, 196 | "deletable": true, 197 | "editable": true 198 | }, 199 | "outputs": [], 200 | "source": [ 201 | "assert type(l) is list" 202 | ] 203 | }, 204 | { 205 | "cell_type": "code", 206 | "execution_count": null, 207 | "metadata": { 208 | "collapsed": true, 209 | "deletable": true, 210 | "editable": true 211 | }, 212 | "outputs": [], 213 | "source": [] 214 | } 215 | ], 216 | "metadata": { 217 | "anaconda-cloud": {}, 218 | "kernelspec": { 219 | "display_name": "Python 3", 220 | "language": "python", 221 | "name": "python3" 222 | }, 223 | "language_info": { 224 | "codemirror_mode": { 225 | "name": "ipython", 226 | "version": 3 227 | }, 228 | "file_extension": ".py", 229 | "mimetype": "text/x-python", 230 | "name": "python", 231 | "nbconvert_exporter": "python", 232 | "pygments_lexer": "ipython3", 233 | "version": "3.5.2" 234 | } 235 | }, 236 | "nbformat": 4, 237 | "nbformat_minor": 1 238 | } 239 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/testing/solutions/maxima.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true, 8 | "deletable": true, 9 | "editable": true 10 | }, 11 | "outputs": [], 12 | "source": [ 13 | "# a function that returns positions of local maxima in a list of numbers\n", 14 | "def find_maxima(list_of_numbers):\n", 15 | " maxima = []\n", 16 | " if list_of_numbers[0] > list_of_numbers[1]:\n", 17 | " maxima.append(0)\n", 18 | " for i in range(1, len(list_of_numbers)-1):\n", 19 | " if list_of_numbers[i-1] < list_of_numbers[i] > list_of_numbers[i+1]:\n", 20 | " maxima.append(i)\n", 21 | " if list_of_numbers[-1] > list_of_numbers[-2]:\n", 22 | " maxima.append(len(list_of_numbers)-1)\n", 23 | " return maxima\n", 24 | " " 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": null, 30 | "metadata": { 31 | "collapsed": true, 32 | "deletable": true, 33 | "editable": true 34 | }, 35 | "outputs": [], 36 | "source": [ 37 | "# testing the function for four lists\n", 38 | "def test_maxima():\n", 39 | " inputs = [[1, 2, 1, 0], [-1, 2, 1, 3, 2], [4, 3, 4, 3], [1, 2, 3]]\n", 40 | " expected_maxima = [[1], [1, 3], [0, 2], [2]]\n", 41 | " for i in range(len(inputs)):\n", 42 | " assert find_maxima(inputs[i]) == expected_maxima[i]" 43 | ] 44 | }, 45 | { 46 | "cell_type": "code", 47 | "execution_count": null, 48 | "metadata": { 49 | "collapsed": false, 50 | "deletable": true, 51 | "editable": true 52 | }, 53 | "outputs": [], 54 | "source": [ 55 | "test_maxima()" 56 | ] 57 | }, 58 | { 59 | "cell_type": "code", 60 | "execution_count": null, 61 | "metadata": { 62 | "collapsed": true, 63 | "deletable": true, 64 | "editable": true 65 | }, 66 | "outputs": [], 67 | "source": [] 68 | } 69 | ], 70 | "metadata": { 71 | "anaconda-cloud": {}, 72 | "kernelspec": { 73 | "display_name": "Python 3", 74 | "language": "python", 75 | "name": "python3" 76 | }, 77 | "language_info": { 78 | "codemirror_mode": { 79 | "name": "ipython", 80 | "version": 3 81 | }, 82 | "file_extension": ".py", 83 | "mimetype": "text/x-python", 84 | "name": "python", 85 | "nbconvert_exporter": "python", 86 | "pygments_lexer": "ipython3", 87 | "version": "3.5.2" 88 | } 89 | }, 90 | "nbformat": 4, 91 | "nbformat_minor": 1 92 | } 93 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/testing/solutions/random_numbers.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 55, 6 | "metadata": { 7 | "collapsed": false 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "import random\n", 12 | "import numpy as np" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 56, 18 | "metadata": { 19 | "collapsed": true 20 | }, 21 | "outputs": [], 22 | "source": [ 23 | "# a function that returns the mean absolute value of the list of pseudo-random numbers\n", 24 | "def mean_random_numbers():\n", 25 | " a = random.sample(range(-100, 100), 10)\n", 26 | " mean = np.absolute(a).mean()\n", 27 | " return mean" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": 57, 33 | "metadata": { 34 | "collapsed": false 35 | }, 36 | "outputs": [], 37 | "source": [ 38 | "# testing the results for a specific seed (the value can be different for python2)\n", 39 | "def test_random_numbers():\n", 40 | " random.seed(3)\n", 41 | " np.testing.assert_almost_equal(mean_random_numbers(), 47)" 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "execution_count": 58, 47 | "metadata": { 48 | "collapsed": false 49 | }, 50 | "outputs": [], 51 | "source": [ 52 | "test_random_numbers()" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": null, 58 | "metadata": { 59 | "collapsed": true 60 | }, 61 | "outputs": [], 62 | "source": [] 63 | } 64 | ], 65 | "metadata": { 66 | "anaconda-cloud": {}, 67 | "kernelspec": { 68 | "display_name": "Python 3", 69 | "language": "python", 70 | "name": "python3" 71 | }, 72 | "language_info": { 73 | "codemirror_mode": { 74 | "name": "ipython", 75 | "version": 3 76 | }, 77 | "file_extension": ".py", 78 | "mimetype": "text/x-python", 79 | "name": "python", 80 | "nbconvert_exporter": "python", 81 | "pygments_lexer": "ipython3", 82 | "version": "3.5.2" 83 | } 84 | }, 85 | "nbformat": 4, 86 | "nbformat_minor": 1 87 | } 88 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/testing/solutions/sector_area.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true, 8 | "deletable": true, 9 | "editable": true 10 | }, 11 | "outputs": [], 12 | "source": [ 13 | "import math" 14 | ] 15 | }, 16 | { 17 | "cell_type": "code", 18 | "execution_count": null, 19 | "metadata": { 20 | "collapsed": true, 21 | "deletable": true, 22 | "editable": true 23 | }, 24 | "outputs": [], 25 | "source": [ 26 | "# a function that calculates area of a sector of a circle \n", 27 | "def sector_area(radius, angle_deg):\n", 28 | " angle_rad = (2 * math.pi / 360) * angle_deg # changing degrees to radians\n", 29 | " area = 0.5 * radius**2 * angle_rad\n", 30 | " return area" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": null, 36 | "metadata": { 37 | "collapsed": false, 38 | "deletable": true, 39 | "editable": true 40 | }, 41 | "outputs": [], 42 | "source": [ 43 | "# testing if the function returns values greater than zero\n", 44 | "def test_gt0():\n", 45 | " for rad, ang in [(2,30), (10, 270)]:\n", 46 | " assert sector_area(rad, ang) > 0" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": null, 52 | "metadata": { 53 | "collapsed": true, 54 | "deletable": true, 55 | "editable": true 56 | }, 57 | "outputs": [], 58 | "source": [ 59 | "# testing if the function returns 0 for angle=0\n", 60 | "def test_angle0():\n", 61 | " assert sector_area(5, 0) == 0" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": null, 67 | "metadata": { 68 | "collapsed": true, 69 | "deletable": true, 70 | "editable": true 71 | }, 72 | "outputs": [], 73 | "source": [ 74 | "# testing if the function retuns a proper value for angle=360deg (2*pi)\n", 75 | "def test_full():\n", 76 | " assert sector_area(5, 360) == math.pi * 25" 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "execution_count": null, 82 | "metadata": { 83 | "collapsed": false, 84 | "deletable": true, 85 | "editable": true 86 | }, 87 | "outputs": [], 88 | "source": [ 89 | "# running all tests\n", 90 | "test_gt0()\n", 91 | "test_angle0()\n", 92 | "test_full()" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": null, 98 | "metadata": { 99 | "collapsed": true, 100 | "deletable": true, 101 | "editable": true 102 | }, 103 | "outputs": [], 104 | "source": [] 105 | } 106 | ], 107 | "metadata": { 108 | "kernelspec": { 109 | "display_name": "Python 3", 110 | "language": "python", 111 | "name": "python3" 112 | }, 113 | "language_info": { 114 | "codemirror_mode": { 115 | "name": "ipython", 116 | "version": 3 117 | }, 118 | "file_extension": ".py", 119 | "mimetype": "text/x-python", 120 | "name": "python", 121 | "nbconvert_exporter": "python", 122 | "pygments_lexer": "ipython3", 123 | "version": "3.5.2" 124 | } 125 | }, 126 | "nbformat": 4, 127 | "nbformat_minor": 1 128 | } 129 | -------------------------------------------------------------------------------- /170327-nipype/notebooks/testing/solutions/sector_area_general.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "import math" 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": 2, 17 | "metadata": { 18 | "collapsed": true 19 | }, 20 | "outputs": [], 21 | "source": [ 22 | "# a more general form of the function \n", 23 | "def sector_area(radius1, radius2, angle_deg):\n", 24 | " angle_rad = (2 * math.pi / 360) * angle_deg # changing degrees to radians\n", 25 | " area = 0.5 * (radius1**2 - radius2**2) * angle_rad\n", 26 | " return area" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 7, 32 | "metadata": { 33 | "collapsed": false 34 | }, 35 | "outputs": [], 36 | "source": [ 37 | "def test_gt0():\n", 38 | " for rad1, rad2, ang in [(2, 1, 30), (10, 5, 270)]:\n", 39 | " assert sector_area(rad1, rad2, ang) > 0" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": 8, 45 | "metadata": { 46 | "collapsed": true 47 | }, 48 | "outputs": [], 49 | "source": [ 50 | "def test_angle0():\n", 51 | " assert sector_area(5, 1, 0) == 0" 52 | ] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "execution_count": 9, 57 | "metadata": { 58 | "collapsed": true 59 | }, 60 | "outputs": [], 61 | "source": [ 62 | "def test_full():\n", 63 | " assert sector_area(5, 0, 360) == math.pi * 25" 64 | ] 65 | }, 66 | { 67 | "cell_type": "code", 68 | "execution_count": 10, 69 | "metadata": { 70 | "collapsed": false 71 | }, 72 | "outputs": [], 73 | "source": [ 74 | "test_gt0()\n", 75 | "test_angle0()\n", 76 | "test_full()" 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "execution_count": null, 82 | "metadata": { 83 | "collapsed": true 84 | }, 85 | "outputs": [], 86 | "source": [] 87 | } 88 | ], 89 | "metadata": { 90 | "anaconda-cloud": {}, 91 | "kernelspec": { 92 | "display_name": "Python 3", 93 | "language": "python", 94 | "name": "python3" 95 | }, 96 | "language_info": { 97 | "codemirror_mode": { 98 | "name": "ipython", 99 | "version": 3 100 | }, 101 | "file_extension": ".py", 102 | "mimetype": "text/x-python", 103 | "name": "python", 104 | "nbconvert_exporter": "python", 105 | "pygments_lexer": "ipython3", 106 | "version": "3.5.2" 107 | } 108 | }, 109 | "nbformat": 4, 110 | "nbformat_minor": 1 111 | } 112 | -------------------------------------------------------------------------------- /170327-nipype/startup.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Day 2 Preparation\n", 8 | "\n", 9 | "Start Docker" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "docker run -it --rm -p 8888:8888 -v /path/to/local_workshop_dir:/home/jovyan/work \\\n", 19 | " nipype/workshops:latest-base jupyter-lab" 20 | ] 21 | }, 22 | { 23 | "cell_type": "markdown", 24 | "metadata": {}, 25 | "source": [ 26 | "Update your workshops directory" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 2, 32 | "metadata": {}, 33 | "outputs": [ 34 | { 35 | "name": "stdout", 36 | "output_type": "stream", 37 | "text": [ 38 | "Already up-to-date.\r\n" 39 | ] 40 | } 41 | ], 42 | "source": [ 43 | "import os\n", 44 | "os.chdir('/home/jovyan/work/workshops')\n", 45 | "!git pull" 46 | ] 47 | }, 48 | { 49 | "cell_type": "markdown", 50 | "metadata": {}, 51 | "source": [ 52 | "If the above does not work, you probably don't have the workshops downloaded. Try:" 53 | ] 54 | }, 55 | { 56 | "cell_type": "code", 57 | "execution_count": null, 58 | "metadata": {}, 59 | "outputs": [], 60 | "source": [ 61 | "os.chdir('/home/jovyan/work')\n", 62 | "!git clone https://github.com/nipy/workshops.git" 63 | ] 64 | }, 65 | { 66 | "cell_type": "markdown", 67 | "metadata": {}, 68 | "source": [ 69 | "Make sure your data is up-to-date" 70 | ] 71 | }, 72 | { 73 | "cell_type": "code", 74 | "execution_count": 4, 75 | "metadata": {}, 76 | "outputs": [], 77 | "source": [ 78 | "os.chdir('/home/jovyan/work/data')\n", 79 | "!datalad install -r -g ///workshops/nipype-2017/ds000114" 80 | ] 81 | }, 82 | { 83 | "cell_type": "code", 84 | "execution_count": 6, 85 | "metadata": {}, 86 | "outputs": [], 87 | "source": [ 88 | "import nilearn.datasets\n", 89 | "\n", 90 | "haxby_dataset = nilearn.datasets.fetch_haxby(data_dir='/home/jovyan/work/data')" 91 | ] 92 | }, 93 | { 94 | "cell_type": "markdown", 95 | "metadata": {}, 96 | "source": [ 97 | "## Download the heudiconv image (for Mathias)\n", 98 | "\n", 99 | "On your host computer (not in Docker!)\n", 100 | "\n", 101 | "`docker pull nipy/heudiconv:latest`" 102 | ] 103 | } 104 | ], 105 | "metadata": { 106 | "kernelspec": { 107 | "display_name": "Python 3", 108 | "language": "python", 109 | "name": "python3" 110 | }, 111 | "language_info": { 112 | "codemirror_mode": { 113 | "name": "ipython", 114 | "version": 3 115 | }, 116 | "file_extension": ".py", 117 | "mimetype": "text/x-python", 118 | "name": "python", 119 | "nbconvert_exporter": "python", 120 | "pygments_lexer": "ipython3", 121 | "version": "3.5.2" 122 | } 123 | }, 124 | "nbformat": 4, 125 | "nbformat_minor": 2 126 | } 127 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Workshops 2 | 3 | This project contains directories with scripts used at various workshops. 4 | 5 | 120908_Nipype - Sep 2012, Magdeburg, Germany --------------------------------------------------------------------------------