-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from wiheto/develop
0.3.0
- Loading branch information
Showing
137 changed files
with
6,407 additions
and
359 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Changelog | ||
|
||
## [0.3.0] - in development | ||
|
||
### Added | ||
|
||
- Changelog added. (wiheto) | ||
- Preliminary BIDS operations that generate edge df from BIDS layout `edges_from_bids()` (wiheto) | ||
- Connectivity matrix as view option (wiheto) | ||
- Rotation of connectivity matrix (wiheto) | ||
- cm_order for connectivity matrix (wiheto) | ||
- Dual colours for positive and negative edges (wiheto) | ||
- Allow dual colors for positive and negative edges (wiheto) | ||
- Some gallery examples (plot_dmn, connectivity matrix) (wiheto) | ||
|
||
### Update | ||
- Updated README with network neuroscience reference (wiheto) | ||
- Removed matplotlib deprecated `matplotlib.cm.get_cmap` for `matplotlib.colormaps` (wiheto) | ||
- Rasterization for glass brains (and all template/cms) for faster svg rendering (wiheto) | ||
- Example data is now packaged in ./netplotbrain/example_data to be included in package (wiheto) | ||
|
||
### Fixed | ||
- Renaming "legend_tick_fontsize" and "legend_title_fontsize" to be more consistent (wiheto) | ||
- Renaming "highlightlevel" to "highlight_level" to be more consistent (wiheto) | ||
- Correcting some kwarg names in documentation (wiheto) | ||
- A bug with spring layout and node_color when only subset of nodes plotted (wiheto) |
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,3 +1,4 @@ | ||
include examples/* | ||
include netplotbrain/example_data/*.tsv | ||
recursive-include netplotbrain/example_data/bids_test/ * | ||
include netplotbrain/profiles/*.json | ||
include netplotbrain/templatesettings/*.json |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,48 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "cf30fa87", | ||
"metadata": {}, | ||
"source": [ | ||
" \n", | ||
"# Node properties: size\n", | ||
"\n", | ||
"Netplotbrain allows for specifying different figure properties by only specifyign the column name.\n", | ||
"\n", | ||
"Below we demonstrate how node_size can change based on different columns in the nodes dataframe.\n", | ||
"\n", | ||
"The key lines of code here are when:\n", | ||
"\n", | ||
"`node_size='centrality_measure1'`\n", | ||
"\n", | ||
"and\n", | ||
"\n", | ||
"`node_size='centrality_measure2'`\n", | ||
"\n", | ||
"These columns could be called anything such as \"module_degree_zscore\" or \"efficiency\"" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"jupytext": { | ||
"cell_metadata_filter": "-all", | ||
"main_language": "python", | ||
"notebook_metadata_filter": "-all" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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,43 @@ | ||
# | ||
# # Highlight Parcels | ||
# | ||
# One possble use of netplotbrain is to highlight a seed region used. Here we will highlight two regions of interest. | ||
|
||
# + | ||
# Load imports | ||
import netplotbrain | ||
import pandas as pd | ||
import numpy as np | ||
|
||
# Get 100 node atlas from templateflow | ||
node_dict = {'atlas': 'Schaefer2018', | ||
'desc': '100Parcels7Networks', | ||
'extension': '.nii.gz', | ||
'resolution': 1} | ||
|
||
# pyton index of atlas rois. | ||
# this will start at 0 but atlas starts at 1. | ||
# So below select node 15 and 66 in atlas. | ||
seeds = [14, 65] | ||
|
||
# Create dataframe of 100 rois | ||
nodeinfo = np.zeros(100) | ||
nodeinfo[seeds] = 1 | ||
|
||
node_color = ['gray'] * 100 | ||
node_color[seeds[0]] = 'cornflowerblue' | ||
node_color[seeds[1]] = 'salmon' | ||
nodes_df = pd.DataFrame({'seed': nodeinfo, 'color': node_color}) | ||
|
||
|
||
fig, _ = netplotbrain.plot(template = 'MNI152NLin2009cAsym', | ||
nodes = node_dict, | ||
nodes_df = nodes_df, | ||
node_type = 'parcels', | ||
view = 'preset-3', | ||
node_color = 'color', | ||
highlight_nodes = 'seed', | ||
highlighlevel = 1, | ||
node_alpha = 0.4, | ||
save_name='/home/xthowi/scratch/sham.png', | ||
figdpi=300) |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,45 @@ | ||
# | ||
# # Visualizing a single network | ||
# | ||
# [Open interactive notebook in Binder](https://mybinder.org/v2/gh/wiheto/netplotbrain/main?filepath=docs/gallery/plot_connectivitymatrix.ipynb) | ||
# | ||
# ## Goal | ||
# Here we are plot the nodes on the brain from the Schaefer atlas and plot the connectivity matrix next to it | ||
# | ||
|
||
# + | ||
# Import packages | ||
import templateflow.api as tf | ||
import netplotbrain | ||
import pandas as pd | ||
|
||
# + | ||
# Get template information | ||
template = 'MNI152NLin2009cAsym' | ||
atlas = 'Schaefer2018' | ||
atlas_desc = '100Parcels7Networks' | ||
|
||
# + | ||
# Get and load the tsv file (information about the atlas) | ||
atlas_path = tf.get(atlas=atlas, | ||
template=template, | ||
desc=atlas_desc, | ||
extension='.tsv') | ||
atlas_df = pd.read_csv(atlas_path, sep='\t') | ||
atlas_df.head() | ||
|
||
#+ | ||
# Create a column called "network" by extracting the relevant information from the column "name" | ||
atlas_df['network'] = list(map(lambda x: x.split('_')[2], atlas_df.name.values)) | ||
atlas_df.head() | ||
|
||
# + | ||
# Nodes in connectivity will automatically be organized by node_color, unless cm_order is specified. | ||
netplotbrain.plot(nodes={'atlas': atlas, | ||
'desc': atlas_desc, | ||
'resolution': 1}, | ||
view='LSc', | ||
node_type='parcels', | ||
nodes_df=atlas_df, | ||
node_color='network', | ||
node_cmap='Set2') |
Oops, something went wrong.