How to use the tables.Int32Col function in tables

To help you get started, we’ve selected a few tables examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ver228 / tierpsy-tracker / MWTracker / analysis / traj_create / getWormTrajectories.py View on Github external
coord_y = tables.Float32Col(pos=4)
    area = tables.Float32Col(pos=5)
    perimeter = tables.Float32Col(pos=6)
    box_length = tables.Float32Col(pos=7)
    box_width = tables.Float32Col(pos=8)
    quirkiness = tables.Float32Col(pos=9)
    compactness = tables.Float32Col(pos=10)
    box_orientation = tables.Float32Col(pos=11)
    solidity = tables.Float32Col(pos=12)
    intensity_mean = tables.Float32Col(pos=13)
    intensity_std = tables.Float32Col(pos=14)

    threshold = tables.Int32Col(pos=15)
    bounding_box_xmin = tables.Int32Col(pos=16)
    bounding_box_xmax = tables.Int32Col(pos=17)
    bounding_box_ymin = tables.Int32Col(pos=18)
    bounding_box_ymax = tables.Int32Col(pos=19)

    # deprecated, probably it would be good to remove it in the future
    segworm_id = tables.Int32Col(pos=20)

    hu0 = tables.Float32Col(pos=21)
    hu1 = tables.Float32Col(pos=22)
    hu2 = tables.Float32Col(pos=23)
    hu3 = tables.Float32Col(pos=24)
    hu4 = tables.Float32Col(pos=25)
    hu5 = tables.Float32Col(pos=26)
    hu6 = tables.Float32Col(pos=27)


def _getWormThreshold(pix_valid):
github wehr-lab / autopilot / autopilot / tasks / gonogo.py View on Github external
# Set plot params, which data should be plotted, its default shape, etc.
    PLOT = {
        'data': {
            'x': 'shaded',
            'target': 'point',
            'response': 'segment'
        },
        'continuous': True
    }

    # PyTables Data descriptor
    # for numpy data types see http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html#arrays-dtypes-constructing
    class TrialData(tables.IsDescription):
        # This class allows the Subject object to make a data table with the correct data types. You must update it for any new data you'd like to store
        trial_num = tables.Int32Col()
        target = tables.BoolCol()
        response = tables.StringCol(1)
        correct  = tables.Int32Col()
        RQ_timestamp = tables.StringCol(26)
        DC_timestamp = tables.StringCol(26)
        shift = tables.Float32Col()
        angle = tables.Float32Col()
        delay = tables.Float32Col()

    class ContinuousData(tables.IsDescription):
        x = tables.Float64Col()
        y = tables.Float64Col()
        t = tables.Float64Col()

    HARDWARE = {
        'POKES': {
github ver228 / tierpsy-tracker / work_in_progress / old / track_segWorm.py View on Github external
if not 'eng' in globals():
    import matlab.engine
    eng = matlab.engine.start_matlab()
    #eng.addpath(eng.genpath('/Users/ajaver/GitHub_repositories/SegWorm/Only_segWorm'));
    eng.addpath(eng.genpath('/Users/ajaver/GitHub_repositories/Multiworm_Tracking/OnlySegWorm/'));
    eng.warning('off', 'normWorms:VulvaContourTooShort')
    eng.warning('off', 'normWorms:NonVulvaContourTooShort')


RESAMPLING_NUM = 65.0
class segworm_results(tables.IsDescription):
#class for the pytables 
    plate_worms_id = tables.Int32Col(pos=0)
    worm_index_joined = tables.Int32Col(pos=1)
    frame_number = tables.Int32Col(pos=2)
    skeleton = tables.Float32Col(shape = (RESAMPLING_NUM,2), pos=3)
    contour_ventral = tables.Float32Col(shape = (RESAMPLING_NUM,2), pos=4)
    contour_dorsal = tables.Float32Col(shape = (RESAMPLING_NUM,2), pos=5)
    
#import StringIO
#out = StringIO.StringIO()

#masked_image_file = '/Volumes/behavgenom$/GeckoVideo/Compressed/20150220/CaptureTest_90pc_Ch3_20022015_183607.hdf5'
#trajectories_file = '/Volumes/behavgenom$/GeckoVideo/Trajectories/20150220/CaptureTest_90pc_Ch3_20022015_183607.hdf5'

#masked_image_file = '/Users/ajaver/Desktop/Gecko_compressed/CaptureTest_90pc_Ch2_18022015_230213.hdf5'
#trajectories_file = '/Users/ajaver/Desktop/Gecko_compressed/Trajectory_CaptureTest_90pc_Ch2_18022015_230213.hdf5'

#masked_image_file = '/Users/ajaver/Desktop/Gecko_compressed/CaptureTest_90pc_Ch2_18022015_230213.hdf5'
#trajectories_file = '/Users/ajaver/Desktop/Gecko_compressed/Trajectory_CaptureTest_90pc_Ch2_18022015_230213.hdf5'
github wehr-lab / autopilot / autopilot / core / subject.py View on Github external
if group_name not in current_group:
                step_group = h5f.create_group(current_group, group_name)
            else:
                step_group = current_group._f_get_child(group_name)

            # The task class *should* have at least one PyTables DataTypes descriptor
            try:
                if hasattr(task_class, "TrialData"):
                    trial_descriptor = task_class.TrialData
                    # add a session column, everyone needs a session column
                    if 'session' not in trial_descriptor.columns.keys():
                        trial_descriptor.columns.update({'session': tables.Int32Col()})
                    # same thing with trial_num
                    if 'trial_num' not in trial_descriptor.columns.keys():
                        trial_descriptor.columns.update({'trial_num': tables.Int32Col()})
                    # if this task has sounds, make columns for them
                    # TODO: Make stim managers return a list of properties for their sounds
                    if 'stim' in step.keys():
                        if 'manager' in step['stim'].keys():
                            # managers have stim nested within groups, but this is still really ugly
                            sound_params = {}
                            for g in step['stim']['groups']:
                                for side, sounds in g['sounds'].items():
                                    for sound in sounds:
                                        for k, v in sound.items():
                                            if k in STRING_PARAMS:
                                                sound_params[k] = tables.StringCol(1024)
                                            else:
                                                sound_params[k] = tables.Float64Col()
                            trial_descriptor.columns.update(sound_params)
github durden / python_science_apps / code_samples / model.py View on Github external
class OilProductionByMonth(tables.IsDescription):
    """Data model class for oil production by month"""

    date = tables.Time64Col()
    barrels = tables.Int32Col()


class OilProductionByStateAndMonth(tables.IsDescription):
    """Data model class for oil production by state and month/year"""

    date = tables.Time64Col()
    la_barrels = tables.Int32Col()
    tx_barrels = tables.Int32Col()
    ak_barrels = tables.Int32Col()
    ca_barrels = tables.Int32Col()


class ExcelToHdf5(object):
    """Create hdf5 file from excel workbook"""

    def __init__(self, xls_filename, hdf5_filename, supported_sheets=None):
        """Convert given filename to hdf5"""

        self.xls_filename = xls_filename
        self.hdf5_filename = hdf5_filename

        self.workbook = None
        self.hdf5_file = None

        # Sheet indexes we support
        if supported_sheets is None:
github afiedler / tstables / src / tstables / benchmark.py View on Github external
import tables
import tstables
import tempfile
import datetime
import pytz
import pandas
import numpy
import timeit
import os

# Class to define record structure
class Price(tables.IsDescription):
    timestamp = tables.Int64Col(pos=0)
    price = tables.Int32Col(pos=1)

class Benchmark:
    @classmethod
    def log_me(cls, s):
        cls.log.write(s)
        print(s) 
    
    @classmethod
    def write_data(cls):
        # This simple benchmark creates a HDF5 file with a timeseries. It then loads about one year of random secondly
        #  data into it, closes it, and reads it back.
   
        cls.log_me("Started benchmark at %s\n\n" % datetime.datetime.now())
    
        cls.temp_file = tempfile.mkstemp('h5')[1]
        cls.h5_file = tables.open_file(cls.temp_file,'r+')
github ver228 / tierpsy-tracker / work_in_progress / old / track_worms_avg.py View on Github external
frame_number = tables.Int32Col(pos=2)
    coord_x = tables.Float32Col(pos=3)
    coord_y = tables.Float32Col(pos=4) 
    area = tables.Float32Col(pos=5) 
    perimeter = tables.Float32Col(pos=6) 
    major_axis = tables.Float32Col(pos=7) 
    minor_axis = tables.Float32Col(pos=8) 
    eccentricity = tables.Float32Col(pos=9) 
    compactness = tables.Float32Col(pos=10) 
    orientation = tables.Float32Col(pos=11) 
    solidity = tables.Float32Col(pos=12) 
    intensity_mean = tables.Float32Col(pos=13)
    intensity_std = tables.Float32Col(pos=14)
    
    threshold = tables.Int32Col(pos=15)
    bounding_box_xmin = tables.Int32Col(pos=16)
    bounding_box_xmax = tables.Int32Col(pos=17)
    bounding_box_ymin = tables.Int32Col(pos=18)
    bounding_box_ymax = tables.Int32Col(pos=19)
    
    segworm_id = tables.Int32Col(pos=20);
    
def triangle_th(hist):
    '''
    useful function to threshold the worms in a ROI
    adapted from m-file in MATLAB central form: Dr B. Panneton, June, 2010
    '''
    #   Find maximum of histogram and its location along the x axis
    xmax = np.argmax(hist)

    #find first and last nonzero index
    ind = np.nonzero(hist)[0]
github saroele / awesim / awesim / simman.py View on Github external
if summary.has_key('steps_nok'):    
                    summary['perc_wrong'] = 100. * float(summary['steps_nok']) / \
                                            float(summary['steps_ok'])
                else:
                    summary['perc_wrong'] = 0
                return summary            
            
            class Meta(tbl.IsDescription):
                SID = tbl.StringCol(itemsize=16)
                path = tbl.StringCol(itemsize=160)
                log_analysed = tbl.BoolCol()
                successful = tbl.BoolCol()
                algorithm = tbl.StringCol(itemsize=16)
                CPU_time = tbl.Float32Col()
                steps_ok = tbl.Int32Col()
                steps_nok = tbl.Int32Col()
                timed_out = tbl.BoolCol()
                perc_wrong = tbl.Float32Col()
                
            self.openh5()
            
            # if it's the first simulation, we need to create the Metadata tbl
            try:
                meta = self.h5.getNode(self.h5.root.Metadata)
            except(tbl.NoSuchNodeError):
                meta = self.h5.createTable('/', 'Metadata', Meta, 
                            title='All metadata for the simulations')
            
            # check if there's a log file 
            logfilename = simulation.filename.replace('result_','dslog_')\
                                             .replace('.mat','.txt')
            try:
github wehr-lab / autopilot / tasks / nafc.py View on Github external
# TODO: Plots should take the default type, but options panel should be able to set - eg. corrects are done by rolling mean as default, but can be made points
    PLOT = {
        'data': {
            'target'   : 'point',
            'response' : 'segment',
            'correct'  : 'rollmean'
        },
        'chance_bar'  : True, # Draw a red bar at 50%
        'roll_window' : 50 # number of trials to roll window over
    }

    # PyTables Data descriptor
    # for numpy data types see http://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html#arrays-dtypes-constructing
    class TrialData(tables.IsDescription):
        # This class allows the Mouse object to make a data table with the correct data types. You must update it for any new data you'd like to store
        trial_num = tables.Int32Col()
        target = tables.StringCol(1)
        response = tables.StringCol(1)
        correct = tables.Int32Col()
        correction = tables.Int32Col()
        RQ_timestamp = tables.StringCol(26)
        DC_timestamp = tables.StringCol(26)
        bailed = tables.Int32Col()

    HARDWARE = {
        'POKES':{
            'L': hardware.Beambreak,
            'C': hardware.Beambreak,
            'R': hardware.Beambreak
        },
        'LEDS':{
            # TODO: use LEDs, RGB vs. white LED option in init
github fspaolo / altimpy / altimpy / io.py View on Github external
except:
    #raise ImportError('The following module is missing: `osgeo` (GDAL)')
    print 'The following module is missing: `osgeo` (GDAL)'
    print 'Proceeding without it!!!'
    pass

from altimpy import is_meter


# definition of Table structures for HDF5 files

class TimeSeries(tb.IsDescription):
    sat_name = tb.StringCol(20, pos=1)
    ref_time = tb.StringCol(20, pos=2)
    date = tb.StringCol(20, pos=3)
    year = tb.Int32Col(pos=4)
    month = tb.Int32Col(pos=5)
    dh_mean = tb.Float64Col(pos=6)
    dh_error = tb.Float64Col(pos=7)
    dg_mean = tb.Float64Col(pos=8)
    dg_error = tb.Float64Col(pos=9)
    n_ad = tb.Int32Col(pos=10)
    n_da = tb.Int32Col(pos=11)


class TimeSeriesGrid(tb.IsDescription):
    sat_name = tb.StringCol(20, pos=1)
    ref_time = tb.StringCol(20, pos=2)
    date = tb.StringCol(20, pos=3)
    year = tb.Int32Col(pos=4)
    month = tb.Int32Col(pos=5)