Comments (9)
I will certainly up vote. However, in lieu of this feature it would be great for collaboration and reproduction purposes to share the code that you can as markdown/text. I will use the notebook you shared. thanks!
from ipyniivue.
great to hear that, here we go!
from ipyniivue_experimental import AnyNiivue, SliceType
# based on https://niivue.github.io/niivue/features/additive.voxels.html
volumes = [
{ "path": "../images/mni152.nii.gz" },
{
"path": "../images/narps-4965_9U7M-hypo1_unthresh.nii.gz",
"colormap": "red",
"cal_min": 2,
"cal_max": 4,
},
{
"path": "../images/narps-4735_50GV-hypo1_unthresh.nii.gz",
"colormap": "green",
"cal_min": 2,
"cal_max": 4,
},
]
nv = AnyNiivue()
nv.load_volumes(volumes)
nv
nv.volumes[0].colorbarVisible = False
nv.volumes[1].cal_min = 1
from ipyniivue.
I don't see
volume.visible
used anywhere in the codebase, or a way to set the visibility of an existing volume in the viewer. In fact, setting"visible": false
in the JS Viewer doesn't seem to do anything?
@manzt , right. visible
as used with NVImage
is a relic that should be removed in a future version of niivue. However, visible
is used in drawMesh3D
.
So, perhaps it is best to omit visible
from ipyniivue
volumes. We hide images by setting their opacity
to zero.
What do you think?
from ipyniivue.
![image](https://private-user-images.githubusercontent.com/44469195/306701686-9a74ce2b-3fa7-405f-8788-ea094a95aed0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjEyNzY3NjYsIm5iZiI6MTcyMTI3NjQ2NiwicGF0aCI6Ii80NDQ2OTE5NS8zMDY3MDE2ODYtOWE3NGNlMmItM2ZhNy00MDVmLTg3ODgtZWEwOTRhOTVhZWQwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE4VDA0MjEwNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYwMGY3NjIzMWZkZmY2YWFjNjMwNzk3NWQxYTE5ODA2ZmY2YmQ0NjFhNWU5OTQ5ODc0YzhjNWFkMDc0NjM4NzMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0._cXPRH378U7d8imyyD_NIJmmxH0GOWNLYPR14PEJ9wg)
from ipyniivue.
Please try to avoid pasting large images without code. It makes it very hard to reproduce. Would be great to have the code snippet you shared, and just an image of the expected notebook output.
from ipyniivue.
I know, I really wish there was a feature to drag and drop notebooks directly into issues!
Feel free to upvote this discussion for that -> https://github.com/orgs/community/discussions/50144
here's the notebook, just committed it to the main branch
https://github.com/niivue/ipyniivue-experimental/blob/main/demo/additive_voxels.ipynb
from ipyniivue.
I don't see volume.visible
used anywhere in the codebase, or a way to set the visibility of an existing volume in the viewer. In fact, setting "visible": false
in the JS Viewer doesn't seem to do anything?
from ipyniivue.
I found it used like this in basic.multiplanar.html
var volumeList1 = [
{
url: "../images/mni152.nii.gz",
colormap: "gray",
visible: false,
opacity: 1
},
{
url: "../images/hippo.nii.gz",
colormap: "red",
visible: true,
opacity: 1
}
];
and I found it here
https://niivue.github.io/niivue/features/mesh.layers.html
![image](https://private-user-images.githubusercontent.com/44469195/306729609-2f4f3a67-46c2-46f7-b341-aea12fef84d5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjEyNzY3NjYsIm5iZiI6MTcyMTI3NjQ2NiwicGF0aCI6Ii80NDQ2OTE5NS8zMDY3Mjk2MDktMmY0ZjNhNjctNDZjMi00NmY3LWIzNDEtYWVhMTJmZWY4NGQ1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE4VDA0MjEwNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE1NzQwZGE1ZGYwOGI5NDIyMjE2MTU5YTcyNDdhOWZiNTMwYjg5NTY0YjJkZWZkMDQ4ZjdlMGYxMDAwMGNhNTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.m1RzuMeae62tUBmnyYyDZuGaL-9vxpg560fppyZXOGY)
var checkbox1 = document.getElementById("meshCheckbox1");
checkbox1.onclick = function () {
nv1.setMeshProperty(nv1.meshes[0].id, 'visible', checkbox1.checked);
console.log(`visible=${nv1.meshes[0].visible}`);
}
from ipyniivue.
great that min and max is working now!
What do you think would be a good next example to implement?
I think that staying with Volumes and going for
https://niivue.github.io/niivue/features/colormaps.html
would be a good choice.
import * as niivue from "../dist/index.js";
var slider = document.getElementById("gammaSlider");
slider.oninput = function () {
nv1.setGamma(this.value * 0.01);
};
invertCheck.onchange = function () {
nv1.volumes[0].colormapInvert = this.checked;
nv1.updateGLVolume();
}
selectCheck.onchange = function () {
if (this.checked)
nv1.setSelectionBoxColor([0, 1, 0, 0.7]);
else
nv1.setSelectionBoxColor([1, 1, 1, 0.5]);
}
crossCheck.onchange = function () {
if (this.checked)
nv1.setCrosshairColor([0, 1, 0, 1]);
else
nv1.setCrosshairColor([1, 0, 0, 1]);
}
wideCheck.onchange = function () {
if (this.checked)
nv1.setCrosshairWidth(3);
else
nv1.setCrosshairWidth(1);
}
document.getElementById("custom").addEventListener("click", doCustom);
function doCustom() {
var val = document.getElementById("scriptText").value;
val += ';let key = "Custom"; nv1.addColormap(key, cmap); nv1.volumes[0].colormap = key;nv1.updateGLVolume();';
val && eval(val);
}
document.getElementById("saveBmp").addEventListener("click", doSaveBmp);
function doSaveBmp() {
nv1.saveScene("ScreenShot.png");
}
var volumeList1 = [
{
url: "../images/mni152.nii.gz",
colormap: "gray",
opacity: 1,
visible: true,
},
];
var nv1 = new niivue.Niivue({backColor: [0.3, 0.3, 0.3, 1]});
nv1.attachTo("gl1");
nv1.loadVolumes(volumeList1);
nv1.opts.multiplanarForceRender = true;
nv1.opts.isColorbar = true;
let cmaps = nv1.colormaps();
let cmapEl = document.getElementById("colormaps");
for (let i = 0; i < cmaps.length; i++) {
let btn = document.createElement("button");
btn.innerHTML = cmaps[i];
btn.onclick = function () {
nv1.setColormap(nv1.volumes[0].id, cmaps[i]);
};
cmapEl.appendChild(btn);
}
I think the two new functions here are nv1.saveScene and nv1.volumes[0].colormapInvert
from ipyniivue.
Related Issues (20)
- a
- Graph features
- Add custom colormaps
- devDependency requirement on @jupyterlab/builder@^4.0.0
- load_meshes HOT 1
- Building documentation HOT 8
- Review code of NiiVue Jupyter notebook integration in IPyNiiVue HOT 4
- load_meshes does not add the mesh to self.meshes in MacOS and Linux HOT 5
- Restarting the kernel fails to destroy the NiiVue object
- jupyterlab 4 support HOT 4
- ENH: Integration with MNE-Python
- Possible to add overlays and/or possibly saving the whole scene as .html file to harddrive?
- Prototype of ipyniivue using anywidget HOT 7
- Exposing `nv.saveScene` on the python side HOT 1
- Project admin, milestones, and roadmap
- Priorities HOT 6
- Better camel/snake scale conversion HOT 10
- Deleting big files HOT 2
- Larger NIfTI images cause Jupyter Notebook to crash
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipyniivue.