Skip to content

Commit 23f25cc

Browse files
author
Romain Andres
committed
ajout du dicom web server Orthanc du front dans le back
1 parent 1a42dca commit 23f25cc

35 files changed

Lines changed: 478 additions & 614 deletions

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
/App/unetr/pretrained_models/*
44
.env
55
*.dcm
6-
/MetIA
6+
/MetIA
7+
./Orthanc/orthanc_db/*
8+
/Orthanc/orthanc_db/*
4.55 KB
Binary file not shown.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/python
2+
3+
import os
4+
import sys
5+
import os.path
6+
import httplib2
7+
import base64
8+
9+
if len(sys.argv) != 4 and len(sys.argv) != 6:
10+
print("""
11+
Sample script to recursively import in Orthanc all the DICOM files
12+
that are stored in some path. Please make sure that Orthanc is running
13+
before starting this script. The files are uploaded through the REST
14+
API.
15+
16+
Usage: %s [hostname] [HTTP port] [path]
17+
Usage: %s [hostname] [HTTP port] [path] [username] [password]
18+
For instance: %s localhost 8042 .
19+
""" % (sys.argv[0], sys.argv[0], sys.argv[0]))
20+
exit(-1)
21+
22+
URL = 'http://%s:%d/instances' % (sys.argv[1], int(sys.argv[2]))
23+
24+
success = 0
25+
26+
27+
# This function will upload a single file to Orthanc through the REST API
28+
def UploadFile(path):
29+
global success
30+
31+
f = open(path, "rb")
32+
content = f.read()
33+
f.close()
34+
35+
try:
36+
sys.stdout.write("Importing %s" % path)
37+
38+
h = httplib2.Http()
39+
40+
headers = { 'content-type' : 'application/dicom' }
41+
42+
if len(sys.argv) == 6:
43+
username = sys.argv[4]
44+
password = sys.argv[5]
45+
46+
# h.add_credentials(username, password)
47+
48+
# This is a custom reimplementation of the
49+
# "Http.add_credentials()" method for Basic HTTP Access
50+
# Authentication (for some weird reason, this method does
51+
# not always work)
52+
# http://en.wikipedia.org/wiki/Basic_access_authentication
53+
headers['authorization'] = 'Basic ' + base64.b64encode(username + ':' + password)
54+
55+
resp, content = h.request(URL, 'POST',
56+
body = content,
57+
headers = headers)
58+
59+
if resp.status == 200:
60+
sys.stdout.write(" => success\n")
61+
success += 1
62+
else:
63+
sys.stdout.write(" => failure (Is it a DICOM file?)\n")
64+
65+
except:
66+
sys.stdout.write(" => unable to connect (Is Orthanc running? Is there a password?)\n")
67+
68+
69+
if os.path.isfile(sys.argv[3]):
70+
# Upload a single file
71+
UploadFile(sys.argv[3])
72+
else:
73+
# Recursively upload a directory
74+
for root, dirs, files in os.walk(sys.argv[3]):
75+
for f in files:
76+
UploadFile(os.path.join(root, f))
77+
78+
79+
print("\nSummary: %d DICOM file(s) have been imported" % success)
File renamed without changes.
File renamed without changes.

Orthanc/docker-compose.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
version: "3"
2+
services:
3+
pacs:
4+
container_name: orthanc
5+
image: jodogne/orthanc-plugins
6+
ports:
7+
- 8042:8042
8+
- 4242:4242
9+
volumes:
10+
- ./orthanc.json:/etc/orthanc/orthanc.json:ro
11+
- ./orthanc_db:/var/lib/orthanc/db/
12+
restart: always
13+
networks:
14+
- pacs
15+
16+
nginx:
17+
image: nginx:latest
18+
container_name: nginx_cors
19+
depends_on:
20+
- pacs
21+
volumes:
22+
- ./nginx.conf:/etc/nginx/nginx.conf:ro
23+
ports:
24+
- "8080:80"
25+
networks:
26+
- pacs
27+
28+
# COMMENTE CAR J'UTILISE OHIF EN LOCAL !
29+
#ohif_viewer:
30+
# container_name: ohif
31+
# image: ohif/viewer
32+
# ports:
33+
# - 3000:80
34+
# environment:
35+
# - APP_CONFIG:/usr/share/nginx/html/app-config.js
36+
# volumes:
37+
# - ./nginx_ohif.conf:/etc/nginx/conf.d/default.conf:ro
38+
# - ./ohif.js:/usr/share/nginx/html/app-config.js:ro
39+
# - ./logo.png:/usr/share/nginx/html/logo.png:ro
40+
# restart: always
41+
# networks:
42+
# - pacs
43+
44+
networks:
45+
pacs:
46+
external: true

Orthanc/logo.png

71.3 KB
Loading

Orthanc/nginx.conf

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
events { }
2+
3+
http {
4+
server {
5+
listen 80;
6+
7+
location / {
8+
proxy_pass http://pacs:8042;
9+
proxy_set_header Host $host;
10+
proxy_set_header X-Real-IP $remote_addr;
11+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
12+
proxy_set_header X-Forwarded-Proto $scheme;
13+
14+
# Gestion des requêtes OPTIONS pour CORS
15+
if ($request_method = 'OPTIONS') {
16+
add_header 'Access-Control-Allow-Origin' '*';
17+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
18+
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
19+
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
20+
add_header 'Access-Control-Max-Age' 1728000;
21+
add_header 'Content-Type' 'text/plain charset=UTF-8';
22+
add_header 'Content-Length' 0;
23+
return 204;
24+
}
25+
26+
# Ajout des en-têtes CORS pour les autres méthodes
27+
add_header 'Access-Control-Allow-Origin' '*' always;
28+
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
29+
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
30+
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)