def __init__(self, **kwargs):
        """Initialization"""

        Block.__init__(self, **kwargs)
        self.add_input('data', structure='dict')
        self.add_input('mads', structure='dict')
        self.add_input('peaks', structure='dict')

        # The following line is useful to avoid PyCharm warnings.
        self.probe_path = self.probe_path

        self._dtype = None
        self._nb_samples = None
        self._nb_channels = None
        self._sampling_rate = None

        self._params_pipe = Pipe()
        self._number_pipe = Pipe()
        self._data_pipe = Pipe()
        self._mads_pipe = Pipe()
        self._peaks_pipe = Pipe()
        self._qt_process = GUIProcess(self._params_pipe,
                                      self._number_pipe,
                                      self._data_pipe,
                                      self._mads_pipe,
                                      self._peaks_pipe,
                                      probe_path=self.probe_path)

        self._is_mad_reception_blocking = False
        self._is_peak_reception_blocking = False
Ejemplo n.º 2
0
    def __init__(self, **kwargs):
        """Initialization of the object.

        Parameters:
            data_path: string
            dtype: string
            nb_channels: integer
            nb_samples: integer
            sampling_rate: float
            is_realistic: boolean
            speed_factor: float
            nb_replay: integer
            probe_path: string

        See also:
            circusort.block.Block
        """

        Block.__init__(self, **kwargs)
        self.add_output('data', structure='dict')

        # Lines useful to remove PyCharm warnings.
        self.data_path = self.data_path
        self.dtype = self.dtype
        self.nb_channels = self.nb_channels
        self.nb_samples = self.nb_samples
        self.sampling_rate = self.sampling_rate
        self.is_realistic = self.is_realistic
        self.speed_factor = self.speed_factor
        self.nb_replay = self.nb_replay
        self.offset = self.offset
        self.probe_path = self.probe_path
        self.zero_channels = self.zero_channels
        self._output_dtype = 'float32'
        self._quantum_size = self.gain
        self._quantum_offset = float(np.iinfo('int16').min)
        self._buffer_rate = float(self.nb_samples) / self.sampling_rate

        self._absolute_start_time = None
        self._absolute_end_time = None

        if self.probe_path is not None:
            self.probe = load_probe(self.probe_path, logger=self.log)
            # Log info message.
            string = "{} reads the probe layout"
            message = string.format(self.name)
            self.log.info(message)
        else:
            self.probe = None

        if self.zero_channels is not None:
            if np.iterable(self.zero_channels):
                self.zero_channels = np.array(self.zero_channels)
            else:
                self.zero_channels = np.array([self.zero_channels])
Ejemplo n.º 3
0
    def __init__(self, **kwargs):

        Block.__init__(self, **kwargs)

        self.add_input('updater', structure='dict')

        # The following line is useful to disable a PyCharm warning.
        self.output_directory = self.output_directory

        self._output_counter = 0
        self._sleep_duration = 0.01  # s
    def __init__(self, **kwargs):
        """Initialize block."""

        Block.__init__(self, **kwargs)

        # The following lines are useful to avoid some PyCharms's warnings.
        self.input_specs = self.input_specs
        self.degree = self.degree
        self.overlap = self.overlap
        self.nb_samples = self.nb_samples
        self.sampling_rate = self.sampling_rate

        assert self.degree >= self.overlap  # TODO add docstring.

        # Declare input names and structures.
        self._input_names = []
        self._input_structures = []
        self._input_policies = []
        self._are_synced_inputs = {}
        for input_spec in self.input_specs:
            if isinstance(input_spec, (str, unicode)):
                name = input_spec
                structure = 'array'
                policy = 'hard_blocking'
            elif isinstance(input_spec, dict):
                name = input_spec['name']
                if 'structure' in input_spec:
                    structure = input_spec['structure']
                else:
                    structure = 'array'
                if 'policy' in input_spec:
                    policy = input_spec['policy']
                else:
                    policy = 'hard_blocking'
            else:
                raise NotImplementedError()  # TODO complete.
            self._input_names.append(name)
            self._input_structures.append(structure)
            self._input_policies.append(policy)
            self._are_synced_inputs[name] = False

        # Declare the inputs.
        for name, structure in zip(self._input_names, self._input_structures):
            self.add_input(name, structure)
        # Declare the outputs.
        for name, structure in zip(self._input_names, self._input_structures):
            for k in range(0, self.degree):
                output_name = self._get_output_name(name, k)
                self.add_output(output_name, structure)

        self._nb_channels = None
        self._nb_samples = None
Ejemplo n.º 5
0
    def __init__(self, **kwargs):
        """Initialize channel dispatcher.
        """

        Block.__init__(self, **kwargs)

        keys = ['data', 'peaks', 'mads', 'pcs']

        for key in keys:
            self.add_input(key, structure='dict')
            self.add_output(key, structure='dict')

        self._nb_samples = None
    def __init__(self, **kwargs):
        """Initialize template updater.

        Arguments:
            probe_path: string
            radius: none | float (optional)
            cc_merge: float (optional)
            cc_mixture: none | float (optional)
            templates_path: none | string (optional)
            overlaps_path: none | string (optional)
            precomputed_template_paths: none | list (optional)
            sampling_rate: float (optional)
            nb_samples: integer (optional)
        """

        Block.__init__(self, **kwargs)

        # The following lines are useful to avoid some PyCharm's warnings.
        self.probe_path = self.probe_path
        self.radius = self.radius
        self.cc_merge = self.cc_merge
        self.cc_mixture = self.cc_mixture
        self.templates_path = self.templates_path
        self.overlaps_path = self.overlaps_path
        self.precomputed_template_paths = self.precomputed_template_paths
        self.sampling_rate = self.sampling_rate
        self.nb_samples = self.nb_samples
        self.skip_overlaps = self.skip_overlaps

        # Initialize private attributes.
        if self.probe_path is None:
            self.probe = None
            # Log error message.
            string = "{}: the probe file must be specified!"
            message = string.format(self.name)
            self.log.error(message)
        else:
            self.probe = load_probe(self.probe_path, radius=self.radius, logger=self.log)
            # Log info message.
            string = "{} reads the probe layout"
            message = string.format(self.name)
            self.log.info(message)
        self._template_store = None
        self._template_dictionary = None
        self._overlap_store = None
        self._two_components = None

        self.add_input('templates', structure='dict')
        self.add_output('updater', structure='dict')
Ejemplo n.º 7
0
    def __init__(self, **kwargs):
        """Initialize multiplexer.

        Arguments:
            output_specs: list (optional)
            degree: integer (optional)
                The default value is 2.
            nb_samples: integer (optional)
                The default value is 1024.
            sampling_rate: float (optional)
                The default value is 20e+3.
        """

        Block.__init__(self, **kwargs)

        # The following lines are useful to avoid some PyCharms's warnings.
        self.output_specs = self.output_specs
        self.degree = self.degree
        self.nb_samples = self.nb_samples
        self.sampling_rate = self.sampling_rate

        # Declare output names and structures.
        self._output_names = []
        self._output_structures = []
        for output_spec in self.output_specs:
            if isinstance(output_spec, (str, unicode)):
                name = output_spec
                structure = 'array'
            elif isinstance(output_spec, dict):
                name = output_spec['name']
                if 'structure' in output_spec:
                    structure = output_spec['structure']
                else:
                    structure = 'array'
            else:
                raise NotImplementedError()  # TODO complete.
            self._output_names.append(name)
            self._output_structures.append(structure)

        # Declare the inputs.
        for name, structure in zip(self._output_names,
                                   self._output_structures):
            for k in range(0, self.degree):
                input_name = self._get_input_name(name, k)
                self.add_input(input_name, structure)
        # Declare the outputs.
        for name, structure in zip(self._output_names,
                                   self._output_structures):
            self.add_output(name, structure)
    def __init__(self, **kwargs):

        Block.__init__(self, **kwargs)

        # The following lines are useful to avoid some PyCharm's warning.
        self.templates_init_path = self.templates_init_path

        self.add_input('updater')
        self.add_output('spikes', 'dict')
        self._data = {}
        self.n_size = 2 * self.max_delay + 1
        self.bin_size =  int(self.cc_bin * self.sampling_rate * 1e-3)
        self.raw_lags = np.linspace(-self.max_delay*self.cc_bin, self.max_delay*self.cc_bin, 2*self.max_delay+1)
        self.results = {
            'spikes': [],
            'templates': []
        }
Ejemplo n.º 9
0
    def __init__(self, **kwargs):
        """Initialization.

        Arguments:
            sampling_rate: float (optional)
                The sampling rate used to record the signal [Hz].
                The default value is 20e+3.
            cut_off: float (optional)
                The cutoff frequency used to define the high-pass filter [Hz].
                The default value is 500.0.
            order: integer (optional)
                The order used to define the high-pass filter.
                The default value is 1.
            remove_median: boolean (optional)
                The option to remove the median over all the channels for each time step.
                The default value is False.
            use_gpu: boolean (optional)
                The option to use the GPU.
                The default value is False.
        """

        Block.__init__(self, **kwargs)
        self.add_output('data', structure='dict')
        self.add_input('data', structure='dict')

        # Lines useful to solve PyCharm warnings.
        self.cut_off = self.cut_off
        self.order = self.order
        self.sampling_rate = self.sampling_rate
        self.remove_median = self.remove_median
        self.use_gpu = self.use_gpu

        # Check that the cut off frequency is at least 0.1 Hz.
        if self.cut_off < 0.1:
            self.cut_off = 0.1  # Hz

        self.dtype = None
        self.nb_samples = None
        self.nb_channels = None
        # self.sampling_rate = None  # already defined above

        self._b = None
        self._a = None
        self._z = None
        self._filter_engine = None
    def __init__(self, **kwargs):

        Block.__init__(self, **kwargs)
        self.add_output('mads', structure='dict')
        self.add_input('data', structure='dict')

        # The following lines are useful to avoid some PyCharm warnings.
        self.sampling_rate = self.sampling_rate
        self.time_constant = self.time_constant
        self.epsilon = self.epsilon

        self._dtype = None
        self._nb_samples = None
        self._nb_channels = None
        self._n = 0
        self._medians = None
        self._mads = None
        self._last_mads = None
    def __init__(self, **kwargs):
        """Initialize peak grouper.

        Argument:
            nb_groups: integer (optional)
                The number of groups from which data will be gathered.
                The default value is 1.
        """

        Block.__init__(self, **kwargs)

        # The following line is useful to avoid some PyCharm's warning.
        self.nb_groups = self.nb_groups

        for k in range(0, self.nb_groups):
            self.add_input('peaks_{}'.format(k), structure='dict')
        self.add_output('peaks', structure='dict')

        self.nb_samples = None
        self.sampling_rate = None
    def __init__(self, **kwargs):

        Block.__init__(self, **kwargs)
        self.add_input('peaks', structure='dict')

        # The following lines are useful to avoid some PyCharm warnings.
        self.pos_peaks = self.pos_peaks
        self.neg_peaks = self.neg_peaks
        self.data_path = self.data_path
        self.sampling_rate = self.sampling_rate
        self.nb_samples = self.nb_samples

        if self.pos_peaks is not None or self.neg_peaks is not None:
            self._mode = 'raw'
        elif self.data_path is not None:
            self._mode = 'hdf5'
        else:
            self._mode = 'raw'  # TODO complete.

        self._h5_file = None
    def __init__(self, **kwargs):

        Block.__init__(self, **kwargs)

        # The following lines are useful to avoid some PyCharm's warning.
        self.data_path = self.data_path
        self.spike_times = self.spike_times
        self.amplitudes = self.amplitudes
        self.templates = self.templates
        self.rejected_times = self.rejected_times
        self.rejected_amplitudes = self.rejected_amplitudes
        self.directory = self.directory
        self.sampling_rate = self.sampling_rate
        self.nb_samples = self.nb_samples

        self.add_input('spikes', structure='dict')

        if self.data_path is None:
            self._mode = 'raw'
        else:
            self._mode = 'hdf5'
        self._h5_file = None
Ejemplo n.º 14
0
    def __init__(self, **kwargs):
        """Initialization.

        Parameter:
            data_path: none | string (optional)
                The path to the file to use to write the data.
                The default value is None.
            dataset_name: none | string (optional)
                The name to use for the HDF5 dataset.
                The default value is None
            mode: none | string (optional)
                The mode to use to write into the file.
                The default value is None.
            nb_samples: integer (optional)
                The number of sampling times for each buffer.
                The default value is 1024.
            sampling_rate: float (optional)
                The sampling rate used to record the data.
                The default value is 20e+3.
        """

        Block.__init__(self, **kwargs)
        self.add_input('data', structure='dict')

        # Lines useful to remove some PyCharm warnings.
        self.data_path = self._get_temp_file(
        ) if self.data_path is None else self.data_path
        self.dataset_name = 'dataset' if self.dataset_name is None else self.dataset_name
        self.mode = 'default' if self.mode is None else self.mode
        self.nb_samples = self.nb_samples
        self.sampling_rate = self.sampling_rate

        self._dtype = None
        self._nb_samples = None
        self._nb_channels = None
        self._previous_number = None
        self._raw_file = None
        self._h5_file = None
        self._h5_dataset = None
Ejemplo n.º 15
0
    def __init__(self, **kwargs):
        """Initialize channel dispatcher.

        Argument:
            nb_groups: integer (optional)
                The number of groups into which data will be dispatch.
                The default value is 1.
        """

        Block.__init__(self, **kwargs)

        # The following line is useful to disable some PyCharm's warning.
        self.nb_groups = self.nb_groups

        self.add_input('data', structure='dict')
        for k in range(0, self.nb_groups):
            output_name = 'data_{}'.format(k)
            self.add_output(output_name, structure='dict')

        self.dtype = None
        self.nb_samples = None
        self.nb_channels = None
        self.sampling_rate = None
Ejemplo n.º 16
0
    def __init__(self, **kwargs):
        """Initialize fitter

        Arguments:
            templates_init_path: string (optional)
            overlaps_init_path: string (optional)
            with_rejected_times: boolean (optional)
            sampling_rate: float (optional)
            discarding_eoc_from_updater: boolean (optional)
            _nb_fitters: integer (optional)
            _fitter_id: integer (optional)
        """

        Block.__init__(self, **kwargs)

        # The following lines are useful to avoid some PyCharm's warnings.
        self.templates_init_path = self.templates_init_path
        self.overlaps_init_path = self.overlaps_init_path
        self.with_rejected_times = self.with_rejected_times
        self.sampling_rate = self.sampling_rate
        self.discarding_eoc_from_updater = self.discarding_eoc_from_updater
        self._nb_fitters = self._nb_fitters
        self._fitter_id = self._fitter_id

        # Initialize private attributes.
        self._template_store = None
        self._overlaps_store = None

        self.add_input('updater', structure='dict')
        self.add_input('data', structure='dict')
        self.add_input('peaks', structure='dict')
        self.add_output('spikes', structure='dict')

        self._nb_channels = None
        self._nb_samples = None
        self._number = None
Ejemplo n.º 17
0
    def __init__(self, **kwargs):

        Block.__init__(self, **kwargs)