Example #1
0
    def get(self, batch, cellid):
        '''
        Queries the MySQL database, finds the file, and returns
        the corresponding data in a NEMS-friendly Recording object.
        '''
        ensure_valid_batch(batch)
        ensure_valid_cellid(cellid)
        batch = int(batch)

        options = request.args.copy()

        # TODO: Sanitize arguments

        # TODO: Wrapping this in a try/catch is acceptable given how likely it is to fail,
        #       and then give clients some feedback about what went wrong:

        rec = baphy.baphy_load_recording(cellid, batch, options)

        if rec:
            targz = rec.as_targz()
            return Response(targz, status=200, mimetype='application/gzip')
        else:
            abort(400, 'load_recording_from_baphy returned None')
Example #2
0
    options["stimfmt"] = "envelope"
    options["chancount"] = 0
    options["rasterfs"] = 100
    options['includeprestim'] = 1

elif batch == 296:
    cellid = "chn002h-a1"
    options = {}
    options["stimfmt"] = "envelope"
    options["chancount"] = 0
    options["rasterfs"] = 100
    options['includeprestim'] = 1
    # modelname = "env100_fir2x18_dexp1_basic"


rec = nb.baphy_load_recording(cellid, batch, options)
rec2 = nb.baphy_load_recording_nonrasterized(cellid, batch, options)

if 'stim' in rec.signals.keys():
    stim1 = rec['stim']
    stim2 = rec2['stim'].rasterize()
    assert (np.sum(np.square(stim1.as_continuous()-stim2.as_continuous())))==0

resp1=rec['resp']
resp2=rec2['resp'].rasterize()
assert (np.sum(np.square(resp1.as_continuous()-resp2.as_continuous())))==0

if test_save:

    dataroot = '/tmp/test/'
    # rec['resp'].save(dataroot+'resp1/')