mrqart¶
Broadcast filesystem updates (via inotify) over websockets. Serve javascript over HTTP for receiving websocket messages in a browser.
Module Attributes
Websocket port used to send updates to browser |
|
HTTP port used to serve static/index.html |
|
list of all web socket connections to broadcast to TODO: will eventually need to track station id when serving multiple scanners |
|
track the current state of each scanner based on filename we can skip parsing a dicoms (and spamming the browser) if we've already seen the session |
Functions
|
Actually run web server, listening on |
|
Run all services on different threads. |
|
Perpetually wait for new dicom files. |
|
We can use the file name to see if session name has changed. Don't need to read the dicom header -- if we know the station name. Can extract from |
|
Track connecting and disconnecting websocket connections. |
Classes
|
Current Sequence settings at a MR Scanner station |
|
Handle index page request |
HTTP server (tornado request handler) Currently (20241102), this is just a fancy way to serve a static page. |
- class mrqart.CurSeqStation(station)[source]¶
Current Sequence settings at a MR Scanner station
- Parameters:
station (str)
- class mrqart.HttpIndex(application, request, **kwargs)[source]¶
Handle index page request
- Parameters:
application (Application)
request (HTTPServerRequest)
kwargs (Any)
- mrqart.STATE: dict[str, CurSeqStation] = {}[source]¶
track the current state of each scanner based on filename we can skip parsing a dicoms (and spamming the browser) if we’ve already seen the session
- mrqart.WS_CONNECTIONS = {}[source]¶
list of all web socket connections to broadcast to TODO: will eventually need to track station id when serving multiple scanners
- class mrqart.WebServer[source]¶
HTTP server (tornado request handler) Currently (20241102), this is just a fancy way to serve a static page. Eventually
will match
/scanner-id
URL tostation id
dicom header for scanner specific pagecould give more insite into or modify DB.
- mrqart.http_run()[source]¶
Actually run web server, listening on
HTTP_PORT
.WebServer
defines what is actually served (and dispatches toHttpIndex
)
- async mrqart.main(path)[source]¶
Run all services on different threads. HTTP and inotify are forked. Websocket holds the main thread.
- async mrqart.monitor_dirs(watcher, dcm_checker)[source]¶
Perpetually wait for new dicom files. Broadcast new files to the browser over websockets.
- mrqart.session_from_fname(dcm_fname)[source]¶
We can use the file name to see if session name has changed. Don’t need to read the dicom header – if we know the station name. Can extract from
001_sequencenum_seriesnum
:ls /data/dicomstream/20241016.MRQART_test.24.10.16_16_50_16_DST_1.3.12.2.1107.5.2.43.67078/|head 001_000001_000001.dcm ... 001_000017_000066.dcm
- Parameters:
dcm_fname (PathLike)
- Return type:
str
- async mrqart.track_ws(websocket)[source]¶
Track connecting and disconnecting websocket connections.
Stored in
WS_CONNECTIONS
. Might eventually need a dict to broadcast only to dicom specified station id.