Browse Source

Remove time shift and add common behavior channel names

Michael Denker 11 months ago
parent
commit
7a5639cba2
1 changed files with 11 additions and 15 deletions
  1. 11 15
      code/convert_to_nix.py

+ 11 - 15
code/convert_to_nix.py

@@ -17,7 +17,7 @@ from reachgraspio import reachgraspio
 
 
 # Choose which session you want to convert into a nix file
-# session = "i140703-001"
+#session = "i140703-001"
 session = "l101210-001"
 
 # Input data. i.e., original Blackrock files and odML
@@ -48,19 +48,14 @@ block = session.read_block(lazy=False, load_waveforms=True)
 # Neo AnalogSignal, which is used for plotting later on in this script.
 # =============================================================================
 
-nsx_to_anasig_name = {2: 'LFP signal (online filtered)',
-                      5: 'raw signal',
-                      6: 'raw signal'}
-
 # this factor was heuristically determined as an approximate shift introduced
 # by the online filtering. Here, the offline filtering does not introduce a
 # noticable shift, so we set it to zero.
 time_shift_factor = 0*pq.ms
 
+# identify neuronal signals and provide labels for plotting
 filtered_anasig = None
 raw_anasig = None
-
-# identify neuronal signals and provide labels for plotting
 for anasig in block.segments[0].analogsignals:
     # skip non-neuronal signals
     if not anasig.annotations['neural_signal']:
@@ -139,6 +134,15 @@ if filtered_anasig is None:
     block.segments[0].analogsignals.insert(0, offline_filtered_anasig)
 
 
+##### MISC FIXES ###################
+
+# for lilou, behavior channels were not set with nice names in the setup
+# Here, we hard code these handwritten annotations to make both recordings
+# more similar
+block.segments[0].analogsignals[1].array_annotate(
+    channel_names=['GFpr1', 'GFside1', 'GFpr2', 'GFside2', 'LF', 'Displ'])
+
+
 ##### SAVE NIX FILE ###################
 nix_filename = nix_session_path + '.nix'
 if os.path.exists(nix_filename):
@@ -162,7 +166,6 @@ with neo.NixIO(nix_filename, mode='ro') as io:
             assert_same_sub_schema(anasig_old, anasig_new)
             assert_same_annotations(anasig_old, anasig_new)
             assert_same_array_annotations(anasig_old, anasig_new)
-            del anasig_old
         print(f'AnalogSignals are equivalent.')
         
         for st_old, st_new in zip(seg_old.spiketrains, seg_new.spiketrains):
@@ -172,7 +175,6 @@ with neo.NixIO(nix_filename, mode='ro') as io:
             assert_same_sub_schema(st_old, st_new)
             assert_same_annotations(st_old, st_new)
             assert_same_array_annotations(st_old, st_new)
-            del st_old
         print(f'Spiketrains are equivalent.')
         
         for ev_old, ev_new in zip(seg_old.events, seg_new.events):
@@ -186,7 +188,6 @@ with neo.NixIO(nix_filename, mode='ro') as io:
             assert_same_sub_schema(ev_old, ev_new)
             assert_same_annotations(ev_old, ev_new)
             assert_same_array_annotations(ev_old, ev_new)
-            del ev_old
         print(f'Events are equivalent.')
         
         for ep_old, ep_new in zip(seg_old.epochs, seg_new.epochs):
@@ -196,9 +197,4 @@ with neo.NixIO(nix_filename, mode='ro') as io:
             assert_same_sub_schema(ep_old, ep_new)
             assert_same_annotations(ep_old, ep_new)
             assert_same_array_annotations(ep_old, ep_new)
-            del ep_old
         print(f'Epochs are equivalent.')
-            
-            
-
-