Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dicom-upload
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jupyter4jsc
j4j_extras
dicom-upload
Commits
2f58163b
Commit
2f58163b
authored
5 years ago
by
alice grosch
Browse files
Options
Downloads
Patches
Plain Diff
Update introduction.ipynb
parent
7c060ad6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/introduction.ipynb
+63
-42
63 additions, 42 deletions
examples/introduction.ipynb
with
63 additions
and
42 deletions
examples/introduction.ipynb
+
63
−
42
View file @
2f58163b
...
@@ -9,92 +9,113 @@
...
@@ -9,92 +9,113 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
8
,
"execution_count":
1
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"import dicom_upload"
"import dicom_upload\n",
"from ipywidgets import Output"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count": 9,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# Upload to the examples subdirectory.\n",
"upload_url = 'http://localhost:8888/api/contents/examples/'\n",
"token = 'c13dac305e39982bb3236b508fda269b2b79daeaafd07d80'\n",
"\n",
"uploader = dicom_upload.Uploader(upload_url=upload_url,\n",
" token=token,\n",
" button_style='primary', \n",
" layout={'border': 'solid blue 1px'})"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"out = Output()\n",
"@out.capture()\n",
"def observe_hash(change):\n",
" print(\"Hash of files: {}\".format(change['owner'].hash))\n",
"\n",
"@out.capture()\n",
"def observe_responses(change):\n",
" print(\"Upload progress: {}\".format(change['owner'].responses))\n",
" \n",
"@out.capture()\n",
"def observe_finish(change):\n",
" print(\"Finished upload: {}\".format(change['owner'].finished))\n",
"\n",
"uploader.observe(observe_hash, 'hash')\n",
"uploader.observe(observe_responses, 'responses')\n",
"uploader.observe(observe_finish, 'finished')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"metadata": {},
"outputs": [
"outputs": [
{
{
"data": {
"data": {
"application/vnd.jupyter.widget-view+json": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "
6
be
94a2d5283483c9683ebafff621ec1
",
"model_id": "be
486335a3fb40d8a1c3af9326da53bd
",
"version_major": 2,
"version_major": 2,
"version_minor": 0
"version_minor": 0
},
},
"text/plain": [
"text/plain": [
"Uploader(value=None, button_style='primary', description='Upload', layout=Layout(
width='200px'), token='cf7d6b
…"
"Uploader(value=None, button_style='primary', description='Upload', layout=Layout(
border='solid blue 1px'), tok
…"
]
]
},
},
"metadata": {},
"metadata": {},
"output_type": "display_data"
"output_type": "display_data"
}
],
"source": [
"w = dicom_upload.Uploader(button_style='primary', layout={'width': '200px'}, \n",
" token='cf7d6b9dbb046d0983585f930a4d1ffadf4f18d8a9a921c3')\n",
"w.upload_url = 'http://localhost:8888/api/contents/examples/'\n",
"w"
]
},
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
{
"data": {
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "20eb44ff6efb40228d316f854b21445c",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"text/plain": [
"
'51195e955bfc80c23dc7f96907225c90'
"
"
Output()
"
]
]
},
},
"execution_count": 10,
"metadata": {},
"metadata": {},
"output_type": "
execute_result
"
"output_type": "
display_data
"
}
}
],
],
"source": [
"source": [
"w.hash"
"display(uploader)\n",
"display(out)"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
3
,
"execution_count":
5
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"w.upload()"
"# Select some files to upload, then run\n",
"uploader.upload()"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "markdown",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['ok']"
]
},
"execution_count": 4,
"metadata": {},
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"source": [
"
w.responses
"
"
### Check header was anonymized
"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
5
,
"execution_count":
null
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -121,7 +142,7 @@
...
@@ -121,7 +142,7 @@
"name": "python",
"name": "python",
"nbconvert_exporter": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"pygments_lexer": "ipython3",
"version": "3.6.
6
"
"version": "3.6.
9
"
}
}
},
},
"nbformat": 4,
"nbformat": 4,
...
...
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
# Introduction
# Introduction
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
import
dicom_upload
import
dicom_upload
from
ipywidgets
import
Output
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
w
=
dicom_upload
.
Uploader
(
button_style
=
'
primary
'
,
layout
=
{
'
width
'
:
'
200px
'
},
# Upload to the examples subdirectory.
token
=
'
cf7d6b9dbb046d0983585f930a4d1ffadf4f18d8a9a921c3
'
)
upload_url
=
'
http://localhost:8888/api/contents/examples/
'
w
.
upload_url
=
'
http://localhost:8888/api/contents/examples/
'
token
=
'
c13dac305e39982bb3236b508fda269b2b79daeaafd07d80
'
w
```
%% Output
uploader
=
dicom_upload
.
Uploader
(
upload_url
=
upload_url
,
token
=
token
,
button_style
=
'
primary
'
,
layout
=
{
'
border
'
:
'
solid blue 1px
'
})
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
w
.
hash
out
=
Output
()
```
@out.capture
()
def
observe_hash
(
change
):
print
(
"
Hash of files: {}
"
.
format
(
change
[
'
owner
'
].
hash
))
%% Output
@out.capture
()
def
observe_responses
(
change
):
print
(
"
Upload progress: {}
"
.
format
(
change
[
'
owner
'
].
responses
))
@out.capture
()
def
observe_finish
(
change
):
print
(
"
Finished upload: {}
"
.
format
(
change
[
'
owner
'
].
finished
))
'51195e955bfc80c23dc7f96907225c90'
uploader
.
observe
(
observe_hash
,
'
hash
'
)
uploader
.
observe
(
observe_responses
,
'
responses
'
)
uploader
.
observe
(
observe_finish
,
'
finished
'
)
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
w
.
upload
()
display
(
uploader
)
display
(
out
)
```
```
%% Output
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
w
.
responses
# Select some files to upload, then run
uploader
.
upload
()
```
```
%%
Output
%%
Cell type:markdown id: tags:
['ok']
### Check header was anonymized
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
import
pydicom
import
pydicom
ds
=
pydicom
.
dcmread
(
'
./IM000001
'
)
ds
=
pydicom
.
dcmread
(
'
./IM000001
'
)
ds
ds
```
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment