Browse Source

[single cell ephys] improve section printing 2

Jan Grewe 5 years ago
parent
commit
7dba986db9
1 changed files with 12 additions and 13 deletions
  1. 12 13
      single_cell_intracellular_spikes/explore.py

+ 12 - 13
single_cell_intracellular_spikes/explore.py

@@ -19,18 +19,15 @@ def metadata_overview(nf, sec_type=None, sec_name=None):
     sec_type --- string: the section type (default None)
     sec_name --- string, the section name (default None)
     """
-    if sec_type or sec_name:
-        sec_type = sec_type.lower() if sec_type else None
-        sec_name = sec_name.lower() if sec_name else None
-        sections = nf.find_sections(lambda s:
-                                    (sec_type and sec_type in s.type.lower() or not sec_type)
-                                    and (sec_name and sec_name in s.name.lower() or not sec_name)
-                                    or (not sec_name and not sec_type))
-        for s in sections:
-            s.pprint()
-    else:
-        for s in nf.sections:
-            s.pprint(max_depth=-1)
+
+    sec_type = sec_type.lower() if sec_type else None
+    sec_name = sec_name.lower() if sec_name else None
+    sections = nf.find_sections(lambda s:
+                                (sec_type and sec_type in s.type.lower() or not sec_type)
+                                and (sec_name and sec_name in s.name.lower() or not sec_name)
+                                or (not sec_name and not sec_type))
+    for s in sections:
+        s.pprint()
 
 
 if __name__ == "__main__":
@@ -40,7 +37,9 @@ if __name__ == "__main__":
         exit()
     nix_file = nix.File.open(example_file, nix.FileMode.ReadOnly)
     metadata_overview(nix_file, sec_type="recording", sec_name="recording")
-
+    print("*" * 80)
+    metadata_overview(nix_file)
+    
     nix_file.close()