def __init__(self, filename, dataset=0): """ Arguments: filename : the filename dataset: points to a specific dataset in the .kwik and .raw.kwd file, however this can be an issue to change in e.g. OpenElectrophy or Spykeviewer """ BaseIO.__init__(self) self._filename = filename self._path, file = os.path.split(filename) self._kwik = h5py.File(filename, 'r') self._dataset = dataset try: rawfile = self._kwik['recordings'][str( self._dataset )]['raw'].attrs[ 'hdf5_path'] # klustakwik/phy and newest version of open ephys rawfile = rawfile.split('/')[0] except: rawfile = file.split( '.')[0] + '_100.raw.kwd' # first version of open ephys files self._kwd = h5py.File(self._path + os.sep + rawfile, 'r') self._attrs = {} self._attrs['kwik'] = self._kwik['recordings'][str( self._dataset)].attrs self._attrs['kwd'] = self._kwd['recordings'][str(self._dataset)].attrs self._attrs['shape'] = self._kwd['recordings'][str( self._dataset)]['data'].shape try: self._attrs['app_data'] = self._kwd['recordings'][str( self._dataset )]['application_data'].attrs # TODO: find bitvolt conversion in phy generated data except: self._attrs['app_data'] = False
def __init__(self, filename, mode="rw"): """ Initialise IO instance and NIX file. :param filename: Full path to the file """ if not HAVE_NIX: raise Exception("Failed to import NIX. " "The NixIO requires the Python bindings for NIX " "(nixio on PyPi). Try `pip install nixio`.") BaseIO.__init__(self, filename) self.filename = filename if mode == "ro": filemode = nix.FileMode.ReadOnly elif mode == "rw": filemode = nix.FileMode.ReadWrite elif mode == "ow": filemode = nix.FileMode.Overwrite else: raise ValueError("Invalid mode specified '{}'. " "Valid modes: 'ro' (ReadOnly)', 'rw' (ReadWrite)," " 'ow' (Overwrite).".format(mode)) self.nix_file = nix.File.open(self.filename, filemode, backend="h5py") self._neo_map = dict() self._nix_map = dict() self._lazy_loaded = list() self._object_hashes = dict() self._block_read_counter = 0 self._path_map = dict()
def __init__(self, filename): if not HAVE_H5PY: raise ImportError("h5py is not available") BaseIO.__init__(self, filename=filename) self._data = h5py.File(filename, 'r') self.object_refs = {} self._lazy = False
def __init__(self, filename=None): """ Arguments: filename : the filename """ BaseIO.__init__(self, filename)
def __init__(self, filename, dataset=0) : """ Arguments: filename : the filename dataset: points to a specific dataset in the .kwik and .raw.kwd file, however this can be an issue to change in e.g. OpenElectrophy or Spykeviewer """ BaseIO.__init__(self) self._filename = filename self._path, file = os.path.split(filename) self._kwik = h5py.File(filename, 'r') self._dataset = dataset try: rawfile = self._kwik['recordings'][str(self._dataset)]['raw'].attrs['hdf5_path'] # klustakwik/phy and newest version of open ephys rawfile = rawfile.split('/')[0] except: rawfile = file.split('.')[0] + '_100.raw.kwd' # first version of open ephys files self._kwd = h5py.File(self._path + os.sep + rawfile, 'r') self._attrs = {} self._attrs['kwik'] = self._kwik['recordings'][str(self._dataset)].attrs self._attrs['kwd'] = self._kwd['recordings'][str(self._dataset)].attrs self._attrs['shape'] = self._kwd['recordings'][str(self._dataset)]['data'].shape try: self._attrs['app_data'] = self._kwd['recordings'][str(self._dataset)]['application_data'].attrs # TODO: find bitvolt conversion in phy generated data except: self._attrs['app_data'] = False
def __init__(self, filename, dataset=0): """ Arguments: filename : the filename dataset: points to a specific dataset in the .kwik and .raw.kwd file, however this can be an issue to change in e.g. OpenElectrophy or Spykeviewer """ BaseIO.__init__(self) self._filename = filename self._path, file = os.path.split(filename) self._kwik = h5py.File(filename, "r") self._dataset = dataset try: rawfile = self._kwik["recordings"][str(self._dataset)]["raw"].attrs[ "hdf5_path" ] # klustakwik/phy and newest version of open ephys rawfile = rawfile.split("/")[0] except: rawfile = file.split(".")[0] + "_100.raw.kwd" # first version of open ephys files self._kwd = h5py.File(self._path + os.sep + rawfile, "r") self._attrs = {} self._attrs["kwik"] = self._kwik["recordings"][str(self._dataset)].attrs self._attrs["kwd"] = self._kwd["recordings"][str(self._dataset)].attrs self._attrs["shape"] = self._kwd["recordings"][str(self._dataset)]["data"].shape try: self._attrs["app_data"] = self._kwd["recordings"][str(self._dataset)][ "application_data" ].attrs # TODO: find bitvolt conversion in phy generated data except: self._attrs["app_data"] = False
def __init__(self, filename, mode="rw"): """ Initialise IO instance and NIX file. :param filename: Full path to the file """ if not HAVE_NIX: raise Exception("Failed to import NIX. " "The NixIO requires the Python bindings for NIX " "(nixio on PyPi). Try `pip install nixio`.") BaseIO.__init__(self, filename) self.filename = filename if mode == "ro": filemode = nix.FileMode.ReadOnly elif mode == "rw": filemode = nix.FileMode.ReadWrite elif mode == "ow": filemode = nix.FileMode.Overwrite else: raise ValueError("Invalid mode specified '{}'. " "Valid modes: 'ro' (ReadOnly)', 'rw' (ReadWrite)," " 'ow' (Overwrite).".format(mode)) self.nix_file = nix.File.open(self.filename, filemode, backend="h5py") self._object_map = dict() self._lazy_loaded = list() self._object_hashes = dict() self._block_read_counter = 0 self._path_map = dict()
def __init__(self, filename=None): """ Parameters ---------- filename: string, default=None The filename. """ BaseIO.__init__(self, filename=filename)
def __init__(self, filename=None): """ This class read a abf file. Arguments: filename : the filename to read """ BaseIO.__init__(self) self.filename = filename
def __init__(self, filename=None): """ This class read a smr file. Arguments: filename : the filename """ BaseIO.__init__(self) self.filename = filename
def __init__(self, filename=None): """ Arguments: filename : the .map Alpha Omega file name """ BaseIO.__init__(self) self.filename = filename
def __init__(self, filename=None): """ Arguments: filename: the filename """ BaseIO.__init__(self) self._path = filename self._filename = os.path.basename(filename) self._fsrc = None
def __init__(self , filename = '', dllname = '') : """ Arguments: filename: the file to read ddlname: the name of neuroshare dll to be used for this file """ BaseIO.__init__(self) self.dllname = dllname self.filename = filename
def __init__(self, filename=None): """ This class read/write a elan based file. **Arguments** filename : the filename to read or write """ BaseIO.__init__(self) self.filename = filename
def __init__(self, filename=None): ''' Arguments: filename: the filename ''' BaseIO.__init__(self) self._path = filename self._filename = os.path.basename(filename) self._fsrc = None
def __init__(self, filename='', dllname=''): """ Arguments: filename: the file to read ddlname: the name of neuroshare dll to be used for this file """ BaseIO.__init__(self) self.dllname = dllname self.filename = filename
def __init__(self , filename = None) : """ Arguments: filename : the .map Alpha Omega file name """ BaseIO.__init__(self) self.filename = filename
def __init__(self, filename=None): """ This class read a micromed TRC file. Arguments: filename : the filename to read """ BaseIO.__init__(self) self.filename = filename
def __init__(self , filename = None) : """ This class read a WinEDR file. Arguments: filename : the filename """ BaseIO.__init__(self) self.filename = filename
def __init__(self, filename=None, **kwargs): if not HAVE_TABLES: raise TABLES_ERR BaseIO.__init__(self, filename=filename) self.connected = False self.objects_by_ref = {} # Loaded objects by reference id self.parent_paths = {} # Tuples of (Segment, other parent) paths self.name_indices = {} if filename: self.connect(filename=filename)
def __init__(self, filename=None): """ This class read a WinWCP wcp file. Arguments: filename : the filename to read """ BaseIO.__init__(self) self.filename = filename
def __init__(self, filename): """ """ BaseIO.__init__(self) # remove extension because there is bunch of files : nev, ns1, ..., ns5, nsf for ext in self.extensions: if filename.endswith('.' + ext): filename = filename.strip('.' + ext) self.filename = filename
def __init__(self, filename) : """ """ BaseIO.__init__(self) # remove extension because there is bunch of files : nev, ns1, ..., ns5, nsf for ext in self.extensions: if filename.endswith('.'+ext): filename = filename.strip('.'+ext) self.filename = filename
def __init__(self, filename): """ Arguments: filename : the filename """ BaseIO.__init__(self) self.filename = os.path.abspath(filename) model = kwik.KwikModel(self.filename) # TODO this group is loaded twice self.models = [kwik.KwikModel(self.filename, channel_group=grp) for grp in model.channel_groups]
def __init__(self , filename = None) : """ This class read a nex file. Arguments: filename : the filename to read you can pu what ever it do not read anythings """ BaseIO.__init__(self) self.filename = filename
def __init__(self, filename) : """ Arguments: filename : the filename """ BaseIO.__init__(self, filename) self._extension_dir = tempfile.mkdtemp() extension_file = join(self._extension_dir, "nwb_neo_extension.py") with open(extension_file, "w") as fp: fp.write(str(neo_extension)) self.extensions = [extension_file]
def __init__(self , filename = None) : """ This class read a plx file. Arguments: filename : the filename load_spike_waveform : load or not waveform of spikes (default True) """ BaseIO.__init__(self) self.filename = filename
def __init__(self, filename=None): """ This class read/write neo objects in matlab 5 to 7.2 format. Arguments: filename : the filename to read """ if not HAVE_SCIPY: raise SCIPY_ERR BaseIO.__init__(self) self.filename = filename
def __init__(self , filename = None) : """ This class read a binary file. **Arguments** filename : the filename to read """ BaseIO.__init__(self) self.filename = filename
def __init__(self, filename=None): """ This class read/write AnalogSignal in a text file. Each signal is a column. One of the column can be the time vector Arguments: filename : the filename to read/write """ BaseIO.__init__(self) self.filename = filename
def __init__(self, filename=None): """ This class read a nex file. Arguments: filename : the filename to read you can pu what ever it do not read anythings """ BaseIO.__init__(self) self.filename = filename
def __init__(self, filename=None): """ This class read a binary file. **Arguments** filename : the filename to read """ BaseIO.__init__(self) self.filename = filename
def __init__(self, filename=None): """ This class read a plx file. Arguments: filename : the filename load_spike_waveform : load or not waveform of spikes (default True) """ BaseIO.__init__(self) self.filename = filename
def __init__(self, filename, full_range=8192.*pq.mV) : """Initialize Blackrock reader. **Arguments** filename: string, the filename to read full_range: Quantity, the full-scale analog range of the data. This is set by your digitizing hardware. It should be in volts or millivolts. """ BaseIO.__init__(self) self.filename = filename self.full_range = full_range
def __init__(self, filename, readonly=False): """ Initialize new IO instance. If the file does not exist, it will be created. This I/O works in a detached mode. :param filename: full path to the file (like '/tmp/foo.h5') """ BaseIO.__init__(self, filename=filename) self.f = FileHandler(filename) self.readonly = readonly
def __init__(self, filename=None): """ This class read/write SpikeTrains in a text file. Each row is a spiketrain. **Arguments** filename : the filename to read/write """ BaseIO.__init__(self) self.filename = filename
def __init__(self , dirname=None) : """ **Arguments** Arguments: dirname: path of the TDT tank (a directory) """ BaseIO.__init__(self) self.dirname = dirname if self.dirname.endswith('/'): self.dirname = self.dirname[:-1]
def __init__(self, dirname=None): """ **Arguments** Arguments: dirname: path of the TDT tank (a directory) """ BaseIO.__init__(self) self.dirname = dirname if self.dirname.endswith('/'): self.dirname = self.dirname[:-1]
def __init__(self, filename): """ Arguments: filename : the filename """ BaseIO.__init__(self) self.filename = os.path.abspath(filename) model = kwik.KwikModel( self.filename) # TODO this group is loaded twice self.models = [ kwik.KwikModel(self.filename, channel_group=grp) for grp in model.channel_groups ]
def __init__(self , dirname = None) : """ This class read a WinEDR wcp file. **Arguments** Arguments: dirname: path of the TDT tank (a directory) """ BaseIO.__init__(self) self.dirname = dirname if self.dirname.endswith('/'): self.dirname = self.dirname[:-1]
def __init__(self, filename, mode='r'): """ Arguments: filename : the filename """ if not have_pynwb: raise Exception("Please install the pynwb package to use NWBIO") if not have_hdmf: raise Exception("Please install the hdmf package to use NWBIO") BaseIO.__init__(self, filename=filename) self.filename = filename self.blocks_written = 0 self.nwb_file_mode = mode
def __init__(self, filename, print_diagnostic=False): """ Initialize the UAModel class and associate it to a file. """ self.associated = False # Call base constructor BaseIO.__init__(self) # Remember choice whether to print diagnostic messages or not self._print_diagnostic = print_diagnostic # Associate to the session self._associate(filename=filename) # For consistency with baseio self.filename = filename
def __init__(self, filename=None, ced_units=False): """ This class read a smr file. Arguments: filename : the filename ced_units: whether a spike trains should be added for each unit as determined by Spike2's spike sorting (True), or if a spike channel should be considered a single unit and will ignore Spike2's spike sorting (False). Defaults to False. """ BaseIO.__init__(self) self.filename = filename self.ced_units = ced_units
def __init__(self, filename=None, delimiter='\t', usecols=None, skiprows=0, timecolumn=None, sampling_rate=1.0 * pq.Hz, t_start=0.0 * pq.s, units=pq.V, time_units=pq.s, method='genfromtxt', signal_group_mode='split-all', metadata_filename=None): """ This class read/write AnalogSignal in a text file. Each signal is a column. One of the columns can be the time vector. Arguments: filename : the filename to read/write """ # todo: allow units to be a list/array (e.g. current and voltage in the same file) BaseIO.__init__(self) self.filename = filename self.metadata_filename = metadata_filename metadata = self.read_metadata() self.delimiter = metadata.get("delimiter", delimiter) self.usecols = metadata.get("usecols", usecols) self.skiprows = metadata.get("skiprows", skiprows) self.timecolumn = metadata.get("timecolumn", timecolumn) self.sampling_rate = metadata.get("sampling_rate", sampling_rate) self.time_units = metadata.get("time_units", time_units) if self.time_units is not None: self.time_units = pq.Quantity(1, self.time_units) self.t_start = metadata.get("t_start", t_start) if not isinstance(t_start, pq.Quantity): if not isinstance(self.time_units, pq.Quantity): raise ValueError("Units of t_start not specified") self.t_start *= self.time_units self.units = metadata.get("units", pq.Quantity(1, units)) self.method = metadata.get("method", method) if not (self.method in ('genfromtxt', 'csv', 'homemade') or callable(self.method)): raise ValueError( "method must be one of 'genfromtxt', 'csv', 'homemade', or a function" ) self.signal_group_mode = metadata.get("signal_group_mode", signal_group_mode)
def __init__(self, filename, dataset=0): """ Arguments: filename : the filename dataset : dataset number experimentNum : experiment number """ BaseIO.__init__(self) self._filename = filename self._path, file = os.path.split(filename) self._dataset = dataset if int(file[-5]) > 1: xmlfile = 'settings_' + file[-5] + '.xml' else: xmlfile = 'settings.xml' tree = ET.parse(self._path + os.sep + xmlfile) root = tree.getroot() nodes = {} for processor in root.iter('PROCESSOR'): processorName = processor.attrib['name'].split('/') node_info = {} if processorName[0] == 'Sources': if processorName[1] == 'OSC Port': oscInfo = processor.findall('EDITOR') osc = oscInfo[0].findall('OSCNODE') node_info['address'] = osc[0].get('address') node_info['NodeId'] = processor.attrib['NodeId'] elif processorName[1] == 'Rhythm FPGA': chanInfo = processor.findall('CHANNEL_INFO')[0] chan = [a.get('name') for a in chanInfo.findall('CHANNEL')] node_info['chanNames'] = chan node_info['NodeId'] = processor.attrib['NodeId'] else: node_info['NodeId'] = processor.attrib['NodeId'] if processorName[1] in nodes.keys(): nodes[processorName[1]] += [node_info] else: nodes[processorName[1]] = [node_info] self._nodes = nodes rawfile = file.split( '.')[0] + '_' + nodes['Rhythm FPGA'][0]['NodeId'] + '.raw.kwd' self._kwe = h5py.File(filename, 'r') self._kwd = h5py.File(self._path + os.sep + rawfile, 'r') self._attrs = {} self._attrs['kwe'] = self._kwe['recordings'][str(self._dataset)].attrs self._attrs['kwd'] = self._kwd['recordings'][str(self._dataset)].attrs self._attrs['shape'] = self._kwd['recordings'][str( self._dataset)]['data'].shape self._attrs['app_data'] = self._kwd['recordings'][str( self._dataset)]['application_data'].attrs
def __init__(self, filename=None, ced_units=False): """ This class reads an smr file. Arguments: filename : the filename ced_units: whether a spike trains should be added for each unit as determined by Spike2's spike sorting (True), or if a spike channel should be considered a single unit and will ignore Spike2's spike sorting (False). Defaults to False. """ BaseIO.__init__(self) self.filename = filename self.ced_units = ced_units
def __init__(self, filename=None, parse_notes=None) : """ Arguments: filename: the filename parse_notes: (optional) A function which will parse the 'notes' field in the file header and return a dictionary which will be added to the object annotations. """ BaseIO.__init__(self) self.filename = filename self.parse_notes = parse_notes
def __init__(self,filename = './test_data/CEN184/THL_2012-03-21_18-40-42_000.dat'): BaseIO.__init__(self) self.filename = filename f = open(filename) #create a bundle header object with the file head = BundleHeader(f) #load the file head.load(f) #get the .pgf and .pul items in the file for bi in head.oBundleItems: if str(bi.oExtension)[0:4] == '.pgf': self.pgf = PGFFile(f,bi) if str(bi.oExtension)[0:4] == '.pul': self.pul = PULFile(f,bi) f.close()
def __init__(self , filename = None) : """ Arguments: filename : the filename Note: - filename is here just for exampe because it will not be take in account - if mode=='dir' the argument should be dirname (See TdtIO) """ BaseIO.__init__(self) self.filename = filename # Seed so all instances can return the same values np.random.seed(1234)