Skip to content

Commit

Permalink
Merge pull request #263 from NeuroML/development
Browse files Browse the repository at this point in the history
For 1.1.3 release
  • Loading branch information
sanjayankur31 authored Oct 20, 2023
2 parents e49d725 + 03e3230 commit 3674f6b
Show file tree
Hide file tree
Showing 10 changed files with 466 additions and 377 deletions.
15 changes: 15 additions & 0 deletions docs/source/pyneuroml.plot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,18 @@ pyneuroml.plot.PlotMorphology module
:show-inheritance:
:exclude-members: set, add_line, plot_from_console, main, process_args, LineDataUnits

pyneuroml.plot.PlotMorphologyVispy module
------------------------------------------

.. automodule:: pyneuroml.plot.PlotMorphologyVispy
:members:
:undoc-members:
:show-inheritance:

pyneuroml.plot.PlotMorphologyPlotly module
------------------------------------------

.. automodule:: pyneuroml.plot.PlotMorphologyPlotly
:members:
:undoc-members:
:show-inheritance:
2 changes: 1 addition & 1 deletion pyneuroml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
__version__ = importlib_metadata.version("pyNeuroML")


JNEUROML_VERSION = "0.12.4"
JNEUROML_VERSION = "0.13.0"

# Define a logger for the package
logging.basicConfig(
Expand Down
8 changes: 5 additions & 3 deletions pyneuroml/analysis/ChannelDensityPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +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
target_directory=None,
):
"""Plot channel densities on a Cell on morphology plots.
Expand Down Expand Up @@ -601,11 +601,13 @@ def plot_channel_densities(
:param colormap_name: name of matplotlib colormap to use for morph plot.
Note that if there's only one overlay value, the colormap is modified
to only show the max value of the colormap to indicate this.
See: https://matplotlib.org/stable/users/explain/colors/colormaps.html
:type colormap_name: str
:returns: None
"""
tgt_dir = target_directory+'/' if target_directory else './'
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"
Expand Down
Binary file not shown.
58 changes: 30 additions & 28 deletions pyneuroml/plot/PlotMorphology.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,31 @@


import argparse
import logging
import os
import sys
import random

import sys
import typing
import logging

import numpy
import matplotlib
import numpy
from matplotlib import pyplot as plt

from neuroml import Cell, NeuroMLDocument, Segment, SegmentGroup
from neuroml.neuro_lex_ids import neuro_lex_ids
from pyneuroml.pynml import read_neuroml2_file
from pyneuroml.utils.cli import build_namespace
from pyneuroml.utils import extract_position_info
from pyneuroml.utils.cli import build_namespace
from pyneuroml.utils.plot import (
add_text_to_matplotlib_2D_plot,
get_next_hex_color,
DEFAULTS,
add_box_to_matplotlib_2D_plot,
get_new_matplotlib_morph_plot,
autoscale_matplotlib_plot,
add_scalebar_to_matplotlib_plot,
add_line_to_matplotlib_2D_plot,
DEFAULTS,
add_scalebar_to_matplotlib_plot,
add_text_to_matplotlib_2D_plot,
autoscale_matplotlib_plot,
get_new_matplotlib_morph_plot,
get_next_hex_color,
load_minimal_morphplottable__model,
)
from neuroml import SegmentGroup, Cell, Segment, NeuroMLDocument
from neuroml.neuro_lex_ids import neuro_lex_ids


logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
Expand Down Expand Up @@ -144,7 +142,7 @@ def plot_from_console(a: typing.Optional[typing.Any] = None, **kwargs: str):
:param kwargs: other arguments
"""
a = build_namespace(DEFAULTS, a, **kwargs)
print(a)
logger.debug(a)
if a.interactive3d:
from pyneuroml.plot.PlotMorphologyVispy import plot_interactive_3D

Expand Down Expand Up @@ -251,21 +249,27 @@ def plot_2D(
if verbose:
print("Plotting %s" % nml_file)

# do not recursive read the file, the extract_position_info function will
# do that for us, from a copy of the model
if type(nml_file) is str:
nml_model = read_neuroml2_file(
nml_file,
include_includes=False,
check_validity_pre_include=False,
verbose=False,
optimized=True,
)
# load without optimization for older HDF5 API
# TODO: check if this is required: must for MultiscaleISN
if nml_file.endswith(".h5"):
nml_model = read_neuroml2_file(nml_file)
else:
nml_model = read_neuroml2_file(
nml_file,
include_includes=False,
check_validity_pre_include=False,
verbose=False,
optimized=True,
)
load_minimal_morphplottable__model(nml_model, nml_file)

if title is None:
try:
title = f"{nml_model.networks[0].id} from {nml_file}"
except IndexError:
title = f"{nml_model.cells[0].id} from {nml_file}"

elif isinstance(nml_file, Cell):
nml_model = NeuroMLDocument(id="newdoc")
nml_model.add(nml_file)
Expand All @@ -290,9 +294,7 @@ def plot_2D(
positions,
pop_id_vs_color,
pop_id_vs_radii,
) = extract_position_info(
nml_model, verbose, nml_file if type(nml_file) is str else ""
)
) = extract_position_info(nml_model, verbose)

if verbose:
logger.debug(f"positions: {positions}")
Expand Down
Loading

0 comments on commit 3674f6b

Please sign in to comment.