From 26092e074ae77ff1f77dd963c16697a2a0b28329 Mon Sep 17 00:00:00 2001 From: Jermiah Joseph Date: Sun, 4 Feb 2024 17:14:56 -0500 Subject: [PATCH 1/3] docs: update --- docs/test.rst | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/docs/test.rst b/docs/test.rst index 1b354ea..9ba8955 100644 --- a/docs/test.rst +++ b/docs/test.rst @@ -1,13 +1,9 @@ -.. Your Project Documentation - =========================== - -Introduction ------------- - -Your introduction goes here. - -Usage +Initialize Client ----- +By default, nbiatoolkit uses the guest account to access all collections in the API that are publicly available. +If you have a user account that has been granted specific access to a collection, you can use your credentials to +initialize the client when performing a query. + .. tabs:: From 1f242d51cd5ebf93cff5dfae9816c01b1dc961a5 Mon Sep 17 00:00:00 2001 From: Jermiah Joseph Date: Sun, 4 Feb 2024 17:24:59 -0500 Subject: [PATCH 2/3] docs: add example initialization --- docs/test.rst | 67 +++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/docs/test.rst b/docs/test.rst index 9ba8955..006fe9e 100644 --- a/docs/test.rst +++ b/docs/test.rst @@ -7,13 +7,13 @@ initialize the client when performing a query. .. tabs:: - .. tab:: Command Line + .. tab:: + + + - To perform an operation using the command line, use the following command: - .. code-block:: bash - your_command_line_tool --option1 value1 --option2 value2 .. tab:: Python @@ -27,49 +27,61 @@ initialize the client when performing a query. instance.run_operation() + .. tabs:: - .. tab:: Apples + To get a list of available public collections that start with "TCGA", run the following command: - Apples are green, or sometimes red. + .. tab:: Command Line - .. tab:: Pears + .. tabs:: - Pears are green. + .. tab:: Guest Account - .. tab:: Oranges + .. code-block:: bash - Oranges are orange. + getCollections --prefix TCGA -.. tabs:: + .. tab:: Your Account + + getCollections -u -p --prefix TCGA - .. tab:: Stars + .. tab:: Python .. tabs:: - .. tab:: The Sun + .. tab:: Guest Account - The closest star to us. + .. code-block:: python - .. tab:: Proxima Centauri + from nbiatoolkit import NBIAClient - The second closest star to us. + client = NBIAClient() + client.getCollections(prefix='TCGA') - .. tab:: Polaris + .. tab:: Your Account - The North Star. + .. code-block:: python - .. tab:: Moons + from nbiatoolkit import NBIAClient - .. tabs:: + client = NBIAClient(username = "", password = "") + client.getCollections(prefix='TCGA') - .. tab:: The Moon +.. tabs:: + + .. tab:: Apples + + Apples are green, or sometimes red. + + .. tab:: Pears - Orbits the Earth + Pears are green. + + .. tab:: Oranges - .. tab:: Titan + Oranges are orange. - Orbits Jupiter .. tabs:: @@ -171,10 +183,3 @@ initialize the client when performing a query. main <- function() { return(0) } -Configuration -------------- - -Your configuration details go here. - -... - From 39c7994d083c43d89aee46eaaedab19f5d809d95 Mon Sep 17 00:00:00 2001 From: Jermiah Joseph Date: Sun, 4 Feb 2024 18:01:51 -0500 Subject: [PATCH 3/3] docs: added cool functionality for documentation --- docs/Tutorial.ipynb | 1079 ---- docs/_html_notebooks/test_setup.ipynb | 63 + docs/_static/test_setup.html | 7526 +++++++++++++++++++++++++ docs/conf.py | 4 +- docs/index.md | 2 +- docs/test.rst | 54 +- 6 files changed, 7614 insertions(+), 1114 deletions(-) delete mode 100644 docs/Tutorial.ipynb create mode 100644 docs/_html_notebooks/test_setup.ipynb create mode 100644 docs/_static/test_setup.html diff --git a/docs/Tutorial.ipynb b/docs/Tutorial.ipynb deleted file mode 100644 index 11dcc09..0000000 --- a/docs/Tutorial.ipynb +++ /dev/null @@ -1,1079 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Setup \n", - "\n", - "By default the client will use the Public API with the Guest Login credentials.\n", - "from the nbia which has access to all public data. \n", - "\n", - "To use your own credentials you can pass them in as parameters to the client using:\n", - "\n", - "``` python\n", - "NBIAClient(\n", - " username=\"YOUR_USERNAME\", \n", - " password=\"YOUR_PASSWORD\", \n", - " log_level = [\"DEBUG\", \"INFO\", \"WARNING\", \"ERROR\", \"CRITICAL\"]\n", - ")\n", - "```" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": {}, - "outputs": [], - "source": [ - "import nbiatoolkit\n", - "from nbiatoolkit import NBIAClient\n", - "from pprint import pprint\n", - "\n", - "# Instantiate the client. \n", - "# NOTE: if using guest access, you dont have to provide the following, it will default to guest access\n", - "client = NBIAClient(username = \"nbia_guest\", password = \"\", log_level='info')\n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'0.22.1'" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# import nbiatoolkit \n", - "nbiatoolkit.__version__" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Get Collection Methods" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### get list of collections (names only)\n", - "``` python\n", - "client.getCollections(prefix: str = \"\")\n", - "```" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total collections: 124\n", - "['4D-Lung', 'ACRIN-6698', 'ACRIN-Contralateral-Breast-MR', 'ACRIN-FLT-Breast', 'ACRIN-NSCLC-FDG-PET']\n" - ] - } - ], - "source": [ - "collections = client.getCollections()\n", - "print(\"Total collections: \", len(collections))\n", - "print(collections[0:5])" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['TCGA-BLCA', 'TCGA-BRCA', 'TCGA-CESC', 'TCGA-COAD', 'TCGA-ESCA', 'TCGA-KICH', 'TCGA-KIRC', 'TCGA-KIRP', 'TCGA-LIHC', 'TCGA-LUAD', 'TCGA-LUSC', 'TCGA-OV', 'TCGA-PRAD', 'TCGA-READ', 'TCGA-SARC', 'TCGA-STAD', 'TCGA-THCA', 'TCGA-UCEC']\n" - ] - } - ], - "source": [ - "collections = client.getCollections(prefix = \"TCGA\")\n", - "print(collections)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### get Collection Description\n", - "\n", - "``` python\n", - "getCollectionDescriptions(\n", - " collectionName: str # (required)\n", - ")\n", - "```" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[{'collectionName': 'TCGA-BLCA',\n", - " 'description': 'The Cancer Genome Atlas-Bladder Endothelial Carcinoma '\n", - " '(TCGA-BLCA) data collection is part of a larger effort to '\n", - " 'enhance the TCGA http://cancergenome.nih.gov/ data set with '\n", - " 'characterized radiological images. The Cancer Imaging '\n", - " 'Program (CIP), with the cooperation of several of the TCGA '\n", - " 'tissue-contributing institutions, has archived a large '\n", - " 'portion of the radiological images of the '\n", - " 'genetically-analyzed BLCA cases. Please see the TCGA-BLCA '\n", - " 'page to learn more about the images and to obtain any '\n", - " 'supporting metadata for this collection.',\n", - " 'descriptionURI': 'https://doi.org/10.7937/K9/TCIA.2016.8LNG8XDR',\n", - " 'lastUpdated': '2023-03-16'}]\n" - ] - } - ], - "source": [ - "pprint(client.getCollectionDescriptions(\"TCGA-BLCA\"))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### get Counts of Patients for each collection\n", - "`getCollectionPatientCount(prefx: str = \"\")`" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[{'Collection': '4D-Lung', 'PatientCount': 20},\n", - " {'Collection': 'ACRIN-6698', 'PatientCount': 385},\n", - " {'Collection': 'ACRIN-Contralateral-Breast-MR', 'PatientCount': 984},\n", - " {'Collection': 'ACRIN-FLT-Breast', 'PatientCount': 83},\n", - " {'Collection': 'ACRIN-NSCLC-FDG-PET', 'PatientCount': 242}]\n" - ] - } - ], - "source": [ - "collectionsPatientCount = client.getCollectionPatientCount()\n", - "pprint(collectionsPatientCount[0:5])" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[{'Collection': 'TCGA-BLCA', 'PatientCount': 120},\n", - " {'Collection': 'TCGA-BRCA', 'PatientCount': 139},\n", - " {'Collection': 'TCGA-CESC', 'PatientCount': 54},\n", - " {'Collection': 'TCGA-COAD', 'PatientCount': 25},\n", - " {'Collection': 'TCGA-ESCA', 'PatientCount': 16},\n", - " {'Collection': 'TCGA-KICH', 'PatientCount': 15},\n", - " {'Collection': 'TCGA-KIRC', 'PatientCount': 267},\n", - " {'Collection': 'TCGA-KIRP', 'PatientCount': 33},\n", - " {'Collection': 'TCGA-LIHC', 'PatientCount': 97},\n", - " {'Collection': 'TCGA-LUAD', 'PatientCount': 69},\n", - " {'Collection': 'TCGA-LUSC', 'PatientCount': 37},\n", - " {'Collection': 'TCGA-OV', 'PatientCount': 143},\n", - " {'Collection': 'TCGA-PRAD', 'PatientCount': 14},\n", - " {'Collection': 'TCGA-READ', 'PatientCount': 3},\n", - " {'Collection': 'TCGA-SARC', 'PatientCount': 5},\n", - " {'Collection': 'TCGA-STAD', 'PatientCount': 46},\n", - " {'Collection': 'TCGA-THCA', 'PatientCount': 6},\n", - " {'Collection': 'TCGA-UCEC', 'PatientCount': 65}]\n", - "Collection with max PatientCount: {'Collection': 'TCGA-KIRC', 'PatientCount': 267}\n" - ] - } - ], - "source": [ - "collectionsPatientCount = client.getCollectionPatientCount(prefix=\"TCGA\")\n", - "pprint(collectionsPatientCount)\n", - "\n", - "# get the collection with max PatientCount\n", - "print(\"Collection with max PatientCount: \", max(collectionsPatientCount, key=lambda x:x['PatientCount']))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### get Counts of Patients grouped by Body Parts\n", - "`getBodyPartCounts(collection: str = \"\", modality: str = \"\")`" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total Number of body parts:60\n", - "First 5 body parts:\n", - "[{'BodyPartExamined': 'NOT SPECIFIED', 'Count': 7839},\n", - " {'BodyPartExamined': 'ABDOMEN', 'Count': 1731},\n", - " {'BodyPartExamined': 'ABDOMEN CAVIT', 'Count': 2},\n", - " {'BodyPartExamined': 'ABDOMENPELVIC', 'Count': 2},\n", - " {'BodyPartExamined': 'ABDOMENPELVIS', 'Count': 50}]\n" - ] - } - ], - "source": [ - "bodypart_count = client.getBodyPartCounts()\n", - "print(\"Total Number of body parts:\" + str(len(bodypart_count)))\n", - "\n", - "print(\"First 5 body parts:\")\n", - "pprint(bodypart_count[0:5])" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total Number of body parts:1\n", - "Number of patients for each body part in 4D-Lung collection:\n", - "[{'BodyPartExamined': 'LUNG', 'Count': 20}]\n" - ] - } - ], - "source": [ - "bodypart_count = client.getBodyPartCounts(Collection = '4D-Lung')\n", - "print(\"Total Number of body parts:\" + str(len(bodypart_count)))\n", - "\n", - "print(\"Number of patients for each body part in 4D-Lung collection:\")\n", - "pprint(bodypart_count)" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total Number of body parts:5\n", - "Number of patients for each body part in 4D-Lung collection:\n", - "[{'BodyPartExamined': 'NOT SPECIFIED', 'Count': 194},\n", - " {'BodyPartExamined': 'ABDOMEN', 'Count': 11},\n", - " {'BodyPartExamined': 'CHEST', 'Count': 54},\n", - " {'BodyPartExamined': 'HEART', 'Count': 2},\n", - " {'BodyPartExamined': 'THORAX', 'Count': 1}]\n" - ] - } - ], - "source": [ - "bodypart_count = client.getBodyPartCounts(Collection = 'NSCLC Radiogenomics', Modality='CT')\n", - "print(\"Total Number of body parts:\" + str(len(bodypart_count)))\n", - "\n", - "print(\"Number of patients for each body part in 4D-Lung collection:\")\n", - "pprint(bodypart_count)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Get Patient Methods" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### getPatients\n", - "``` python\n", - "getPatients(\n", - " Collection: str = \"\", # (optional)\n", - ")\n", - "````" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total patients in TCGA-BLCA: 120\n", - "[{'Collection': 'TCGA-BLCA',\n", - " 'EthnicGroup': '1',\n", - " 'PatientId': 'TCGA-CU-A3QU',\n", - " 'PatientName': 'TCGA-CU-A3QU',\n", - " 'PatientSex': 'M',\n", - " 'Phantom': 'NO',\n", - " 'SpeciesCode': '337915000',\n", - " 'SpeciesDescription': 'Homo sapiens'},\n", - " {'Collection': 'TCGA-BLCA',\n", - " 'EthnicGroup': '1',\n", - " 'PatientId': 'TCGA-CU-A3KJ',\n", - " 'PatientName': 'TCGA-CU-A3KJ',\n", - " 'PatientSex': 'M',\n", - " 'Phantom': 'NO',\n", - " 'SpeciesCode': '337915000',\n", - " 'SpeciesDescription': 'Homo sapiens'}]\n" - ] - } - ], - "source": [ - "patients = client.getPatients(Collection = \"TCGA-BLCA\")\n", - "print(f\"Total patients in TCGA-BLCA: {len(patients)}\")\n", - "pprint(patients[0:2])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### getPatientsByCollectionAndModality\n", - "``` python\n", - "getPatientsByCollectionAndModality(\n", - " Collection: str, # (required)\n", - " Modality: str, # (required)\n", - ")\n", - "````" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total patients in TCGA-BLCA with modality CT: 107\n", - "['TCGA-CU-A3QU', 'TCGA-CU-A3KJ', 'TCGA-CU-A0YR', 'TCGA-CU-A0YO', 'TCGA-CU-A3YL']\n" - ] - } - ], - "source": [ - "patients = client.getPatientsByCollectionAndModality(Collection=\"TCGA-BLCA\", Modality=\"CT\")\n", - "print(f\"Total patients in TCGA-BLCA with modality CT: {len(patients)}\")\n", - "pprint(patients[0:5])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### getNewPatients In Collection\n", - "\n", - "``` python\n", - "getNewPatients(\n", - " Collection: str, # (required)\n", - " Date: str, # (required) accepted formats:\n", - " # \"%Y-%m-%d\", \"%Y/%m/%d\", \"%Y%m%d\", \n", - " # \"%m/%d/%Y\", \"%d/%m/%Y\", \"%d-%m-%Y\"\n", - ")\n" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total new patients in TCGA-BLCA after 2019-01-01: 15\n", - "[{'Collection': 'TCGA-BLCA',\n", - " 'PatientId': 'TCGA-4Z-AA86',\n", - " 'PatientName': 'TCGA-4Z-AA86',\n", - " 'PatientSex': 'M',\n", - " 'Phantom': 'NO',\n", - " 'SpeciesCode': '337915000',\n", - " 'SpeciesDescription': 'Homo sapiens'},\n", - " {'Collection': 'TCGA-BLCA',\n", - " 'PatientId': 'TCGA-G2-A2EC',\n", - " 'PatientName': 'TCGA-G2-A2EC',\n", - " 'PatientSex': 'F',\n", - " 'Phantom': 'NO',\n", - " 'SpeciesCode': '337915000',\n", - " 'SpeciesDescription': 'Homo sapiens'},\n", - " {'Collection': 'TCGA-BLCA',\n", - " 'EthnicGroup': 'W',\n", - " 'PatientId': 'TCGA-G2-A2EF',\n", - " 'PatientName': 'TCGA-G2-A2EF',\n", - " 'PatientSex': 'M',\n", - " 'Phantom': 'NO',\n", - " 'SpeciesCode': '337915000',\n", - " 'SpeciesDescription': 'Homo sapiens'},\n", - " {'Collection': 'TCGA-BLCA',\n", - " 'PatientId': 'TCGA-G2-A2EJ',\n", - " 'PatientName': 'TCGA-G2-A2EJ',\n", - " 'PatientSex': 'F',\n", - " 'Phantom': 'NO',\n", - " 'SpeciesCode': '337915000',\n", - " 'SpeciesDescription': 'Homo sapiens'},\n", - " {'Collection': 'TCGA-BLCA',\n", - " 'EthnicGroup': 'W',\n", - " 'PatientId': 'TCGA-G2-A2EK',\n", - " 'PatientName': 'TCGA-G2-A2EK',\n", - " 'PatientSex': 'M',\n", - " 'Phantom': 'NO',\n", - " 'SpeciesCode': '337915000',\n", - " 'SpeciesDescription': 'Homo sapiens'}]\n" - ] - } - ], - "source": [ - "newPatients = client.getNewPatients(Collection=\"TCGA-BLCA\", Date=\"2019-01-01\")\n", - "print(f\"Total new patients in TCGA-BLCA after 2019-01-01: {len(newPatients)}\")\n", - "pprint(newPatients[0:5])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Get Studies Methods" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "``` python\n", - "getStudies(\n", - " Collection: str, # (required)\n", - " PatientID: str = \"\", # (optional)\n", - " StudyInstanceUID: str = \"\" # (optional)\n", - " ) \n", - "```" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total studies in TCGA-BLCA: 192\n", - "[{'Collection': 'TCGA-BLCA',\n", - " 'EthnicGroup': '1',\n", - " 'PatientAge': '058Y',\n", - " 'PatientID': 'TCGA-CU-A3QU',\n", - " 'PatientName': 'TCGA-CU-A3QU',\n", - " 'PatientSex': 'M',\n", - " 'SeriesCount': 2,\n", - " 'StudyDate': '2004-01-20 00:00:00.0',\n", - " 'StudyDescription': 'CT ABDOMEN PELVIS W CONT',\n", - " 'StudyInstanceUID': '1.3.6.1.4.1.14519.5.2.1.8421.4016.447463489999137002327924629563'},\n", - " {'Collection': 'TCGA-BLCA',\n", - " 'EthnicGroup': '1',\n", - " 'PatientAge': '076Y',\n", - " 'PatientID': 'TCGA-CU-A3KJ',\n", - " 'PatientName': 'TCGA-CU-A3KJ',\n", - " 'PatientSex': 'M',\n", - " 'SeriesCount': 2,\n", - " 'StudyDate': '2003-12-30 00:00:00.0',\n", - " 'StudyDescription': 'CT ABDOMEN PELVIS W CONT',\n", - " 'StudyInstanceUID': '1.3.6.1.4.1.14519.5.2.1.8421.4016.457123040069610055154620740646'}]\n" - ] - } - ], - "source": [ - "studies = client.getStudies(Collection = \"TCGA-BLCA\")\n", - "print(f\"Total studies in TCGA-BLCA: {len(studies)}\")\n", - "pprint(studies[0:2])" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total studies in TCGA-BLCA for patient TCGA-CU-A0YO: 2\n", - "[{'Collection': 'TCGA-BLCA',\n", - " 'PatientAge': '084Y',\n", - " 'PatientID': 'TCGA-CU-A0YO',\n", - " 'PatientName': 'TCGA-CU-A0YO',\n", - " 'PatientSex': 'M',\n", - " 'SeriesCount': 5,\n", - " 'StudyDate': '2001-11-06 00:00:00.0',\n", - " 'StudyDescription': 'Outside Read or Comparison BODY CT',\n", - " 'StudyInstanceUID': '1.3.6.1.4.1.14519.5.2.1.8421.4016.315224324288394499015843085109'},\n", - " {'Collection': 'TCGA-BLCA',\n", - " 'PatientAge': '084Y',\n", - " 'PatientID': 'TCGA-CU-A0YO',\n", - " 'PatientName': 'TCGA-CU-A0YO',\n", - " 'PatientSex': 'M',\n", - " 'SeriesCount': 5,\n", - " 'StudyDate': '2001-05-31 00:00:00.0',\n", - " 'StudyDescription': 'Outside Read or Comparison BODY CT',\n", - " 'StudyInstanceUID': '1.3.6.1.4.1.14519.5.2.1.8421.4016.119440479687638160287088326194'}]\n" - ] - } - ], - "source": [ - "collection = \"TCGA-BLCA\"\n", - "patients = client.getPatientsByCollectionAndModality(Collection=collection, Modality=\"CT\")\n", - "studies = client.getStudies(Collection = collection, PatientID = patients[3])\n", - "print(f\"Total studies in TCGA-BLCA for patient {patients[3]}: {len(studies)}\")\n", - "pprint(studies[0:5])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Get Series Methods" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### get Series Data using parameters\n", - "\n", - "``` python\n", - "getSeries(\n", - " Collection: str = \"\", \n", - " PatientID: str = \"\",\n", - " StudyInstanceUID: str = \"\",\n", - " Modality: str = \"\",\n", - " SeriesInstanceUID: str = \"\",\n", - " BodyPartExamined: str = \"\",\n", - " ManufacturerModelName: str = \"\",\n", - " Manufacturer: str = \"\") \n", - "```" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "There are 1351 series in the NSCLC Radiogenomics collection.\n", - "First series:\n", - "{'Collection': 'NSCLC Radiogenomics',\n", - " 'CollectionURI': 'https://doi.org/10.7937/K9/TCIA.2017.7hs46erv',\n", - " 'FileSize': 135541046,\n", - " 'ImageCount': 257,\n", - " 'LicenseName': 'Creative Commons Attribution 3.0 Unported License',\n", - " 'LicenseURI': 'http://creativecommons.org/licenses/by/3.0/',\n", - " 'Manufacturer': 'GE MEDICAL SYSTEMS',\n", - " 'ManufacturerModelName': 'Discovery STE',\n", - " 'Modality': 'CT',\n", - " 'PatientID': 'R01-054',\n", - " 'ProtocolName': '6.2 VA_STD_TORSO_3D',\n", - " 'SeriesDate': '1993-10-09 00:00:00.0',\n", - " 'SeriesDescription': 'CT_SLICES',\n", - " 'SeriesInstanceUID': '1.3.6.1.4.1.14519.5.2.1.4334.1501.313535848942036628030417605312',\n", - " 'SeriesNumber': 3,\n", - " 'SoftwareVersions': 'dm09_dvctsp1.23',\n", - " 'StudyInstanceUID': '1.3.6.1.4.1.14519.5.2.1.4334.1501.251618660025569025068340782649',\n", - " 'TimeStamp': '2017-11-21 10:18:42.0'}\n" - ] - } - ], - "source": [ - "# Get all the series in the NSCLC Radiogenomics collection\n", - "seriesJSON = client.getSeries(Collection=\"NSCLC Radiogenomics\")\n", - "print(f\"There are {len(seriesJSON)} series in the NSCLC Radiogenomics collection.\")\n", - "print(\"First series:\")\n", - "pprint(seriesJSON[0])" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "There are 8 series in the NSCLC Radiogenomics collection for HEART.\n", - "First series:\n", - "{'BodyPartExamined': 'HEART',\n", - " 'Collection': 'NSCLC Radiogenomics',\n", - " 'CollectionURI': 'https://doi.org/10.7937/K9/TCIA.2017.7hs46erv',\n", - " 'FileSize': 196233190,\n", - " 'ImageCount': 372,\n", - " 'LicenseName': 'Creative Commons Attribution 3.0 Unported License',\n", - " 'LicenseURI': 'http://creativecommons.org/licenses/by/3.0/',\n", - " 'Manufacturer': 'SIEMENS',\n", - " 'Modality': 'CT',\n", - " 'PatientID': 'AMC-015',\n", - " 'ProtocolName': 'GATED_CHEST_CTA',\n", - " 'SeriesDate': '1992-02-04 00:00:00.0',\n", - " 'SeriesDescription': 'Gated Chest 1.0 B25f BestDiast 70 %',\n", - " 'SeriesInstanceUID': '1.3.6.1.4.1.14519.5.2.1.4334.1501.253298261882254993527951068007',\n", - " 'SeriesNumber': 5,\n", - " 'SoftwareVersions': 'syngo CT 2008G',\n", - " 'StudyInstanceUID': '1.3.6.1.4.1.14519.5.2.1.4334.1501.119531128953610472040332469413',\n", - " 'TimeStamp': '2017-12-12 13:58:34.0'}\n" - ] - } - ], - "source": [ - "# Get all the series in the NSCLC Radiogenomics collection for a given body part\n", - "seriesbyPatientJSON = client.getSeries(Collection=\"NSCLC Radiogenomics\", BodyPartExamined=\"HEART\")\n", - "print(f\"There are {len(seriesbyPatientJSON)} series in the NSCLC Radiogenomics collection for HEART.\")\n", - "print(\"First series:\")\n", - "pprint(seriesbyPatientJSON[0])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### get New Series after a given date\n", - "\n", - "``` python\n", - "getNewSeries(\n", - " Date: Union[str, datetime], # (required) accepted formats:\n", - " # \"%Y-%m-%d\", \"%Y/%m/%d\", \"%Y%m%d\", \n", - " # \"%m/%d/%Y\", \"%d/%m/%Y\", \"%d-%m-%Y\"\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "01/01/2024\n", - "Total new series after 2024-01-01: 4751\n", - "{'BodyPartExamined': 'BREAST',\n", - " 'Collection': 'Advanced-MRI-Breast-Lesions',\n", - " 'ImageCount': 580,\n", - " 'Manufacturer': 'GE MEDICAL SYSTEMS',\n", - " 'ManufacturerModelName': 'Signa HDxt',\n", - " 'Modality': 'MR',\n", - " 'PatientID': 'AMBL-376',\n", - " 'SeriesDate': '2005-04-14 00:00:00.0',\n", - " 'SeriesDescription': 'AX Sen Vibrant MultiPhase',\n", - " 'SeriesInstanceUID': '1.3.6.1.4.1.14519.5.2.1.196168555404542578475976858220037429361',\n", - " 'SeriesNumber': 5,\n", - " 'SoftwareVersions': '24',\n", - " 'StudyInstanceUID': '1.3.6.1.4.1.14519.5.2.1.201692485188138093977458202425301357349'}\n" - ] - } - ], - "source": [ - "newSeries = client.getNewSeries(Date=\"2024/01/01\")\n", - "print(f\"Total new series after 2024-01-01: {len(newSeries)}\")\n", - "pprint(newSeries[0])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# download Series Methods\n", - "\n", - "``` python\n", - "downloadSeries(\n", - " SeriesInstanceUID: Union[str, list],\n", - " downloadDir: str,\n", - " filePattern: str,\n", - " overwrite: bool,\n", - " nParallel: int)\n", - "```" - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['1.3.6.1.4.1.14519.5.2.1.4334.1501.313535848942036628030417605312',\n", - " '1.3.6.1.4.1.14519.5.2.1.4334.1501.180142538487513002896749276822',\n", - " '1.3.6.1.4.1.14519.5.2.1.4334.1501.207646861287507872880088145139',\n", - " '1.3.6.1.4.1.14519.5.2.1.4334.1501.823771517339737505191046408406',\n", - " '1.3.6.1.4.1.14519.5.2.1.4334.1501.351960674707545278169101032360']\n" - ] - } - ], - "source": [ - "# Get all the series in the NSCLC Radiogenomics collection\n", - "seriesJSON = client.getSeries(Collection=\"NSCLC Radiogenomics\")\n", - "\n", - "# first get a list of the SeriesInstanceUIDs\n", - "seriesUIDS = [series['SeriesInstanceUID'] for series in seriesJSON]\n", - "pprint(seriesUIDS[0:5])" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Downloading to: /Users/bhklab/Documents/GitHub/NBIA-toolkit/docs/data\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Downloading 5 series: 0%| | 0/5 [00:00 + + + + +test_setup + + + + + + + + + + + + +
+
+ + diff --git a/docs/conf.py b/docs/conf.py index b11381a..0e507db 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -31,7 +31,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "_html_notebooks"] # -- Options for HTML output ------------------------------------------------- @@ -39,3 +39,5 @@ # a list of builtin themes. # html_theme = "sphinx_rtd_theme" + +html_static_path = ["_static"] diff --git a/docs/index.md b/docs/index.md index c05c32a..b0336b3 100755 --- a/docs/index.md +++ b/docs/index.md @@ -7,8 +7,8 @@ markdowns/NBIA.md test.rst + test_setup.html markdowns/Installation.md -Tutorial.ipynb markdowns/CHANGELOG.md markdowns/CONTRIBUTING.md markdowns/CONDUCT.md diff --git a/docs/test.rst b/docs/test.rst index 006fe9e..5f02561 100644 --- a/docs/test.rst +++ b/docs/test.rst @@ -1,39 +1,15 @@ Initialize Client ------ +----------------- By default, nbiatoolkit uses the guest account to access all collections in the API that are publicly available. If you have a user account that has been granted specific access to a collection, you can use your credentials to initialize the client when performing a query. - -.. tabs:: - - .. tab:: - - - - - - - - .. tab:: Python - - To perform the same operation using the Python package, follow these steps: - - .. code-block:: python - - from your_python_package import YourClass - - instance = YourClass(option1='value1', option2='value2') - instance.run_operation() - - - .. tabs:: - To get a list of available public collections that start with "TCGA", run the following command: - .. tab:: Command Line + To get a list of available public collections that start with "TCGA", run the following command: + .. tabs:: .. tab:: Guest Account @@ -44,10 +20,14 @@ initialize the client when performing a query. .. tab:: Your Account + .. code-block:: bash + getCollections -u -p --prefix TCGA .. tab:: Python + To do the same in Python, run the following code: + .. tabs:: .. tab:: Guest Account @@ -68,20 +48,28 @@ initialize the client when performing a query. client = NBIAClient(username = "", password = "") client.getCollections(prefix='TCGA') +.. raw:: html + + + +Logging +^^^^^^^ .. tabs:: - .. tab:: Apples + .. tab:: Python - Apples are green, or sometimes red. + .. code-block:: python - .. tab:: Pears + from nbiatoolkit import NBIAClient - Pears are green. + client = NBIAClient(log_level='DEBUG) + client.getCollections(prefix='TCGA') - .. tab:: Oranges + .. tab:: Command Line - Oranges are orange. + .. code-block:: bash + getCollections --prefix TCGA # TODO:: implement logging for cli .. tabs::