Exemplo n.º 1
0
def test_resolve_hdf5_path():
    path = "{kwx}/channel_groups/0"

    files = open_files('myexperiment', dir=DIRPATH)
    assert _resolve_hdf5_path(files, path)

    close_files(files)
Exemplo n.º 2
0
def test_resolve_hdf5_path():
    path = "{kwx}/channel_groups/0"

    files = open_files('myexperiment', dir=DIRPATH)
    assert _resolve_hdf5_path(files, path)

    close_files(files)
Exemplo n.º 3
0
 def __init__(self, name=None, dir=None, files=None, mode='r', prm={}):
     """`name` must correspond to the basename of the files."""
     self.name = name
     self._dir = dir
     self.dir = dir
     self._mode = mode
     self._files = files
     self._prm = prm
     if self._files is None:
         self._files = open_files(self.name, dir=self._dir, mode=self._mode)
     def _get_filename(file):
         if file is None:
             return None
         else:
             return os.path.realpath(file.filename)
     self._filenames = {type: _get_filename(file)
         for type, file in iteritems(self._files)}
     super(Experiment, self).__init__(self._files)
     self._root = self._node
     
     # Ensure the version of the kwik format is exactly 2.
     assert self._root._f_getAttr('kwik_version') == 2
     
     self.application_data = NodeWrapper(self._root.application_data)
     self.user_data = NodeWrapper(self._root.user_data)
     
     self.channel_groups = self._gen_children('channel_groups', ChannelGroup)
     self.recordings = self._gen_children('recordings', Recording)
     self.event_types = self._gen_children('event_types', EventType)
     
     # Initialize the spike cache of all channel groups.
     for grp in self.channel_groups.itervalues():
         grp.spikes.init_cache()
Exemplo n.º 4
0
def _setup(_name, has_masks=True):
    # Create files.
    prm = {'nfeatures': 3, 'waveforms_nsamples': 10, 'nchannels': 3,
           'sample_rate': 20000.,
           'nfeatures_per_channel': 1,
           'has_masks': has_masks
           }
    prb = {0:
        {
            'channels': [4, 6, 8],
            'graph': [[4, 6], [8, 4]],
            'geometry': {4: [0.4, 0.6], 6: [0.6, 0.8], 8: [0.8, 0.0]},
        }
    }
    create_files(_name, dir=DIRPATH, prm=prm, prb=prb)

    # Open the files.
    files = open_files(_name, dir=DIRPATH, mode='a')

    # Add data.
    add_recording(files,
                  sample_rate=20000.,
                  start_time=10.,
                  start_sample=200000.,
                  bit_depth=16,
                  band_high=100.,
                  band_low=500.,
                  nchannels=3,)
    add_event_type(files, 'myevents')
    add_cluster_group(files, channel_group_id='0', id='0', name='Noise')
    add_cluster(files, channel_group_id='0', cluster_group=0)

    # Close the files
    close_files(files)
Exemplo n.º 5
0
    def __init__(self, name=None, dir=None, files=None, mode='r', prm={}):
        """`name` must correspond to the basename of the files."""
        self.name = name
        self._dir = dir
        self.dir = dir
        self._mode = mode
        self._files = files
        self._prm = prm
        if self._files is None:
            self._files = open_files(self.name, dir=self._dir, mode=self._mode)
        def _get_filename(file):
            if file is None:
                return None
            else:
                return os.path.realpath(file.filename)
        self._filenames = {type: _get_filename(file)
            for type, file in iteritems(self._files)}
        super(Experiment, self).__init__(self._files)
        self._root = self._node

        # Ensure the version of the kwik format is exactly 2.
        assert self._root._f_getAttr('kwik_version') == 2

        self.application_data = NodeWrapper(self._root.application_data)
        # self.user_data = NodeWrapper(self._root.user_data)

        self.channel_groups = self._gen_children('channel_groups', ChannelGroup)
        self.recordings = self._gen_children('recordings', Recording)
        # self.event_types = self._gen_children('event_types', EventType)

        # Initialize the spike cache of all channel groups.
        for grp in self.channel_groups.itervalues():
            grp.spikes.init_cache()
Exemplo n.º 6
0
def _setup(_name, has_masks=True):
    # Create files.
    prm = {'nfeatures': 3, 'waveforms_nsamples': 10, 'nchannels': 3,
           'sample_rate': 20000.,
           'nfeatures_per_channel': 1,
           'has_masks': has_masks
           }
    prb = {0:
        {
            'channels': [4, 6, 8],
            'graph': [[4, 6], [8, 4]],
            'geometry': {4: [0.4, 0.6], 6: [0.6, 0.8], 8: [0.8, 0.0]},
        }
    }
    create_files(_name, dir=DIRPATH, prm=prm, prb=prb)
    
    # Open the files.
    files = open_files(_name, dir=DIRPATH, mode='a')
    
    # Add data.
    add_recording(files, 
                  sample_rate=20000.,
                  start_time=10., 
                  start_sample=200000.,
                  bit_depth=16,
                  band_high=100.,
                  band_low=500.,
                  nchannels=3,)
    add_event_type(files, 'myevents')
    add_cluster_group(files, channel_group_id='0', id='0', name='Noise')
    add_cluster(files, channel_group_id='0', cluster_group=0)
    
    # Close the files
    close_files(files)
Exemplo n.º 7
0
def _setup(_name, has_masks=True):
    # Create files.
    prm = {
        'nfeatures': 3 * 3,
        'waveforms_nsamples': 10,
        'nchannels': 3,
        'sample_rate': 20000.,
        'nfeatures_per_channel': 3,
        'has_masks': has_masks
    }
    prb = {
        0: {
            'channels': [0, 1, 2],
            'graph': [[0, 1], [0, 2]],
            'geometry': {
                0: [0.4, 0.6],
                1: [0.6, 0.8],
                2: [0.8, 0.0]
            },
        }
    }
    create_files(_name, dir=DIRPATH, prm=prm, prb=prb)

    # Open the files.
    files = open_files(_name, dir=DIRPATH, mode='a')

    # Add data.
    add_recording(
        files,
        sample_rate=20000.,
        bit_depth=16,
        band_high=100.,
        band_low=500.,
        nchannels=3,
    )
    add_event_type(files, 'myevents')
    add_cluster_group(files, channel_group_id='0', id='0', name='Noise')
    add_cluster_group(files, channel_group_id='0', id='1', name='MUA')
    add_cluster_group(files, channel_group_id='0', id='2', name='Good')
    add_cluster_group(files, channel_group_id='0', id='3', name='Unsorted')
    add_cluster(files, channel_group_id='0', cluster_group=0)

    add_spikes(
        files,
        channel_group_id='0',
        cluster=np.random.randint(5, 10, 1000),
        time_samples=np.cumsum(np.random.randint(0, 1000,
                                                 1000)).astype(np.int64),
        features=np.random.randint(-30000, 30000, (1000, 9)).astype(np.int16),
        masks=np.random.randint(0, 2, (1000, 9)).astype(np.int16),
    )

    # Close the files
    close_files(files)
Exemplo n.º 8
0
def _setup(_name, has_masks=True):
    # Create files.
    prm = {
        "nfeatures": 3 * 3,
        "waveforms_nsamples": 10,
        "nchannels": 3,
        "sample_rate": 20000.0,
        "nfeatures_per_channel": 3,
        "has_masks": has_masks,
    }
    prb = {
        0: {"channels": [0, 1, 2], "graph": [[0, 1], [0, 2]], "geometry": {0: [0.4, 0.6], 1: [0.6, 0.8], 2: [0.8, 0.0]}}
    }
    create_files(_name, dir=DIRPATH, prm=prm, prb=prb)

    # Open the files.
    files = open_files(_name, dir=DIRPATH, mode="a")

    # Add data.
    add_recording(files, sample_rate=20000.0, bit_depth=16, band_high=100.0, band_low=500.0, nchannels=3)
    add_event_type(files, "myevents")
    add_cluster_group(files, channel_group_id="0", id="0", name="Noise")
    add_cluster_group(files, channel_group_id="0", id="1", name="MUA")
    add_cluster_group(files, channel_group_id="0", id="2", name="Good")
    add_cluster_group(files, channel_group_id="0", id="3", name="Unsorted")
    add_cluster(files, channel_group_id="0", cluster_group=0)

    add_spikes(
        files,
        channel_group_id="0",
        cluster=np.random.randint(5, 10, 1000),
        time_samples=np.cumsum(np.random.randint(0, 1000, 1000)).astype(np.int64),
        features=np.random.randint(-30000, 30000, (1000, 9)).astype(np.int16),
        masks=np.random.randint(0, 2, (1000, 9)).astype(np.int16),
    )

    # Close the files
    close_files(files)