sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
d428a42c040914c3991f40aba4430af2c5b4a16c84a8d3cba9b4c2b491b85daa | MATLAB | 187 | 9 | function SLsys = getSLsys(img, scale, imagepad)
if ~exist('imagepad','var')
imagepad = 20;
end
SLsys = SLgetShearletSystem2D(0,size(img,1)+imagepad,size(img,2)+imagepad,scale);
end |
6706b3767375ce6444881edbc51da697ee2ef982ed7a761a4e12d0c79bf8f534 | MATLAB | 190 | 16 | function [S_mean, S_std, S] = calculate_SSIM(ref,im)
ref = nrm(ref);
im = nrm(im);
for idx = 1:size(im,3)
S(idx) = ssim(ref,im(:,:,idx));
end
S_mean = mean(S);
S_std = std(S);
end |
94936199ac1bdaeff1b35de55c1c93d8cf1d67a65115b471836be536700f5199 | MATLAB | 190 | 4 | function out_manager = update_plot_handle(out_manager,index,h)
handles_list=get(out_manager,'Plot_handles');
handles_list(index)=h;
out_manager=set(out_manager,'Plot_handles',handles_list);
|
e30d8f062d089d09f1711a1cf8300c46541318065549976c8bae599145c37fcb | MATLAB | 190 | 16 | function [S_mean, S_std, S] = calculate_PSNR(ref,im)
ref = nrm(ref);
im = nrm(im);
for idx = 1:size(im,3)
S(idx) = psnr(ref,im(:,:,idx));
end
S_mean = mean(S);
S_std = std(S);
end |
d4841b30f93e0abdc01054ed2e029690f6b4e19ccfe6273a42cc3cabed727841 | MATLAB | 192 | 6 | function N = createWhiteNoise(n,p)
% calculation of Gaussian white noise process
% calculation a priori for entire time
% no temporal correlation
N = p.varNoise .* randn(n,p.numSteps);
end |
ef9ecdf39e8b15e0044f8b863856f2f51ad00975789b887c7369a95ba83255c6 | MATLAB | 198 | 8 | function cleanPlot()
set(gca,'xtick',[]); set(gca,'xticklabel',[]);
set(gca,'ytick',[]); set(gca,'yticklabel',[]);
%set(gca,'XColor', 'none','YColor','none')
set(gcf,'color','none');
end |
2985b23cadf53c426e1a26b27d64d8d0372b1fc3cbc2de94139380c7d6e67e76 | MATLAB | 200 | 8 | function rmkdir(path)
path = strsplit(path, filesep);
dirString = '';
for i=1:numel(path)
dirString = [dirString, filesep, path{i}];
[~,~,~] = mkdir(dirString);
end
end |
5b4cf4f8cd13ffa1946fa45a71a0290f0b279f53c88a806e05402daed7db0ffb | MATLAB | 201 | 8 | function I_k1 = inward_rectifier_k(V, E_k, K_o, data)
E_0 = V - E_k + 3.6;
g_K1 = 5.08;
k_mK1 = 0.59;
I_k1 = 2.5.*g_K1 .* (K_o./(K_o + k_mK1)).^3 .* (V - E_k)./(1 + exp(1.393.*E_0./data.RTONF));
end
|
196b0842c863a27e059661b07093b090d10b8307b18b301f054bcbf3a2028db9 | MATLAB | 202 | 9 | function I_NaK = NaK_ATPase(K_o, Na_i, V)
I_NaKmax = 64.41;
k_mK = 1;
k_mNa = 11.^1.5;
I_NaK = I_NaKmax .*(K_o./(K_o + k_mK)).*(Na_i.^1.5./(Na_i.^1.5 + k_mNa)).*(1.6./(1.5 + exp(-(V + 60)./40)));
end |
1c471553774df513021c968689a74f7bd4ba2921853caa412b21b159bd6c036f | MATLAB | 203 | 12 |
clc
clear
close all
figure('Units','normalized','OuterPosition',[.1 .1 .05 .7])
prep_for_fig05A1
figure('Units','normalized','OuterPosition',[.1 .1 .05 .7])
prep_for_fig05A2
set(gca,'YColor','none')
|
60f84c9caa7092ae7ced1411056e7a2bcbfd3dc84df14f9421887a2b37ec641b | MATLAB | 213 | 11 | function [beamind] = InputBeams(s)
datain=inputSingleScan(s);
beamind = find(datain == 0);
if isempty(beamind)
beamind = 0;
end
if length(beamind)>1
beamind=0;
disp('Start behavioral program!');
end
|
b004bd23fdb4af5d3ac438d7d038c20c796d216278fdeb2b46b82dad9faf2427 | MATLAB | 220 | 10 | function u = nanunique(varargin)
x = varargin{1};
t = rand;
while any(x(:)==t)
t = rand;
end
x(isnan(x)) = t;
u = unique(x,varargin{2:end});
u(u==t)=[];
end |
df098e1d913c4a5011793d7b007e855b8462a0d6ed3d372470beb68f7887d623 | MATLAB | 221 | 6 | function [contralateralChannels] = getContralateralChannels(ECoGchannels)
ECoGchannels = ECoGchannels{:};
[s,~,j] = unique({ECoGchannels(:).side});
contralateralChannels = ~strcmp(s{mode(j)},{ECoGchannels.side});
|
e7ae2369df0f21789b1194d8b93b899556cdd1183e378c89efe82584b4ab9e2e | MATLAB | 221 | 13 | %%%teting
Connect
AO_AddBufferingChannel(10000,1500)
AO_AddBufferingChannel(10001,1500)
AO_AddBufferingChannel(10002,1500)
arr=[10000,10001,10002]
[Result,pData,DataCapture,TS_FirstSample] = AO_GetAlignedData(arr,3) |
b0f2427c2f666acab1ad5eebab156ed21aed1d0d137c3cb2db02fd4fb51ed7aa | MATLAB | 222 | 11 | function val=check_if_all_comps_wrap(sig_c)
comp_list=get_comp_list(sig_c);
for k=1:length(comp_list);
comp=comp_list{k};
comp_wrap=get(comp,'Wrap');
if (~comp_wrap)
val=0;
return;
end
end
val=1; |
6fa4f9b0d34bdd8591333244bce75fcd6ae6d29e06555d23d4f00ba0f79e0bee | MATLAB | 226 | 14 | % Script for manually testing the feeder device
% Author: Lasse Osterhagen
a = ArduinoDevice();
pause(2);
feederPin = 12;
for index=1:5
a.send(feederPin, 1);
pause(0.01);
a.send(feederPin, 0);
pause(3);
end
|
53bb6469bfc4d565cb32feb9d4f39ad50ca6607191df0d93c2370037abaee989 | MATLAB | 228 | 5 | % take mask inputs from GUI and update mask paramaters (i.e. ez_segmentParams)
% in PointManager instance (pipeline_data.points)
function set_mask_parameters_points(blur_value, threshold_value, minimum_value, pipeline_data)
end |
f08f0e62d43b190fb5fa301abe7650b6d0d332f68ee5131ef8eb983b68b67d94 | MATLAB | 233 | 17 | function playing = soundIsPlaying(app)
data='soundIsPlaying';
send(app.Qout,data);
gotMsg=false;
while ~gotMsg
[n, gotMsg]=poll(app.Queue);
end
if n==1
playing = 1;
elseif n == 0
playing = 0;
else
playing = -1;
end |
f2dd25eea394a99c369564762364f8ff76503128f28bd886ceda145717cadfa2 | MATLAB | 237 | 12 | % cleanplot
% Mohammad Shams <m.shams.ahmar@gmail.com>
%
% For the current axis:
% - calls cleanplot
% - removes the edges of each bar
function cleanhist(h)
for ih = 1:length(h)
h(ih).EdgeColor = 'none';
end
cleanplot |
2672e86188a1a125a990cc0448b0e6bdd2d0dda3641c32218a700eaa4dde770e | MATLAB | 238 | 11 | function [counts, labels, tags] = sortByLabel(counts, labels, tags)
[~, idx] = sort(upper(labels));
try
counts = counts(:,:,idx);
catch
% do nothing
end
labels = labels(idx);
tags = tags(idx);
end
|
48519cb0516b4d818a56f807f0072536eb4e13ae4b80c2fff877f4d852e28f05 | MATLAB | 238 | 17 | function COM=fb_compute_com(DATA)
% computes the center of mass, DATA is samples x trials
%
%
%
[nsamples,ntrials]=size(DATA)
COM=zeros(1,ntrials);
ind=[1:nsamples]';
for i=1:ntrials
COM(i)=sum(ind.*DATA(:,i))./sum(DATA(:,i));
end
|
15aa067bcad4d94435668bfc8fe6cfb80024ae7e0f7b01b90f60430e94b4eb58 | MATLAB | 242 | 6 | function m_sig = set_comp_by_index(m_sig,comp,comp_index)
% SET Set Main_signal properties and return the updated object
% Property names are:
% Level_comp, STime_comp, ETime_comp, Ramp_comp, Envelope_list.
m_sig.comp_list{comp_index}=comp;
|
2ea7c2b9614c1614ee50c5fbca2c4f32d325e4dfb10c391f6ff2d5994848831d | MATLAB | 242 | 13 | function [cD] = merge_feedback_Dobjects(D1,D2)
%
if isfile(fullfile(D1.path, ['c', D1.fname]))
cD = spm_eeg_load(fullfile(D1.path, ['c', D1.fname]));
else
S = [];
S.D = {D1, D2};
cD = spm_eeg_merge(S);
save(cD);
end
end |
38e350c12ad01fdc7f15f1be06d8d901c4edcf98a5035194915f44f34dd3fd6d | MATLAB | 242 | 14 | function Z = indices2bipartition( indices, N )
% Transform indices to a bi-partition
% Ex. N=5, indices=[1,2,4] -> Z=[1,1,2,1,2];
if iscell(indices)
ind = cell2mat(indices);
else
ind = indices;
end
Z = 2*ones(1, N);
Z(ind) = 1;
end |
7d324a6fb87fac1d0c8a1075ea75338115ea29d8ed7dd7d49824a9209b2e4662 | MATLAB | 242 | 5 | function dated_num = AO_generate_dated_from_file_num(year, month, day, num)
% JN 2020-05-15
% create a dated SNR file number (used to capture some SNR reboot cases)
dated_num = str2double(sprintf('%04d%02d%02d%04d', year, month, day, num));
|
cd3964d3d73e4cd7e435f5940690f2681ad638db84331396dd585a43cc658b70 | MATLAB | 244 | 10 | % Sript for manually testing ContinuousBgndAudioPlayer
% Author: Lasse Osterhagen
load('cSineBgnAPConfig.mat')
audioPlayer = depInj.createObjFromTree(audioPlayerConfig);
audioPlayer.start();
pause(2);
audioPlayer.stop();
delete(audioPlayer);
|
46de770e2ae27f829c508422e29ffb90a9e16a77d63edf09c15e6dd6ce1708dd | MATLAB | 246 | 9 | function [intND] = MIBI_get_int_norm_dist(data, K)
[IDX, closestDvecBA] = gui_MibiGetClosestDDoubleCountPeaks(data,data,K);
if isempty(closestDvecBA)
intND=[];
else
intND = mean(closestDvecBA(:,[2:K]),2);
end
end
|
cf6a713e161716540e0136dc9ca525a35b3023c0c85a790bbcbf6198d671d742 | MATLAB | 246 | 12 | function phi = phi_dis_pq(type_of_phi, probs, q_probs)
switch type_of_phi
case 'MI1'
phi = MI1_dis(probs,q_probs);
case 'star'
phi = phi_star_dis(probs,q_probs);
case 'SI'
phi = SI_dis(probs,q_probs);
end
end |
68282a38991c0bfaad88ce540709523f4f0f50ab3a0dd2db1a8563b6dd963f25 | MATLAB | 251 | 5 | function effDim = effectiveDimensionality(obj)
%EffectiveDimensionality
% Calculate based on quadratic entropy, skip first dimension
effDim = (sum(abs(obj.EigenValues(2:end))).^2/(sum(obj.EigenValues(2:end).^2)))/(length(obj.EigenValues)-1);
end |
0ab863f3023db05de81a901ccaac025bed511bc63786d1f7aefc14de8ccb3495 | MATLAB | 252 | 6 | function [data] = download_file(auth_token, url, path)
%UNTITLED6 Summary of this function goes here
% Detailed explanation goes here
response = httpGET(auth_token, [url, '/download/?path=', path]);
data = urlread(response.Body.Data.url);
end |
d976d6f826fcab7a56f486501fd906249857717843569e91bf6cccb2ae9f1eae | MATLAB | 254 | 13 | function P = power_set( S )
n = numel(S);
x = 1:n;
P = cell(1,2^n-1);
p_ix = 1;
for nn = 1:n
a = combnk(x,nn);
for j=1:size(a,1)
P{p_ix} = S(a(j,:));
p_ix = p_ix + 1;
end
end
end |
4432d7df9c554e415e368419c061722666cbd266729705df2290bb058e7b817c | MATLAB | 263 | 12 | % This function generates a cell array containing n copies of the input image
% scaled by a certain factor one from the other.
function P = Pyramid(img,n)
P = cell(n,1);
P{1} = impyramid(img,'reduce');
for i = 2:n
P{i} = impyramid(P{i-1},'reduce');
end
end |
4678b0192db856a7edfc876ada5096dc48fbce46017e774dd78c890cba83daa1 | MATLAB | 263 | 6 | function pahandle=pawavplay(tmp_points,samp_rate,nn,tmp_routing)
global ASIODev
pahandle=PsychPortAudio('Open', ASIODev, [], nn, samp_rate, 6);
toplay=zeros(length(tmp_points),6);
toplay(:,tmp_routing)=tmp_points;
PsychPortAudio('FillBuffer', pahandle, toplay');
|
8076ffe2bce9e3484e9eb7f595c21da0e1c7007df9fa4bff094cb33d1ba17d74 | MATLAB | 265 | 14 | function testAll
%TESTALL Run all tests.
files = dir(fullfile('test', 'test*.m'));
for i = 1:numel(files)
fname = strrep(files(i).name, '.m', '');
if ~strcmp(fname, 'testAll')
fprintf('== %s ==\n', fname);
feval(fname);
end
end
end
|
566c47d8de4095fda6a5d76521cd670d6bd92db49e5dc838e819bf80c672d3b6 | MATLAB | 271 | 8 | function meta=add_line(meta,line)
% ADD_LINE adds the given line to the line-list of the MetaBlock.
% META=ADD_LINE(META,LINE) adds the given line to the
% line-list of this metablock.
list=get(meta,'Line_list');
loc=length(list);
meta=add_line_index(meta,line,loc+1);
|
590beed3f2370f6a8952e085258e16bdeaefe539a54ed4bc10261d11a1e316ed | MATLAB | 273 | 11 | function [new_text] = wrap_text(old_text,columns,breaks)
new_text = {};
sub = '';
count = 1;
while ~isequal(sub, old_text)
[sub, old_text] = sub_text(old_text, columns, breaks);
new_text{count} = sub;
count = count + 1;
end
end
|
f20dee3c4bd989a55c41b14e215aac25c94daf6ef102a5491647392943b665cf | MATLAB | 275 | 10 | function w = WTAcalc(Fa,Fb)
% Calculates WTA index with the firing rates of the two summation neurons
% Closer to 1 means strong rivalry, closer to 0 means responses are
% similar
e = 0.005;
frac = abs(Fa - Fb)./(e + Fa + Fb);
frac(isnan(frac)) = 0;
w = mean(frac);
end
|
309106a1a10238983d93d90afb27be29b5893afa2003f1ff95c64b5c0111ca0a | MATLAB | 276 | 17 | function out = animated_comparison(im1,im2,nframes)
im1 = im1(:,:,1);
im2 = im2(:,:,1);
sz = size(im1,2);
out = repmat(im1,1,1,nframes);
step = round(sz/nframes);
out(:,:,end) = im2;
for i = 2:nframes-1
idx = min(sz,i*step);
out(:,1:idx,i) = im2(:,1:idx);
end
end |
580866eb06596677874d45cd5727d017f46a053d8fc0c03497ef8c3d31bc345f | MATLAB | 277 | 12 | function MibiComputerWriteLog(filename)
% function writes a log of the time every 5 minutes to a file
LogDir = ('/Users/lkeren/Box Sync/Leeat_Share/Data/');
nSecs= 250;
go = true;
while go
pause(nSecs);
c=clock;
dlmwrite([LogDir,'/',filename],c,'-append')
end |
e3626e05f180a1327c1c8fb333d6267962ee6565aaa5a998123c2d082e887c69 | MATLAB | 277 | 12 | function legal=is_legal(line)
% IS_LEGAL checks if the line is legal(if there are channels defined for
% it).
% LEGAL=IS_LEGAL checks if the line is legal returns 1 if legal, 0
% otherwise.
num_chans=get(line,'Num_of_chans');
if num_chans==0
legal=0;
else
legal=1;
end |
f37a63469af3c9bf49fff3bc3ab844f24d605b8ca4c0aeeef5866fc8e5a2b468 | MATLAB | 278 | 15 |
function time = whatsthetime(T)
if length(num2str(hour(T))) == 1
hr = ['0',num2str(hour(T))];
else
hr = num2str(hour(T));
end
if length(num2str(minute(T))) == 1
min = ['0',num2str(minute(T))];
else
min = num2str(minute(T));
end
time = [hr,':',min,' - '];
end
|
1d30bd814d0a44ec9de3881ec56ed05c092cf39f85b32ab96c16a92df82ea273 | MATLAB | 282 | 12 | function num_samples=mAO_get_numsamples
global mAO
mt=mAO.NextTrig;
for ic=1:length(mAO.LFPChannels)
if mt>mAO.LFPtime{ic}(mAO.LFPind(ic))
mt=mAO.LFPtime{ic}(mAO.LFPind(ic));
end
end
mAO.mt=mt;
difftime=mAO.mt-mAO.PrevTrig;
num_samples=ceil(difftime*mAO.RX8sfreq);
|
5514dde1c159e2da4ba6cafe4b86adf3bbb7b271a101ab1e575cf52c325d3810 | MATLAB | 282 | 11 | function checkPositiveNumber( value )
%CHECKPOSITIVENUMBER throws an exception if value is nonnumercal or lower
% than 0.
% Author: Lasse Osterhagen
if ~(isnumeric(value) && min(value) >= 0) %works for NaN too
error('Input is not a valid number >= 0');
end
end
|
b1e1be4c1bc24614dcb4f6182bb7a17a8890b72ea44985ba5c0f778884adbd49 | MATLAB | 283 | 9 | function outStruct = publicProperties2Struct(obj)
%PUBLICPROPERTIES2STRUCT converts public properties of an Object to a struct.
% Author: Lasse Osterhagen
props = properties(obj);
outStruct = cell2struct(cellfun(@(p) obj.(p), props, ...
'UniformOutput', false), props, 1);
end
|
48dc92c73575ad869ce6be0c90b5e8836415d1c714d6f9a5f2af2f53277f860e | MATLAB | 286 | 11 | function [T] = clustConn(clustVec)
T = zeros(length(clustVec));
for ii=1:length(clustVec)
for jj=ii:length(clustVec)
if clustVec(ii) == clustVec(jj)
T(ii,jj) = 1;
T(jj,ii) = 1;
end
end
end
end |
e2e41384f1084fec3d242e37f08adf90c38cbbf5dfbb7ba29b679ed00c7619a4 | MATLAB | 287 | 14 | dfc_645=load("full_data_linear/subject_31_mx645.txt");
imagesc(dfc_645);
colorbar;
axis off;
dfc_1400=load("full_data_linear/subject_31_mx1400.txt");
imagesc(dfc_1400);
colorbar;
axis off;
dfc_2500=load("full_data_linear/subject_31_std2500.txt");
imagesc(dfc_2500);
colorbar;
axis off; |
df8a83291560a23e5ce04a068d20793916d81ed8b86b2e76773cd73027f4ad26 | MATLAB | 291 | 14 | function blSDF = blSubSDF(SDF,sdftm)
startTm = find(sdftm == -.05);
stopTm = find(sdftm == 0);
for i = 1:size(SDF,1) % ch loop
clear holder
holder = squeeze(SDF(i,startTm:stopTm,:));
blSubThis(i) = nanmean(holder,'all');
blSDF(i,:,:) = SDF(i,:,:) - blSubThis(i);
end
end |
edb50f8fc14b8977b58f14c620fc3ef2547589580e00471a721e00de6f01bb2d | MATLAB | 291 | 12 | function ih = PlotLabels(L)
L = single(L);
bL = imdilate( abs( imfilter(L, fspecial('log'), 'symmetric') ) > 0.8, strel('disk', 1)); %0.1
LL = zeros(size(L),class(L));
LL(bL) = L(bL);
Am = zeros(size(L));
Am(bL) = .8;
ih = imagesc(LL);
set(ih, 'AlphaData', Am);
colormap 'jet'; |
1af413130e2580e43ba5069ba34b7a9d05b307b4e0d182da4f46135e3e10a070 | MATLAB | 293 | 9 | function Display_results(measurement,threshold)
if measurement >= threshold
cprintf([0,0.5,0],['+' num2str(measurement) '\n']);
elseif abs(measurement - threshold) == 0
cprintf([0.75,0.5,0],[num2str(measurement) '\n']);
else
cprintf([0.75,0,0],[num2str(measurement) '\n']);
end
end |
afc9ecbe1b06edc749ea73be0834fe6e26854c3fb14c5bacbc337f76f3afd032 | MATLAB | 294 | 19 | % [out] = nrm(in)
% Normalizes an n-dimensional matrix in
%
function [out] = nrm(in)
in = double(in);
in_max = max(in,[],'all');
in_min = min(in,[],'all') ;
% for i = 1:ndims(in)
% in_max = max(in_max);
% in_min = min(in_min);
% end
out = (in - in_min)/(in_max- in_min);
end |
8acc60f701a50c60c3b765a40756b1394a75d6f697e06e92d9d493c19fab3947 | MATLAB | 295 | 10 | function [Final_img_0, m_Weight_0, m_Kaiser] = MIRO_Collaborative_Wiener_Initialization(img, blk_size, max_i)
m_shape = size(img);
% K = kaiser(blk_size, Beta_Kaiser);
K = parzenwin(blk_size);
m_Kaiser = (K * K');
Final_img_0 = zeros(m_shape(1),m_shape(2),max_i);
m_Weight_0 = Final_img_0;
end |
c795c7c3ac66eeef004f33a3e4aba6ef3c68673c7bc7e41dd6c5dd2586e58629 | MATLAB | 300 | 12 | function [Dir] = simpleDirVA(respMatrix, params, epsilon)
numTrials = size(respMatrix, 1);
numCells = size(respMatrix, 2);
pDir = params.PD;
Dir = NaN(numTrials, 1);
for i = 1:numTrials
Dir(i) = sum(pDir.*respMatrix(i,:))./(epsilon+sum(respMatrix(i,:)));
end
%Dir = Dir+normrnd(0,1, numTrials,1); |
3eb328f59560ef5059e1e40b16973b097748461e8811694c1bb14655cb9d3758 | MATLAB | 303 | 9 | function [croppedSDFforSimult,croppedSdftmforSimult] = cropSDF_getSimultBRFS(SDF,STIM,sdftm)
% Crop dow to [-150 to 200 ms based on sdftm]
startTm = find(sdftm == -.050);
stopTm = find(sdftm == .500);
croppedSdftmforSimult = sdftm(1,startTm:stopTm);
croppedSDFforSimult = SDF(:,startTm:stopTm,:);
end |
44ac2244eca414af29ab80adda2a2fdbe1f8b2d54f279e8907dff69d1bd71db9 | MATLAB | 303 | 13 | function print_plot_to_file(h_f, name, mdata)
if ~mdata.do_print
return;
end
full_name = strcat(name, '.png');
res = '-r450';
print(h_f, full_name, '-dpng', res);
if isfield(mdata, 'do_close_all') && mdata.do_close_all
drawnow(); % Allow the drawing and saving to finish
close(h_f);
end
end |
696861731c12bbeabce6365eb80a314ad8b13397e6791db34a4b1fe28c2a178b | MATLAB | 305 | 9 | load('stimulusListFile');
stimlist = S;
for k=5:5:100
stim=struct;
[stim.T, stim.paramFile,stim.paramBBN,stim.paramF,stim.paramGap] = ...
createFileRow(stimlist.T,stimlist.paramFile,stimlist.paramBBN,stimlist.paramF,stimlist.paramGap,...
'safety.wav',500,k);
stimlist=stim;
end |
1ecb0a610055cc1e24bcec6c22bfec86aee2126b2f0a1e7c5209856b3e15468f | MATLAB | 307 | 11 | function I_NaCa = NCX(Na_i, Ca_i, V, data)
Ca_o = data.Ca_o;
Na_o = data.Na_o;
gamma_NaCa = 0.450;
d_NaCa = 0.0003;
I_NaCa = 0.02.*(Na_i.^3.*Ca_o.*exp(gamma_NaCa.*V./data.RTONF) - Na_o.^3.*Ca_i.*exp(V.*(gamma_NaCa - 1)./data.RTONF))...
./(1 + d_NaCa.*(Ca_i.*Na_o.^3 + Ca_o.*Na_i.^3));
end |
924469432aa687e4243a6f65eb00abddb6aab3212b0e5601c964e41b2717fd0d | MATLAB | 307 | 17 | function [ data_reg] = regressor( data, reg )
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
[n_vox, n_time] = size(data);
data_reg = zeros(size(data));
for i = 1:n_vox
data_i = data(i,:);
b = glmfit(data_i, reg);
data_reg(i,:) = data_i - b(1)*reg;
end
end
|
c46ba968c340fd2833cb645c171f8ad65d43d0f37119d272cdd5707ca6561755 | MATLAB | 308 | 22 | classdef InputDeviceData < event.EventData
% Holds data of an InputDevice
% Author: Lasse Osterhagen
properties
% Pin no
pin
% Value of pin
value
end
methods
function this = InputDeviceData(pin, value)
this.pin = pin;
this.value = value;
end
end
end
|
db8ebda86dc8b530be6be4ca2805cc42c9131598e75600531e82b343d4309129 | MATLAB | 315 | 15 | bb=zeros(12,0);
tt=[];
s=setupDaqSession(); % Initialize daq session
while 1>0
tt(end+1)=cputime;
beamind=InputBeams(s); % read beams
bb(:,end+1)=0;
if beamind(1)
bb(beamind,end)=1;
end
while cputime-tt(end)<0.001
end
end
%%
deleteDaqSession(s); % When fininshed, delete daq session
|
be8713e3ba334f9cd7dd7d895c3ab61242ee51c40050c39f748045316c07809a | MATLAB | 316 | 7 | function [response] = httpGET(auth_token, uri)
authinfo = matlab.net.http.AuthInfo('JWT', auth_token);
header = matlab.net.http.field.AuthorizationField('Authorization', authinfo);
request = matlab.net.http.RequestMessage('GET', header);
[response,completedrequest,history] = send(request,uri);
end
|
ea3c57531118529c292b54231951818392ebe4bdd3a798acfa2a4d9e94b086de | MATLAB | 317 | 19 | function K=kernel_RBF(Img,value)
% RBF-kernel parameters
a = 2;
b = 1;
sigma = .5;
sz=size(Img);
if length(sz)==3
for k=1:3
Kint(:,:,k)=Img(:,:,k)-value(k);
end
Kint=Kint.^a;
Kint=squeeze(sum(Kint,3));
K=exp(-Kint/sigma^2);
else
K=exp(-(Img-value).^a/sigma^2);
end |
a0b51046c737d2e267061f3de8c2bc2a8e6f1cec50998fd1783308f2f199dda8 | MATLAB | 319 | 17 | global IDXDIR
cd(IDXDIR)
clear
close all
load('IDXforIOTana.mat')
for i = 1:30
RESPmonoc(i,:) = IDX.allV1(i).RESP_avg{1};
RESPIOT(i,:) = IDX.allV1(i).RESP_avg{2};
end
win_ms = [50,100;150,250;50,250;-50,0];
percentChange = (RESPmonoc(:,:) - RESPIOT(:,:))./RESPmonoc(:,:) * 100;
plot(percentChange(:,1))
|
d1be7834d80b4699e0955fc9afa49827537f21cbc8b7953f6fb8e3ae36000da0 | MATLAB | 320 | 10 | function [txt] = myupdatefcn(trash,event)
global channel
pos = get(event,'Position');
dts = get(event.Target,'Tag');
display([dts, ['X: ',num2str(pos(1))], ['Y: ',num2str(pos(2))]]);
txt = dts;
Num = regexp(dts,'\d');
channel = str2num(dts(Num));
% [' X: ',num2str(pos(1))],[' Y: ',num2str(pos(2))]};
end |
d66862e804568d90c169beab82cb19e566f77e2835c52c8267644367a32fd567 | MATLAB | 323 | 12 | classdef (Abstract) SampleSource < handle
%SAMPLESOURCE Abstract interface for sample sources.
% A sample source provides continuous samples that can be used as
% background sound in which stimuli will be inserted.
% Author: Lasse Osterhagen
methods (Abstract)
samples = getSamples(this, numSamples)
end
e... |
87ca139e738f92309458d67b6eb801f9cd8e25358559e2ae0ee43037fbbf9219 | MATLAB | 324 | 23 | a = [1;2;3;0];
b = [1;3;2;0];
r = rand(1,300) < 0.10;
ff = find(r);
ii = find(diff(ff)==1);
fii = ff(ii);
r(fii) = 0;
S = zeros(4,length(r));
S(:,r==1) = repmat(b,1,sum(r==1)),;
S(:,r==0) = repmat(a,1,sum(r==0));
min(diff(find(r)))
imagesc(S)
F1=[0,1047,1319,1568];
S1=F1(S+1);
S1=S1(:)';
S2=S1.*2;
S3=S1.*3;
S4=S1.... |
7f5430d565cc40f5a2210f91d509dd1273d1991a598e3c9ae8f3d6c22c975fff | MATLAB | 325 | 13 | function group = micca_sort_group(group,min_ind)
%
% group = micca_sort_group(group,min_ind)
%
stats = regionprops(group, 'Area');
[valeur indice] = sort( [stats.Area ], 'descend');
tmp_group = 0*group;
i = 1;
while(i<=max(group) && valeur(i) > min_ind)
tmp_group(group == indice(i)) = i;
i = i+1;
end
group = tmp_gr... |
93e22d1ad642fdd975da41b1f7f1d276d00bff6adddfefd266bc25be9bed4370 | MATLAB | 325 | 12 | function [I_Ks, dn] = slow_delayed_rectifier_k(V, n, E_k)
g_Ks = 2.5; % Conductace of the slow delayed rectifier k+ channel [nS]
I_Ks = g_Ks.*n.*(V - E_k);
alpha_n = 1.66.*exp(V./69.452);
beta_n = 0.3.*exp(-V./21.826);
n_m = 1./(1 + exp(-(V - 0.9)./13.8));
tau_n = 1./(alpha_n + beta_n) + 0.06;
dn = (n_m - n)./tau_n;
... |
7a3f720702644f9b425a110d215979871e5e748ce29c0c2a08d6c7ccd2e9d2f0 | MATLAB | 328 | 11 | function s=setupDaqSession()
s = daq.createSession('ni');
addDigitalChannel(s,'Dev1','Port0/Line0:3','InputOnly');
addDigitalChannel(s,'Dev1','Port2/Line0:3','InputOnly');
addDigitalChannel(s,'Dev1','Port4/Line0:3','InputOnly');
datain=inputSingleScan(s);
idx = find(datain == 0);
if ~isempty(idx)
removeChannel(s,i... |
aa41578c39ab04847a1f639ba87753a9d6349d720d2038262c5b24e7dc5c8d83 | MATLAB | 328 | 12 | function [L, n_ca3, ca3_peak_locations, dt, plateau_duration] = Exp_setup(L, n_ca3)
dt = 10 / 1000;
% length of track; number of input ca3; time step in ms
plateau_duration = 300;
% in mileseconds
peak_dist = L / n_ca3;
ca3_peak_locations = peak_dist/2 : peak_dist : L;
... |
1c4766b6941292c813b9ab1f281c59c9904de6913b48475a5333e95190aa7714 | MATLAB | 333 | 13 | function [hC vC] = SpatialCues(im)
g = fspecial('gauss', [13 13], sqrt(13));
dy = fspecial('sobel');
vf = conv2(g, dy, 'valid');
sz = size(im);
vC = zeros(sz(1:2));
hC = vC;
for b=1:size(im,3)
vC = max(vC, abs(imfilter(im(:,:,b), vf, 'symmetric')));
hC = max(hC, abs(imfilter(im(:,:,b), vf', 'symmet... |
ed50cac99bb9c83bedd00358bb27f1404202357b1f3eac9805c375a23292ce93 | MATLAB | 333 | 14 | function mAO_stop_hardware
global mAO
r=AO_CloseConnection();
if r==0
disp('closing SnR connection');
else
disp('Problems in AO_CloseCOnnection');
end
mAO.LFPind=zeros(length(mAO.LFPChannels),1);
mAO.SEGind=zeros(length(mAO.SEGChannels),1);
mAO.TRIGind=zeros(length(mAO.TRIGChannels),1);
mAO.PrevTrig=NaN;
mAO.Ne... |
18735f3e9d439390559ad62e15b917ce0243d9ef99f588184b4b3bea4c1e1c60 | MATLAB | 336 | 21 | %% Remove hot spots
function I = MIRO_Hotspot2(I,alpha,var)
%% Median filter
pad = [1 1];
I1 = padarray(I,pad,'replicate','both');
I_med = medfilt2(I1);
I_med = removePad(I_med,pad);
I2 = I;
%% Hotspot removal
T = (alpha).*sqrt(var+I_med);
I2(abs(I-I_med)>T) = I_med(abs(I-I_med)>T);
I2(I<=0) = 1e-6;
%% Pre-denois... |
c618d55cbb90c7b76039bed2cd323477d142efbcb2d022870dc73b4ab70429af | MATLAB | 339 | 12 | function Display_results_percentage(measurement,reference)
percentage = round(100*(measurement - reference)/reference);
if percentage <= 0
cprintf([0.75,0,0],[num2str(percentage) '%%\n']);
elseif percentage == 0
cprintf([0.75,0.5,0],[num2str(percentage) '%%\n']);
else
cprintf([0,0.5,0],[num2str(percentage... |
aee28100aa2177ff27e792312fa5f59155f03578b111c2daba3041fe56ebcd6f | MATLAB | 342 | 12 | function checkInterval(value)
%checkInterval checks whether a correct interval in the form (a, b); a<=b
%is provided. If not, an exception is thrown.
% Author: Lasse Osterhagen
if value(1) > value(2)
error(['The lower bound must be lower than the upper ', ...
'bound and vice ve... |
bfbe32736ee421af98a380277e14a37b6374d37da7a1769f476a036c9aaeb317 | MATLAB | 342 | 9 | function f = imagescCapByPercentile(data,prcLow,prcHigh)
% function f = imagescCapByPercentile(data,prcLow,prcHigh)
% function plots an image using imagesc. It receives a lower and upper
% percentile and caps all values below/above it
lowVal = prctile(data(:),prcLow);
highVal = prctile(data(:),prcHigh);
f = imagesc(d... |
1a311c955ca0134c9d636477e5a60c252c5866e377d2643c4c67523e4a6a674a | MATLAB | 344 | 12 | function meta=remove_line(meta)
% REMOVE_LINE removes the last line from the list of lines of the MetaBlock.
% META=REMOVE_LINE_INDEX(META) removes the last line from the list of lines
% of the MetaBlock and returns the new MetaBlock.
list=get(meta,'Line_list');
loc=length(list);
if loc==0
return;
end
meta=remov... |
ba33e6e676cec422ed65fe8d10ee629a23bf21a18ed2a9d226f4222a27f36a65 | MATLAB | 344 | 12 | function [exponent_determined]=yticks_sci_notation_SHP(y_axis_max)
% Automatically determine exponent of y axis
for ii=-10:10
% ii
if y_axis_max/(10^ii)>1 & y_axis_max/(10^ii)<10
exponent_determined=ii;
break;
end
end
ax=gca; ax.YAxis.Exponent=e... |
db45153a77ffba818b22ec90038eb53e967c263a9bf585e2458c55b6e2d5878d | MATLAB | 345 | 30 | function jitterExamples
%
% % Jitter examples
% % default jitter is 0.3
%
% clf
%
% R = randn(20,5);
%
% subplot(2,1,1)
% notBoxPlot(R,'jitter',0.15)
%
% subplot(2,1,2)
% notBoxPlot(R,'jitter',0.75);
%
help(['NBP.',mfilename])
clf
R = randn(20,5);
subplot(2,1,1)
notBoxPlot(R,'jitter',0.15)
subplot(2,1,2)
notBox... |
8284f8ee29336e7d42270679d2e5007c71e248ecd82d847a8dfb340ab700e39f | MATLAB | 347 | 14 | function val= get(rx8,prop)
% GET Get RX8 property from the specified object
% and return the value. Property names are:
if isa(prop,'char')
switch prop
case 'Device_num'
val=rx8.device_num;
case 'Controler'
val=rx8.controler;
otherwise
treat_error('The property input must be ... |
c556fcf0c3e0914364666302a38a3f6025760556890a551cfcb8e80133322d5a | MATLAB | 349 | 9 | function m_sig=add_envelope(m_sig,env)
% ADD_ENVELOPE adds the given envelope to the given Main-Signal list of
% envelopes.
% M_SIG=ADD_ENVELOPE(M_SIG,ENV) adds the given envelope (ENV) to the end of
% the list of envelopes of this main signal.
env_list=get(m_sig,'Envelope_list');
loc=length(env_list);
m_sig=add_enve... |
6d2831fb30f457e05e26f011f39fb7d47d6421180893f521ab32b704f13771bd | MATLAB | 350 | 13 | function str_env=show_envelope(env)
% show_envelope (env) outputs a String representing the given envelope.
% str_env=show_env_list(env) returns a string representing the given envelope.
if nargout==0
s= get(env,'Name');
disp(s);
elseif nargout==1
str_env=get(env,'Name');
else
treat_error('Wrong use of s... |
2c55461e8eff44197bc9b8fabdf8538d32e3863378ed8e1f281f51894280f8f0 | MATLAB | 351 | 15 | function [V_AM, ATP_XB] = force_energy_consumption(Force, ATP_i, A, data)
Ff=data.F_f;
MaxATP=data.MaxATP;
F_f=data.F_f;
K_M_ATP=data.K_M_ATP;
Max_ATP=data.Max_ATP;
CATPi=data.CATPi;
K_M_ADP = data.K_M_ADP;
Force_ATP = 1.02./(1 + (K_M_ATP./ATP_i).*(1 + (CATPi - ATP_i)./K_M_ADP));
V_AM = Max_ATP.*F_f.*A.*Force_ATP;
AT... |
96fe546e1b908fac294b387a88de8bcbbfc8da330134e61715f0d0d38c9a75a3 | MATLAB | 352 | 21 | load('v1.mat')
load('v2.mat')
load('v3.mat')
load('v4.mat')
figure(8)
hold off
tm = (0:1/10000: (length(v1)-1)/10000)';
plot(tm,v1)
hold on
tm = (0:1/10000: (length(v2)-1)/10000)';
plot(tm,v2)
hold on
tm = (0:1/10000: (length(v3)-1)/10000)';
plot(tm,v3)
hold on
tm = (0:1/10000: (length(v4)-1)/10000)';
plot(tm,v4)
le... |
def661ac2831d5886a1fef13feea191c570adc5784babe857a446c8db215a3d9 | MATLAB | 352 | 16 | %
%
%
% Test the data density plot
%
%
x = randn(2048, 1);
y = randn(2048, 1);
x(1:512) = x(1:512) + 2.75;
x(1537:2048) = x(1537:2048) + 2.75;
y(1025:2048) = y(1025:2048) + 2.75;
% On scatter plot you probably can't see the data density
scatter(x, y);
% On data density plot the structure should be visib... |
8b677ecd8f8814f6db0cc9c0954c7b783ceb18a12b70e0b1f8ebfc5c88b53fff | MATLAB | 354 | 13 | classdef Target
%TARGET is a type-safe enumeration for stimulus reward categories.
% Stimuli can be targets that are rewarded: 'Yes_Reward', targets that
% are not rewarded: 'Yes_NoReward', or non-targets that likewise are
% not rewarded: 'No'.
% Author: Lasse Osterhagen
enumeration
Yes_Reward, ... |
b0cb87250d4038ad32d0435ecbd052ab0938dd1d9b496bf09d2232e561c108ea | MATLAB | 354 | 12 | function m_sig=remove_envelope(m_sig)
% REMOVE_ENVELOPE removes the last envelope of the list of envelopes
% of this main signal.
% M_SIG=REMOVE_ENVELOPE(M_SIG) removes the last envelope of the list of envelopes
% of this main signal.
list=get(m_sig,'Envelope_list');
loc=length(list);
if loc==0
return;
end
m_sig=... |
c307a68a81d7c1227b6d461662f936821ac26da7e6338cdca13bb3420d24a472 | MATLAB | 355 | 14 | vals=linspace(150,450,5);
hvals=ones(1,5)*250/5;
a(1)=50;
for ii=2:250
shortest=300-a(ii-1);
list=find(vals>=shortest);
rr=randi(length(list));
while hvals(list(rr))==0
disp(['too many' num2str(vals(list(rr)))]);
rr=randi(length(list));
end
a(ii)=vals(list(rr))-shortest;
hval... |
cd7c102260228e89980ba2a6e9cffdaef245c67d39d5eb4d217caa92070e818e | MATLAB | 355 | 17 | function [t] = knnThresh(adjMat,k)
%knnThresh Threshold to k nearest neighbors for each row
% Detailed explanation goes here
if size(adjMat,1) ~= size(adjMat,2)
error('Matrix not square');
end
t = false(size(adjMat));
for iRow = 1:size(adjMat,1)
[~,idx] = maxk(adjMat(iRow,:),k);
t(iRow,idx) = t... |
dd174a05f7deff7aea73148b270c9671909b0cd1a9c7e3e1883a2248dd5b78d9 | MATLAB | 357 | 11 | folders = uigetdiles('/');
for i=1:numel(folders)
temp = dir([folders{i}, '/TIFs']);
for j=1:numel(temp)
name = temp(j).name;
name = strrep(name, ' ', '');
old_filename = [temp(j).folder, filesep, temp(j).name];
new_filename = [temp(j).folder, filesep, name];
movefile(old... |
24a4b9bf0c9aaf97f5928edd0fe75ab47394d6b568b0de7bffb186d64555dc8f | MATLAB | 360 | 25 |
function FS_tiff(framerate,videodata)
% Convert FS to tiff- for 16 bit images
% WALIII
% 02.12.14
videodata = double(videodata);
files = videodata(:,:,1,:);
imwrite(uint16(files(:,:,:,1)),'myMultipageFile4.tif');
for i=2:size(files,4) %number of images to be read
imwrite(uint16(files(:,:,:,i)),'myMultipage... |
27d81f547e62693615e3ae78dd3d78d73b745693d8b8163b2d0f1687fbef4ee9 | MATLAB | 360 | 9 | function crop_riff_circle()
frame = imread('C:\logging_data\20-03-2017T\single_frame.tif',1);
[~, ~, center_x, center_y, radius] = calc_geometry(false);
imageSize = size(frame);
[xx,yy] = ndgrid((1:imageSize(1))-center_y,(1:imageSize(2))-center_x);
mask = uint8((xx.^2 + yy.^2)<radius^2);
temp = ... |
d74ddb324c9ab741883cdab3d9a74867b8c494989eb219e12a64cf4898c8c294 | MATLAB | 365 | 15 | function [CTRL, TAG]=ASLSplitControlTag(CTRLTAG)
% ClinicalASL toolbox 2023, JCWSiero
% interleave CTRL and TAG data; CTRL1..TAG1..CTRL2..TAG2..
CTRL=[];
TAG=[];
dims = size(CTRLTAG);% xdim y xim zdim tdim asl_label
odd_index=2*(1:dims(4)/2) - 1;
even_index=2*(1:dims(4)/2);
CTRL = CTRLTAG(:,:,:,odd_index);
... |
0a5f6e70ea2103aab83e3b57a2e7f45aeca5b1897be935dbc3acd83205222759 | MATLAB | 371 | 21 | classdef EventGenerator < handle
% Author: Lasse Osterhagen
events
Event1
Event2
end
methods
function sendEvent(this, evtName, evtData)
if isempty(evtData)
this.notify(evtName);
else
this.notify(evtName, evtDa... |
0f6bb4bd8a19274042c513ef581c70e428fdce7c933f396c067d67e3d31a4ea1 | MATLAB | 375 | 15 | function homePath = getHomePath()
%GETHOMEPATH returns the full path to the current user's home directory.
% The last character of the returned string is always the file seperator
% character.
% Author: Lasse Osterhagen
if ispc % Windows
homePath = [getenv('HOMEDRIVE'), getenv('HOMEPATH'), filesep];
else % Un... |
48cce536a77c10e3d1492be7ef716469d0336f9b62c69a4976d2350030d3a5b4 | MATLAB | 376 | 11 | %% Compile functions for Unbiased NLM
%
% Use this function if the precompiled MEX files do not work on your
% machine. Beware, you will need a supported compiler.
% Please, For more information, visit https://www.mathworks.com/support/compilers.
mex -v -compatibleArrayDims MIRO_image2vectors_double.c
mex -v -compatib... |
42cb44c00b46d573bcf0d193df1a9362627ad21ee685dde8bf8e5475fc93dc9f | MATLAB | 382 | 23 | function [fpn,bias,scale] = MIRO_FPN_correction(im,Parameters)
offset = Parameters.Offset;
gain = Parameters.Gain;
var = Parameters.Var;
HS = Parameters.HS;
method = Parameters.max_est_method;
%%
fpn = (max(0,im-offset))./gain;
if HS > 0
[fpn, scale,bias]= MIRO_Hotspot(fpn,HS,var,method);
else
[~,... |
7ea313df8732c4bbbff7f28fd50323748f44ba4e6b4d4d368357cd7b0ec79902 | MATLAB | 382 | 17 | function p = circle( ctr, rad, opts )
% CIRCLE draws a circle
%
% p = circle( ctr, rad, opts )
%
% circle( ctr, rad ) defaults opts to '-'
%
% 1995 Matteo Carandini
% 2002 VM added the handle as an output
% part of the Matteobox toolbox
if nargin == 2, opts = '-'; end
theta = linspace(-pi,pi);
p = pl... |
dab8899bbe0b12d102934fe71910ca2d3417b91e7a5d3507e2a23c9e3bde6063 | MATLAB | 385 | 13 | function expdata = load_session(expdata, i)
% JN 2020-04-25
expdata.row = expdata.rat_table(i, :);
out_folder_session = expdata.folders.session_folders{i};
expdata.folders.out_folder_session = out_folder_session;
% load snr times
fname = fullfile(out_folder_session, 'snr_times.mat');
S = load(fname);
expdata.snr_tim... |
5df556578233fe4bf1e8ff14123a565f02a852f7a8cd8f2b347d47db2a0b5589 | MATLAB | 391 | 7 | function [stateMap] = defaultStateMap()
%defaultStateMap Default mapping of states to more general states
stateMap = containers.Map({'N2','N3','OAAS5','OAAS4','OAAS3','OAAS2','OAAS1','W','wake','RS','RSctrl','RSpreEx','RSpostEx','RSctrlEarly','RSctrlLate','RSresolved','RSictal'},...
{'N2','N3','S','S','S','U',... |
bc52223fcec03526a3bd9f710b4c6e10a957ab2e02f71cb0c4ab69f046c74822 | MATLAB | 391 | 23 | function playing = soundIsPlaying(app)
% zerarr = zeros(1,length(app.ASIODev.ChannelMapping));
% y=0;
% for ii = 1:3
% y=y+app.ASIODev(zerarr);
% end
% n=1;
% while n==1
data='soundIsPlaying';
send(app.Qout,data);
gotMsg=false;
while ~gotMsg
[n, gotMsg]=poll(app.Queue);
end
% end
% playing = n;
if n==1 %y==0
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.