def fetch_lfps(path, nest_output='nest_output'):
    ids, labels = read_ids_parameters(os.path.join(path, 'id_parameters.txt'))
    lfps = []
    for i in ids:
        fpath = os.path.join(path, nest_output, i, 'LFP_firing_rate.h5')
        with h5py.File(fpath) as f:
            lfps.append(f['data'][:,150:])
    return np.array(labels), np.array(lfps)
예제 #2
0
import numpy as np
import os, keras, pickle, h5py, re
import matplotlib
import matplotlib.pyplot as plt
from scipy.signal import welch
from helper_functions import calc_psds, remove_zero_lfps, set_up_model, read_ids_parameters

DATA_DIR = os.path.join('../simulation_code/lfp_simulations_small/')
SAVE_DIR = os.path.join('./save/')

## Load LFPs
ids, labels = read_ids_parameters(os.path.join(DATA_DIR, 'id_parameters.txt'))
lfps = np.zeros((len(ids), 6, 2851), dtype=np.float32)
for j, i in enumerate(ids):
    with h5py.File(
            os.path.join(DATA_DIR, 'nest_output', i,
                         'LFP_firing_rate.h5')) as f:
        lfp = f['data'][:, 150:]
    lfps[j] = lfp

lfps = np.array(lfps)
labels = np.array(labels)

## Get PSDs
fs, psds = calc_psds(lfps)
del lfps

## Remove cases of simulations where no neurons spiked
psds, labels = remove_zero_lfps(psds, labels)

test_psds = psds[:10000]
예제 #3
0
TICK_FONT_SIZE = 7
TITLE_FONT_SIZE = 7
LABEL_FONT_SIZE = 7
FULL_WIDTH_FIG_SIZE = 7
HALF_WIDTH_FIG_SIZE = FULL_WIDTH_FIG_SIZE / 2

DATA_DIR_LARGE = os.path.join('../simulation_code/lfp_simulations_large/')
DATA_DIR_SMALL = os.path.join('../simulation_code/lfp_simulations_small/')
LARGE_MODEL_PATH = os.path.join(
    '../training_scripts/save/model_full_parameterspace.h5')
SMALL_MODEL_PATH = os.path.join(
    '../training_scripts/save/model_small_parameterspace.h5')
SAVE_DIR = os.path.join('./save/')

#### Load large parameterspace LFPs
ids, labels_large = read_ids_parameters(
    os.path.join(DATA_DIR_LARGE, 'id_parameters.txt'))

## Test sims
ids = ids[:10000]
labels_large = labels_large[:10000]

lfps = np.zeros((len(ids), 6, 2851), dtype=np.float32)
for j, i in enumerate(ids[:10000]):
    with h5py.File(
            os.path.join(DATA_DIR_LARGE, 'nest_output', i,
                         'LFP_firing_rate.h5')) as f:
        lfp = f['data'][:, 150:]
    lfps[j] = lfp

lfps = np.array(lfps)
labels_large = np.array(labels_large)
import os, keras, pickle, h5py, re
import matplotlib
import matplotlib.pyplot as plt
from scipy.signal import welch
from helper_functions import calc_psds, remove_zero_lfps, set_up_model, read_ids_parameters

DATA_DIR_GRID = os.path.join('../simulation_code/lfp_simulations_grid/')
DATA_DIR_RANDOM = os.path.join('../simulation_code/lfp_simulations_grid/')
DATA_DIR_TEST = os.path.join('../simulation_code/lfp_simulations_large/')

SAVE_DIR = os.path.join('./save/')

### GRID SAMPLED DATA
# Load LFPs
print('loading grid sampled data')
ids, grid_labels = read_ids_parameters(os.path.join(DATA_DIR_GRID, 'id_parameters.txt'))
lfps = np.zeros((len(ids), 6, 2851), dtype=np.float32)
for j, i in enumerate(ids):
    with h5py.File(os.path.join(DATA_DIR_GRID, 'nest_output', i, 'LFP_firing_rate.h5')) as f:
        lfp = f['data'][:,150:]
    lfps[j] = lfp

grid_labels = np.array(grid_labels)

## Get PSDs
fs, grid_psds = calc_psds(lfps)
del lfps

## Remove cases of simulations where no neurons spiked
psds, labels = remove_zero_lfps(grid_psds, grid_labels)
예제 #5
0
import h5py, os
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec
from scipy.signal import periodogram, welch
from helper_functions import read_ids_parameters

TICK_FONT_SIZE = 7
TITLE_FONT_SIZE = 7
LABEL_FONT_SIZE = 7
FULL_WIDTH_FIG_SIZE = 7
HALF_WIDTH_FIG_SIZE = FULL_WIDTH_FIG_SIZE / 2

fig_dir = os.path.join('.')
data_dir = os.path.join('../simulation_code/example_activity_lfp')
ids, labels = read_ids_parameters(os.path.join(data_dir, 'id_parameters.txt'))

# Example parameter values to show
example_parameters = [np.array([2.0, 3.5, 0.25], dtype=np.float32),
                      np.array([4.0, 7.0, 0.15], dtype=np.float32),
                      np.array([0.9, 7.0, 0.25], dtype=np.float32),
                      np.array([2.8, 5.5, 0.05], dtype=np.float32),
                      np.array([2.0, 4.5, 0.35], dtype=np.float32)]

# Get sims in right order
indices = [(labels == param).all(axis=1).nonzero()[0][0] for param in example_parameters]
print(indices)
ids = [ids[i] for i in indices]
labels = [labels[i] for i in indices]

# Fetches rasters from simulation