Skip to content

Commit

Permalink
Update simulation parameters and improve analysis plotting
Browse files Browse the repository at this point in the history
- Changed master_seed in experiment_stabilized_groundstate.py
- Specified exact versions for dependencies in humam.yml
- Enhanced raster statistics plotting in analysis.py
- Updated display name in humam_tutorial.ipynb
- Fixed NaN handling in connectivity.py
  • Loading branch information
shimoura committed Nov 14, 2024
1 parent 4ed2fdb commit 27f2df8
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion experiments/experiment_stabilized_groundstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Overwrite values of src/default_sim_params.py
sim_params = {
't_sim': 12500.0,
'master_seed': 2106
'master_seed': 2903
}

# Parameters for the analysis
Expand Down
35 changes: 16 additions & 19 deletions humam.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
name: humam
channels:
- conda-forge
- defaults
dependencies:
- nest-simulator
- joblib
- xlrd
- matplotlib
- pyyaml
- numpy
- seaborn
- python
- pandas
- scipy
- ipykernel
- pip
- nest-simulator=3.8
- joblib=1.4.2
- xlrd=2.0.1
- matplotlib=3.9.2
- pyyaml=6.0.2
- numpy=2.1.3
- seaborn=0.13.2
- python=3.12.7
- pandas=2.2.3
- scipy=1.14.1
- ipykernel=6.29.5
- pip=24.3.1
- pip:
- nnmt
- dicthash
- networkx
- snakemake
- nnmt==1.3.0
- dicthash==0.0.2
- networkx==3.4.2
- snakemake==8.25.3
4 changes: 2 additions & 2 deletions humam_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@
"areas_to_plot = ['caudalanteriorcingulate', 'pericalcarine', 'fusiform']\n",
"\n",
"# Plot the raster plot for the selected areas\n",
"ana.plot_raster_statistics()"
"ana.plot_raster_statistics(raster_areas=areas_to_plot)"
]
},
{
Expand Down Expand Up @@ -705,7 +705,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "humam-nest3",
"display_name": "humam_nest3",
"language": "python",
"name": "python3"
},
Expand Down
17 changes: 10 additions & 7 deletions src/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ def fullAnalysis(self):
self.plotRasterArea(area)
print('{} Plotting BOLD connectivities'.format(datetime.now().time()))
self.plotBOLDConnectivity()
print('{} Plotting {}'.format(datetime.now().time(), 'Raster statistics'))
self.plot_raster_statistics(save_fig=True)
plt.close('all')

@timeit
def meanFiringRate(self):
Expand Down Expand Up @@ -311,14 +314,14 @@ def plot_instantaneous_firing_rate(self, save_fig=False):
rate_hist_areas_df = pd.DataFrame(rate_hist_areas.tolist(), index=rate_hist_areas.index)

# Plot the heatmap with an orange-yellow color palette
plt.style.use('default')
plt.figure(figsize=(12, 5))
sns.heatmap(rate_hist_areas_df, cmap='YlOrBr', cbar_kws={'label': 'Spikes/s'}, yticklabels=rate_hist_areas_df.index)
plt.xlabel('Time (ms)')
plt.ylabel('Area')
plt.title('Instantaneous firing rate over simulated areas')
plt.xticks(rotation=0) # Rotate x-axis labels to make the times horizontal
plt.xlim(self.sim_dict['t_sim']-500, self.sim_dict['t_sim'])
plt.tight_layout()

# Save the plot if save_fig is True
if save_fig:
Expand Down Expand Up @@ -358,6 +361,7 @@ def plot_average_rate_per_pop(self, save_fig=False):
mask = mean_rates_df.isna()

# Plot the heatmap with external grid
plt.style.use('default')
plt.figure(figsize=(12, 4.5))
sns.heatmap(mean_rates_df, cmap='YlOrBr', fmt=".2f", mask=mask, cbar_kws={'label': 'Spikes/s'})
plt.title('Time-averaged firing rate over simulated populations')
Expand Down Expand Up @@ -1099,13 +1103,13 @@ def calculateFuncionalConnectivityCorrelations(self):
# (df_sim_fc_syn)
df_sim_fc_syn = synaptic_currents[synaptic_currents.index >= tmin].corr()
if exclude_diagonal:
np.fill_diagonal(df_sim_fc_syn.values, np.NaN)
np.fill_diagonal(df_sim_fc_syn.values, np.nan)

# Read in simulated functional connectivity based on calculated BOLD
# signal
df_sim_fc_bold = self.BOLD_correlation
if exclude_diagonal:
np.fill_diagonal(df_sim_fc_bold.values, np.NaN)
np.fill_diagonal(df_sim_fc_bold.values, np.nan)

# Sort
df_sim_fc_syn = df_sim_fc_syn.sort_index(axis=0).sort_index(axis=1)
Expand Down Expand Up @@ -1199,8 +1203,8 @@ def calculateFuncionalConnectivityCorrelations(self):
# Correlation with itself is trivially 1, set those values to
# nan
if exclude_diagonal:
np.fill_diagonal(lh_fc.values, np.NaN)
np.fill_diagonal(rh_fc.values, np.NaN)
np.fill_diagonal(lh_fc.values, np.nan)
np.fill_diagonal(rh_fc.values, np.nan)

# Sort and put into dictionary
lh_fc = lh_fc.sort_index(axis=0).sort_index(axis=1)
Expand Down Expand Up @@ -1667,7 +1671,6 @@ def plot_raster_statistics(self, save_fig=False, raster_areas=None):
upper.append(upper_whisker)
print('label:', label, 'lowest whisker:', round(min(lower), 1))
print('label:', label, 'highest whisker:', round(max(upper), 1))
ax.set_yticks(ind)
ax.set_yticklabels(names)
ax_rates.set_xlim(0)
ax_rates.set_xlabel('Firing rate (spikes/s)')
Expand All @@ -1679,7 +1682,7 @@ def plot_raster_statistics(self, save_fig=False, raster_areas=None):
if save_fig:
extension = self.ana_dict['extension']
fig.savefig(os.path.join(self.plot_folder, f'figure_spike_statistics.{extension}'))
plt.show()
plt.close(fig)

def plot_all_binned_spike_rates_area(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/data_preprocessing/connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def tmp(val, SLN_FF, SLN_FB):
return 'lat'
else:
return 'FF'
d = self.SLN.map(lambda x: tmp(x, SLN_FF, SLN_FB))
d = self.SLN.applymap(lambda x: tmp(x, SLN_FF, SLN_FB))
return d

def populationSpecificSynapseNumbers(self, SLN_FF, SLN_FB, Z_i, lmbda):
Expand Down

0 comments on commit 27f2df8

Please sign in to comment.