diff --git a/getting_started/basics.ipynb b/getting_started/01_basics.ipynb similarity index 56% rename from getting_started/basics.ipynb rename to getting_started/01_basics.ipynb index 4cd6d7951303564e791df3d80c95220afd2ce159..a3210a7e20a0249eb372f786bdbd83688074a0d2 100644 --- a/getting_started/basics.ipynb +++ b/getting_started/01_basics.ipynb @@ -30,17 +30,9 @@ }, { "cell_type": "code", - "execution_count": 63, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "a = 4\n", "b = 3.6\n", @@ -59,19 +51,9 @@ }, { "cell_type": "code", - "execution_count": 64, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[10, 20, 30]\n", - "{'b': 20, 'a': 10}\n", - "4 3.6 abc\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "print(d)\n", "print(e)\n", @@ -100,17 +82,9 @@ }, { "cell_type": "code", - "execution_count": 65, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "test string :: another test string\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "s1 = \"test string\"\n", "s2 = 'another test string'\n", @@ -126,20 +100,9 @@ }, { "cell_type": "code", - "execution_count": 66, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "This is\n", - "a string over\n", - "multiple lines\n", - "\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "s3 = '''This is\n", "a string over\n", @@ -159,18 +122,9 @@ }, { "cell_type": "code", - "execution_count": 67, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The numerical value is 1 and a name is PyTreat\n", - "A name is PyTreat and a number is 1\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "x = 1\n", "y = 'PyTreat'\n", @@ -192,18 +146,9 @@ }, { "cell_type": "code", - "execution_count": 68, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "THIS IS A TEST STRING\n", - "this is a test string\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "s = 'This is a Test String'\n", "print(s.upper())\n", @@ -219,17 +164,9 @@ }, { "cell_type": "code", - "execution_count": 69, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "This is a Better String\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "s = 'This is a Test String'\n", "s2 = s.replace('Test', 'Better')\n", @@ -245,17 +182,9 @@ }, { "cell_type": "code", - "execution_count": 70, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "This is an example of an example String\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "import re\n", "s = 'This is a test of a Test String'\n", @@ -277,17 +206,9 @@ }, { "cell_type": "code", - "execution_count": 71, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['This', 'is', 'a', 'test', 'of', 'a', 'Test', 'String']\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "print(s.split())" ] @@ -311,18 +232,9 @@ }, { "cell_type": "code", - "execution_count": 72, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(3, 7.6, 'str')\n", - "[1, 'mj', -5.4]\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "xtuple = (3, 7.6, 'str')\n", "xlist = [1, 'mj', -5.4]\n", @@ -339,18 +251,9 @@ }, { "cell_type": "code", - "execution_count": 73, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "x2 is: ((3, 7.6, 'str'), [1, 'mj', -5.4])\n", - "x3 is: [(3, 7.6, 'str'), [1, 'mj', -5.4]]\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "x2 = (xtuple, xlist)\n", "x3 = [xtuple, xlist]\n", @@ -369,17 +272,9 @@ }, { "cell_type": "code", - "execution_count": 74, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[10, 20, 30, 70, 80]\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "a = [10, 20, 30]\n", "a = a + [70]\n", @@ -398,17 +293,9 @@ }, { "cell_type": "code", - "execution_count": 75, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "20\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "d = [10, 20, 30]\n", "print(d[1])" @@ -424,18 +311,9 @@ }, { "cell_type": "code", - "execution_count": 76, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10\n", - "30\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "a = [10, 20, 30, 40, 50, 60]\n", "print(a[0])\n", @@ -451,18 +329,9 @@ }, { "cell_type": "code", - "execution_count": 77, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "60\n", - "10\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "print(a[-1])\n", "print(a[-6])" @@ -477,42 +346,18 @@ }, { "cell_type": "code", - "execution_count": 78, - "metadata": {}, - "outputs": [ - { - "ename": "IndexError", - "evalue": "list index out of range", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m<ipython-input-78-f4cf4536701c>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m7\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mIndexError\u001b[0m: list index out of range" - ], - "output_type": "error" - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "print(a[-7])" ] }, { "cell_type": "code", - "execution_count": 79, - "metadata": {}, - "outputs": [ - { - "ename": "IndexError", - "evalue": "list index out of range", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m<ipython-input-79-52d95fbe5286>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m6\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mIndexError\u001b[0m: list index out of range" - ], - "output_type": "error" - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "print(a[6])" ] @@ -526,17 +371,9 @@ }, { "cell_type": "code", - "execution_count": 80, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "6\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "print(len(a))" ] @@ -550,18 +387,9 @@ }, { "cell_type": "code", - "execution_count": 81, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "20\n", - "40\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "b = [[10, 20, 30], [40, 50, 60]]\n", "print(b[0][1])\n", @@ -584,17 +412,9 @@ }, { "cell_type": "code", - "execution_count": 82, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[10, 20, 30]\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "print(a[0:3])" ] @@ -611,18 +431,9 @@ }, { "cell_type": "code", - "execution_count": 83, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[10, 20, 30]\n", - "[20, 30]\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "a = [10, 20, 30, 40, 50, 60]\n", "print(a[0:3]) # same as a(1:3) in MATLAB\n", @@ -641,21 +452,9 @@ }, { "cell_type": "code", - "execution_count": 84, - "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "list indices must be integers or slices, not list", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m<ipython-input-84-aad7915ae3d8>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m4\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mb\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m: list indices must be integers or slices, not list" - ], - "output_type": "error" - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "b = [3, 4]\n", "print(a[b])" @@ -672,17 +471,9 @@ }, { "cell_type": "code", - "execution_count": 85, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30]\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "d = [10, 20, 30]\n", "print(d * 4)" @@ -697,19 +488,9 @@ }, { "cell_type": "code", - "execution_count": 86, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[10, 20, 30, 40]\n", - "[10, 30, 40]\n", - "[30, 40]\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "d.append(40)\n", "print(d)\n", @@ -728,19 +509,9 @@ }, { "cell_type": "code", - "execution_count": 87, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10\n", - "20\n", - "30\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "d = [10, 20, 30]\n", "for x in d:\n", @@ -760,134 +531,9 @@ }, { "cell_type": "code", - "execution_count": 88, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Help on list object:\n", - "\n", - "class list(object)\n", - " | list() -> new empty list\n", - " | list(iterable) -> new list initialized from iterable's items\n", - " | \n", - " | Methods defined here:\n", - " | \n", - " | __add__(self, value, /)\n", - " | Return self+value.\n", - " | \n", - " | __contains__(self, key, /)\n", - " | Return key in self.\n", - " | \n", - " | __delitem__(self, key, /)\n", - " | Delete self[key].\n", - " | \n", - " | __eq__(self, value, /)\n", - " | Return self==value.\n", - " | \n", - " | __ge__(self, value, /)\n", - " | Return self>=value.\n", - " | \n", - " | __getattribute__(self, name, /)\n", - " | Return getattr(self, name).\n", - " | \n", - " | __getitem__(...)\n", - " | x.__getitem__(y) <==> x[y]\n", - " | \n", - " | __gt__(self, value, /)\n", - " | Return self>value.\n", - " | \n", - " | __iadd__(self, value, /)\n", - " | Implement self+=value.\n", - " | \n", - " | __imul__(self, value, /)\n", - " | Implement self*=value.\n", - " | \n", - " | __init__(self, /, *args, **kwargs)\n", - " | Initialize self. See help(type(self)) for accurate signature.\n", - " | \n", - " | __iter__(self, /)\n", - " | Implement iter(self).\n", - " | \n", - " | __le__(self, value, /)\n", - " | Return self<=value.\n", - " | \n", - " | __len__(self, /)\n", - " | Return len(self).\n", - " | \n", - " | __lt__(self, value, /)\n", - " | Return self<value.\n", - " | \n", - " | __mul__(self, value, /)\n", - " | Return self*value.n\n", - " | \n", - " | __ne__(self, value, /)\n", - " | Return self!=value.\n", - " | \n", - " | __new__(*args, **kwargs) from builtins.type\n", - " | Create and return a new object. See help(type) for accurate signature.\n", - " | \n", - " | __repr__(self, /)\n", - " | Return repr(self).\n", - " | \n", - " | __reversed__(...)\n", - " | L.__reversed__() -- return a reverse iterator over the list\n", - " | \n", - " | __rmul__(self, value, /)\n", - " | Return self*value.\n", - " | \n", - " | __setitem__(self, key, value, /)\n", - " | Set self[key] to value.\n", - " | \n", - " | __sizeof__(...)\n", - " | L.__sizeof__() -- size of L in memory, in bytes\n", - " | \n", - " | append(...)\n", - " | L.append(object) -> None -- append object to end\n", - " | \n", - " | clear(...)\n", - " | L.clear() -> None -- remove all items from L\n", - " | \n", - " | copy(...)\n", - " | L.copy() -> list -- a shallow copy of L\n", - " | \n", - " | count(...)\n", - " | L.count(value) -> integer -- return number of occurrences of value\n", - " | \n", - " | extend(...)\n", - " | L.extend(iterable) -> None -- extend list by appending elements from the iterable\n", - " | \n", - " | index(...)\n", - " | L.index(value, [start, [stop]]) -> integer -- return first index of value.\n", - " | Raises ValueError if the value is not present.\n", - " | \n", - " | insert(...)\n", - " | L.insert(index, object) -- insert object before index\n", - " | \n", - " | pop(...)\n", - " | L.pop([index]) -> item -- remove and return item at index (default last).\n", - " | Raises IndexError if list is empty or index is out of range.\n", - " | \n", - " | remove(...)\n", - " | L.remove(value) -> None -- remove first occurrence of value.\n", - " | Raises ValueError if the value is not present.\n", - " | \n", - " | reverse(...)\n", - " | L.reverse() -- reverse *IN PLACE*\n", - " | \n", - " | sort(...)\n", - " | L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE*\n", - " | \n", - " | ----------------------------------------------------------------------\n", - " | Data and other attributes defined here:\n", - " | \n", - " | __hash__ = None\n", - "\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "help(d)" ] @@ -901,64 +547,9 @@ }, { "cell_type": "code", - "execution_count": 89, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['__add__',\n", - " '__class__',\n", - " '__contains__',\n", - " '__delattr__',\n", - " '__delitem__',\n", - " '__dir__',\n", - " '__doc__',\n", - " '__eq__',\n", - " '__format__',\n", - " '__ge__',\n", - " '__getattribute__',\n", - " '__getitem__',\n", - " '__gt__',\n", - " '__hash__',\n", - " '__iadd__',\n", - " '__imul__',\n", - " '__init__',\n", - " '__iter__',\n", - " '__le__',\n", - " '__len__',\n", - " '__lt__',\n", - " '__mul__',\n", - " '__ne__',\n", - " '__new__',\n", - " '__reduce__',\n", - " '__reduce_ex__',\n", - " '__repr__',\n", - " '__reversed__',\n", - " '__rmul__',\n", - " '__setattr__',\n", - " '__setitem__',\n", - " '__sizeof__',\n", - " '__str__',\n", - " '__subclasshook__',\n", - " 'append',\n", - " 'clear',\n", - " 'copy',\n", - " 'count',\n", - " 'extend',\n", - " 'index',\n", - " 'insert',\n", - " 'pop',\n", - " 'remove',\n", - " 'reverse',\n", - " 'sort']" - ] - }, - "execution_count": 89, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "dir(d)" ] @@ -978,20 +569,9 @@ }, { "cell_type": "code", - "execution_count": 90, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2\n", - "dict_keys(['b', 'a'])\n", - "dict_values([20, 10])\n", - "10\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "e = {'a' : 10, 'b': 20}\n", "print(len(e))\n", @@ -1015,17 +595,9 @@ }, { "cell_type": "code", - "execution_count": 91, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'c': 555, 'b': 20, 'a': 10}\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "e['c'] = 555 # just like in Biobank! ;)\n", "print(e)" @@ -1042,18 +614,9 @@ }, { "cell_type": "code", - "execution_count": 92, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'c': 555, 'a': 10}\n", - "{'a': 10}\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "e.pop('b')\n", "print(e)\n", @@ -1072,19 +635,9 @@ }, { "cell_type": "code", - "execution_count": 93, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('c', 555)\n", - "('b', 20)\n", - "('a', 10)\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "e = {'a' : 10, 'b': 20, 'c':555}\n", "for k, v in e.items():\n", @@ -1102,19 +655,9 @@ }, { "cell_type": "code", - "execution_count": 94, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('c', 555)\n", - "('b', 20)\n", - "('a', 10)\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "for k in e:\n", " print((k, e[k]))" @@ -1137,17 +680,9 @@ }, { "cell_type": "code", - "execution_count": 95, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "7\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "a = 7\n", "b = a\n", @@ -1164,17 +699,9 @@ }, { "cell_type": "code", - "execution_count": 96, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[8888]\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "a = [7]\n", "b = a\n", @@ -1191,17 +718,9 @@ }, { "cell_type": "code", - "execution_count": 97, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[7, 7]\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "a = [7]\n", "b = a * 2\n", @@ -1218,17 +737,9 @@ }, { "cell_type": "code", - "execution_count": 98, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[7]\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "a = [7]\n", "b = list(a)\n", @@ -1245,18 +756,9 @@ }, { "cell_type": "code", - "execution_count": 99, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(2, 5, 7)\n", - "[2, 5, 7]\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "xt = (2, 5, 7)\n", "xl = list(xt)\n", @@ -1275,20 +777,9 @@ }, { "cell_type": "code", - "execution_count": 100, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[5]\n", - "[5, 10]\n", - "[5, 10]\n", - "[5, 10]\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "def foo1(x):\n", " x.append(10)\n", @@ -1326,21 +817,9 @@ }, { "cell_type": "code", - "execution_count": 101, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Not a is: False\n", - "Not 1 is: False\n", - "Not 0 is: True\n", - "Not {} is: True\n", - "{}==0 is: False\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "a = True\n", "print('Not a is:', not a)\n", @@ -1359,19 +838,9 @@ }, { "cell_type": "code", - "execution_count": 102, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "False\n", - "True\n", - "True\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "print('the' in 'a number of words')\n", "print('of' in 'a number of words')\n", @@ -1389,18 +858,9 @@ }, { "cell_type": "code", - "execution_count": 103, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0.9933407850276534\n", - "Positive\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "import random\n", "a = random.uniform(-1, 1)\n", @@ -1422,17 +882,9 @@ }, { "cell_type": "code", - "execution_count": 104, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Variable is true, or at least not empty\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "a = [] # just one of many examples\n", "if not a:\n", @@ -1454,21 +906,9 @@ }, { "cell_type": "code", - "execution_count": 105, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2\n", - "is\n", - "more\n", - "than\n", - "1\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "for x in [2, 'is', 'more', 'than', 1]:\n", " print(x)" @@ -1485,23 +925,9 @@ }, { "cell_type": "code", - "execution_count": 106, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2\n", - "3\n", - "4\n", - "5\n", - "6\n", - "7\n", - "8\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "for x in range(2, 9):\n", " print(x)" @@ -1518,18 +944,9 @@ }, { "cell_type": "code", - "execution_count": 107, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4\n", - "7\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "x, y = [4, 7]\n", "print(x)\n", @@ -1545,21 +962,9 @@ }, { "cell_type": "code", - "execution_count": 108, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[('Some', 0), ('set', 1), ('of', 2), ('items', 3)]\n", - "0 Some\n", - "1 set\n", - "2 of\n", - "3 items\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "alist = ['Some', 'set', 'of', 'items']\n", "blist = list(range(len(alist)))\n", @@ -1581,17 +986,9 @@ }, { "cell_type": "code", - "execution_count": 109, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "35.041627991396396\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "import random\n", "n = 0\n", @@ -1625,17 +1022,9 @@ }, { "cell_type": "code", - "execution_count": 110, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "0.6576892259376057 0.11717666603919556\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "import random\n", "x = random.uniform(0, 1)\n", @@ -1654,18 +1043,9 @@ }, { "cell_type": "code", - "execution_count": 111, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]\n", - "[0, 1, 4, 9, 16, 25, 36, 64, 81]\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "v1 = [ x**2 for x in range(10) ]\n", "print(v1)\n", @@ -1679,34 +1059,9 @@ "source": [ "You'll find that python programmers use this kind of construction _*a lot*_." ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], - "metadata": { - "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.5.2" - } - }, + "metadata": {}, "nbformat": 4, "nbformat_minor": 2 } diff --git a/getting_started/basics.md b/getting_started/01_basics.md similarity index 100% rename from getting_started/basics.md rename to getting_started/01_basics.md diff --git a/getting_started/nifti.ipynb b/getting_started/05_nifti.ipynb similarity index 78% rename from getting_started/nifti.ipynb rename to getting_started/05_nifti.ipynb index 994edd80c08830bcf5e2d0ab2bb116f1ac5f4029..f157ec0113f48fb0a2d900017b926ed1db17116d 100644 --- a/getting_started/nifti.ipynb +++ b/getting_started/05_nifti.ipynb @@ -15,17 +15,9 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(182, 218, 182)\n" - ] - } - ], + "outputs": [], "source": [ "import numpy as np\n", "import nibabel as nib\n", @@ -65,17 +57,9 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(1.0, 1.0, 1.0)\n" - ] - } - ], + "outputs": [], "source": [ "voxsize = imhdr.get_zooms()\n", "print(voxsize)" @@ -92,21 +76,9 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "4\n", - "[[ -1. 0. 0. 90.]\n", - " [ 0. 1. 0. -126.]\n", - " [ 0. 0. 1. -72.]\n", - " [ 0. 0. 0. 1.]]\n" - ] - } - ], + "outputs": [], "source": [ "sform = imhdr.get_sform()\n", "sformcode = imhdr['sform_code']\n", @@ -127,7 +99,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -147,25 +119,7 @@ ] } ], - "metadata": { - "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.5.2" - } - }, + "metadata": {}, "nbformat": 4, "nbformat_minor": 2 } diff --git a/getting_started/nifti.md b/getting_started/05_nifti.md similarity index 100% rename from getting_started/nifti.md rename to getting_started/05_nifti.md diff --git a/getting_started/scripts.ipynb b/getting_started/08_scripts.ipynb similarity index 63% rename from getting_started/scripts.ipynb rename to getting_started/08_scripts.ipynb index 7b87ec6388573c9cebb864bdbea98da654593e9c..1d3d705d5b636c281ce97e6a527431c69075847d 100644 --- a/getting_started/scripts.ipynb +++ b/getting_started/08_scripts.ipynb @@ -18,9 +18,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "#!/usr/bin/env python" @@ -38,9 +36,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "#!/usr/bin/env fslpython" @@ -60,9 +56,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "import subprocess as sp\n", @@ -79,9 +73,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "spobj = sp.run(['ls'], stdout = sp.PIPE)" @@ -97,9 +89,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "spobj = sp.run('ls -la'.split(), stdout = sp.PIPE)\n", @@ -119,9 +109,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "import os\n", @@ -143,9 +131,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "commands = \"\"\"\n", @@ -176,9 +162,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "import sys\n", @@ -200,19 +184,10 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Usage: bash <input image> <output image>\n" - ] - } - ], + "outputs": [], "source": [ - "%%bash\n", "#!/bin/bash\n", "if [ $# -lt 2 ] ; then\n", " echo \"Usage: $0 <input image> <output image>\"\n", @@ -238,21 +213,9 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "IndexError", - "evalue": "list index out of range", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m<ipython-input-2-f7378930c369>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0mspobj\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mfsldir\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;34m'/bin/fslstats'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0moutfile\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'-V'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstdout\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mPIPE\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0msout\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mspobj\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstdout\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdecode\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'utf-8'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 15\u001b[0;31m \u001b[0mvol_vox\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfloat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msout\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msplit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 16\u001b[0m \u001b[0mvol_mm\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfloat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msout\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msplit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 17\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Volumes are: '\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvol_vox\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m' in voxels and '\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvol_mm\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m' in mm'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mIndexError\u001b[0m: list index out of range" - ], - "output_type": "error" - } - ], + "outputs": [], "source": [ "#!/usr/bin/env fslpython\n", "import os, sys\n", @@ -272,55 +235,9 @@ "vol_mm = float(sout.split()[1])\n", "print('Volumes are: ', vol_vox, ' in voxels and ', vol_mm, ' in mm')" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] } ], - "metadata": { - "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.6.2" - }, - "toc": { - "colors": { - "hover_highlight": "#DAA520", - "running_highlight": "#FF0000", - "selected_highlight": "#FFD700" - }, - "moveMenuLeft": true, - "nav_menu": { - "height": "105px", - "width": "252px" - }, - "navigate_menu": true, - "number_sections": true, - "sideBar": true, - "threshold": 4.0, - "toc_cell": false, - "toc_section_display": "block", - "toc_window_display": false - } - }, + "metadata": {}, "nbformat": 4, "nbformat_minor": 2 } diff --git a/getting_started/scripts.md b/getting_started/08_scripts.md similarity index 100% rename from getting_started/scripts.md rename to getting_started/08_scripts.md