Example #1
0
def extract_recording(timeseries):
    sampling_frequency = 40000
    geom = np.zeros((num_channels, 2))
    geom[:, 0] = range(num_channels)
    recording = se.NumpyRecordingExtractor(
        timeseries=timeseries,
        geom=geom,
        sampling_frequency=sampling_frequency)
    return recording
Example #2
0
def extract_preprocessed_recording(timeseries, sorting_params,
                                   preprocess_params):
    sampling_frequency = sorting_params.sampling_frequency
    num_channels = timeseries.shape[0]
    timeseries_f = preprocess_timeseries(timeseries, preprocess_params,
                                         sampling_frequency)
    geom = sorting_params.get_geometry(num_channels)
    return se.NumpyRecordingExtractor(timeseries=timeseries_f,
                                      geom=geom,
                                      sampling_frequency=sampling_frequency)
Example #3
0
    print("Block shape", str(blocks.shape))

    geom = genfromtxt('256ANS_locs.csv', delimiter=',')

    geom = geom[1:129]

    print('Geom Shape:  ' + str(geom.shape))

    experiment_metadata = braingeneers.datasets_electrophysiology.load_experiment(
        UUID, i)

    fs = experiment_metadata["sample_rate"]

    recording = se.NumpyRecordingExtractor(timeseries=blocks,
                                           geom=geom,
                                           sampling_frequency=fs)

    channel_ids = recording.get_channel_ids()

    fs = recording.get_sampling_frequency()

    num_chan = recording.get_num_channels()

    recording_f = st.preprocessing.bandpass_filter(recording,
                                                   freq_min=300,
                                                   freq_max=6000)
    recording_cmr = st.preprocessing.common_reference(recording_f,
                                                      reference='median')

    sorting_MS4 = sorting_MS4 = sorters.run_mountainsort4(
Example #4
0
import matplotlib.pyplot as plt
import spikeinterface.extractors as se

##############################################################################
# First, let's create some traces in unsigned int16 type. Assuming the ADC output of our recording system has 10 bits,
# the values will be between 0 and 1024. Let's assume our signal is centered at 512 and it has a standard deviation
# of 50 bits

sampling_frequency = 30000
traces = 512 + 50 * np.random.randn(4, 10 * sampling_frequency)
traces = traces.astype("uint16")

###############################################################################
# Let's now instantiate a :code:`NumpyRecordingExtractor` with the traces we just created

recording = se.NumpyRecordingExtractor(traces,
                                       sampling_frequency=sampling_frequency)
print(f"Traces dtype: {recording.get_dtype()}")

###############################################################################
# Since our ADC samples between 0 and 1024, we need to convert to uV. To do so, we need to transform the traces as:
# traces_uV = traces_raw * gains + offset
#
# Let's assume that our gain (i.e. the value of each bit) is 0.1, so that our voltage range is between 0 and 1024*0.1.
# We also need an offset to center the traces around 0. The offset will be:  - 2^(10-1) * gain = -512 * gain
# (where 10 is the number of bits of our ADC)

gain = 0.1
offset = -2**(10 - 1) * gain

###############################################################################
# We are now ready to set gains and offsets to our extractor. We also have to set the :code:`has_unscaled` field to
Example #5
0
offset = 0
small_data = data[offset:(offset + small_n_channels), :seconds_of_data *
                  sample_rate]
print("Small data loaded")
small_data = small_data.astype(np.float32)
print("Data shape:", small_data.shape)
"""
fft = np.abs(np.fft.rfft(small_data,axis=1))
plt.plot(np.linspace(0,15001,fft.shape[1]),fft.T)
plt.savefig("FFT_small_data.png")
plt.close()
"""
geom = np.zeros((small_n_channels, 2))
geom[:, 0] = range(small_n_channels)
recording = se.NumpyRecordingExtractor(timeseries=small_data,
                                       geom=geom,
                                       sampling_frequency=sample_rate)
#recording = st.preprocessing.resample(st.preprocessing.rectify(recording), 1000)
#recording = st.preprocessing.bandpass_filter(recording,freq_min=300,freq_max=6000)

#recording = st.preprocessing.resample(recording, 1000)
#small_data = small_data.get_traces()
#recording = se.NumpyRecordingExtractor(timeseries=small_data,geom=geom,sampling_frequency=sample_rate)
"""
fft = np.abs(np.fft.rfft(small_data,axis=1))
plt.plot(np.linspace(0,15001,fft.shape[1]),fft.T)
plt.savefig("FFT_small_data_BP.png")
plt.close()
"""
sorting = se.NumpySortingExtractor()
sorting.set_times_labels(times=times, labels=labels)