-
Notifications
You must be signed in to change notification settings - Fork 100
Open
Description
Summary
This was an experiment to see if niivue can be easily included in the html output. The main issue identified is the CORS policy (security feature that disallows opening local files by javascript code).
Why it works on png / svg files
They are directly rendered by the browser and don't trigger the CORS policy, because no arbitrary javascript code execution can happen.
Why it doesn't work on NIfTI files with niivue
niivue is a javascript library and is not allowed to access local files, because of CORS security enforcing. To open files, they need to be served by a server with CORS headers.
Possible workarounds
- Open a python server that serves the files while creating the report only works while the notebook still is running (program that created the html file) Code that does this
- Create callable scripts (.sh / .bat) that run a local http server and host the local nifti files (python -m http.server). requires a local python and second user engagement. When the file is not available, this could also appear in the html as "To be able to see live rendered nifti image, run
python -m http.serverin the console in the folder of the html file" Code that works after running "python -m http.server" - Embed the nifti file in the html as base64, which bloats the size of the html file, but only needs a simple click from the user perspective Code that doesn't work yet, probably niivue call needs to be fixed to url:-name.nii.gz- data:-base64-
handwerkerd, tsalo and eurunuela
Metadata
Metadata
Assignees
Labels
No labels