r.raise_for_status() # in case the abort URL is effed sys.exit(1) # now that we have our params, let's do cool stuff with them command = params['command'] args = params.get('args', []) kwargs = params.get('kwargs', {}) if command not in GDAL_COMMANDS: requests.post(abort_url, data={ 'error_text': "{command} is not a valid GDAL or OGR command".format(command=command) }) # okay, we have a valid command and some params. we're sure we're going to run this thing # so let's get the data tmpd = tempfile.mkdtmp() os.chroot(tmpd) source_data_filename = os.path.split(source_data_filename)[-1] try: r = requests.get(source_data_url) with open(source_data_filename, 'wb') as f: for chunk in r.iter_content(chunk_size): fd.write(chunk) except requests.ConnectionError as e: requests.post(abort_url, data={ 'error_text': str(e) }) r.raise_for_status() # in case the abort URL is effed sys.exit(1)
# # Arguments: # * channel_group: the channel group index to process # * filename: the filename of the KWIK file # * params: a dictionary with all KK parameters import os import shutil import tempfile from spikedetekt2.dataio import Experiment # get the basename (filename without the extension) basename = os.path.splitext(filename)[0] # Create a temporary working folder where we're going to run KK. tmpdir = tempfile.mkdtmp() curdir = os.getpwd() os.chdir(tmpdir) # Create the filenames of the .fet and .fmask files to create. filename_fet = os.path.join(tmpdir, basename + '.fet') filename_fmask = os.path.join(tmpdir, basename + '.fmask') filename_clu = os.path.join(tmpdir, basename + '.clu') with Experiment(filename) as exp: # Open in read-only, close the file at the end of the block # Load all features and masks in memory. # WARNING: this might consume to much Ram ==> need to do it by chunks. fm = exp.channel_groups[channel_group].spikes.features_masks[:] # fm is a Nspikes x Nfeatures x 2 array (features AND masks) fet = fm[:,:,0] fmask = fm[:,:,1]
# # Arguments: # * channel_group: the channel group index to process # * filename: the filename of the KWIK file # * params: a dictionary with all KK parameters import os import shutil import tempfile from spikedetekt2.dataio import Experiment # get the basename (filename without the extension) basename = os.path.splitext(filename)[0] # Create a temporary working folder where we're going to run KK. tmpdir = tempfile.mkdtmp() curdir = os.getpwd() os.chdir(tmpdir) # Create the filenames of the .fet and .fmask files to create. filename_fet = os.path.join(tmpdir, basename + '.fet') filename_fmask = os.path.join(tmpdir, basename + '.fmask') filename_clu = os.path.join(tmpdir, basename + '.clu') with Experiment( filename ) as exp: # Open in read-only, close the file at the end of the block # Load all features and masks in memory. # WARNING: this might consume to much Ram ==> need to do it by chunks. fm = exp.channel_groups[channel_group].spikes.features_masks[:] # fm is a Nspikes x Nfeatures x 2 array (features AND masks)