This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Example code for analysis of neural correlate with spectral differences. | |
% This looks at differences in spectral power (but will not uncover | |
% relationships between neural activity and timing differences, as all that | |
% is masked by the warping process; a similar approach could look at | |
% correlates between neural activity and amount of warping). | |
%% Step 1: warp spectrograms | |
% How the spectrogram is warped is important, as you want to avoid spectral | |
% artifacts of the warping process. The exact code will vary a bit | |
% depending on what spectral routine you are using. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ORSSerial | |
/// An example of an extension of the ORSSerialPacketDescriptor that enables identifying delimited packets. | |
class DelimitedSerialPacketDescriptor: ORSSerialPacketDescriptor { | |
var delimiter: NSData? | |
convenience init(delimiter: NSData, maximumPacketLength maxPacketLength: UInt, userInfo: AnyObject?, responseEvaluator: ORSSerialPacketEvaluator) { | |
self.init(maximumPacketLength: maxPacketLength, userInfo: userInfo, responseEvaluator: responseEvaluator) | |
// set delimiter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [Area, Dsq, Time, AreaCoef, DCoef, angle, axisRatio, xyCorrelation, Mean, std_th] = SimpleCalculate2DArea(fix_x, fix_y, varargin) | |
%SIMPLECALCULATE2DAREA Summary of this function goes here | |
% This function calculates the are covered by the 2D displacement distribution | |
% at each delta t. | |
% | |
% function [Area] = DiffusionCoefficient2D (Fix,varargin) | |
% | |
% INPUT: | |
% Fix : matrix with the eye movements data. This matrix should be | |
% organized in the the following way: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
""" | |
This is NOT the polynomial time solution (should build lookup table instead). | |
""" | |
def knapsack(c, w, remaining_capacity, i=None): | |
""" | |
Recursively solve the knapsack problem to maximize utility given the remaining capacity and items with weight w |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
# match all script blocks | |
r = re.compile('<script[^>]*?>.*?</script>', re.IGNORECASE | re.DOTALL) | |
# can be used to easily remove script tags | |
html_without_scripts = r.sub('', html) | |
# match all style blocks | |
r = re.compile('<style[^>]*?>.*?</style>', re.IGNORECASE | re.DOTALL) | |
# can be used to easily remove script tags |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% number of random points to generate | |
number = 500; | |
x_dim = 100; | |
y_dim = 100; | |
% generate points | |
points = rand(number,2) * [x_dim 0; 0 y_dim]; | |
% list of nearest neighbors | |
nearest_neighbors = nan(1, number); |