ims = data[4] # The arrays with the images 
    ims = np.transpose(ims)
    ims = ims / 2.0  # Scale 
    ims = ims - 0.5  # Center 
    ims2 = ims**2
    Nside = ims.shape[2]
    
    frame_times = data[0] # The times at which the frames start 
    diff_frame = np.diff(frame_times, axis=0) # This calculate the duration of each frame 
    vm = data[2] # Extracts voltage 

    ## Pre-process the signal 
    # sampling interval
    sampling_time_interval = 0.102 # Obtained from Cyrills, experimental value 
    factor = 10  # 
    vm = downsample(vm, factor) # Sample down the signal by factor 

    first_image = int( frame_times[0] / (factor * sampling_time_interval))   # time of the first image
    last_image = int( (frame_times[-1] + np.mean(diff_frame)) / (factor * sampling_time_interval))
    last_image = int( (frame_times[-1] ) / (factor * sampling_time_interval)) # time of the last image 

    vm = vm[first_image:last_image] # Takes only the voltage that corresponds to images 
        
    ################
    ## Data parameters 
    ################
        
    #Scale and size values 
    dt = sampling_time_interval * factor # Sampling time interval (ms)
    dim = np.mean(diff_frame) # Duration of each image (ms)
     
Esempio n. 2
0
    ims = np.transpose(ims)
    ims = ims / 2.0  # Scale
    ims = ims - 0.5  # Center
    ims2 = ims**2
    Nside = ims.shape[2]

    frame_times = data[0]  # The times at which the frames start
    diff_frame = np.diff(frame_times,
                         axis=0)  # This calculate the duration of each frame
    vm = data[2]  # Extracts voltage

    ## Pre-process the signal
    # sampling interval
    sampling_time_interval = 0.102  # Obtained from Cyrills, experimental value
    factor = 10  #
    vm = downsample(vm, factor)  # Sample down the signal by factor

    first_image = int(
        frame_times[0] /
        (factor * sampling_time_interval))  # time of the first image
    last_image = int((frame_times[-1] + np.mean(diff_frame)) /
                     (factor * sampling_time_interval))
    last_image = int(
        (frame_times[-1]) /
        (factor * sampling_time_interval))  # time of the last image

    vm = vm[first_image:
            last_image]  # Takes only the voltage that corresponds to images

    ################
    ## Data parameters
#Scale and size values
dt = 1.0  # time sampling (ms)
dim = 21.0  # duration of the image (ms)
dh = 7.0  # resolution of the kernel (ms)

kernel_duration = 150  # ms
kernel_size = int(kernel_duration / dh)

# Scale factors
input_to_image = dt / dim  # Transforms input to image
kernel_to_input = dh / dt  # Transforms kernel to input
image_to_input = dim / dt  # transforms imagen to input

## Input preprocesing
vm = downsample(vm, dt)

# Take the percentage of the total that is going to be used
percentage = 0.30
Ntotal = int(percentage * vm.size)

# Take the minimum between the maximum and the choice
Ntotal = np.min((Ntotal, vm.size))
V = vm[0:int(Ntotal)]
vm = None  # Liberate memory

# Size of the training set as a percentage of the data
alpha = 0.95  #  training vs total
Ntraining = int(alpha * Ntotal)

# Construct the set of indexes (training, test, working)
# Scale and size values
dt = 1.0  # time sampling (ms)
dim = 21.0  # duration of the image (ms)
dh = 7.0  # resolution of the kernel (ms)

kernel_duration = 150  # ms
kernel_size = int(kernel_duration / dh)

# Scale factors
input_to_image = dt / dim  # Transforms input to image
kernel_to_input = dh / dt  # Transforms kernel to input
image_to_input = dim / dt  # transforms imagen to input

## Input preprocesing
vm = downsample(vm, dt)

# Take the percentage of the total that is going to be used
percentage = 0.30
Ntotal = int(percentage * vm.size)

# Take the minimum between the maximum and the choice
Ntotal = np.min((Ntotal, vm.size))
V = vm[0 : int(Ntotal)]
vm = None  # Liberate memory

# Size of the training set as a percentage of the data
alpha = 0.95  #  training vs total
Ntraining = int(alpha * Ntotal)

# Construct the set of indexes (training, test, working)