Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] New directory for jupyter notebooks #6854

Merged
merged 48 commits into from
Nov 5, 2020

Conversation

spell00
Copy link
Contributor

@spell00 spell00 commented Jul 21, 2020

Brief summary of changes

New Jupyter notebooks to display how the api works.

@spell00 spell00 added API PR or issue introducing/requiring modifications to the API code Needs Work PR awaiting additional changes by the author or contains issues that the author needs to fix labels Jul 21, 2020
@christinerogers christinerogers added the Documentation PR or issue introducing/requiring modifications to the code documentation (test plans, wikis, docs) label Jul 21, 2020
@spell00 spell00 changed the base branch from master to main July 23, 2020 14:20
@spell00 spell00 requested a review from xlecours August 5, 2020 15:28
Copy link
Contributor

@xlecours xlecours left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide markdown files as well?

docs/notebooks/LORIS-API_Part1-HTTP.ipynb Outdated Show resolved Hide resolved
@xlecours
Copy link
Contributor

xlecours commented Sep 1, 2020

@spell00 Remove the outputs of the notebooks before sending to github please.

@spell00
Copy link
Contributor Author

spell00 commented Sep 4, 2020

@xlecours I provided the markdowns, but now that I cleared the outputs from the notebooks before sending to Github, the content of the notebooks that I see is very similar to the markdowns. I wonder if it is still necessary? Before clearing the output, I could not see part2 as a notebook in Github, so I understood the necessity of the markdowns, but it seems redundant now. Does it serve another purpose I am not seeing?

@xlecours
Copy link
Contributor

xlecours commented Sep 8, 2020

@xlecours I provided the markdowns, but now that I cleared the outputs from the notebooks before sending to Github, the content of the notebooks that I see is very similar to the markdowns. I wonder if it is still necessary? Before clearing the output, I could not see part2 as a notebook in Github, so I understood the necessity of the markdowns, but it seems redundant now. Does it serve another purpose I am not seeing?

Maybe @christinerogers can clarify if the markdown can be useful in our readthedoc. Otherwise, it can be removed so we don't have to make sure it is synchronized whit the actual notebook.

@spell00
Copy link
Contributor Author

spell00 commented Sep 21, 2020

@xlecours @christinerogers I think everyone agrees the markdowns are redundant, so I removed them. If anyone thinks of a good reason to include them, it can be added again very easily. I added links to the notebooks in Google colab, so that it can be tried directly in the browser. This way, anyone can test the notebooks even if they don't have Jupyter or Loris installed.

@spell00 spell00 requested a review from xlecours October 8, 2020 18:59
docs/notebooks/LORIS-API_Part1-HTTP.ipynb Outdated Show resolved Hide resolved
docs/notebooks/LORIS-API_Part1-HTTP.ipynb Outdated Show resolved Hide resolved
Comment on lines 1984 to 2062
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "ZJhfo1iB_PqE"
},
"outputs": [],
"source": [
"# The flag is used to break the loops once an example that contains a \n",
"# Dicom file is found\n",
"flag = 0\n",
"\n",
"for candidate in allCandidates['Candidates']:\n",
" candid = candidate['CandID']\n",
" visit_labels = GET('/'.join([baseurl, 'candidates', candid]))['Visits']\n",
" if flag == 1:\n",
" break\n",
" candid = candidate['CandID']\n",
" visit_labels = GET('/'.join([baseurl, 'candidates', candid]))['Visits']\n",
" for visit_label in visit_labels:\n",
" dicoms = GET('/'.join([baseurl, 'candidates', candid, \n",
" visit_label, 'dicoms']))\n",
" # We only want to get a single valid example of a candidate and visit that\n",
" # has Dicom files that can be used to test the Dicoms endpoints \n",
" if len(dicoms['DicomTars']) > 0:\n",
" flag = 1\n",
" break\n"
]
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block won't be necessary when PR #6775 will be merged. It will add an endpoint listing all Dicoms in a project. It will then be possible to get a complete list of candidates and for which visits there is a Dicom file for a given project. For the moment, it is the only way to get these informations without hardcoding them in the notebook, which is problematic when not executed with raisinbread...

"source": [
"### Scripting and parsing json \n",
" \n",
"see: [part2 - Python script](https://github.com/aces/Loris/blob/main/docs/notebooks/LORIS-API_Part2-Python-script.ipynb)"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link will be valid when the PR is merged to aces/main

@spell00 spell00 removed the Needs Work PR awaiting additional changes by the author or contains issues that the author needs to fix label Oct 26, 2020
@spell00 spell00 requested a review from xlecours October 26, 2020 22:57
@spell00
Copy link
Contributor Author

spell00 commented Oct 26, 2020

Some commands will fail until PR #6780 is merged. I tested using the branch containing the changes and there is no error.

@spell00 spell00 added the Blocked PR awaiting the merge, resolution or rejection of an other Pull Request label Oct 26, 2020
@spell00 spell00 force-pushed the 2020-07-20-jupyterApiPart2 branch 2 times, most recently from 4526194 to 5dbe25b Compare October 29, 2020 15:54
@spell00 spell00 requested a review from driusan October 29, 2020 17:35
@spell00 spell00 removed the Blocked PR awaiting the merge, resolution or rejection of an other Pull Request label Oct 29, 2020
"source": [
"url = '/'.join([baseurl, 'projects', projectNames[0]])\n",
"project = GET(url)\n",
"prettyPrint(projects)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"prettyPrint(projects)"
"prettyPrint(project)"

" \"PSCID\" : PSCID, # only if config is set to prompt \n",
" \"EDC\" : \"YYYY-MM-DD\", # optional\n",
" \"DoB\" : \"YYYY-MM-DD\",\n",
" \"Gender\" : \"Male|Female\",\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
" \"Gender\" : \"Male|Female\",\n",
" \"Sex\" : \"Male|Female\",\n",

},
"outputs": [],
"source": [
"battery = candidateVisits['Meta']['Battery']\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is not used

Comment on lines 673 to 679
{
"cell_type": "markdown",
"metadata": {
"id": "V0Clu1dSCHvJ"
},
"source": []
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shows as Type Markdown and LaTeX: 𝛼2

@spell00 spell00 requested a review from xlecours November 2, 2020 17:50
@christinerogers christinerogers requested review from driusan and removed request for driusan November 2, 2020 20:09
@christinerogers
Copy link
Contributor

@driusan requesting final review - this is our last stretch in which @spell00 can readily make changes. thank you!

@spell00 spell00 added the Blocked PR awaiting the merge, resolution or rejection of an other Pull Request label Nov 2, 2020
"cell_type": "markdown",
"metadata": {},
"source": [
"#LORIS API Tour 1/2\nThis tutorial is also available as a Google colab notebook so you can run it directly from your browser. To access it, click on the button below: <a href=\"https://colab.research.google.com/github/aces/Loris/blob/main/docs/notebooks/LORIS-API_Part1-HTTP.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"\n",
"This tutorial contains basic examples in Python to demonstrate how to interact with the API.\n",
"To run this tutorial, click on `Runtime -> Run all`",
"This tutorial is also available as a Google colab notebook so you can run it directly from your browser. To access it, click on the button below: <a href=\"https://colab.research.google.com/github/aces/Loris/blob/main/docs/notebooks/LORIS_API_Part2_Python-script.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spell00 spell00 removed the Blocked PR awaiting the merge, resolution or rejection of an other Pull Request label Nov 5, 2020
@spell00
Copy link
Contributor Author

spell00 commented Nov 5, 2020

@xlecours @driusan It is now passing Travis and ready for final review

Copy link
Collaborator

@driusan driusan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know enough about jupyter notebooks to really review this, I'll merge it based on @xlecours approval..

@driusan driusan merged commit c1bb1da into aces:main Nov 5, 2020
@ridz1208 ridz1208 added this to the 24.0.0 milestone Nov 27, 2020
AlexandraLivadas pushed a commit to AlexandraLivadas/Loris that referenced this pull request Jun 29, 2021
New Jupyter notebooks to demonstrate how the REST API works.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API PR or issue introducing/requiring modifications to the API code Documentation PR or issue introducing/requiring modifications to the code documentation (test plans, wikis, docs)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants