99
1010
1111import  argparse 
12+ import  logging 
1213import  os 
13- import  sys 
1414import  random 
15- 
15+ import   sys 
1616import  typing 
17- import  logging 
1817
19- import  numpy 
2018import  matplotlib 
19+ import  numpy 
2120from  matplotlib  import  pyplot  as  plt 
22- 
21+ from  neuroml  import  Cell , NeuroMLDocument , Segment , SegmentGroup 
22+ from  neuroml .neuro_lex_ids  import  neuro_lex_ids 
2323from  pyneuroml .pynml  import  read_neuroml2_file 
24- from  pyneuroml .utils .cli  import  build_namespace 
2524from  pyneuroml .utils  import  extract_position_info 
25+ from  pyneuroml .utils .cli  import  build_namespace 
2626from  pyneuroml .utils .plot  import  (
27-     add_text_to_matplotlib_2D_plot ,
28-     get_next_hex_color ,
27+     DEFAULTS ,
2928    add_box_to_matplotlib_2D_plot ,
30-     get_new_matplotlib_morph_plot ,
31-     autoscale_matplotlib_plot ,
32-     add_scalebar_to_matplotlib_plot ,
3329    add_line_to_matplotlib_2D_plot ,
34-     DEFAULTS ,
30+     add_scalebar_to_matplotlib_plot ,
31+     add_text_to_matplotlib_2D_plot ,
32+     autoscale_matplotlib_plot ,
33+     get_new_matplotlib_morph_plot ,
34+     get_next_hex_color ,
35+     load_minimal_morphplottable__model ,
3536)
36- from  neuroml  import  SegmentGroup , Cell , Segment , NeuroMLDocument 
37- from  neuroml .neuro_lex_ids  import  neuro_lex_ids 
38- 
3937
4038logger  =  logging .getLogger (__name__ )
4139logger .setLevel (logging .INFO )
@@ -144,7 +142,7 @@ def plot_from_console(a: typing.Optional[typing.Any] = None, **kwargs: str):
144142    :param kwargs: other arguments 
145143    """ 
146144    a  =  build_namespace (DEFAULTS , a , ** kwargs )
147-     print (a )
145+     logger . debug (a )
148146    if  a .interactive3d :
149147        from  pyneuroml .plot .PlotMorphologyVispy  import  plot_interactive_3D 
150148
@@ -251,21 +249,27 @@ def plot_2D(
251249    if  verbose :
252250        print ("Plotting %s"  %  nml_file )
253251
254-     # do not recursive read the file, the extract_position_info function will 
255-     # do that for us, from a copy of the model 
256252    if  type (nml_file ) is  str :
257-         nml_model  =  read_neuroml2_file (
258-             nml_file ,
259-             include_includes = False ,
260-             check_validity_pre_include = False ,
261-             verbose = False ,
262-             optimized = True ,
263-         )
253+         # load without optimization for older HDF5 API 
254+         # TODO: check if this is required: must for MultiscaleISN 
255+         if  nml_file .endswith (".h5" ):
256+             nml_model  =  read_neuroml2_file (nml_file )
257+         else :
258+             nml_model  =  read_neuroml2_file (
259+                 nml_file ,
260+                 include_includes = False ,
261+                 check_validity_pre_include = False ,
262+                 verbose = False ,
263+                 optimized = True ,
264+             )
265+             load_minimal_morphplottable__model (nml_model , nml_file )
266+ 
264267        if  title  is  None :
265268            try :
266269                title  =  f"{ nml_model .networks [0 ].id } { nml_file }  
267270            except  IndexError :
268271                title  =  f"{ nml_model .cells [0 ].id } { nml_file }  
272+ 
269273    elif  isinstance (nml_file , Cell ):
270274        nml_model  =  NeuroMLDocument (id = "newdoc" )
271275        nml_model .add (nml_file )
@@ -290,9 +294,7 @@ def plot_2D(
290294        positions ,
291295        pop_id_vs_color ,
292296        pop_id_vs_radii ,
293-     ) =  extract_position_info (
294-         nml_model , verbose , nml_file  if  type (nml_file ) is  str  else  "" 
295-     )
297+     ) =  extract_position_info (nml_model , verbose )
296298
297299    if  verbose :
298300        logger .debug (f"positions: { positions }  )
0 commit comments