Skip to content

Commit

Permalink
remove community analysis and its dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
shimoura committed Nov 14, 2023
1 parent dcaf30f commit a8f76e5
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 282 deletions.
3 changes: 1 addition & 2 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ if 'BASE_PATH' in config:
else:
BASE_PATH = os.getcwd()

INFOMAP_PATH = config['INFOMAP_PATH']
NEST_VARS_PATH = os.path.join(config['NEST_PATH'], 'bin', 'nest_vars.sh')

with open('cluster.json', 'r') as f:
Expand Down Expand Up @@ -80,4 +79,4 @@ rule analyzeNetwork:
log:
'out/log/{experiment}_analyzeNetwork.log'
shell:
'{RUN_ANALYSIS} src/snakemake_analysis.py {input} {output} {INFOMAP_PATH} {BASE_PATH}'
'{RUN_ANALYSIS} src/snakemake_analysis.py {input} {output} {BASE_PATH}'
1 change: 0 additions & 1 deletion config_jureca.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
NEST_PATH: /path/to/installation
INFOMAP_PATH: /path/to/infomapinstallation
OUTPATH: /where/to/write/simulationdata/to

MPIRUN: srun
Expand Down
1 change: 0 additions & 1 deletion humam.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ dependencies:
- pysocks=1.7.0=py36_0
- python=3.6.5=hc3d631a_0
- python-dateutil=2.8.0=py36_0
- python-igraph=0.7.1.post7=py36h516909a_0
- pytz=2019.1=py_0
- pyyaml=3.12=py36hafb9ca4_1
- qt=5.6.2=hd25b39d_14
Expand Down
91 changes: 3 additions & 88 deletions src/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@

from dicthash import dicthash

from helpers.mapequation import getCommunityStructure
from helpers.resting_state_networks import left_ordering
from data_loader.dk_fullnames_to_shortnames import dk_full_to_short

from joblib import Parallel, delayed
import multiprocessing
Expand All @@ -49,11 +47,10 @@ class Analysis():
"""

def __init__(self, ana_params, net_dict, sim_dict, sim_folder,
infomap_path, base_path):
base_path):
self.ana_dict = ana_params
self.net_dict = net_dict
self.sim_dict = sim_dict
self.infomap_path = infomap_path

self.base_path = base_path
self.sim_folder = sim_folder
Expand Down Expand Up @@ -124,12 +121,12 @@ def fullAnalysis(self):
datetime.now().time(), 'Correlation coefficients')
)
self.plotCorrCoff()
print('{} plotting binned spike rates per neuron'.format(
print('{} Plotting binned spike rates per neuron'.format(
datetime.now().time())
)
self.plot_all_binned_spike_rates_area()

print('{} plotting functional connectivity based on synaptic input currents'.format(
print('{} Plotting functional connectivity based on synaptic input currents'.format(
datetime.now().time())
)
self.plot_functional_connectivity()
Expand All @@ -148,12 +145,6 @@ def fullAnalysis(self):
for area in self.popGids.index.levels[0]:
print('{} Plotting {}'.format(datetime.now().time(), area))
self.plotRasterArea(area)
try:
print('{} Plotting connectivities'.format(datetime.now().time()))
self.plotConnectivities()
except OSError:
print("Something went wrong when plotting community structures."
" Probably infomap is not installed.")
print('{} Plotting BOLD connectivities'.format(datetime.now().time()))
self.plotBOLDConnectivity()

Expand Down Expand Up @@ -777,82 +768,6 @@ def plotPopCVIsi(self):
plt.clf()
plt.close(fig)

def plotConnectivities(self):
"""
Plots structural and functional connectivities.
"""
# Read values
if not hasattr(self, 'self.rate'):
self.curr_in = self.synapticInputCurrent()
curr_in = self.curr_in

extension = self.ana_dict['extension']
tmin = self.ana_dict['plotConnectivities']['tmin']
bold = curr_in.T
synapses = self.net_dict['synapses_internal']
# Aggregate synapses to area-level
synapses = synapses.groupby(level=0).sum().T.groupby(level=0).sum().T

cluster_membership_Synapses = getCommunityStructure(
synapses, work_dir=os.path.join(self.ana_folder, 'infomap'),
infomap_path=self.infomap_path
)

# Normalize struct_conn, calculate func_conn
struct_conn = synapses
struct_conn[struct_conn < 1] = np.NaN
struct_conn = np.log10(struct_conn)
funct_conn = bold[bold.index >= tmin].corr()
np.fill_diagonal(funct_conn.values, np.NaN)

# Map area names to short area names & add cluster membership to index
funct_conn.index = [
cluster_membership_Synapses,
funct_conn.index.map(dk_full_to_short)
]
funct_conn.index.names = ['', '']
funct_conn.columns = [
cluster_membership_Synapses,
funct_conn.columns.map(dk_full_to_short)
]
funct_conn.columns.names = ['', '']
struct_conn.index = [
cluster_membership_Synapses,
struct_conn.index.map(dk_full_to_short)
]
struct_conn.index.names = ['', '']
struct_conn.columns = [
cluster_membership_Synapses,
struct_conn.columns.map(dk_full_to_short)
]
struct_conn.columns.names = ['', '']

# Sort according to cluster membership
funct_conn = funct_conn.sort_index(axis=0).sort_index(axis=1)
struct_conn = struct_conn.sort_index(axis=0).sort_index(axis=1)

# Plot using seaborn heatmap
fig, axarr = plt.subplots(1, 2, figsize=(12, 6))
axarr[0].set_title('Structural connectivity (log synapse number)')
sns.heatmap(
struct_conn, square=True, ax=axarr[0], cmap="YlGnBu",
cbar=True, cbar_kws={"shrink": .66}
)
axarr[1].set_title('Functional connectivity (abs. input currents)')
mask = np.zeros_like(funct_conn)
mask[np.triu_indices_from(mask)] = True
sns.heatmap(
funct_conn, square=True, ax=axarr[1], mask=mask, cmap="YlGnBu",
cbar=True, cbar_kws={"shrink": .66}
)
plt.tight_layout()
fig.savefig(os.path.join(
self.plot_folder,
'connectivity.{0}'.format(extension)
))
plt.clf()
plt.close(fig)

def plot_functional_connectivity(self):
"""
Plots structural and functional connectivities.
Expand Down
187 changes: 0 additions & 187 deletions src/helpers/mapequation.py

This file was deleted.

5 changes: 2 additions & 3 deletions src/snakemake_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@
sim_dict = simulationDictFromDump(sim_folder)

# Create Analysis class and export it
infomap_path = sys.argv[5]
base_path = sys.argv[6]
ana = Analysis(ana_params, net_dict, sim_dict, sim_folder, infomap_path, base_path)
base_path = sys.argv[5]
ana = Analysis(ana_params, net_dict, sim_dict, sim_folder, base_path)
ana.dump(sim_folder)

# Do the analysis
Expand Down

0 comments on commit a8f76e5

Please sign in to comment.