Exemple #1
0
# 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
    if asig.name == "Board ADC"
][0]  # This is the entire microphone recording
fs_mic = np.int(mic.sampling_rate)
t_mic = np.asarray(mic.times)
too_long = too_long * fs_mic
mic = mic.squeeze()
if normalize_mic:  # because our mic channel has leak current / noise
    i = 0
    previous_i = 0
# plot_spectrogram(t, freq, timefreq, dBNoise=80, colorbar = False)
################################################################################################################################
###############################################################################################################################
# Get the neural data
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
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)
# This is the entire microphone recording
mic = [
    asig for asig in block.segments[0].analogsignalarrays
    if asig.name == "Board ADC"
][0]
fs_mic = np.int(mic.sampling_rate)
t_mic = np.asarray(mic.times)
mic = mic.squeeze()
if normalize_mic:
    mic = mic - np.mean(
        mic
    )  # because our mic channel often has 1.652 v of dc leak from somewhere!
vocal_band = lowpass_filter(mic, fs_mic, low_power)
vocal_band = highpass_filter(vocal_band, fs_mic, high_power)
vocal_band = np.abs(vocal_band)