diff --git a/.gitignore b/.gitignore index f61cd928..0356e6dc 100644 --- a/.gitignore +++ b/.gitignore @@ -164,3 +164,4 @@ arm64 /tests/plot/test_schematic_plot_2d_test_cell_nml_xy.png /tests/plot/test_schematic_plot_2d_test_cell_nml_xz.png /tests/plot/test_schematic_plot_2d_test_cell_nml_yz.png +/tests/analysis/*png diff --git a/examples/LeakConductance.mod b/examples/LeakConductance.mod index 1e5459c8..19bf52d2 100644 --- a/examples/LeakConductance.mod +++ b/examples/LeakConductance.mod @@ -18,9 +18,7 @@ NEURON { RANGE i__LeakConductance : a copy of the variable for current which makes it easier to access from outside the mod file RANGE gmax : Will be changed when ion channel mechanism placed on cell! RANGE conductance : parameter - RANGE g : exposure - RANGE fopen : exposure RANGE conductanceScale : derived variable RANGE fopen0 : derived variable @@ -36,11 +34,13 @@ UNITS { (mV) = (millivolt) (mS) = (millisiemens) (uS) = (microsiemens) + (nF) = (nanofarad) (molar) = (1/liter) (kHz) = (kilohertz) (mM) = (millimolar) (um) = (micrometer) (umol) = (micromole) + (pC) = (picocoulomb) (S) = (siemens) } @@ -49,7 +49,7 @@ PARAMETER { gmax = 0 (S/cm2) : Will be changed when ion channel mechanism placed on cell! - conductance = 1.0E-5 (uS) + conductance = 1.0E-5 (uS) : was: 1.0E-11 (conductance) } ASSIGNED { @@ -62,14 +62,10 @@ ASSIGNED { i (mA/cm2) i__LeakConductance (mA/cm2) - - conductanceScale : derived variable - - fopen0 : derived variable - - fopen : derived variable - - g (uS) : derived variable + conductanceScale : derived variable + fopen0 : derived variable + fopen : derived variable + g (uS) : derived variable } diff --git a/pyneuroml/analysis/ChannelDensityPlot.py b/pyneuroml/analysis/ChannelDensityPlot.py index 853d85d4..2c817bfe 100644 --- a/pyneuroml/analysis/ChannelDensityPlot.py +++ b/pyneuroml/analysis/ChannelDensityPlot.py @@ -564,6 +564,7 @@ def plot_channel_densities( show_plots_already: bool = True, morph_plot_type: str = "constant", morph_min_width: float = 2.0, + target_directory=None ): """Plot channel densities on a Cell on morphology plots. @@ -603,6 +604,8 @@ def plot_channel_densities( :type colormap_name: str :returns: None """ + tgt_dir = target_directory+'/' if target_directory else './' + if channel_density_ids is not None and ion_channels is not None: raise ValueError( "Only one of channel_density_ids or ions channels may be provided" @@ -685,7 +688,7 @@ def plot_channel_densities( min_width=morph_min_width, overlay_data=data, overlay_data_label="(S/m2)", - save_to_file=f"{cell.id}_{cd.id}.cd.png", + save_to_file=f"{tgt_dir}{cell.id}_{cd.id}.cd.png", datamin=ymin, plane2d=plane2d, nogui=not show_plots_already, @@ -710,7 +713,7 @@ def plot_channel_densities( title_above_plot=True, xaxis="Distance from soma (um)", yaxis="g density (S/m2)", - save_figure_to=f"{cell.id}_{cd.id}_cd_vs_dist.png", + save_figure_to=f"{tgt_dir}{cell.id}_{cd.id}_cd_vs_dist.png", show_plot_already=show_plots_already, linestyles=[" "], linewidths=["0"], @@ -786,7 +789,7 @@ def plot_channel_densities( min_width=morph_min_width, overlay_data=data, overlay_data_label="(S/m2)", - save_to_file=f"{cell.id}_{ion_channel}.ion.png", + save_to_file=f"{tgt_dir}{cell.id}_{ion_channel}.ion.png", datamin=ymin, plane2d=plane2d, nogui=not show_plots_already, @@ -811,7 +814,7 @@ def plot_channel_densities( title_above_plot=True, xaxis="Distance from soma (um)", yaxis="g density (S/m2)", - save_figure_to=f"{cell.id}_{ion_channel}_ion_vs_dist.png", + save_figure_to=f"{tgt_dir}{cell.id}_{ion_channel}_ion_vs_dist.png", show_plot_already=show_plots_already, linestyles=[" "], linewidths=["0"], diff --git a/tests/analysis/test_channel_density_plots.py b/tests/analysis/test_channel_density_plots.py index 5001d2f3..2242a4fc 100644 --- a/tests/analysis/test_channel_density_plots.py +++ b/tests/analysis/test_channel_density_plots.py @@ -75,10 +75,13 @@ def test_plot_channel_densities(self): channel_density_ids=["Ih_apical", "Ih_somatic", "Ih_basal", "Ih"], distance_plots=True, show_plots_already=False, + target_directory='tests/analysis' ) plot_channel_densities( - cell, ion_channels=["Ih"], distance_plots=True, show_plots_already=False + cell, ion_channels=["Ih"], distance_plots=True, show_plots_already=False, + target_directory='tests/analysis' ) # no channel densities or ion channels, so generate for all ion # channels - plot_channel_densities(cell, distance_plots=True, show_plots_already=False) + plot_channel_densities(cell, distance_plots=True, show_plots_already=False, + target_directory='tests/analysis')