Example #1
0
def get_observation(dataset_id, kind, cached=True, quiet=False):
    """
    Gets an observation of kind 'kind' from the dataset with id 'dataset_id', 
    optionally using the cached value retrieved previously.
    """
    
    db = shelve.open('aibs-cache') if cached else {}
    identifier = '%d_%s' % (dataset_id,kind)
    if identifier in db:
        print("Getting %s cached data value for from AIBS dataset %s" \
              % (kind.title(),dataset_id))
        value = db[identifier]
    else:
        print("Getting %s data value for from AIBS dataset %s" \
              % (kind.title(),dataset_id))    
        ct = CellTypesApi()
        cmd = ct.get_cell(dataset_id) # Cell metadata
        if kind == 'rheobase':
            sweep_id = cmd['ephys_features'][0]['rheobase_sweep_id']
        sp = get_sweep_params(dataset_id, sweep_id)
        if kind == 'rheobase':
            value = sp['stimulus_absolute_amplitude']
            value = np.round(value,2) # Round to nearest hundredth of a pA.
            value *= pq.pA # Apply units.
        db[identifier] = value
    
    if cached:
        db.close()
    return {'value': value}
Example #2
0
def get_observation(dataset_id,kind,cached=True):
    ct = CellTypesApi()
    cmd = ct.get_cell(dataset_id) # Cell metadata
    
    sweep_num = None
    if kind == 'rheobase':
        sweep_id = cmd['ephys_features'][0]['rheobase_sweep_id']
    sp = get_sweep_params(dataset_id, sweep_id)
    if kind == 'rheobase':
        value = sp['stimulus_absolute_amplitude']
        value = np.round(value,2) # Round to nearest hundredth of a pA.
        value *= pq.pA # Apply units.  
    return {'value': value}
Example #3
0
def get_observation(dataset_id, kind, cached=True, quiet=False):
    """Get an observation.

    Get an observation of kind 'kind' from the dataset with id 'dataset_id'.
    optionally using the cached value retrieved previously.
    """
    db = shelve.open('aibs-cache') if cached else {}
    identifier = '%d_%s' % (dataset_id, kind)
    if identifier in db:
        print("Getting %s cached data value for from AIBS dataset %s" %
              (kind.title(), dataset_id))
        value = db[identifier]
    else:
        print("Getting %s data value for from AIBS dataset %s" %
              (kind.title(), dataset_id))
        ct = CellTypesApi()
        cmd = ct.get_cell(dataset_id)  # Cell metadata

        if kind == 'rheobase':
            if 'ephys_features' in cmd:
                value = cmd['ephys_features'][0][
                    'threshold_i_long_square']  # newer API
            else:
                value = cmd['ef__threshold_i_long_square']  # older API

            value = np.round(value, 2)  # Round to nearest hundredth of a pA.
            value *= pq.pA  # Apply units.

        else:
            value = cmd[kind]

        db[identifier] = value

    if cached:
        db.close()
    return {'value': value}