Package: pyscivis
pyscivispyscivis is a Python package for visualizing ismrmrd/mrd-files. You can run it as both a standalone application or embed it into  a jupyter notebook.Note that this package is still under heavy development.
If you encounter any bugs please open an issue where you include the exception, the steps to reproduce the bug and (if possible) the data you tried to visualize!If you do not have ismrmrd-files but still want to play around with this application, I suggest using ismrmrd-files (.h5) from this repo:ismrmrdviewer.NoteIf selecting the BoxEditTool (to draw ROIs) you need to hold shift while dragging OR double click, then drag to draw the box:DemoTable of contentsInstallationProductionDevelopmentUsageStandaloneNotebookServerConfigurationWriting ExtensionsCreating and Compiling custom modelsDifference between "start up" and pre-compiled modelsBuilding the documentationInstallationProductionUse the package managerpipto install pyscivis.>pipinstallpyscivisDevelopmentClone this repository>gitclonehttps://gitlab.com/chi-imrt/pyscivis/pyscivis.gitand install dev-dependencies>pipinstall-rrequirements/test.txtor to run setup.py locally>pipinstall-e.[testing]UsageStandaloneAfter installation simply run this in your terminal:>pyscivisThis will show you possible command-line arguments:>pyscivis--help

usage:pyscivis[-h][-fFILE][-n][-c]pyscivis

optionalarguments:-h,--helpshowthishelpmessageandexit-fPATH,--filePATH,--filenamePATHPathoffiletobeinitiallydisplayed-n,--noselectorDisablethefileselectorwidget-c,--configfilePrintthepathoftheconfigurationfile-pPORT,--portPORTTheportthebokehapplicationshoulduse.Bokeh-default:5006-s[SHARED_DIR],--server[SHARED_DIR]Runtheapplicationinserver-mode.Theoptionalparametersetstherootdirectorycontainingaccessiblefiles.DefaultforSHARED_DIRisthecurrentworkingdirectory-wHOST[:PORT],--allow-websocket-originHOST[:PORT]ThebokehserverwillonlyacceptconnectionscomingfromthespecifiedURL.Canbespecifiedmultipletimestoallowmultipleorigins.Default:localhost:5006NotebookPlease check thenotebook-examplein the examples folder for an introduction on how to use pyscivis in conjunction with jupyter notebook.Be aware that if you use the Notebook in a dockerized environment you will need to make sure the bokeh-server ports (as specified in the config) are forwarded and you callnb.enablewith the docker keyword, i.e.,nb.enable(docker=True)ServerIt is possible to deploy this application using web frameworks likeflask.
An example snippet to run a flask server is locatedhere.This script will fetch a session from the currently running pyscivis at the specified port.
To run pyscivis in server-mode use>pyscivis--serverSHARED_DIR--allow-websocket-origin=URL_OF_SERVING_WEBSITE:PORTNote that, if the optional argumentSHARED_DIRis omitted, the current working directory will be browsable by the user.
If the bokeh-application should run on a different port, specify--port YOUR_PORT.If reverse proxies are used certain modifications like usingrelative URLsmight be necessary.
Checkthe bokeh docsfor further information on how to set up a server with a bokeh-app.ConfigurationThere are a few parameters that you can tune to your liking.
The configuration file is located in "src/pyscivis".If you have trouble finding it, consider using>pyscivis--configfilewhich will print a path to your configuration file.Writing Extensions for other filesCurrently only ismrmrd-files and (some) types of images are supported.
If you wish to support other files you will have to implement a custom extension.The procedere is describedhere.Creating and Compiling custom modelsBokeh supports the usage ofcustom models.
This allows the usage of more specialized HTML+JS constructs in a bokeh-supported way.However, these models have to be compiled on every start of the bokeh server (be it standalone or in the notebook), which can introduce huge delays.
To avoid this,pyscivisships with all custom models pre-compiled.If you wish to modify existing models or create new ones, studypyscivis's models and read the docs.
To manually re-compile them, go tosrc/pyscivisand run> bokeh buildwhich will require external dependencies like npm.
Seethis manualfor further explanation.Note:
Models that get compiled on every startup have a different structure compared to the ones that you pre-compile.
For the first, simply read the docs linked above. For the latter, look atpyscivis's models AND readthis awesome tutorial from Marc Skov MadsenAND specificallythis minimal examplecarefully. Even though it's written for the higher-level bokeh wrapperAwesome Panel, it holds true for pre-compiling bokeh models.Difference between "start up" and pre-compiled models.The following table shows all structural differences between "start up" and pre-compiled files to allow an easier entry point to writing models and pre-compiling them.TSmeans it's related to the typescript-files,PYto python files.start uppre-compiled"library import"(TS)plain "bokeh""@bokehjs"*__implementation__-dunder(PY)necessaryforbiddenstatic __module__ = "pyscivis.visualizer.models.mymodel"(TS)forbiddennecessaryNote: All other things have been explained in great detail in the documentation above (including the links).* Name can vary depending on what you write into yourtsconfig.json.Building the documentationThe documentation is written withGoogle-style docstrings.
This allows the documentation to be build using either doxygen+doxypypy or sphinx.To build the documentation using doxygen follow these steps:Installing dependenciesInstall doxygen from thedoxygen website, make sure it's in your path if you are using windowsInstall doxypypy from the repo (not pypi as it's outdated)>pipinstallgit+https://github.com/Feneric/doxypypyNavigate to thedoxygenfolder of this repo>cddoxygenRun the script appropriate for your OS, e.g. for Unix systems do:>doxygenDoxyfile_unixDone. Check the directoryhtmlfor the outputNote: Depending on your Python version the 2nd step might fail (errors in output log), in this case addthis snippetto your local doxypypy version.