Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cornerstone: Display NIfTI and dicom image previews #30

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

kousu
Copy link
Member

@kousu kousu commented Nov 30, 2022

Use CornerstoneJS to render previews of .nii and .dcm on the web, making Gitea more helpful for clinicians and researchers building medical databases.

Here's a DICOM:

Screenshot 2022-11-29 at 19-59-54 test

and here's a NIfTI:

Screenshot 2022-11-27 at 11-22-38 lfs-test

Fixes #23

@kousu kousu changed the title Display NIfTI and dicom image previews cornerstone: Display NIfTI and dicom image previews Nov 30, 2022
@kousu
Copy link
Member Author

kousu commented Nov 30, 2022

This also works naturally with LFS files. If combined with #1 (-> #24), it works equally well for annexed files.

@kousu
Copy link
Member Author

kousu commented Nov 30, 2022

As a reminder to the future: I was very confused by the current rewrite Cornerstone is going through. It went from cornerstone-core ^2.6.1 to @cornerstonejs/core ^0.22.0. The docs are based on the rewrite, but don't actually explain how to use NIfTIs (or many other things), and the docs for the old version have disappeared from the internet.

It turns out the new version is at best unfinished and at worst vaporware, since not even the flagship app currently uses the rewrite (it's still on 2.6.1) and neither has the author of the NIfTI plugin ported to the new API (even though that plugin has started being published under the new namespace at @cornerstonejs/nifti-image-loader ^1.0.8 with cornerstone-nifti-image-loader being abandoned and only running up to 1.0.0).

The upshot is that if the dependencies look inconsistent to you:

https://github.com/neuropoly/gitea/blob/c528c18ae17a52c6a9dc9f71722309270a3bf9ea/package.json#L10-L13

it's because they are.

For future reference: the way I actually figured out how to use this plugin was with the help of GitHub's downstream tab; it helped me find ChRIS_UI whose package.json clearly shows a working configuration and code shows how to actually use all the different filetypes together.

@kousu
Copy link
Member Author

kousu commented Nov 30, 2022

Testing ⚔️

I don't know how to write tests for this since it's mostly frontend code so I'm just not going to do it. I don't think upstream even bothers to test the frontend automatically that much, there only really seems to be these two files:

https://github.com/neuropoly/gitea/blob/fa43bce541507c8a702723f84764a48db9278506/web_src/js/features/repo-code.test.js#L1-L18

https://github.com/neuropoly/gitea/blob/fa43bce541507c8a702723f84764a48db9278506/web_src/js/features/repo-findfile.test.js#L1-L35

which don't actually test loading any pages or images, they are just unit tests on some utils that happen to be in javascript instead of go.

@kousu
Copy link
Member Author

kousu commented Feb 14, 2023

Oh, whoops. Looks like Gitea has a hook for doing just this that can be configured via app.ini. It would be something like

[markup.nifti]
ENABLED = true
FILE_EXTENSIONS = .nii.gz .nii
RENDER_COMMAND = "cornerstone-wrapper.sh"
IS_INPUT_FILE = false

and then we would have to make sure that cornerstone.js and everything else it needs is in custom/public/.

@kousu
Copy link
Member Author

kousu commented Mar 7, 2023

There is a competitor, (thanks @valosekj for the tip): https://brainsprite.github.io/.

We used this in the past: spine-generic/spine-generic#218; it's live on https://spine-generic.readthedocs.io/data-acquisition.html#example-of-datasets.

I am not motivated to rewriting what I already have working, and I found something to support my bias: brainsprite requires server-side pre-processing:

The brainsprite python library uses nilearn in order to generate the sprites, as well as the html and javascript code required above. This code can be inserted into an html page template based on the tempita library.

We'd need a route that turns a .nii.gz image into a .jpg of stitched together sprites, and maybe a place on-disk to cache those, separate from the usual Gitea folders. This is possible, but complicates things a lot.

@valosekj
Copy link
Member

There is a competitor, (thanks @valosekj for the tip): https://brainsprite.github.io/.

Another potential competitor is NiiVue. It is used, for example, by AFNI QC HTML report; see NV figure under Methods and Results section:

IMG_5456

@kousu
Copy link
Member Author

kousu commented Jul 26, 2023

Lovely, good find!

lunny and others added 9 commits November 2, 2023 22:14
…unactive auth source (go-gitea#27798)

The steps to reproduce it.

First, create a new oauth2 source.
Then, a user login with this oauth2 source.
Disable the oauth2 source.
Visit users -> settings -> security, 500 will be displayed.
This is because this page only load active Oauth2 sources but not all
Oauth2 sources.
We should not use `asset.ID` in DownloadFunc because DownloadFunc is a
closure.

https://github.com/go-gitea/gitea/blob/1bf5527eac6b947010c8faf408f6747de2a2384f/services/migrations/gitea_downloader.go#L284-L295

A similar bug when migrating from GitHub has been fixed in go-gitea#14703. This
PR fixes the bug when migrating from Gitea and GitLab.
This PR is a small refactor to merge removeOrgUser into RemoveOrgUser.
Remove the "tabindex" from some form buttons on the "diff box" / "issue view content" page, let the browser use the default tab order.

---------

Co-authored-by: Gusted <[email protected]>
Co-authored-by: wxiaoguang <[email protected]>
Revert the workaround of go-gitea#26409 and fix go-gitea#26411, update github.com/gliderlabs/ssh to include gliderlabs/ssh@02f9d57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants