Esempio n. 1
0
 def get_data(self):
     """Return the recorded current as a Neo signal object"""
     t_arr, i_arr = self._get_data()
     intervals = numpy.diff(t_arr)
     if intervals.size > 0 and intervals.max() - intervals.min() < 1e-9:
         signal = neo.AnalogSignal(i_arr, units="nA", t_start=t_arr[0] * pq.ms,
                                   sampling_period=intervals[0] * pq.ms)
     else:
         signal = neo.IrregularlySampledSignal(t_arr, i_arr, units="nA", time_units="ms")
     return signal
Esempio n. 2
0
def DownsampleNeoSignal(sig, decimation_factor):
    """

    """

    assert sig.shape[1] == 1, 'Can only downsample single-channel signals'

    num_points = int(sig.shape[0] / decimation_factor)

    x_downsampled, y_downsampled = lttb(
        x=sig.times.magnitude,
        y=sig.magnitude[:, 0],
        threshold=num_points,
    )

    sig_downsampled = neo.IrregularlySampledSignal(
        times=x_downsampled,
        signal=y_downsampled,
        units=sig.units,
        time_units=sig.times.units,
    )
    return sig_downsampled
Esempio n. 3
0
chn_index.units.append(unit)

seg = neo.Segment()
asig = neo.AnalogSignal(name="signal",
                        signal=[1.1, 1.2, 1.5],
                        units="mV",
                        sampling_rate=1 * pq.Hz)
seg.analogsignals.append(asig)
asig2 = neo.AnalogSignal(name="signal2",
                         signal=[1.1, 1.2, 2.5],
                         units="mV",
                         sampling_rate=1 * pq.Hz)
seg.analogsignals.append(asig2)
irasig = neo.IrregularlySampledSignal(name="irsignal",
                                      signal=np.random.random((100, 2)),
                                      units="mV",
                                      times=np.cumsum(
                                          np.random.random(100) * pq.s))
seg.irregularlysampledsignals.append(irasig)
event = neo.Event(name="event",
                  times=np.cumsum(np.random.random(10)) * pq.ms,
                  labels=["event-" + str(idx) for idx in range(10)])
seg.events.append(event)
epoch = neo.Epoch(name="epoch",
                  times=np.cumsum(np.random.random(10)) * pq.ms,
                  durations=np.random.random(10) * pq.ms,
                  labels=["epoch-" + str(idx) for idx in range(10)])
seg.epochs.append(epoch)
st = neo.SpikeTrain(name="train1",
                    times=[0.21, 0.37, 0.53, 0.56],
                    t_start=0 * pq.s,
Esempio n. 4
0
    seg = neo.Segment(name='testSegment' + str(ind1), index=ind1)
    seg.block = blk

    for ind2 in range(3):
        sp = neo.SpikeTrain(name='SpikeTrain' + str(ind2), times=np.random.rand(10) * qu.s, t_stop=1.2)
        sp.segment = seg
        seg.spiketrains.append(sp)

    for ind2 in range(3):
        sp = neo.Spike(name='Spike' + str(ind2), time=np.random.rand() * qu.s)
        sp.segment = seg
        seg.spikes.append(sp)

    for ind2 in range(3):
        irr = neo.IrregularlySampledSignal(name='IrregularlySampled' + str(ind2), times=np.random.rand(10) * qu.s,
                                           signal=np.random.rand(10) * qu.mV)
        irr.segment = seg
        seg.irregularlysampledsignals.append(irr)

    for ind2 in range(3):
        an = neo.AnalogSignal(name='AnalogSignal' + str(ind2), signal=np.random.rand(10) * qu.mV,
                              sampling_rate=10 * qu.Hz)
        an.segment = seg
        seg.analogsignals.append(an)

    for ind2 in range(3):
        an = neo.AnalogSignalArray(name='AnalogSignalArray' + str(ind2), signal=np.random.rand(10, 10) * qu.mV,
                                   sampling_rate=10 * qu.Hz)
        sp.segment = seg
        seg.analogsignalarrays.append(an)
Esempio n. 5
0
import neo
import numpy as np
time = np.array([0, 1, 2])
val = np.array([2, 3, 2])
id = np.array(['a', 'b', 'c'])
print(time.shape)
print(val.shape)
print(id.shape)
irsig0 = neo.IrregularlySampledSignal(time, val, units='mV', time_units='ms')
irsig0.array_annotate(id=id)