Browse Source

Elimina 'code/python/supportFunctions/get_all_data.py'

Stefano Diomedi 2 months ago
parent
commit
2ee799df76
1 changed files with 0 additions and 71 deletions
  1. 0 71
      code/python/supportFunctions/get_all_data.py

+ 0 - 71
code/python/supportFunctions/get_all_data.py

@@ -1,71 +0,0 @@
-# The function extracts the spikes and the markers from a .h5 dataset
-# authors: Stefano Diomedi
-# date: 10/2022
-
-import h5py
-import numpy as np
-
-def get_all_data_from_level_h5(filename, str):
-    """
-    INPUT:
-         filename = a string that identifies the h5 file from which to extract data
-         str = the group from which to extract the data. The function
-         automatically extracts every dataset of the group
-
-     RETURN:
-         spikes = numpy arrays that contains the extracted spike timing for each dataset
-         markers = numpy arrays that contains the extracted marker timing for each dataset
-         all_strings = string that keeps track of the datasets extracted
-    """
-     
-
-    with h5py.File(filename, 'r') as f:
-        if 'trial' in str:
-            lev = 4
-        elif 'condition' in str:
-            lev = 3
-        elif 'unit' in str:
-            lev = 2
-        elif 'DATA' in str:
-            lev = 1
-        else:
-            raise ValueError('str is not correct')
-
-        info = f[str]
-
-        spikes = []
-        markers = []
-        all_strings = []
-
-        if lev == 4:
-            spikes.append(np.array(info['spike_trains']))
-            markers.append(np.array(info['event_markers']))
-
-        elif lev == 3:
-            for trial in info:
-                str_trial = str + '/' + trial
-                spikes.append(np.array(f[str_trial]['spike_trains']))
-                markers.append(np.array(f[str_trial]['event_markers']))
-                all_strings.append(str_trial)
-
-        elif lev == 2:
-            for cond in info:
-                str2check = str + '/' + cond
-                for trial in f[str2check]:
-                    str_trial = str + '/' + cond + '/' + trial
-                    spikes.append(np.array(f[str_trial]['spike_trains']))
-                    markers.append(np.array(f[str_trial]['event_markers']))
-                    all_strings.append(str_trial)
-
-        elif lev == 1:
-            for neu in info:
-                str2check = str + '/' + neu
-                for cond in f[str2check]:
-                    str2check_cond = str2check + '/' + cond
-                    for trial in f[str2check_cond]:
-                        str_trial = str2check_cond + '/' +trial
-                        spikes.append(np.array(f[str_trial]['spike_trains']))
-                        markers.append(np.array(f[str_trial]['event_markers']))
-                        all_strings.append(str_trial)
-
-    return spikes, markers, all_strings