Skip to content

Commit 1a3b515

Browse files
author
Alvaro
committed
added 'all_nodes' param to 'plot_states_network_glass' method
1 parent 85b84c4 commit 1a3b515

3 files changed

Lines changed: 25 additions & 6 deletions

File tree

pyleida/_data_loader.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,7 @@ def plot_clustering_performance(self):
13441344
performance = pd.read_csv(f'{self._clustering_}/clustering_performance.csv',sep='\t')
13451345
plot_clustering_scores(performance)
13461346

1347-
def plot_states_network_glass(self,k=2,darkstyle=False):
1347+
def plot_states_network_glass(self,k=2,all_nodes=False,darkstyle=False):
13481348
"""
13491349
Create a glass brain (axial view) showing the
13501350
network representation of each phase-locking
@@ -1355,6 +1355,11 @@ def plot_states_network_glass(self,k=2,darkstyle=False):
13551355
k : int.
13561356
Select the partition of interest.
13571357
1358+
all_nodes : bool. Default: False.
1359+
Specify whether to show all
1360+
nodes or just the nodes of
1361+
the current state.
1362+
13581363
darkstyle : bool.
13591364
Whether to use a dark theme for
13601365
the plots.
@@ -1363,7 +1368,7 @@ def plot_states_network_glass(self,k=2,darkstyle=False):
13631368
pl_states = self.load_centroids(k=k).values
13641369

13651370
with plt.style.context("dark_background" if darkstyle else "default"):
1366-
states_k_glass(pl_states,self.rois_coordinates_,darkstyle=darkstyle)
1371+
states_k_glass(pl_states,self.rois_coordinates_,all_nodes=all_nodes,darkstyle=darkstyle)
13671372

13681373
def plot_states_in_bold(self,subject_id,k=2,alpha=.5,darkstyle=False):
13691374
"""

pyleida/_leida.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,7 @@ def plot_clustering_performance(self):
17111711
self._check_is_fitted()
17121712
plot_clustering_scores(self._clustering_.performance)
17131713

1714-
def plot_states_network_glass(self,k=2,darkstyle=False):
1714+
def plot_states_network_glass(self,k=2,all_nodes=False,darkstyle=False):
17151715
"""
17161716
Create a glass brain (axial view) showing the
17171717
network representation of each phase-locking
@@ -1722,6 +1722,11 @@ def plot_states_network_glass(self,k=2,darkstyle=False):
17221722
k : int.
17231723
Select the partition of interest.
17241724
1725+
all_nodes : bool. Default: False.
1726+
Specify whether to show all
1727+
nodes or just the nodes of
1728+
the current state.
1729+
17251730
darkstyle : bool.
17261731
Whether to use a dark theme for
17271732
the plots.
@@ -1735,7 +1740,7 @@ def plot_states_network_glass(self,k=2,darkstyle=False):
17351740
pl_states = self.load_centroids(k=k).values
17361741

17371742
with plt.style.context("dark_background" if darkstyle else "default"):
1738-
states_k_glass(pl_states,self.rois_coordinates,darkstyle=darkstyle)
1743+
states_k_glass(pl_states,self.rois_coordinates_,all_nodes=all_nodes,darkstyle=darkstyle)
17391744

17401745
def plot_states_on_surf(self,k=2,state='all',parcellation=None,discretize=True,cmap='auto',darkstyle=False,open=True,save=False):
17411746
"""

pyleida/plotting/_plotting.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def brain_states_on_surf2(centroid,parcellation=None,surface='pial',hemi='right'
448448

449449
return fig_
450450

451-
def states_k_glass(centroids,coords,darkstyle=False):
451+
def states_k_glass(centroids,coords,all_nodes=False,darkstyle=False):
452452
"""
453453
Create a glass brain (axial view) showing the
454454
network representation of each PL pattern for
@@ -462,6 +462,11 @@ def states_k_glass(centroids,coords,darkstyle=False):
462462
463463
coords : ndarray with shape (N_rois, 3).
464464
ROIs coordinates in MNI space.
465+
466+
all_nodes : bool. Default: False.
467+
Specify whether to show all
468+
nodes or just the nodes of
469+
the current state.
465470
466471
darkstyle : bool.
467472
Whether to use a dark theme for the plots.
@@ -507,10 +512,14 @@ def states_k_glass(centroids,coords,darkstyle=False):
507512
edges_lw = {'linewidth':sizes_and_lws['lw'][n_columns-2],'color':'firebrick'}
508513
centroid = centroids[state_idx,:]
509514
network = centroid2network(centroid)
515+
if not all_nodes:
516+
rois_idxs = centroid>0
517+
network = network[rois_idxs,:]
518+
network = network[:,rois_idxs]
510519

511520
plot_connectome(
512521
network,
513-
coords,
522+
coords if all_nodes else coords[rois_idxs],
514523
node_color='blue' if not np.any(network) else 'black' if not darkstyle else 'white',
515524
node_size=sizes_and_lws['node_size'][n_columns-2],
516525
#edge_cmap=<matplotlib.colors.LinearSegmentedColormap object>,

0 commit comments

Comments
 (0)