Example #1
0
import matplotlib.pyplot as plt
import numpy as np
from loadsums import ca_loadsum
from pylab import close, xlabel, ylabel, show, legend, savefig
from mpl_toolkits.axes_grid1 import ImageGrid
from load_vdaq_conds import vdaq_conds
from get_data import unpack_block_file

stim_start = 15
stim_length = 5
en_masse = True # whether or not to show the result for a single block file or export the results of a list of block files

if en_masse == False:
    from get_data import data_name_get
    data_name = data_name_get()
    lenheader, nframesperstim, framewidth, frameheight, _, _, _, _ = unpack_block_file(data_name)
    nframesperstim = np.array(nframesperstim)

    timepts = np.array(nframesperstim)
    img_range_zero = np.arange(0, nframesperstim) # put reading head at the beginning of the baseline condition images (and set limit)
    img_range_one = np.arange(nframesperstim, nframesperstim * 2) # move reading point to the trial condition images (and set limit)
    
    data_type, bytes_per_pixel = vdaq_conds(data_name)
    
    fimg_ca_one = ca_loadsum(data_name, img_range_one, True, data_type, framewidth, frameheight, lenheader, bytes_per_pixel)
    fimg_ca_zero = ca_loadsum(data_name, img_range_zero, True, data_type, framewidth, frameheight, lenheader, bytes_per_pixel)
    fimg_ca = fimg_ca_one / fimg_ca_zero # normalize trial condition to baseline condition
    
    pca = mdp.nodes.PCANode()
    pca_result = pca(fimg_ca)
    pca_time = pca.get_projmatrix()
Example #2
0
def vdaq_conds(data_name):
    _, nframesperstim, _, _, nstimuli, nvideoframesperdataframe, filesubtype, datatype = unpack_block_file(data_name)
    
    nframes = numpy.array(nframesperstim) * numpy.array(nstimuli)
    r = numpy.arange(1, nframes+1)
    r1 = range(1, 10)
    time_bin = 1000 / numpy.array(nvideoframesperdataframe)
    tim = numpy.arange(1, numpy.array(nframesperstim)+1) * numpy.array(time_bin)
    sumframes = False
    
    if numpy.array(filesubtype) != 11:
        raise InputError('not a VDAQ file')
    
    if numpy.array(datatype) == 13:
        data_type = '<u4'
        bytes_per_pixel = 4
    elif numpy.array(datatype) == 14:
        data_type = 2
        bytes_per_pixel = 4
    else:
        raise InputError('Check the data type')
    return data_type, bytes_per_pixel