neuropoly / gitea

https://gitea.io fork with https://git-annex.branchable.com support
https://gitea.io
MIT License
3 stars 2 forks source link

cornerstone: preview medical images online #23

Closed kousu closed 1 year ago

kousu commented 1 year ago

(moved from https://github.com/neuropoly/computers/issues/167#issuecomment-1272611388) Use @cornerstonejs/nifti-image-loader to let Gitea preview medical scans the same way it can preview PDFs and SVGs and spreadsheets. Something like:

Screenshot 2022-10-13 at 17-16-14 https __www cornerstonejs org

This will help orient people when using our git with their datasets, making the process less abstract to them. It will also help people feel confident that git annex sync is behaving as they expect, which I think is important because git-annex is a pain.

I believe I need to patch this if-else tree

https://github.com/neuropoly/gitea/blob/88857cfa502057404c00e88eca2ba4aeab118c70/templates/repo/view_file.tmpl#L88-L105

to add a nifti case that loads and runs the cornerstone javascript. I have a starter demo of what needs to be loaded in https://gist.github.com/kousu/2a31328d9c320393fbd603534265faa7.

Then I will need to figure out how Gitea's frontend build process works (it's webpack I think?) so I can know how to serve cornerstone locally.

Later I would also like to add a toolbar like https://viewer.ohif.org/ has. Unfortunately this is going to be some manual work -- Cornerstone doesn't come with a UI library, all that had to be built on top as a wrapper package by the OHIF Viewer (even though they are also the people funding Cornerstone), so I'll need to replicate some of that work. I don't plan to be super fancy, just pan/zoom/scroll-through-slices.

kousu commented 1 year ago

I'm not sure I want to integrate this into #1. For us, planning to use datalad, git-annex and niftis (and bids are all bound together. But by itself git-annex and nifti support are orthogonal features.

So maybe I'll end up publishing v1.18.9-git-annex-cornerstone. Or maybe I'll be able to move this over into the ansible deploy scripts I have for this project in the other repo.

kousu commented 1 year ago

After writing this out, I don't want to move this into the nebulous collection of ansible scripts that make up neurogitea: I patched view.go to detect and generate IsNIfTI and IsDICOM values and I can't override .go files from ansible, obviously; they just examine the file extension, and that might be doable entirely in the view_file.tmpl file, but it adds a lot of complication that is much easier handled with git merge.

This can be another useful standalone feature! Like #1, one I doubt upstream will want it, but that's okay. It's even orthogonal to git-annex, my code works just as well on LFS files and regular git blob files.

kousu commented 1 year ago

30 is done! Or done enough anyway!

But like #1, I'm not going to actually merge it, but instead maintain it as a feature branch indefinitely (see #31). So I'm counting this finished.