Code Monkey home page Code Monkey logo

beren's People

Contributors

teffalump avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

beren's Issues

Store Dicom

Hi,

I tried to send dicom with Orthanc's store_modality function. I got 400 bad request error. This function takes dcm and data
properties. I didn't fully understand the data parameter. Can you provide an example

Thanks

some guidance

Thank you very much for this developpement. I am struggling to get it work properly though.

What is the id you are referring to ?
this snippet

query_pat = {'Level': 'Patient',
            'Query': {'PatientName': 'test*'},
        }

id = orthanc.find(query_pat)
print(id)
orthanc.get_patient_series(id[0])

gives me a keyword error message. KeyError: 'id'
and some warnings

... site-packages\orthanc_rest_client\orthanc.py:33: RuntimeWarning: An unknown path kwarg was supplied to patients/{id}/series/. kwargs supplied: {'path_kwargs': {'id': 'cf74b893-0c49f5f4-c491da1d-b7485ee8-9a3ea1e1'}}
return function(self, *args, **kwargs)

Timeout when getting patients

when i try to obtain all patients from orthanc, i get a timeout error.
the orthanc server hosts quite a large number of patients, and orthanc is running on a single-core VM, so it might take much more than the 3 seconds default timeout.
how to increase the timeout?
(sorry, i am still not an REST expert, if this issue is a simple extra argument somewhere)

How can I skip verify SSL when accessing a HTTPS endpoind?

Hi, I am using your library when uploading DICOM file to OrthanC server. Previously, I used HTTP client like this:

class OrthancClient:
    def __init__(self, url=None, username=None, password=None):
        self.url = url
        self.client = httpx.AsyncClient(verify=False)

    def init(self, url):
        self.url = url

    async def get_simplified_tags(self, level, uuid):
        res = await self.client.get(f"{self.url}/{level}/{uuid}/simplified-tags")
        res.raise_for_status()
        return res.json()

    async def find(self, body):
        res = await self.client.post(f"{self.url}/tools/find", json=body)
        res.raise_for_status()
        return res.json()

    async def retrieve(self, level, uuid, asset=None):
        if asset is None:
            res = await self.client.get(f"f{self.url}/{level}/{uuid}")
        else:
            res = await self.client.get(f"f{self.url}/{level}/{uuid}/{asset}")
        res.raise_for_status()
        return res

    async def upload(self, data):
        res = await self.client.post(f"{self.url}/instances", content=data)
        res.raise_for_status()
        return res.json()

    async def get(self, path: str):
        res = await self.client.get(f"{self.url}{path}")
        res.raise_for_status()
        return res.json()

As you see, I've set self.client = httpx.AsyncClient(verify=False). But when I used oc2 = Orthanc(settings.ORTHANC_API_URI), I dont know how to configure like it before.

Please help me!

SSL with no verification

hi, thanks for the package.

i want to communicate with a personal, "off-the-internet" server which unfortunately has no kind of SSL certificate, but still communicates with https. i get a handshake error:


Error Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/urllib3/contrib/pyopenssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname)
452 try:
--> 453 cnx.do_handshake()
454 except OpenSSL.SSL.WantReadError:

/usr/lib/python3/dist-packages/OpenSSL/SSL.py in do_handshake(self)
1807 result = _lib.SSL_do_handshake(self._ssl)
-> 1808 self._raise_ssl_error(self._ssl, result)
1809

/usr/lib/python3/dist-packages/OpenSSL/SSL.py in _raise_ssl_error(self, ssl, result)
1547 else:
-> 1548 _raise_current_error()
1549

/usr/lib/python3/dist-packages/OpenSSL/_util.py in exception_from_error_queue(exception_type)
53
---> 54 raise exception_type(errors)
55

Error: [('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')]

During handling of the above exception, another exception occurred:

SSLError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
599 body=body, headers=headers,
--> 600 chunked=chunked)
601

/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
342 try:
--> 343 self._validate_conn(conn)
344 except (SocketTimeout, BaseSSLError) as e:

/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py in _validate_conn(self, conn)
838 if not getattr(conn, 'sock', None): # AppEngine might not have .sock
--> 839 conn.connect()
840

/usr/local/lib/python3.6/dist-packages/urllib3/connection.py in connect(self)
343 server_hostname=server_hostname,
--> 344 ssl_context=context)
345

/usr/local/lib/python3.6/dist-packages/urllib3/util/ssl_.py in ssl_wrap_socket(sock, keyfile, certfile, cert_reqs, ca_certs, server_hostname, ssl_version, ciphers, ssl_context, ca_cert_dir)
356
--> 357 return context.wrap_socket(sock)
358

/usr/local/lib/python3.6/dist-packages/urllib3/contrib/pyopenssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname)
458 except OpenSSL.SSL.Error as e:
--> 459 raise ssl.SSLError('bad handshake: %r' % e)
460 break

SSLError: ("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",)

During handling of the above exception, another exception occurred:

MaxRetryError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
448 retries=self.max_retries,
--> 449 timeout=timeout
450 )

/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
666 release_conn=release_conn, body_pos=body_pos,
--> 667 **response_kw)
668

/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
637 retries = retries.increment(method, url, error=e, _pool=self,
--> 638 _stacktrace=sys.exc_info()[2])
639 retries.sleep()

/usr/local/lib/python3.6/dist-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
397 if new_retry.is_exhausted():
--> 398 raise MaxRetryError(_pool, url, error or ResponseError(cause))
399

MaxRetryError: HTTPSConnectionPool(host='X.X.X.X, port=8042): Max retries exceeded with url: /patients/ (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),))

During handling of the above exception, another exception occurred:

SSLError Traceback (most recent call last)
in ()
----> 1 orthanc.get_patients()

/usr/local/lib/python3.6/dist-packages/beren/orthanc.py in get_patients(self, expand, since, limit, params, **kwargs)
490 kwargs["params"] = params
491 kwargs["auth"] = kwargs.get("auth", self.auth)
--> 492 return self.patients.patients(**kwargs)
493
494 def get_patient(self, id
, **kwargs):

/usr/local/lib/python3.6/dist-packages/apiron/client.py in call(service, endpoint, method, session, params, data, files, json, headers, cookies, auth, encoding, retry_spec, timeout_spec, logger, allow_redirects, return_raw_response_object, **kwargs)
246 timeout=(timeout_spec.connection_timeout, timeout_spec.read_timeout),
247 stream=getattr(endpoint, "streaming", False),
--> 248 allow_redirects=allow_redirects,
249 )
250

/usr/local/lib/python3.6/dist-packages/requests/sessions.py in send(self, request, **kwargs)
641
642 # Send the request
--> 643 r = adapter.send(request, **kwargs)
644
645 # Total elapsed time of the request (approximately)

/usr/local/lib/python3.6/dist-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
512 if isinstance(e.reason, _SSLError):
513 # This branch is for urllib3 v1.22 and later.
--> 514 raise SSLError(e, request=request)
515
516 raise ConnectionError(e, request=request)

SSLError: HTTPSConnectionPool(host='X.X.X.X', port=8042): Max retries exceeded with url: /patients/ (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),))

is there a way to go around this problem? or is it possible to add a "verify" argument to Orthanc? (possibly aprion needs the corresponding change)

thanks

Better documentation

Thoughts:

  • More robust examples.
  • Document every method
  • Doxygen/Sphinx (eventually)

Converting instance to a dcm file

Hello,

Is there any way to convert an instance into a .dcm file? I am trying to do the code below but 'get_file()' doesn't exist.

    query = {'Level': 'Instance',
                'Query': {'PatientName': data.get('case')},
            }
    for id in orthanc.find(query):
        dicom = orthanc.get_instance(id)
        # orthanc.get_file(dicom) - then convert to a file locally using OS or something

In other words, I am trying to do this as mentioned in https://book.orthanc-server.com/users/rest.html#accessing-the-dicom-fields-of-an-instance-as-a-json-file

$ curl http://localhost:8042/instances/e668dcbf-8829a100-c0bd203b-41e404d9-c533f3d4/file > Instance.dcm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.