Code Monkey home page Code Monkey logo

webct's Introduction

WebCT: Interactive Web UI for X-ray CT with Real-time Results

Image of UI


WebCT is a feature-rich environment for previewing and simulating X-ray scans on the browser.

  • Configure and see output spectra in real-time, with support for different physical filters.
  • Upload any 3D model, along with editable materials.
  • Change capture parameters to see the effect projections have on the reconstruction quality.
  • Reconstruct your scans, and tweak for the best results!
  • Save and export your configuration, share source and detector parameters and load them into other applications.

Note

๐Ÿ— WebCT is still in development, and while most features are implemented, some are still a work-in-progress. Feel free to request features, and report bugs. WebCT aims to be a useful tool for everyone, if there is something you'll like to see, please request it!

What WebCT isn't

Although webCT aims to provide an all-in-one solution for simulation and reconstruction, a few aspects that WebCT does not cover:

  • Data analysis tool - Export data from WebCT
  • Batch processor - Export configs & use gVirtualXRay
  • Model editor - Use 3D software like blender
  • Large Data Processor - WebCT is not optimised for large datasets

WebCT does however, aim to facilitate the above with config and dataset exporting.

Installing WebCT

Windows versions of WebCT are available here on github. Download and extract the folder, double-click WebCT.exe to launch!

Packaged version for Linux users are not available, it's recommended to follow the Development setup to compile webct.

Note

โš  Currently WebCT is still in alpha, take a look at the v1.0.0 roadmap or the project dashboard for current project status. A written paper is currently in the works.

Quickstart Video

WebCT-Quick.Introduction2.mp4

Music: Turning Along - The Flashbulb (please support the artist!)

Developing WebCT

  1. Pull the repository from github however you like
  2. Install the conda environment with conda env create
  3. Install npm by downloading node.js with fnm
  4. Install js packages with npm install
  5. Build and host webserver with npm run serve
    • If flask fails to start, ensure the webct environment is activated with conda activate webct
  6. Visit the local url in a browser! (This should open automatically)

Any issues with installing? Please feel free to open an issue!

webct's People

Contributors

wyvern2742 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

webct's Issues

Better Signposting for Advanced Dropdown

Currently the dropdown for advanced settings is a blue bar under options. This is poorly signposted and has been commented on before it's not simple to identify at first.
image

Ideally, some dropdown arrows would indicate the bar as clickable:

image

gVXR Phantom Support

gVXR has new support for parameterised phantoms;- WebCT should expose this feature in its model selection menu.

Better Version Management

With WebCT close to launch; version info should be handled better.

  1. Building to development should include dev/branch/commit on the exe and webpage.
  2. Building to production should include version on the exe and webpage.

Both above points should automatically handled.

This makes it easy to see what version WebCT is using just from the page. It's likely best placed as gray text on the left-hand side.

Material Library

Material library must support:

  • Viewing categories and materials
  • Editing Materials
  • Material Types:
    • Element
    • Compound
    • Fixed HU
    • Mixture (Supported on backend, UI needs to be done)
  • New Materials
  • New Categories
  • Delete Materials
  • Delete Categories

You can manually make new material files in data/materials, but the UI should support everything.

Additionally, make some nice common materials to flesh out the library a bit.

Better Error System

Right now, the error system is a mess and does not cover all scenarios.

The error system should be redone alongside the validation system in order to clearly indicate to the user what has gone wrong. Validation should preemptively prevent any user-side inputs that will cause errors to the backend.

Some examples:

  • Currently, broken configuration files do not show any indicator during import
  • When the backend server is down, errors flood the UI since each component fails to transmit
  • Too fine-grained response from the server doesn't need to say exactly what paramater caused an error

Interactive 3D Scene Preview

Scanning geometry along with models should be displayed in a 3D scene to make model positioning easier. This is especially important with large or unset units on models to know what is happening.

Docker Container

A docker container would allow hosting WebCT with a single command, along with allowing a good route for releases.

Use gVirtualXRay from pip rather than local builds.

Currently, local builds of gvxr must be built to use webct, this hampers distribution.
Recently, gvxr now supports installing using setup.py and pip from the sourcehut source.

WebCT should change to use this pip source.

Detector Gain & Saturation

Currently the detector has no physical limitations. Intensity and Exposure change the photon count hitting the detector, affecting the noise. However at the moment the detector is capable of registering even fractional photons per pixel.

In order to account for photon starvation and panel saturation, gain, and electronic limitations (like uint16) should be included.

Realistically, this would be a generic model at first, and Digital Twins will have a more in-depth approach, with limited-to-real-hardware gain settings.

Linux host PermissionError when downloading files

On a Linux server, downloading projections or reconstructions result in a 500 internal server error due to the server not having permission to read the locally created file.

Folder:

wyvern@ARCHFAE ~/P/R/X/w/o/20240425170134.783732 (master)> ls -la
total 488372
drwxr-xr-x 1 wyvern users        38 Apr 25 18:01 .
drwxr-xr-x 1 wyvern users       294 Apr 25 18:01 ..
-------rwx 1 wyvern users 500089190 Apr 25 18:01 reconstruction.tiff

Log:

[DMAN] - Packaging
output/20240425170134.783732/reconstruction.tiff
[DPREP] - Packaging
Using cached reconstruction
[DMAN] - Done!
127.0.0.1 - - [25/Apr/2024 18:01:44] "PUT /sim/download/prep HTTP/1.1" 200 -
{'resource': 'RECON', 'format': 'TIFF_STACK'}
[2024-04-25 18:01:44,196] ERROR in app: Exception on /sim/download/ [GET]
Traceback (most recent call last):
  File "/home/wyvern/Projects/Research/XCT/webct/.mamba/envs/webct/lib/python3.10/site-packages/flask/app.py", line 1473, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/wyvern/Projects/Research/XCT/webct/.mamba/envs/webct/lib/python3.10/site-packages/flask/app.py", line 882, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/wyvern/Projects/Research/XCT/webct/.mamba/envs/webct/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/wyvern/Projects/Research/XCT/webct/.mamba/envs/webct/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
  File "/home/wyvern/Projects/Research/XCT/webct/webct/blueprints/preview/routes.py", line 106, in getDownload
    return send_file(sim.download.location(resource).absolute(), as_attachment=True,mimetype="data")
  File "/home/wyvern/Projects/Research/XCT/webct/.mamba/envs/webct/lib/python3.10/site-packages/flask/helpers.py", line 499, in send_file
    return werkzeug.utils.send_file(  # type: ignore[return-value]
  File "/home/wyvern/Projects/Research/XCT/webct/.mamba/envs/webct/lib/python3.10/site-packages/werkzeug/utils.py", line 479, in send_file
    file = open(path, "rb")  # type: ignore

Support PDHG, SPDHG and LADMM

Currently, three iterative methods are provided: CGLS, SIRT, and FISTA.
These provide a good way to explain how the different approaches to iterative reconstruction work, along with no being too complex to understand and run.

It was originally planned to support all of CIL's iterative methods, however upon attempting to implement PDHG three things are clear:

  • WebCT is not made to support multiple options of the same type
  • PDHG is very adaptable and supports arbitrary function blocks, and is often used differently all the time.
  • Supporting PDHG will result in a very large amount of options to the user, and is much easier to just script it rather than using a graphical user interface.

Since other iterative methods are covered, it was decided to shelve PDHG for the initial iterative reconstruction methods PR (#34)

If you are using WebCT and would still like to use PDHG (or any other iterative reconstruction method in CIL) please leave a comment below!

Current video transmission does not support high quality previews

Currently, image and video transmission is done via base64 encoding. This works fine for small videos and images (<1mb) but cannot support higher quality previews. This is more noticeable with larger resolution detectors and increasing video quality for reconstruction preview comparison.

Ideally, WebCT should stream from the backend, but this may be hard to do in-memory with flask.

Container fails to build

Container fails to build on step 14:

Step 14/39 : RUN svn checkout svn://[email protected]/p/gvirtualxray/code/branches/use-xraylib gvirtualxray-code
 ---> Running in ddcf8c077075
svn: E170000: URL 'svn://[email protected]/p/gvirtualxray/code/branches/use-xraylib' doesn't exist
Error response from daemon: The command '/bin/sh -c svn checkout svn://[email protected]/p/gvirtualxray/code/branches/use-xraylib gvirtualxray-code' returned a non-zero code: 1
Build completed

Unable to find an image for introspection

This error was reproduced on both Fedora Linux and Windows 10 and on multiple network connections.

Detector PSF

Detector still needs support for Point Spread Function. This should also come with a preview.

  • PSF Upload UI
  • PSF Upload Backend
  • Apply PSF to projections
  • PSF Preview

Internal Material keys are saved in json

When a material is serialised to json, some unneeded internal keys are also saved.

{
	"label": "Placeholder-Pellet",
	"description": "Placeholder uranium pellet interior material",
	"density": 5.68,
	"compound": "ZrO2", // <--- This key is only used internally
	"material": [
		"compound",
		"ZrO2"
	]
}

SVG layout image

Currently, the layout image for capture configuration is a raster format not ideal for use in publications or printing. The file format should be an svg/emf vector format.

The image is currently generated using CIL, and drawn to a virtual matplotlib canvas which is then exported to a byte stream.

Iterative Reconstruction Methods

The framework for different iterative reconstruction methods is in place, awaiting implementation on frontend and backend.

Methods to be implemented are everything CIL supports, with attempts to include as many parameters as possible. If CIL supports combining arbitrary regularisation functions, these should be supported for all iterative methods as well.

Bundle for Distribution

Currently, the only way to install WebCT is to manually download and compile the source, which is unintuitive.

WebCT should be available as a stand-alone single application, with all dependencies bundled into a single executable.

Offline mode

Currently, shoelace elements are loaded from an external cdn. Ideally these should also be hosted from the flask server in order to contain all requests and allow usage while offline.

Data downloading

Data should be downloadable though the web interface in multiple formats.

  • Web Interface
  • Backend Interface

Detector Energy Response

The detector configuration should support different energy responses to more accurately model detector behaviour. This should include a UI to edit values, and support for uploading custom responses.

Performance disparity on windows systems

After some testing, there are anomolous performance results when running on windows.

Platform Projections Noise LSF Time taken Images per second
Windows 360 โœ… โœ… 00:47 7.63/s
Windows 360 โœ… 00:36 9.84/s
Windows 360 โœ… 00:24 14.91/s
Windows 360 00:05 62.07/s
Linux 360 โœ… โœ… 00:13 25.95/s
Linux 360 โœ… 00:12 28.13/s
Linux 360 โœ… 00:08 44.88/s
Linux 360 00:04 84.68/s

In the case of Windows Vs Linux, there is a 70% performance regression. After some talk with Franck, this is assumed to be a random number generator problem. Windows seems to be wasting a ton of time in system calls, with over 50% kernel time on a 32 thread system. This behaviour is not seen on the Linux side.

Also, even within the same OS, applying LSF and Noise are a large detriment to performance. This indicates WebCT should probably have user-defined toggles to enable and disable noise.

XTEK Config support

With the feature of importing and exporting configs, support for XTEK should be added.

Support Beam Spot Size

Currently, the spot size for cone-beam geometries is an infinite point, resulting in no blurring at any distance.

Using GVXR's SquareSource or CubeSource we can implement differently sized sources in order to more accurately model X-ray projectors.

Unfortunately, these functions are not yet exposed to SimpleGVXR, which WebCT is built on.

Initial source type is incorrect

The initial source type when connecting to WebCT is Parallel, but the simulator will create Point projections instead. (and pretend these are parallel projections)

This is only fixed by swapping to point, and then back to parallel.
Changing capture paramaters resets the beam type back to point in the simulator.

GVXR Material Import Error

Chained promises for new materials are not being executed in order, resulting in a race condition when setting a sample with non-id materials. Currently a refresh and re-import works fine, since the materials are still being created.

Config Loading & Exporting

Current settings should be saveable in an selected format. Should keep in mind that other config formats are planned, especially for individual components.

  • Export Config
    • Interface
    • As JSON
  • Import Config
    • Interface
    • As JSON

General Input Validation

The current state of input validation in WebCT is sparse, with a few systems in place for validators.

WebCT should have descriptions and sane defaults for all inputs, along with ranges and feedback from validation errors.

Use Luminance for Synchrotron sources

Currently Synchrotron sources are using X-ray tube settings, this is incorrect.

image

Ideally settings should be:

  • Spectra Energy
  • Luminance (photons/cm2/s)
  • Exposure
  • Beam Harmonics

How to cite?

Please add a section in the README.md file about how to cite this work.

Better support for longer reconstruction duration

Sometimes iterative reconstruction methods can take much longer compared to fdk/fbp on the same data size. Better support for iterative reconstruction methods to display progress along with a cleaner interface for reconstruction timings would be good.

Currently, there is no way to know if the reconstruction method is still running, or the server has halted.

FFMPEG Encode fail with non-even resolutions

During encoding for transmitting reconstruction previews to the client, if the panel resolution, or number of projections is not an even number, ffmpeg fails.

Additionally; there is no recovery done on the client side, meaning a page refresh is required (no parameters are lost though).

[libx264 @ 000002df0a186dc0] width not divisible by 2 (827x827)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
[2022-07-21 16:55:16,445] ERROR in app: Exception on /recon/preview/get [GET]
Traceback (most recent call last):
  File "C:\Users\WYVERN\.micromamba\envs\webct\lib\site-packages\imageio_ffmpeg\_io.py", line 615, in write_frames
    p.stdin.write(bb)
BrokenPipeError: [Errno 32] Broken pipe

Options are:

  • Pad images just for export
  • Pad images for export, and crop exported video
  • Disallow non-even values for height, width, & Projections

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.