sidchop / reponeurovis Goto Github PK
View Code? Open in Web Editor NEWReproducible and Programmatic Human Neuroimaging Visualisations
Reproducible and Programmatic Human Neuroimaging Visualisations
In an attempt to reproduce the below code, I found a line was missing to generate unique values in the first place. I've placed ** around it for you. Cheers
# e.g. pip install numpy brainspace surfplot neuromaps nibabel
from surfplot import Plot
from brainspace.datasets import load_parcellation
from brainspace.mesh.mesh_io import read_surface
from neuromaps.datasets import fetch_fslr
import numpy as np
# Load the surface we want to use as the background
# Read in your own background surface {'.ply', '.vtp', '.vtk', '.fs', '.asc', '.gii'}
surfaces = read_surface('./path/to/surface/file.gii.gz')
# Or use one of the surface files included in the neuromaps package
# Here we are using the 32k FsLR (a symmetric version
# fsaverage space template with ~32k verticies in each hemisphere
surfaces = fetch_fslr()
lh, rh = surfaces['inflated']
# Next we want to load the parcellation/atlas we want to plot
# on the background surface. A parcellation is a array or surface file the same
# length (number of vertices) as the background surface, with the same value
# assigned to clusters of vertivies, representing discrete brain regions
# We can either read in a surface file in FsLR space
atlas = read_surface('./path/to/surface/atlas/file.gii.gz')
# Or use one of the surface files included in the brainspace package
atlas = load_parcellation('schaefer', 100, join = True)
# You can either plot this atlas directly, or assign new values
# to each parcel to demonstrate an statistical effect. Here we assign a
# random value between [0,1] to each unique parcel (excluding the medial wall [0])
**unique = np.unique(atlas)**
unique = unique[1:len(atlas)]
for i in range(unique.shape[0]):
rd = np.random.uniform(low=0.0, high=1.0, size=1).round(3)
atlas = np.where(atlas==unique[i], rd, atlas)
# Generate plot
p = Plot(lh, rh, views=['lateral','medial'], zoom=1.2)
p.add_layer(atlas, cbar=True, cmap='inferno')
p.build()```
Hi,
Thanks for this tool!
For R code, region-level data, atlas_data = left_join(atlas,data))
has an extra ")". Also, ggplot2
needs to be imported as a library.
Best,
Steven
Thank you for this nice tool! I would like to use it to plot surfaces, but I seem to have a slight problem while repeating the steps of the tutorial in "Visualise Vertex-level data".....
I ran the code on jupyter lab; There no output of figure after "p.build()", and the code is shown below:
from surfplot import Plot
from surfplot.datasets import load_example_data
from neuromaps.datasets import fetch_fslr
from brainspace.mesh.mesh_io import read_surface
surfaces = fetch_fslr()
lh, rh = surfaces['inflated']
effect = load_example_data(dataset = 'default_mode', join=True)
p = Plot(lh, rh, views=['lateral','medial','anterior', 'dorsal'], zoom=1.2)
p.add_layer(effect, cbar=True, cmap='inferno')
p.build()
Looking forward to getting your answer, thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.