Diamond Light Source Summer Internship.
This prototype was created with h5web/lib(https://www.npmjs.com/package/@h5web/lib) and React.
Simple REST server made with flask that returns JSON responses.
Made specifically for sending images from an image stack. Option is available to downsample and/or compress(using gzip) the response via the variables at the top of main.py. Downsampling block size can also be set via the variable at the top of main.py
Requests are of the form http://localhost:8081/location-of-image-stack-relative-to-server-folder[image-number]?downsample=true where the URL encoded parameter downsample
indicates whether to request a downsampled image or not.
Example request: http://localhost:8081/demo_data[3]?downsample=true \
Properties:
- downsampled : The downsampling ratio. 0 if no downsampling has been done. E.g. If ratio is 4 then the block size is 16
- item-type : The type of item received. In our case, it will always be "time-series"
- object-type : "h5_object"
- path : Path to the particular image received relative to the server folder. E.g. "demo_data/tomo.h5/2-AstraReconCpu/data[0]"
- shape : Shape of the image series from which the received image is from. E.g. [768,576,768]
- values : Array of data values.
Run python main.py
in the server folder.
This project was bootstrapped with Create React App.
- Run
npm install
in the main directory to install the dependencies. - Open src/App.tsx and modify
dataFolder
to point toward the folder where the hdf5 file is located relative to the server directory. Example:dataFolder="demo_data"
- Modify
dataPath
to point towards the image stack. Example:dataPath="tomo.h5/2-AstraReconCpu/data"
- Modify
port
to the port where the local server is running(will be shown in console when you start the server). - Modify
enableDownsampling
to indicate whether you want the downsampling feature enabled. - Modify
decompress
to indicate whether you want the responses to be decompressed(gzip). - Run
npm start
in the main directory to run the app. - Open http://localhost:3000 to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.