-
Notifications
You must be signed in to change notification settings - Fork 326
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
feat(nifti): Add nifti volume loader to cornerstone 3D repo #696
Merged
Merged
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a9be683
initial commit for nifti reading
sedghi 162fb74
remaining files
sedghi 3c571ab
nifti with tools
sedghi 582d129
apply review comments
sedghi c0be890
merge
sedghi 12d38b5
update api
sedghi 0ffbdc8
update api
sedghi e03af1a
Merge branch 'feat/nifti-loader' of github.com:cornerstonejs/cornerst…
sedghi 4ff2f0c
update api
sedghi 4264a43
fix ci
sedghi 1a3c6db
fix version
sedghi 18a16be
Merge branch 'feat/nifti-loader' of github.com:cornerstonejs/cornerst…
sedghi e9d74c1
apply review comments
sedghi 1fc9273
update api extractor
sedghi f294015
api-check
wayfarer3130 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
type AffineMatrix = [ | ||
[number, number, number, number], | ||
[number, number, number, number], | ||
[number, number, number, number], | ||
[number, number, number, number] | ||
]; | ||
|
||
export type { AffineMatrix }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,8 @@ | ||
/** | ||
* This represents a 3x3 matrix of numbers | ||
*/ | ||
type Mat3 = [ | ||
number, | ||
number, | ||
number, | ||
number, | ||
number, | ||
number, | ||
number, | ||
number, | ||
number | ||
]; | ||
type Mat3 = | ||
| [number, number, number, number, number, number, number, number, number] | ||
| Float32Array; | ||
|
||
export default Mat3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const path = require('path'); | ||
const webpackCommon = require('./../../../.webpack/webpack.common.js'); | ||
const SRC_DIR = path.join(__dirname, '../src'); | ||
const DIST_DIR = path.join(__dirname, '../dist'); | ||
|
||
module.exports = (env, argv) => { | ||
return webpackCommon(env, argv, { SRC_DIR, DIST_DIR }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const { merge } = require('webpack-merge'); | ||
const path = require('path'); | ||
const webpackCommon = require('./../../../.webpack/webpack.common.js'); | ||
const pkg = require('./../package.json'); | ||
|
||
module.exports = (env, argv) => { | ||
const commonConfig = webpackCommon(env, argv); | ||
|
||
return merge(commonConfig, { | ||
devtool: 'source-map', | ||
entry: { | ||
lib: path.join(__dirname, '../src/index.ts'), | ||
}, | ||
output: { | ||
path: path.join(__dirname, '../dist/umd'), | ||
library: 'cornerstoneNiftiVolumeLoader', | ||
libraryTarget: 'umd', | ||
filename: 'index.js', | ||
}, | ||
stats: { | ||
colors: true, | ||
hash: true, | ||
timings: true, | ||
assets: true, | ||
chunks: false, | ||
chunkModules: false, | ||
modules: false, | ||
children: false, | ||
warnings: true, | ||
}, | ||
optimization: { | ||
minimize: true, | ||
}, | ||
externals: [ | ||
{ | ||
'@cornerstonejs/core': { | ||
root: 'cornerstone3D', | ||
commonjs: '@cornerstonejs/core', | ||
commonjs2: '@cornerstonejs/core', | ||
amd: '@cornerstonejs/core', | ||
}, | ||
}, | ||
], | ||
}); | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# @cornerstonejs/nifti-volume-loader | ||
|
||
Nifti volume loader for the cornerstone3D framework. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "../../api-extractor.json", | ||
"projectFolder": ".", | ||
"mainEntryPointFilePath": "<projectFolder>/dist/cjs/index.d.ts", | ||
"apiReport": { | ||
"reportFileName": "<unscopedPackageName>.api.md", | ||
"reportFolder": "../../common/reviews/api" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('../../babel.config.js'); |
102 changes: 102 additions & 0 deletions
102
packages/nifti-volume-loader/examples/niftiBasic/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { | ||
RenderingEngine, | ||
Enums, | ||
init as csInit, | ||
Types, | ||
volumeLoader, | ||
setVolumesForViewports, | ||
} from '@cornerstonejs/core'; | ||
import { init as csTools3dInit } from '@cornerstonejs/tools'; | ||
import { cornerstoneNiftiImageVolumeLoader } from '@cornerstonejs/nifti-volume-loader'; | ||
|
||
import { setCtTransferFunctionForVolumeActor } from '../../../../utils/demo/helpers'; | ||
|
||
// This is for debugging purposes | ||
console.warn( | ||
'Click on index.ts to open source code for this example --------->' | ||
); | ||
|
||
const size = '500px'; | ||
|
||
const content = document.getElementById('content'); | ||
const viewportGrid = document.createElement('div'); | ||
viewportGrid.style.display = 'flex'; | ||
viewportGrid.style.display = 'flex'; | ||
viewportGrid.style.flexDirection = 'row'; | ||
|
||
const element1 = document.createElement('div'); | ||
const element2 = document.createElement('div'); | ||
const element3 = document.createElement('div'); | ||
element1.style.width = size; | ||
element1.style.height = size; | ||
element2.style.width = size; | ||
element2.style.height = size; | ||
element3.style.width = size; | ||
element3.style.height = size; | ||
|
||
viewportGrid.appendChild(element1); | ||
viewportGrid.appendChild(element2); | ||
viewportGrid.appendChild(element3); | ||
|
||
content.appendChild(viewportGrid); | ||
|
||
const viewportId1 = 'CT_NIFTI_AXIAL'; | ||
const viewportId2 = 'CT_NIFTI_SAGITTAL'; | ||
const viewportId3 = 'CT_NIFTI_CORONAL'; | ||
|
||
async function setup() { | ||
await csInit(); | ||
await csTools3dInit(); | ||
|
||
volumeLoader.registerVolumeLoader('nifti', cornerstoneNiftiImageVolumeLoader); | ||
|
||
const niftiURL = | ||
'https://ohif-assets.s3.us-east-2.amazonaws.com/nifti/MRHead.nii.gz'; | ||
const volumeId = 'nifti:' + niftiURL; | ||
|
||
const volume = await volumeLoader.createAndCacheVolume(volumeId); | ||
|
||
const renderingEngineId = 'myRenderingEngine'; | ||
const renderingEngine = new RenderingEngine(renderingEngineId); | ||
|
||
const viewportInputArray = [ | ||
{ | ||
viewportId: viewportId1, | ||
type: Enums.ViewportType.ORTHOGRAPHIC, | ||
element: element1, | ||
defaultOptions: { | ||
orientation: Enums.OrientationAxis.AXIAL, | ||
}, | ||
}, | ||
{ | ||
viewportId: viewportId2, | ||
type: Enums.ViewportType.ORTHOGRAPHIC, | ||
element: element2, | ||
defaultOptions: { | ||
orientation: Enums.OrientationAxis.SAGITTAL, | ||
}, | ||
}, | ||
{ | ||
viewportId: viewportId3, | ||
type: Enums.ViewportType.ORTHOGRAPHIC, | ||
element: element3, | ||
defaultOptions: { | ||
orientation: Enums.OrientationAxis.CORONAL, | ||
}, | ||
}, | ||
]; | ||
|
||
renderingEngine.setViewports(viewportInputArray); | ||
|
||
volume.load(); | ||
|
||
setVolumesForViewports( | ||
renderingEngine, | ||
[{ volumeId, callback: setCtTransferFunctionForVolumeActor }], | ||
viewportInputArray.map((v) => v.viewportId) | ||
); | ||
|
||
renderingEngine.render(); | ||
} | ||
|
||
setup(); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really need to define yet another matrix format? How about affineMatrix as a function producing a gl-matrix mat4 instance instead, taking four arrays like this as the arguments, and producing the standard mat4 representation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in the meeting, I will do it later