{ "metadata": { "name": "Task 2" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "%pylab inline" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "\n", "Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].\n", "For more information, type 'help(pylab)'.\n" ] } ], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "from glob import glob\n", "from nipype.interfaces.dcm2nii import Dcm2nii\n", "from nipype.interfaces.fsl import BET\n", "\n", "import nipype.pipeline.engine as pe" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "convert = pe.Node(Dcm2nii(), name='convert_dicom')\n", "skull_stripper = pe.Node(BET(), name = 'skull_stripper')\n", "\n", "convert_flow = pe.Workflow(name = 'convert_and_strip')\n", "convert_flow.connect(convert, 'converted_files', skull_stripper, 'in_file')" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 3 }, { "cell_type": "code", "collapsed": false, "input": [ "fl = glob('/opt/data/NIPYPE_DATA/NKI.archive.1-5.007.LiteDICOM/3466763/session_1/MPRAGE_1/*.dcm')\n", "convert_flow.inputs.convert_dicom.source_names = fl[0] # or fl\n", "convert_flow.base_dir = '/mnt/mydir/'" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 4 }, { "cell_type": "code", "collapsed": false, "input": [ "convert_flow.run()" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:28,132 workflow INFO:\n", "\t ['check', 'execution', 'logging']\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:28,136 workflow INFO:\n", "\t Running serially.\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:28,138 workflow INFO:\n", "\t Executing node convert_dicom in dir: /mnt/mydir/convert_and_strip/convert_dicom\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:28,151 workflow INFO:\n", "\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" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:28,192 interface INFO:\n", "\t stdout 2012-09-09T06:56:28.191981:Chris Rorden's dcm2nii :: 2 November 2010 (Debian)\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:28,194 interface INFO:\n", "\t stdout 2012-09-09T06:56:28.191981:reading preferences file /home/nipype_user/.dcm2nii/dcm2nii.ini\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:28,195 interface INFO:\n", "\t stdout 2012-09-09T06:56:28.191981:reading preferences file config.ini\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:28,196 interface INFO:\n", "\t stdout 2012-09-09T06:56:28.191981:Data will be exported to /mnt/mydir/convert_and_strip/convert_dicom/\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:29,45 interface INFO:\n", "\t stdout 2012-09-09T06:56:29.044975:Validating 384 potential DICOM images.\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:29,45 interface INFO:\n", "\t stdout 2012-09-09T06:56:29.044975:Found 192 DICOM images.\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:29,46 interface INFO:\n", "\t stdout 2012-09-09T06:56:29.044975:Converting 192/192 1\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:29,46 interface INFO:\n", "\t stdout 2012-09-09T06:56:29.044975:m000-s0001-defaced_MPRAGE.nii.dcm->18991230_010000MPRAGEs011a1001.nii\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:29,47 interface INFO:\n", "\t stdout 2012-09-09T06:56:29.044975:Saving /mnt/mydir/convert_and_strip/convert_dicom/18991230_010000MPRAGEs011a1001.nii\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:29,633 interface INFO:\n", "\t stdout 2012-09-09T06:56:29.633844:Reorienting as /mnt/mydir/convert_and_strip/convert_dicom/o18991230_010000MPRAGEs011a1001.nii\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:29,634 interface INFO:\n", "\t stdout 2012-09-09T06:56:29.633844:Saving /mnt/mydir/convert_and_strip/convert_dicom/o18991230_010000MPRAGEs011a1001.nii\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:29,635 interface INFO:\n", "\t stdout 2012-09-09T06:56:29.633844:Cropping NIfTI/Analyze image /mnt/mydir/convert_and_strip/convert_dicom/o18991230_010000MPRAGEs011a1001.nii\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:29,668 interface INFO:\n", "\t stdout 2012-09-09T06:56:29.668688:Saving /mnt/mydir/convert_and_strip/convert_dicom/co18991230_010000MPRAGEs011a1001.nii\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:29,711 workflow INFO:\n", "\t Executing node skull_stripper in dir: /mnt/mydir/convert_and_strip/skull_stripper\n" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "120909-06:56:29,718 workflow INFO:\n", "\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" ] }, { "output_type": "pyout", "prompt_number": 5, "text": [ "" ] } ], "prompt_number": 5 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 5 } ], "metadata": {} } ] }