This is a Unity project which uses html requests to our web app to provide a graphical interface for brain vizualization. The data visualized includes 3D brain models, electrode locations, and prior stim sites.
The project is intended to be built for WebGL and placed within our web app. The web app then serves up the brain vizualization app on its /brain/ page. To deploy the project:
- Use the unity editor to build to WebGL. (File menu -> Build Settings -> Make sure that "brain" scene is checked under "Scenes in build" and that WebGL is selected under platform -> click "Build" -> select an output location.)
- Find the folder which Unity generates in the selected output location, and within that folder, the subfolder called "Build."
- Update the cml web project to include your new build by replacing the cml-web/static/brain/unity_web_app/Build folder. Note you will need to update the web app on rhino using tmux on the ram_maint account before your change is reflected on the actual running web app. (Optionally also replace TemplateData and logo.png, which are used for css styling of the page the web app is on.)
The web app's responses to the requests of this vizualizer depend on data generated by the brain vizualization pipeline. For information about that pipeline, see https://github.com/pennmem/neurorad_pipeline and our cml-web project on gitlab. To speed up the loading of 3D brain models, Unity can also generate asset bundles. Note the vizualizer first requests asset bundles from the web app, and then regular .objs if an asset bundle isn't available.
To generate asset bundles, create a new scene containing only one objSpawner component on a GameObject, or use the provided "baker" scene. Then use the functions of Editor/CreateAssetBundles.cs which can be triggered by options in the Assets menu (next to the File menu in the upper left of the screen.)
- "Download Brains" option. Download Brains in the unity editor. Do this in a scene with an objSpawner, and note that downloading all brains will take a while. The editor is single threaded and will freeze while downloading- you can check progress by looking at requests on the server.
- "Create Prefab From Selected" option. Create prefabs of the brains you want to make asset bundles for. Do this by selecting the downloaded brains in the scene first.
- "Build Asset Bundles." Build prefabs into asset bundles. This will automatically build all assets bundles. Prefabs will already have been added to the correct asset bundle. This is fast-ish. The bundles will be output to /AssetBundles .
The resultant asset bundles should be uploaded to rhino. They will then be served to the brain viz app upon request. The web app expects asset bundles to be: data10/eeg/freesurfer/subjects/R????X/surf/roi/r????x . (note the capital R and X in the subject directory, and lowercase r and x in the filename. note the file has no extension.)
Note that there is a store of already built asset bundles on box under "system 3 installers/unity brain viz app."