From 437fb82cb8dc9940f46b0132f22014a33974f1a4 Mon Sep 17 00:00:00 2001 From: spinicist Date: Fri, 26 Jun 2020 10:17:08 +0100 Subject: [PATCH] DOC Update README before pushing qipype --- Python/{ => Notebooks}/T1_mapping.ipynb | 0 Python/example_notebook.ipynb | 198 ------------------------ Python/setup.py | 2 +- README.md | 10 +- 4 files changed, 5 insertions(+), 205 deletions(-) rename Python/{ => Notebooks}/T1_mapping.ipynb (100%) delete mode 100644 Python/example_notebook.ipynb diff --git a/Python/T1_mapping.ipynb b/Python/Notebooks/T1_mapping.ipynb similarity index 100% rename from Python/T1_mapping.ipynb rename to Python/Notebooks/T1_mapping.ipynb diff --git a/Python/example_notebook.ipynb b/Python/example_notebook.ipynb deleted file mode 100644 index 63ddfa9..0000000 --- a/Python/example_notebook.ipynb +++ /dev/null @@ -1,198 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "outputs": [], - "source": [ - "# Setup\n", - "\n", - "This notebook deomstrates how to create a basic `nipype` pipeline with `QUIT` programs. The `nanslice` package will be used to display the outputs.\n", - "\n", - "This pipeline downloads the BrainWeb \"crisp\" brain phantom from http://brainweb.bic.mni.mcgill.ca. It then replaces the tissue classification labels with values of Proton Density and T1, simulates an SPGR/FLASH image with some added noise, and finally uses that simulated data to fit for T1 and PD again." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "outputs": [], - "source": [ - "## Imports and Data Fetching" - ] - }, - { - "cell_type": "code", - "metadata": {}, - "outputs": [], - "source": [ - "%matplotlib inline\n", - "from quit.interfaces.relax import DESPOT1, DESPOT1Sim, DESPOT2\n", - "from nanslice import Layer\n", - "import nanslice.jupyter as ns\n", - "import nibabel as nib\n", - "import numpy as np\n", - "import requests\n", - "import gzip\n", - "import os.path" - ] - }, - { - "cell_type": "code", - "metadata": {}, - "outputs": [], - "source": [ - "if not os.path.isfile('classes.mnc'): \n", - " params = {'download_for_real':'[Start Download!]',\n", - " 'do_download_alias':'phantom_1.0mm_normal_crisp',\n", - " 'format_value':'minc',\n", - " 'who_name': 'Tobias Wood',\n", - " 'who_institution': 'KCL',\n", - " 'who_email': 'tobias.wood@kcl.ac.uk'}\n", - " response = requests.get(url='http://brainweb.bic.mni.mcgill.ca/cgi/brainweb1', params=params)\n", - " minc_file = open('classes.mnc', 'wb')\n", - " minc_file.write(response.content)\n", - "classes = Layer('classes.mnc')" - ] - }, - { - "cell_type": "code", - "metadata": {}, - "outputs": [], - "source": [ - "ns.three_plane(classes)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "outputs": [], - "source": [ - "## Create Reference Data" - ] - }, - { - "cell_type": "code", - "metadata": {}, - "outputs": [], - "source": [ - "# 0=Background\n", - "# 1=CSF\n", - "# 2=Grey Matter\n", - "# 3=White Matter\n", - "# 4=Fat\n", - "# 5=Muscle/Skin\n", - "# 6=Skin\n", - "# 7=Skull\n", - "# 8=Glial Matter\n", - "# 9=Connective\n", - "PDvals = np.array([0, 1, 0.8, 0.7, 0, 0, 0, 0, 0, 0])\n", - "T1vals = np.array([0, 3.0, 1.1, 0.9, 0, 0, 0, 0, 0, 0])\n", - "class_data = classes.image.get_data().astype('int32')\n", - "PDdata = np.choose(class_data, PDvals).astype('float32')\n", - "T1data = np.choose(class_data, T1vals).astype('float32')\n", - "# PDdata = np.array(list(map(PDFunc, classes.image.get_data())))\n", - "PDimage = nib.nifti1.Nifti1Image(PDdata, affine=classes.image.affine)\n", - "T1image = nib.nifti1.Nifti1Image(T1data, affine=classes.image.affine)\n", - "nib.save(PDimage, 'PD.nii.gz')\n", - "nib.save(T1image, 'T1.nii.gz')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "outputs": [], - "source": [ - "## Simulate and Display Image" - ] - }, - { - "cell_type": "code", - "metadata": {}, - "outputs": [], - "source": [ - "d1seq = {'SPGR': {'TR': 10e-3, 'FA': [3, 18]}}\n", - "d1sim = DESPOT1Sim(sequence=d1seq, in_file='sim_spgr.nii.gz', noise=0.001, PD='PD.nii.gz', T1='T1.nii.gz')\n", - "d1sim_result = d1sim.run()" - ] - }, - { - "cell_type": "code", - "metadata": {}, - "outputs": [], - "source": [ - "spgr = Layer(d1sim_result.outputs.out_file, volume=0)\n", - "display(ns.three_plane(spgr))\n", - "spgr.volume = 1\n", - "display(ns.three_plane(spgr))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "outputs": [], - "source": [ - "## Run DESPOT1 and Compare Results to Reference" - ] - }, - { - "cell_type": "code", - "metadata": {}, - "outputs": [], - "source": [ - "d1 = DESPOT1(sequence=d1seq, in_file='sim_spgr.nii.gz')\n", - "d1_result = d1.run()" - ] - }, - { - "cell_type": "code", - "metadata": {}, - "outputs": [], - "source": [ - "display(ns.three_plane(Layer('PD.nii.gz', label='PD (Arb Units)'), cbar=True))\n", - "display(ns.three_plane(Layer('T1.nii.gz', clim=(0, 2.0), cmap='plasma', label='T1 (s)'), cbar=True))" - ] - }, - { - "cell_type": "code", - "metadata": {}, - "outputs": [], - "source": [ - "display(ns.three_plane(Layer('D1_PD.nii.gz', label='PD (Arb Units)'), cbar=True))\n", - "display(ns.three_plane(Layer('D1_T1.nii.gz', clim=(0, 2.0), cmap='plasma', label='T1 (s)'), cbar=True))" - ] - }, - { - "cell_type": "code", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernel_info": { - "name": "python3" - }, - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.7.4" - }, - "nteract": { - "version": "0.8.4" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} \ No newline at end of file diff --git a/Python/setup.py b/Python/setup.py index 2af4164..400085e 100644 --- a/Python/setup.py +++ b/Python/setup.py @@ -13,7 +13,7 @@ setup( name='qipype', - version='1.0', + version='0.1', description='nipype interfaces to QUantitative Imaging Tools', long_description=long_description, long_description_content_type="text/markdown", diff --git a/README.md b/README.md index 9900234..d02c926 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ in the documentation. ### Python -QUIT now comes with `nipype` wrappers. Install with `pip install QUIT`. +QUIT now comes with `nipype` wrappers. Install with `pip install qipype`. ## Usage @@ -61,11 +61,9 @@ of commands require an input 4D Nifti file containing the image data to fit, and a `.json` file containing the sequence parameters (e.g. `TR`). See examples for each command at http://quit.readthedocs.io. -For the `nipype` wrappers, there are example iPython notebooks available in this -directory https://github.com/spinicist/QUIT/blob/master/Python/. You can -download the one for T1 mapping here https://github.com/spinicist/QUIT/raw/master/Python/T1_mapping.ipynb. -Alternatively, look at the example workflows for CEST and MPM to see how to -build a complete pipeline. +There is an example iPython notebooks available in this +directory https://mybinder.org/v2/gh/spinicist/QUIT/master?filepath=Python%2FNotebooks%2FT1_mapping.ipynb. +Workflows for CEST and MPM are provided in `qipype.workflows`. ## Getting Help