Ejemplo n.º 1
0
    def load(self, file_path=None, client=None, **kwargs):
        """
        Loads spiketrains from a hdf5 file in the neo data format.

        Parameters
        ----------
        file_path : string
            Path to file
        client :
            When file is loaded from a collab storage a appropriate client
            must be provided.
        Returns :
            List of neo.SpikeTrains
         """
        if file_path is None:
            file_path = self.file_path
        if file_path[-2:] != 'h5':
            raise IOError('file must be in hdf5 file in Neo format')

        if client is None:
            data = NeoHdf5IO(file_path)
        else:
            store_path = './' + file_path.split('/')[-1]
            client.download_file(file_path, store_path)
            data = NeoHdf5IO(store_path)

        spiketrains = data.read_block().list_children_by_class(SpikeTrain)

        for i in xrange(len(spiketrains)):
            spiketrains[i] = spiketrains[i].rescale('ms')

        return spiketrains
    def load(self, file_path, client=None, **kwargs):
        """
        Loads spiketrains from a hdf5 file in the neo data format.

        Parameters
        ----------
        file_path : string
            Path to file
        client :
            When file is loaded from a collab storage a appropriate client
            must be provided.
        Returns :
            List of neo.SpikeTrains of length N
            """
        # Load NEST or SpiNNaker data using NeoHdf5IO
        if file_path[-2:] != 'h5':
            raise IOError, 'file must be in hdf5 file in Neo format'

        if client is None:
            data = NeoHdf5IO(file_path)
        else:
            store_path = './' + file_path.split('/')[-1]
            client.download_file(file_path, store_path)
            data = NeoHdf5IO(store_path)

        spiketrains = data.read_block().list_children_by_class(SpikeTrain)
        return spiketrains
 def load(self, file_path, client=None, **kwargs):
     fnam = "spikes_L6I.h5"
     if not os.path.isfile(fnam):
         client.download_file(file_path + '/' + fnam, './' + fnam)
     dataI = NeoHdf5IO('./' + fnam)
     fnam = "spikes_L6E.h5"        
     if not os.path.isfile(fnam):
         client.download_file(file_path + '/' + fnam, './' + fnam)
     dataE = NeoHdf5IO('./' + fnam)
     print file_path + " ... loaded"
     
     sts_inh = dataI.read_block().list_children_by_class(SpikeTrain)
     sts_exc = dataE.read_block().list_children_by_class(SpikeTrain)
     for st in sts_inh:
         st.annotations['neu_type'] = 'inh'
     for st in sts_exc:
         st.annotations['neu_type'] = 'exc'
     self.spiketrains = sts_inh
     self.spiketrains.extend(sts_exc)
     return self.spiketrains
Ejemplo n.º 4
0
 def _get_io(filename):
     """ Return a Neo IO instance, guessing the type based on the filename\
         suffix.
     """
     logger.debug("Creating Neo IO for filename {}", filename)
     directory = os.path.dirname(filename)
     utility_calls.check_directory_exists_and_create_if_not(directory)
     extension = os.path.splitext(filename)[1]
     if extension in ('.txt', '.ras', '.v', '.gsyn'):
         raise IOError(
             "ASCII-based formats are not currently supported for output"
             " data. Try using the file extension '.pkl' or '.h5'")
     elif extension in ('.h5', ):
         return NeoHdf5IO(filename=filename)
     elif extension in ('.pkl', '.pickle'):
         return PickleIO(filename=filename)
     elif extension == '.mat':
         return NeoMatlabIO(filename=filename)
     else:  # function to be improved later
         raise Exception("file extension %s not supported" % extension)
Ejemplo n.º 5
0
        #         close(2)
        #==============================================================================
        alignments.append(good_align)
    return alignments


################################################################################################################################
###############################################################################################################################
# Get the neural data
# if opening experiment file for the first time run CHRONICRHD2NEO

#==============================================================================
h5_filename = os.path.join(
    experiment_dir,
    os.path.basename(experiment_file).replace(".rhd", "_neo.h5"))
h5_exporter = NeoHdf5IO(h5_filename)
block = h5_exporter.get("/Block_0")

# Get the sound database
if stims_given == 1:
    stimulus_h5_filename = os.path.join(
        experiment_dir,
        os.path.basename(experiment_file).replace(".rhd", "_stimuli.h5"))
    sm = sound_manager.SoundManager(
        HDF5Store, stimulus_h5_filename)  # make a sound manager object
    # Get the number of trials and make a list of stimulus ids, 'sound_data' (because the sm object is a little hard to work with)
    # TODO organizing stimulus times to validate against periods of vocalization
    segment = block.segments[0]  # The block only has one segment
# pull the microphone channel, filter it etc
mic = [
    asig for asig in block.segments[0].analogsignalarrays
Ejemplo n.º 6
0
                    weight=0.005,
                    receptor_type='excitatory',
                    delay=20)

sim.run(tstop)

use_hdf5 = False

if use_hdf5:
    from neo.io import NeoHdf5IO as NeoIO
    suffix = 'h5'

    results_file = "Results/NeuroMLTest_%s.%s" % (simulator_name, suffix)
    if os.path.exists(results_file):
        os.remove(results_file)
    io = NeoIO(results_file)
    pop_IF_curr_alpha.write_data(io)
    pop_IF_curr_exp.write_data(io)
    pop_IF_cond_alpha.write_data(io)
    pop_IF_cond_exp.write_data(io)
    pop_EIF_cond_exp_isfa_ista.write_data(io)
    pop_HH_cond_exp.write_data(io)
    pop_post1.write_data(io)
    pop_post2.write_data(io)

else:
    #from neo.io import AsciiSignalIO as NeoIO
    #suffix = 'txt'
    #results_file = "Results/NeuroMLTest_%s.%s" % (simulator_name, suffix)

    for pop in [
# -*- coding: utf-8 -*-
"""
Created on Thu Mar  9 13:15:22 2017

@author: billewood
"""
from neo.core import EpochArray
from neo.io import RHDIO, NeoHdf5IO
from neosound import sound_manager
from neosound.sound_store import HDF5Store

filename = '/auto/tdrive/carson/processed_intan/LbY6074__161215_145633_neo.h5'
iom = NeoHdf5IO(filename)
block = iom.read_blcok("/Block_0")
mic = [asig for asig in block.segments[0].analogsignalarrays if asig.name == "Board ADC"][0] # This is the entire microphone recording
pupil_song_timings = [asig for asig in block.segments[0].epocharrays if asig.name == "student_birdsong"][0]
tutor_song_timings = [asig for asig in block.segments[0].epocharrays if asig.name == "tutor_birdsong"][0]

 = np.int(mic.sampling_rate)
t_mic = np.asarray(mic.times)
too_long = too_long * fs_mic
mic = mic.squeeze()
connE = sim.connect(pop_EIF_cond_exp_isfa_ista, pop_post1, weight=0.01, receptor_type='excitatory',delay=10)
connE = sim.connect(pop_EIF_cond_exp_isfa_ista, pop_post2, weight=0.005, receptor_type='excitatory',delay=20)

sim.run(tstop)

use_hdf5 = False

if use_hdf5:
    from neo.io import NeoHdf5IO as NeoIO
    suffix = 'h5'

    results_file = "Results/NeuroMLTest_%s.%s" % (simulator_name, suffix)
    if os.path.exists(results_file):
        os.remove(results_file)
    io = NeoIO(results_file)
    pop_IF_curr_alpha.write_data(io)
    pop_IF_curr_exp.write_data(io)
    pop_IF_cond_alpha.write_data(io)
    pop_IF_cond_exp.write_data(io)
    pop_EIF_cond_exp_isfa_ista.write_data(io)
    pop_HH_cond_exp.write_data(io)
    pop_post1.write_data(io)
    pop_post2.write_data(io)

else:
    #from neo.io import AsciiSignalIO as NeoIO
    #suffix = 'txt'
    #results_file = "Results/NeuroMLTest_%s.%s" % (simulator_name, suffix)

    for pop in [pop_IF_curr_alpha, pop_IF_curr_exp, pop_IF_cond_exp, pop_IF_cond_alpha,pop_EIF_cond_exp_isfa_ista, pop_HH_cond_exp, pop_post1,pop_post2]: