Skip to content

Instantly share code, notes, and snippets.

View iandol's full-sized avatar
👾
typing away...

Ian Max Andolina iandol

👾
typing away...
  • Institute of Neuroscience, Chinese Academy of Sciences
  • Shanghai
  • 20:41 (UTC +08:00)
View GitHub Profile
@iandol
iandol / CreateProceduralSineSmoothedGrating.m
Created February 18, 2011 20:21
Add a cosine (method = 0) or hermite (method = 1) smoothed edge to a circularly masked sine grating. sigma is the width of the smoothing in pixels to apply to the edge. You can set useAlpha = 0 to modulate only colour, or useAlpha = 1 to modulate alpha.
function [gratingid, gratingrect] = CreateProceduralSineSmoothedGrating(windowPtr, width, height, backgroundColorOffset, radius, contrastPreMultiplicator, sigma, useAlpha, method)
% [gratingid, gratingrect] = CreateProceduralSineGrating(windowPtr, width, height [, backgroundColorOffset =(0,0,0,0)] [, radius=inf][, contrastPreMultiplicator=1])
%
% Creates a procedural texture that allows to draw sine grating stimulus patches
% in a very fast and efficient manner on modern graphics hardware.
%
% 'windowPtr' A handle to the onscreen window.
% 'width' x 'height' The maximum size (in pixels) of the grating. More
% precise, the size of the mathematical support of the grating. Providing too
% small values here would 'cut off' peripheral parts or your grating. Too big
@iandol
iandol / sendSerial.m
Created March 17, 2011 11:41
sendSerial.m -- simple wrapper for Psych toolbox IOPort TTL output on DTR and RTS pins of serial port
classdef sendSerial < handle
%SENDSERIAL Connects and manages Serial port communication
% Connects and manages Serial port communication
properties
name='pci-serial0'
baudRate=115200
silentMode=0 %this allows us to be called even if no serial port is attached
verbosity=1
openNow=1 %allows the constructor to run the open method immediately
end
function out = uipickfiles(varargin)
%uipickfiles: GUI program to select files and/or folders.
%
% Syntax:
% files = uipickfiles('PropertyName',PropertyValue,...)
%
% The current folder can be changed by operating in the file navigator:
% double-clicking on a folder in the list or pressing Enter to move further
% down the tree, using the popup menu, clicking the up arrow button or
% pressing Backspace to move up the tree, typing a path in the box to move
@iandol
iandol / gist:899981
Created April 2, 2011 22:44
A global wrapper for both pnet (UDP and TCP) and pnet_remote (send/receive matlab objects). See http://144.82.131.18/optickadocs/classdata_connection.html for more details...
% ========================================================================
%> @brief dataConnection Connects and manages a socket connection
%>
%> Connects and manages TCP/UDP Communication. We allow both TCP and UDP
%> connections, and can choose to be a client or server in TCP mode. To use
%> at its simplest in UDP mode, both clients on the same machine:
%>
%> %OPEN CLIENT 1
%> >> d1=dataConnection('rPort',4321,'lPort',1234,'protocol','udp','autoOpen',1)
%> %OPEN CLIENT 2
@iandol
iandol / Console output
Created May 31, 2011 11:20
Bits++ logs
31/05/2011 12:13:06 kernel PsychtoolboxKernelDriverUserClient::openUserClient(): Client connects to us :-)
31/05/2011 12:13:06 kernel PsychtoolboxKernelDriver: GetGPUInfo(): Returning GPU info.
31/05/2011 12:13:06 kernel PsychtoolboxKernelDriver: GetLUTState(): Checking LUT and bias values on GPU for headId 0.
31/05/2011 12:13:06 kernel PsychtoolboxKernelDriver: SetDitherMode: Trying to disable digital display dithering on display head 0.
31/05/2011 12:13:06 kernel PsychtoolboxKernelDriver: SetDitherMode: Current dither setting before our dither disable on head 0 is 0xa960f100. Disabling.
31/05/2011 12:13:06 kernel PsychtoolboxKernelDriver: SetDitherMode: Trying to disable digital display dithering on display head 1.
31/05/2011 12:13:06 kernel PsychtoolboxKernelDriver: SetDitherMode: Dithering already disabled. Skipped.
31/05/2011 12:13:06 kernel PsychtoolboxKernelDriver: SetDitherMode: Trying to disable digital display dithering on display head 2.
31/05/2011 12:13:06 kernel PsychtoolboxKernelDriver: SetDithe
@iandol
iandol / Console log
Created May 31, 2011 11:59
New Bits++ logs
31/05/2011 12:52:47 kernel PsychtoolboxKernelDriverUserClient::openUserClient(): Client connects to us :-)
31/05/2011 12:52:47 kernel PsychtoolboxKernelDriver: GetGPUInfo(): Returning GPU info.
31/05/2011 12:52:47 kernel PsychtoolboxKernelDriver: GetLUTState(): Checking LUT and bias values on GPU for headId 0.
31/05/2011 12:52:47 kernel PsychtoolboxKernelDriver: GetLUTState(): Checking LUT and bias values on GPU for headId 0.
31/05/2011 12:52:58 kernel PsychtoolboxKernelDriver: SetDitherMode: Trying to disable digital display dithering on display head 0.
31/05/2011 12:52:58 kernel PsychtoolboxKernelDriver: SetDitherMode: Dithering already disabled. Skipped.
31/05/2011 12:52:58 kernel PsychtoolboxKernelDriver: SetDitherMode: Trying to disable digital display dithering on display head 1.
31/05/2011 12:52:58 kernel PsychtoolboxKernelDriver: SetDitherMode: Dithering already disabled. Skipped.
31/05/2011 12:52:58 kernel PsychtoolboxKernelDriver: SetDitherMode: Trying to disable digital display dithering on display
@iandol
iandol / CreateProceduralSineSquareGrating.m
Created June 5, 2011 13:14
Square wave gratings using GLSL functions for Psychophysics toolbox. Based on the standard sine shader, thus supports the same options, including radius of a circular mask.
function [gratingid, gratingrect] = CreateProceduralSineSquareGrating(windowPtr, width, height, backgroundColorOffset, radius, contrastPreMultiplicator)
% [gratingid, gratingrect] = CreateProceduralSineGrating(windowPtr, width, height [, backgroundColorOffset =(0,0,0,0)] [, radius=inf][, contrastPreMultiplicator=1])
%
% Creates a procedural texture that allows to draw sine grating stimulus patches
% in a very fast and efficient manner on modern graphics hardware.
%
% 'windowPtr' A handle to the onscreen window.
% 'width' x 'height' The maximum size (in pixels) of the grating. More
% precise, the size of the mathematical support of the grating. Providing too
% small values here would 'cut off' peripheral parts or your grating. Too big
@iandol
iandol / gist:1106683
Created July 26, 2011 12:53
calibrateLuminanance.m -- use PTB and a ColorCalII to generate Gamma correction functions. To use simply type calibrateLuminance and it will prompt if zero calibration needs to be performed, if so it zero calibrates then runs through a defined set of lumi
% ========================================================================
%> @brief calibrateLuminance manaul / automatic luminance calibration
%>
%> calibrateLuminance manaul / automatic luminance calibration
%> To enter settings use a structure:
%>
%> >> mycal = calibrateLuminance(struct('nMeasures',25,'useCCal',true))
%>
%> calibrateLuminance will ask if you need to zero calibrate, you only need
%> to do this after first plugging in the ColorCal. Then simply place the
@iandol
iandol / gist:1109801
Created July 27, 2011 16:50
Output of lsusb -vv
Bus 007 Device 003: ID 0b97:7772 O2 Micro, Inc. OZ776 CCID Smartcard Reader
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
@iandol
iandol / gist:1220396
Created September 15, 2011 20:36
brew install libwpg
┌┬─ian @ Hobbes in ~
└┴─❧ brew install -v libwpg
==> Downloading http://downloads.sourceforge.net/project/libwpg/libwpg/libwpg-0.2.0/libwpg-0.2.0.tar.bz2
File already downloaded in /Users/ian/Library/Caches/Homebrew
/usr/bin/tar xf /Users/ian/Library/Caches/Homebrew/libwpg-0.2.0.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/libwpg/0.2.0 --disable-debug --disable-dependency-tracking
./configure --prefix=/usr/local/Cellar/libwpg/0.2.0 --disable-debug --disable-dependency-tracking
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d