sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
17k
content
stringlengths
1
200k
54d508857a93a5d379811dafe18e8638e8fc018a0565acbc011fa78dcb3af26a
MATLAB
150
4
function gc = wgr_inv_pwGC_F(pvalue,nobs,porder); n = nobs - porder; th = 1+finv(1-pvalue,porder,n-2*porder-1)/(n-2*porder-1)*porder; gc = log(th);
9036e56f68891db093f7b7e0b877c6d0d688d4502917bda67f193d508ba62996
MATLAB
151
7
function [C]=create_timecell(ro,leng) %create_timecell(ro,leng) fn=1000; vec=-ro/fn:1/fn:ro/fn; C = cell(1, leng); C(:) = {vec}; end
4da6fd073e585eb0077406bd26440bd60ecf652b5541a9ba36ffb5fcba0d2649
MATLAB
155
7
function image_sobel_filter(data) h = fspecial('sobel'); for k=1:length(data) data{k}.image = imfilter(data{k}.image,h); end image_plot(data) end
afcaf4992915c610f852f0cc234ebc1dca3b5658ff6615c8d6d0a7011a2bcf56
MATLAB
156
8
function time = mipp_date2time(T, do_norm) % function time = mipp_date2time(T, do_norm) time = datenum(T.Date); if do_norm time = time-min(time); end
2b97050d5fb37a10e92dce8420b7b81c06facb65ee2f711afdafc76ae334b160
MATLAB
158
4
addpath(genpath('/usit/titan/u1/ash022/MAIA/')) addpath(genpath('/usit/titan/u1/ash022/gaimc/')) maia('list5000','Pwgs6dhmovlcod.scf.fasta.len5000.fasta')
0b27df0d983ceaed1900069061ffaa3bbc5e89a8f045df38016b39bbf385a583
MATLAB
159
7
function image_prewitt_filter(data) h = fspecial('prewitt'); for k=1:length(data) data{k}.image = imfilter(data{k}.image,h); end image_plot(data) end
9c71fbab03cda6cbc63ea7355625aa701b00524570e14f4052bd9fb0a6851b87
MATLAB
159
6
function opt = mipp_resQ_opt_nodt(opt) opt.resQ.lb([3 5 7 8 9]) = 0; opt.resQ.ub([3 5 7 8 9]) = 0; opt.resQ.lg([3 5 7 8 9]) = 0; opt.resQ.ug([3 5 7 8 9]) = 0;
0b68de1e658a2e33ea15578d289b49ef21e5ef17062a966bf2201a9df92a638e
MATLAB
162
5
function virtChannels=selectVirtChannels(virtChannels, index) for trial=1:size(timelockData.trial,2) virtChannels{trial}=virtChannels{trial}(index,:); end end
bdd744eb75a122c19500e448aff3229c088f8524fb3fb75d4e00c6e78930e597
MATLAB
164
5
function chunk = colorChunk(color, h, w) %COLORCHUNK create a matrix of size h * w * 3, filled with color chunk = repmat(reshape(color,1,1,[]), h, w); end
6ab0abde2ec71c4188e9253b8c81ab3ce2e888bd269d52328d8d766df6a2a086
MATLAB
166
6
function opt = mipp_resQ_opt_dki(opt) opt.resQ.lb([3 5 6 7 8 9]) = 0; opt.resQ.ub([3 5 6 7 8 9]) = 0; opt.resQ.lg([3 5 6 7 8 9]) = 0; opt.resQ.ug([3 5 6 7 8 9]) = 0;
1532284efb8aa228d1ff163c2c1bdc56c6c0bfe0f48e7880a369f81dca9535af
MATLAB
168
5
function PDC = get_true_pdc(A, nfft, fc, Ns) [~,~,~,gpdc,~,~,~,~,~,~,~] = fdMVAR(A,eye(Ns),nfft,fc); PDC=abs(gpdc).^2; % partial directed coherence PDC=mean(PDC,3); end
38760789ccdbeb6c5728aabd7a6e81189a4e1a5baa2cd03d79f2a7dbfec6248d
MATLAB
169
6
function [x2,inBetween] = error_area(mean,std,x) curve1 = mean + std; curve2 = mean - std; x2 = [x, fliplr(x)]; inBetween = [curve1, fliplr(curve2)]; end
e6bb1c7b1f82066c39050a95c2345bcec9fbf6644c9915d54e416500fceec726
MATLAB
172
7
function q = now_gwf_to_q(gwf, dt) % function q = now_gwf_to_q(gwf, dt) % % Assume gwf is given as the effective waveform. q = 2 * pi * now_gamma * cumsum(gwf, 1) * dt;
bb2c963547aa30040394d3874ebfd8bc86feaf775c5ffdceb55ba9d61a996900
MATLAB
173
8
function image_transpose(data) for k=1:length(data) for j = 1:length(data{k}.image) data{k}.image{j} = data{k}.image{j}'; end end image_plot(data) end
81689a4f80f85ee4d2ea277b1da3350285a0d55e331a43e9bc1f75b69a7b615e
MATLAB
176
10
classdef PartialVarianceType < int32 % What to partial variance from enumeration NONE (0) FCBX (1) ONLY_BX (2) ONLY_FC (3) end end
095b4911133c4531807404c59e1b006ebf9efa78151804b9a2df0c85c519b057
MATLAB
178
8
function image_flip_lr(data) for k=1:length(data) for j = 1:length(data{k}.image) data{k}.image{j} = fliplr(data{k}.image{j}); end end image_plot(data) end
0a5e0455e6fe7d78913f6e5cf313414ebd61921991da9d745838364b35ccd631
MATLAB
178
10
function r=subsref(t,s) switch s.type case '()' cols=s.subs{:}; case '.' cols=find(ismember(t.names,s.subs)); end r=t.matrix(:,cols);
9058ecab70e5c63b8ba0335d63fc7109f52232309a2760484f1697baa26cf942
MATLAB
178
6
function eta = compute_mai(H, noise_cov, data_cov) inv_noise_cov = inv(noise_cov); inv_data_cov = inv(data_cov); eta = trace((H'*inv_noise_cov*H) * inv(H'*inv_data_cov*H)); end
94b86f4809fa3600c985b5a4f5db0a68ad65e50dc9ffaef0285f55f4b656c08f
MATLAB
178
5
function parameters = shape_classification_normalized_parameters(classes) parameters = classes(:,3); parameters = vertcat(parameters{:}); parameters = zscore(parameters); end
d3fb927f697e8ef87e156a7eb7f8168409fb7f9bb4153b5ccce04af32407368d
MATLAB
178
8
function image_flip_ud(data) for k=1:length(data) for j = 1:length(data{k}.image) data{k}.image{j} = flipud(data{k}.image{j}); end end image_plot(data) end
163d7794039bc14dc999ce412f09cc3d29214a347c8b1cdcbaaaabdebe72db18
MATLAB
181
6
function h = LABEL_GAP() %LABEL_GAP The pixel gap of a label. It has to be provided by a % function because Matlab doesn't support package constants. Sad! h = 5; end
b6be30bafbe4490045d5f0d9daf9bdb81a321f277018ed08c31e5beaaf560382
MATLAB
181
6
function h = LABEL_H() %LABEL_H The pixel height of a label. It has to be provided by a % function because Matlab doesn't support package constants. Sad! h = 22; end
d63fa924bee6c008c0ed757c71dc0aed332351a34e530ce8fa0a0bbbe6d39bc8
MATLAB
183
8
classdef TriMatrixDiag < int32 % I really really don't like how this has to be in another file enumeration REMOVE_DIAGONAL (-1) KEEP_DIAGONAL (0) end end
834aaea882e9b8a0be79d49e8a7dc542592db03aa94fdfbfa5986f3671ffb55b
MATLAB
185
6
function v = VERSION() %VERSION The current version number. It has to be provided by a % function because Matlab doesn't support package constants. Sad! v = '1.0.0'; end
951676f96e08311299e5930c5181e02253debe3587e11f1ef9820d94b39a8e69
MATLAB
187
10
classdef (Abstract) IndexGroup < handle %INDEXGROUP Abstract class for passing to UI interfaces properties (Abstract) name color indexes end end
013adbb9985730065e966e583bf7dbdd49158fce79412bcca3848df931bcdf69
MATLAB
189
7
function get_capture_from_figure() [file,path] = uiputfile('*.jpeg'); if path~=0 set(gcf, 'InvertHardcopy', 'off') print(fullfile(path,file),gcf,'-dpng','-r300'); end end
badf680a2314d9f47d37ad23c9cdd5a698e883911730b75b0a18ee95d8557731
MATLAB
189
7
function y = FilterAllChannels(x,frq_band,fs) % x is a signal of shape chans * time for chans = 1:size(x,1) y(chans,:) = bandpasshopf(x(chans,:),[frq_band(1) frq_band(2)],fs); end end
119db43755f6b84ca6fc4f00c06e0d81043e2dd0a714e6e4a11945d6ef36008f
MATLAB
194
6
classdef Base methods (Abstract) [is_sig_vector, p_max] = correct(obj, net_atlas, input_struct, prob) correction_label = createLabel(obj, net_atlas, input_struct) end end
e616249801e72fb9474b2db3eb00f50b73167edd4c14fab5e61ec13210a58599
MATLAB
200
8
function image_flip_color(data) for k=1:length(data) for j = 1:length(data{k}.image) data{k}.image{j} = abs(max(data{k}.image{j})-data{k}.image{j}); end end image_plot(data) end
a92b0e16e1d482547029650750e4aa494662bbb4e2ca15500e9015b5735b94c0
MATLAB
202
9
function [newX] = scaleFunc(X) % scaleFact = 0.6*max(max(X(:)),-min(X(:))); % another way to do it % scaleFact = max(abs(X(:))); scaleFact = prctile(abs(X(:)),95); newX = X ./ scaleFact; end
df0fcfb6b27de5a7d69f4c8f677ed9ad2fa22c1f6eced38bc3cd79882d0b0571
MATLAB
204
3
function feature_signal = tc_fit_feature_template(clean_data, feature_templates) %% feature_signal = tc_fit_feature_template(clean_data, feature_templates) feature_signal = feature_templates \ clean_data;
ef015b35fd1777f75cc26edc4c123db23b138cd0c1d6ba97620a6aa0d7345ea2
MATLAB
204
11
function varargout = imrotate_slices(img,angle) % out = zeros(size(img)); for slice = 1:size(img,3) out(:,:,slice) = imrotate(img(:,:,slice),angle); end varargout{1} = out; end
d0c2295dd4087ae634944e99fc1cc05aa5f2cac8e4be7e065855086cf8176a12
MATLAB
208
11
function [m, s, medi, iqra] = mipp_table2par(datac) for i = 1:numel(datac) tmp = datac{i}; m(i) = mean(tmp(:)); s(i) = std(tmp(:)); medi(i) = median(tmp(:)); iqra(i) = iqr(tmp(:)); end
1d405786c0d469fb89984c2653eed28d6a7ce1e03920fd1e2852b8b99ddeed1d
MATLAB
209
9
function data_cov = compute_cov(Y, num_trials, T) data_cov=0; for j=1:1:num_trials data_cov = data_cov + (squeeze(Y(:,:,j))*squeeze(Y(:,:,j))'); end data_cov = data_cov./T; data_cov=double(data_cov); end
2cc3e08819a161c8d0b1df2f975de9e4fff60d15e328b1042bfa782d0df43a8c
MATLAB
211
7
classdef None < nla.edge.permutationMethods.Base methods function permuted_input_struct = permute(~, orig_input_struct) permuted_input_struct = orig_input_struct; end end end
4c156f34a35c606d7620c0de36d8c8ad97e12b8fa3dfebb001e10b70ce97af20
MATLAB
211
12
function [ftp_site, rfn] = nst_split_ftp(ftp) ftp = strrep(ftp, 'ftp://', ''); toks = strsplit(ftp, '/'); ftp_site = toks{1}; if length(toks) > 1 rfn = strjoin(toks(2:end), '/'); else rfn = ''; end end
652dceb89a88720375504d77a12eb2b217d216dbeea0f261d760195a4cd71510
MATLAB
212
6
function zscore_matrix = tc_zscore(data) %% zscore_matrix = tc_zscore(data) % % zscores values of matrix over all dimensions and rearranges to orignal % shape zscore_matrix = reshape(zscore(data(:)), size(data));
8b4b22a6c17a758f7f781d5847f51d3185841f65a0d6671432f25179065899bb
MATLAB
215
6
function template_names = nst_core_get_available_templates() %TODO: add descriptions template_names = {'Colin27_4NIRS', ... 'Colin27_4NIRS_lowres', ... 'Colin27_4NIRS_Jan19'}; end
9b9c48f1af1647a52e88761c5b648bd84a9e9c6fab70ed29c89ff6e15bf3c3b8
MATLAB
217
7
function m = ACCURACY_MARGIN() %VERSION The margin of accuracy for comparing test statistics. It has % to be provided by a function because Matlab doesn't support package % constants. Sad! m = 0; end
9a5463e1b3e5a141078f7bb7d7d23c91d1f57fea0d4c7d9b3b51d4a4a62b8ca0
MATLAB
219
6
function formats = nst_get_formats() formats.pair_re = 'S(?<src_id>\d+)D(?<det_id>\d+)'; formats.pair_fmt = 'S%dD%d'; formats.chan_re = [formats.pair_re '(?<measure>WL\d+|HbO|HbR|HbT)']; formats.pair_fmt = 'S%dD%d'; end
cf68615e23d689953a9bac723a0119df4ac4211c8dea25f06531b0a049afc374
MATLAB
223
6
data=xlsread('P:\begrenset\HUNTER\MR-metabolomics\NMR_all_cancer_types.xlsx'); dataval=data(2:37,1:66) [coefs,score] = pca(zscore(dataval)); [coefs,score] = pca((dataval)); biplot(coefs(:,1:2),'scores',score(:,1:2))
2e3b60c2364d2424805b9f563f20982a7b5eae1827912485fad0d66688ebb596
MATLAB
224
8
function [str, valid] = validateInputStruct(inp, str, valid) for i = 1:numel(inp) if ~inp{i}.satisfied valid = false; str = [str sprintf('\n - ') inp{i}.disp_name]; end end end
3bf786342821fa14b6c4b9665074c0942aeb277e4cb2ddf5a9bca974f7bafe83
MATLAB
226
6
function normalized = normClipped(x, llimit, ulimit) %NORMCLIPPED clip something between two limits and normalize to 0-1 clipped = min(max(x, llimit), ulimit); normalized = (clipped - llimit) / (ulimit - llimit); end
4c9323da101d165dfd16826c256be17d4a24d0be376e09d19db169b08c249f12
MATLAB
226
13
function save_fig(h,fname) %function save_fig(h,fname) % wrapper for export_fig % % assumes plot is still up % makes plot with a transparent background set(h,'Color','w'); export_fig(h,fname); % matlab central function end
effb62efd879344fdbf1468c967a93b7e6fb2e4dace29b699cd3c2e6f9c91666
MATLAB
229
6
function usageError(err) %USAGEERROR Throw an error with a message explaining how to use the % mex.run function. error("%s\nmex.run usage: [val1, val2, ... valN] = mex.run(func_name, arg1, arg2, ... argN)", err) end
8ed6049a9161a12dba50ecfccd07fadc07b95bf1c069ac5648c63f5dd71b0caf
MATLAB
233
11
function [theta]=extremal_Sueveges(Y,p) u=quantile(Y, p); q=1-p; Li=find(Y>u); Ti=diff(Li); Si=Ti-1; Nc=length(find(Si>0)); N=length(Ti); theta=(sum(q.*Si)+N+Nc- sqrt( (sum(q.*Si) +N+Nc).^2 -8*Nc*sum(q.*Si)) )./(2*sum(q.*Si)); end
a801868316104b7b5d7b5dfa987ecc39061e44036963cee6be8e02547fd6be79
MATLAB
233
6
function z = fisherR2Z(r) %FISHERR2Z Transforms r-value data into z-value data via the % transform: z = 1/2 ln([1+r]/[1-r]) = arctanh(r) % z = arctanh(r); z = 0.5 .* (log(1 + r) - log(1 - r)); z(~isfinite(z)) = 0;
4cb0923a5dece7f8aaa4dbff00634d598d9585fb2d56f3e128d7fdadcd20268c
MATLAB
236
10
function O = mean_D(S) O = []; addpath('/projects/MINDLAB2017_MEG-LearningBach/scripts/osl/osl-core'); %this add the path (not necessary being in the osl-core directory if you have this one) osl_startup D = spm_eeg_average(S); end
2541033c7745b02a9139cf8184d9c7fde9d01e45996b2c9b83c5892a92c3086e
MATLAB
239
6
function [dist_vec, id] = find_nearest_id(pnts,pos) %UNTITLED2 Summary of this function goes here % Detailed explanation goes here dist_vec=sqrt(sum((pnts - repmat(pos,[ size(pnts,1) 1])).^2,2)); id = find(dist_vec == min(dist_vec)); end
140db85fab22b73004c411e683c934633e0fe6cf23cfffac2a863b7543cf2209
MATLAB
243
11
%%%% EXTERNAL FUNCTION % function taken from the LiNGAM package % complete software may be downloaded from http://www.cs.helsinki.fi/group/neuroinf/lingam/ function q = iperm( p ) for i=1:length(p) q(i) = find(p==i); end
84d180523ad14495bb70fd671db156f4ef0b4fc9de2825348c9a80225ee5579a
MATLAB
245
14
if ~isdir('data') mkdir data mkdir data\new mkdir data\original mkdir data\simulated mkdir data\new\raw mkdir data\new\processed mkdir data\original\processed mkdir data\simulated\processed end
9563e4602d9a3791cd7b121e48d73d271df239ff6a920ddb4a868a59c23964e5
MATLAB
245
15
function O = filtering(S2) O = []; addpath('/projects/MINDLAB2017_MEG-LearningBach/scripts/osl/osl-core'); %this add the path (not necessary being in the osl-core directory if you have this one) osl_startup D = spm_eeg_filter(S2); end
31a933976263d0b643449642cb47770298906441e412d26b8f5901cbeb57b8d0
MATLAB
247
7
function col = valToColor(x, llimit, ulimit, color_map) %VALTOCOLOR map values to color map x_indexed = int32(ceil(nla.helpers.normClipped(x, llimit, ulimit) * (size(color_map, 1) - 1))); col = ind2rgb(x_indexed, color_map); end
b2212ce6d60cfd22eb6ae3e3919d0f7ac79057952ed66dab96e578de19543e99
MATLAB
248
11
function O = cluster_spmobject(S) O = []; addpath('/projects/MINDLAB2017_MEG-LearningBach/scripts/osl/osl-core'); %this add the path (not necessary being in the osl-core directory if you have this one) osl_startup D = spm_eeg_convert(S); end
11f9194a3377b9ab9015f03077000a996aad280b286552f995a214c996e92eef
MATLAB
249
10
function c = mergeStruct(a, b) %MERGESTRUCT Merge two structures, with the second overwriting the first if %they set the same key c = a; fnames = fieldnames(b); for n = 1:numel(fnames) c.(fnames{n}) = b.(fnames{n}); end end
fc386ef9c5e6d9323ea669f880efdbfc67f0bf5b5fb9ffee2c39bd6247d41a8d
MATLAB
249
10
classdef (Abstract) AbstractSwEStdErrStrategy < handle methods stdError = calculate(obj, SwEStdErrInput) %input is SwEStdErrorInput object, output is 2D matrix (numCovariates x numFcEdges) end end
35d2c893c4759a644a76ed5dc5b214bd5ca508ab245d59580994f704e1e4addb
MATLAB
252
11
function O = cluster_merging(S) O = []; addpath('/projects/MINDLAB2017_MEG-LearningBach/scripts/osl/osl-core'); %this add the path (not necessary being in the osl-core directory if you have this one) osl_startup D = spm_eeg_merge(S); D.save(); end
36565560b423937646f8cd656acaa4214efcb1aadb65d5c57556acebb8a3db2a
MATLAB
252
15
function O = downsampling(S2) O = []; addpath('/projects/MINDLAB2017_MEG-LearningBach/scripts/osl/osl-core'); %this add the path (not necessary being in the osl-core directory if you have this one) osl_startup D = spm_eeg_downsample(S2); end
4de04e19bd28450da7bcdde65c9affb62fb1a09443375cf167f43235476fe042
MATLAB
253
12
function O = cluster_epoch(S) O = []; addpath('/projects/MINDLAB2017_MEG-LearningBach/scripts/osl/osl-core'); %this add the path (not necessary being in the osl-core directory if you have this one) osl_startup D = spm_eeg_epochs(S); D.save(); end
ee0ebc4776e654110227f968466d59554294e419544648540931e3e65dbf09c5
MATLAB
253
8
function FC_project = get_nroi(FC_project) disp('Getting number of ROIs...') cd(FC_project.CONN_results_dir) FC_project.nroi = numel(load('resultsROI_Subject001_Condition001.mat').names); disp(['Number of ROIs = ',num2str(FC_project.nroi)]) end
355849b0003d62c5f2e9172d63988b131530af3dc3340b17f5ea604f6c2d4077
MATLAB
254
10
classdef DeepCopyable < handle methods function new = copy(obj) %COPY Deep copy of an object objByteArray = getByteStreamFromArray(obj); new = getArrayFromByteStream(objByteArray); end end end
6fd21bc511bf99687dcf1a8d13eaaebc7debbb709ba270556bbca1bd0feb7cba
MATLAB
256
10
function total_size = get_size(data) %size of structured data in MB names = fieldnames(data); total_size = 0; for i=1:numel(names) var = getfield(data,names{i}); s = (whos('var').bytes)/(1024^2); total_size = total_size + s; end end
4d09108b3f1aa1946b795869eef231812232bd6b6e44d92ad82f70391b97aa58
MATLAB
258
9
function data = loc_list_make_same_color(data) f=waitbar(0,'Changing Coloe Value'); for i=1:length(data) data{i}.area = 0.7*ones(length(data{i}.x_data),1); waitbar(i/length(data),f,'Changing Coloe Value'); end close(f) loc_list_plot(data) end
ec6f708cb913d8743cf878aca65993e14f07e7a390420c51293107f91077e783
MATLAB
258
9
classdef Integer < nla.inputField.Number methods function [w, h] = draw(obj, x, y, parent, fig) [w, h] = draw@nla.inputField.Number(obj, x, y, parent, fig); obj.field.RoundFractionalValues = 'on'; end end end
1d2617649775ce1c8617c55ac91f7b615ba62eaaa0628bdca51147b2c129d189
MATLAB
259
13
function s_pval = nst_format_pval(pval) if pval < 0.001 s_pval = sprintf('%1.1e', pval); elseif pval < 0.01 s_pval = sprintf('%1.3f', pval); elseif pval < 0.1 s_pval = sprintf('%1.2f', pval); else s_pval = sprintf('%1.1f', pval); end end
fc5f51a73babef86534a53bfe460ab99290f6e1b6a14a88c9f5363e7801897cd
MATLAB
263
8
%% LODIST from http://online.liebertpub.com/doi/full/10.1089/cmb.2011.0052 [lcs sas na]=PairLcs;%('C:\Users\animeshs\SkyDrive\matlab_toolbox\LODIST\testseqs.fasta') [distmatrix,asydistmatrix]=DistMat(lcs,[500,50],3) %% Ecoli genomes [lcs sas na]=PairLcs
519fb7aeed80c98dfb609290e1d12448d22739a76052bd7629f61cdb13ad191d
MATLAB
264
12
function [n, nt, H] = now_cross_term_sensitivity(result) % function [n, nt, H] = now_cross_term_sensitivity(result) gwf = result.g; rf = result.rf; dt = result.dt; qt = now_gwf_to_q(gwf, dt); H = now_gamma * cumsum(rf)*dt; nt = cumsum(qt.*H)*dt; n = nt(end,:);
85ef3df6a5185cf95c89e38a6debcbaf00a26490cfa908e5818063096ddcd8da
MATLAB
266
10
function [f ,g] = objFun(x) f = -x(end); %fmincon minimizes the objective, so a minus sign is used to maximize instead g = zeros(size(x)); g(end) = -1; OptTime = toc; if OptTime > (length(g)^2/.5e3) error(['Timed out after ' num2str(OptTime) ' seconds!']); end
7fa5ef089d66b9c743b92392c603c4f033ab4ee7639ce2cc22582d1782997e19
MATLAB
267
9
function pvalue = wgr_pwGC_F(gc,nobs,porder) n = nobs - porder; TH = exp(gc); THnew = TH-1; THnew2 = THnew/porder*(n-2*porder-1); pvalue = fcdf(THnew2,porder,n-2*porder-1); end % th = 1+finv(1-pvalue,porder,n-2*porder-1)/(n-2*porder-1)*porder; % gc = log(th);
8d9562aaed67f9edebe9e0426df501cfb5235f6669ef2c37efa54a1195c303c4
MATLAB
267
12
function W = nst_math_fit_AR(x,M) % Autoregressive all-pole model parameters using Yule-Walker equation % W = aryule(x,M); r = xcorr(x,'biased')'; r(1:length(x)-1) = []; R=toeplitz(r(1:M)); W=R\(-r(2:M+1)); W=[1 W']; end
63b2b77384058844bacab159815002776a001858f3c5542f9c4cd5c1ca4d661f
MATLAB
268
12
function [data, A] = gen_mvar_data(A, T, T0, P, M) %UNTITLED Summary of this function goes here % Detailed explanation goes here x=randn(M,T+T0); y=x; for i=P+1:T+T0 yloc=reshape(fliplr(y(:,i-P:i-1)),[],1); y(:,i)=A*yloc+x(:,i); end data=y(:,T0+1:end); end
ccaa012df56ca35463de60362f00839b4e680ad49440876c41376d56763b12af
MATLAB
278
12
function []=findtroisize(valimg, maskimg, N) [infoval, dataval]=read4dfp(valimg); [infomask, datamask]=read4dfp(maskimg); data=dataval(datamask>0); data=sort(data(:),1,'descend'); t=data(N+1); fid=fopen('findtroisize_threshold.txt', 'w'); fprintf(fid,'%f\n',t); fclose(fid);
da09fe434962a6fc90a11c623dbabfc10d795376ebdcfced1a5b8e7b21fc8f1c
MATLAB
279
7
function image_plot_mouse_up(data,name) imagesc(data) colormap(gray) title({'',regexprep(name,'_',' ')},'Interpreter','latex','fontsize',14) set(gca,'TickDir','out','TickLength',[0.02 0.02],'FontName','TimesNewRoman','FontSize',12,'TickLabelInterpreter','latex') box on end
6099fa5500be2eef042a074c0eacbbe3aff71e45035b6313693bdf9e130d142e
MATLAB
284
12
function O = clusterbasedpermutation_osl(S) O = []; addpath('/projects/MINDLAB2017_MEG-LearningBach/scripts/osl/osl-core'); %this add the path (not necessary being in the osl-core directory if you have this one) osl_startup [ gstats ] = oat_cluster_permutation_testing(S); end
cca2750a1211410abf325a622b7db6c15a8343ed550ee062d97da4b60a5cc87c
MATLAB
284
17
function s = getrefsize(contig) % Get the size of a reference node assuming name 'refnode_pos1_pos2' r = regexp(contig.name,'_','split'); pos1 = str2num(r{2}); pos2 = str2num(r{3}); if pos1 >= pos2 s = 0; else s = pos2 - pos1; end end
09dc8e836266629ad88e15608612ad41f6599e1f8f05ea1f376718f860f3b6f2
MATLAB
285
11
classdef SwEStdErrorInput properties scanMetadata nlaEckDev.swedata.ScanMetadata residual % [numObservations x numOutputVectors] pinvDesignMtx % pseudoinverse of design matrix [numCovariates x numObservations] end end
83b0058fa86a635faaf2f0d653327b702c18be470b409f06aabfbb74d1a5d9e1
MATLAB
286
8
function a = angle_dist_nc(p2, p1) %function to calculate the angle on the sphere going from from OP1 to OP2 %for a companion function, see RotateAboutAxis %equivalent in SUMA code is macro : SUMA_ANGLE_DIST_NC m_cr = cross(p1, p2); a = atan2(sqrt(sum(m_cr.^2)),dot(p2, p1)); return;
36432d32d6eda372b4dd87de11043529a71fefe4931e7589a0ea436d7472b42d
MATLAB
289
7
function [link,distance,cophenet_value] = shape_classification_finding_linkage(parameters) disp('Calculating Linkage') distance = pdist(parameters); link = linkage(distance,'average'); cophenet_value = cophenet(link,distance); disp(['Cophenet Value = ',num2str(cophenet_value)]); end
468cf353446709dc335079a9a7ac57631e732cea4196aa99131a0e1f996fc20b
MATLAB
290
6
SetOptions[$FrontEndSession, PrivatePaths -> {"SystemResources" -> {ParentList}, "TextResources" -> {FrontEnd`FileName[{"/export/data/animesh/matica8/AddOns\ /Applications/WolframAlphaClient/./FrontEnd", "TextResources"}, "PacletManager" -> True, "Prepend" -> True], ParentList}} ]
cc8f314b7a36af9ffadb0516a7743a2c0ddb1406e0e5478389b4238765d426ae
MATLAB
290
14
function hideAxes(ax) %HIDEAXES Hide axes borders and tick marks % ax: axes to modify ax.Box = 'off'; ax.XTick = []; ax.YTick = []; ax.XColor = 'w'; ax.YColor = 'w'; ax.TickDir = 'out'; ax.Visible = 'off'; disableDefaultInteractivity(ax) end
bf65d57cc332f0dabc95c05eb27b2aca6fc8fcb4bec172446b117f3aa8b36a1f
MATLAB
291
16
clear clc maindir = '\\uw.lu.se\research\msf_fsz\Data\MIPCART\Pilot MRI\'; %% Data conversion % Conversion in DSI studio % bpv_pv2nii_batch(maindir) %% Denoising and motion correction mipp_run_preprocess(maindir, '*DWEpiWavev7_MAGNITUDE.nii.gz') %% model fitting mipp_run_estimation();
c4b948cc01cf29614a9b14540daa870b294ae5312b4d8a4736067fc3866b8720
MATLAB
291
11
function matching = findMatching(str) %FINDMATCHINGFILES Find files matching the given pattern, returns a % string array of matching files dir_list = string(ls(str)); if strlength(dir_list) > 0 matching = split(dir_list); else matching = {}; end end
dc1e814f69fe42d3436ace1020651b20987e8e1dbbe233079b911eaf09bec5cb
MATLAB
291
9
function model = nst_glm_initialize_model(time) model=struct('X',[],'reg_names',{},'n_roi',0,'time',[],'hrf',[],'accept_filter',[], 'ntime',0,'fs',0); %inizialize the structure model(1).time=time; model(1).ntime=length(time); model(1).fs=1/(time(2)-time(1)); end
c0260ac285ee583f28cb90724ede3010f1ca2de8a5808c13018e55f013b75eeb
MATLAB
293
18
function gamma = now_gamma(nuc) % function gamma = now_gamma(nuc) % % Returns the gyromagnetic constant for given nucleus in units of 1/s/T. if nargin < 1 nuc = 'H'; end switch nuc case 'H' gamma = 42.6e6; otherwise error('Nucleus not recognized') end
ab7862ae27ff3189d2fd71573160a3f2dac9c9ba5be64f73d10aa837f8303266
MATLAB
294
10
function handle = firstInstanceOfClass(arr, class_name) %FIRSTINSTANCEOFCLASS find the first instance of a class in a cell vector handle = false; for i = 1:size(arr, 2) if strcmp(class(arr{i}), class_name) handle = arr{i}; return end end end
b7dc316cf78fb2b4c92bc34ecc12cbd1b23c5d81ca935b4363f03e986b5cad7a
MATLAB
298
11
[A,map,alpha] = imread('C:\Users\animeshs\Desktop\IMG_20130620_112511.jpg'); image(A) p=ginput(2) sqrt(sum((p(:,1) - p(:,2)).^2)) %% source http://www.mathworks.se/help/matlab/ref/imread.html http://stackoverflow.com/questions/10695747/distance-between-two-points-in-a-image-in-matalb
ccfe80676310efe32bd0d661ae0793b0a6bcaad4afd67dcd4eae664ea561e074
MATLAB
298
16
function version = nst_get_version() %NST_GET_VERSION Return the current version of NIRSTORN version = 'github-master'; major=0; minor=0; patches=0; path = fileparts(which('process_nst_mbll.m')); id = fopen(fullfile(path, '..','VERSION')); str=fread(id,'*char' )'; version = str(9:end-1); end
7495631fcee0eadd7395fd123efc00e851408fa8e4d87eae813823a698de9bc0
MATLAB
299
13
function O = cluster_subjlevel(oat) O = []; addpath('/projects/MINDLAB2017_MEG-LearningBach/scripts/osl/osl-core'); %this add the path (not necessary being in the osl-core directory if you have this one) osl_startup oat = osl_check_oat(oat); oat.to_do = [0 0 1 0]; oat = osl_run_oat(oat); end
419235d988908835573e538e60ab3df0436f5280c8d6bd2924e0abd79884cbaa
MATLAB
300
10
function [S] = suff_stats_fast(S, q_ks, q_ks1, Y_, M_t_s, N, nq, ny, w_1) x_t_hat = zeros(3*nq+ny, N); x_t_hat(1:nq,:) = q_ks; x_t_hat(nq+1:2*nq,:) = q_ks1; x_t_hat(2*nq+1:ny+2*nq,:) = Y_; x_t_hat(2*nq+1+ny:end,:) = q_ks; x_t_hat_w = w_1.* x_t_hat; S = S + (x_t_hat_w * x_t_hat' + M_t_s); end
0495149a318cab3f7c9718977ae690c73a9aabea553f67bc18681967d8688abd
MATLAB
301
13
function O = cluster_beamforming(oat) O = []; addpath('/projects/MINDLAB2017_MEG-LearningBach/scripts/osl/osl-core'); %this add the path (not necessary being in the osl-core directory if you have this one) osl_startup oat = osl_check_oat(oat); oat.to_do = [1 0 0 0]; oat = osl_run_oat(oat); end
47a06be203340fe761ce59663832a60f5fda96969bd07c0e8e326e0475cd9c26
MATLAB
302
9
function d = pointDist(p1, p2) %POINTDIST Calculate euclidian distance between points % p1: 2-tuple containing x and y coordinates of point % p2: 2-tuple containing x and y coordinates of point d_x = p1(1) - p2(1); d_y = p1(2) - p2(2); d = sqrt((d_x ^ 2) + (d_y ^ 2)); end
c3dee86947452a0ec3b31bfb387840891f15f7d0f92195c2a62752cd1890975b
MATLAB
302
11
function saveErrorObjInTimestampedMatfile(saveFolder, errorObj) nowTime = datetime; nowTime.Format = 'yyyyMMdd-hhmmss'; errFilename = sprintf('error_%s.mat',nowTime); errFullFilename = fullfile(saveFolder, errFilename); save(errFullFilename, 'errorObj'); end
e10510d1285bce0dac74b38918c9626b7463c67eb206f62602b3ea04913a9f6b
MATLAB
303
13
function O = cluster_beamsubjlevel(oat) O = []; addpath('/projects/MINDLAB2017_MEG-LearningBach/scripts/osl/osl-core'); %this add the path (not necessary being in the osl-core directory if you have this one) osl_startup oat = osl_check_oat(oat); oat.to_do = [0 0 1 0]; oat = osl_run_oat(oat); end
b6821cd0633c09863625115fb91677a958926ae52e6ff7f0f8e3cd214627ee17
MATLAB
304
13
function O = cluster_beamfirstlevel(oat) O = []; addpath('/projects/MINDLAB2017_MEG-LearningBach/scripts/osl/osl-core'); %this add the path (not necessary being in the osl-core directory if you have this one) osl_startup oat = osl_check_oat(oat); oat.to_do = [0 1 0 0]; oat = osl_run_oat(oat); end
b7e932fd54aa007ae2115708c371e253bc14fa69db5ae766a8d333924130a3c7
MATLAB
307
11
function [poly_area,boundary_points] = loc_list_calculate_boundary_area(x,y) try k = boundary(x,y); boundary_points(:,1) = x(k); boundary_points(:,2) = y(k); poly_area = polyarea(boundary_points(:,1),boundary_points(:,2)); catch poly_area = 0; boundary_points = []; end end
16065c82d0525223580054a13f5bbf546789e10bc7646633d6f6cc2adf8d2f1c
MATLAB
308
8
function c = nst_math_dctmtx(n) % Create a DCT matrix, see % https://www.mathworks.com/help/images/ref/dctmtx.html % Simimar output as: %cmat = dctmtx(nsamples)'; [cc,rr] = meshgrid(0:n-1); c = sqrt(2 / n) * cos(pi * (2*cc + 1) .* rr / (2 * n)); c(1,:) = c(1,:) / sqrt(2);
9c156cfc409c3fd3846aa48a27a51af6831b6d9388c3e7be5d10e411eb8baa6a
MATLAB
314
19
%% simulate fMRI a=0; b=1000; alpha=-2/3; n=rand(1000000,1)'; r=(a.^(alpha+1)+n*(b^(alpha+1)-a.^(alpha+1))).^(1/(alpha+1)); plot(n,r,'.'); hist(n); hist(r); %% simulate EEG a=0; b=1000; alpha=-2/3; n=rand(1000000,1)'; r=(a.^(alpha+1)+n*(b^(alpha+1)-a.^(alpha+1))).^(1/(alpha+1)); plot(n,r,'.'); hist(n); hist(r);
a63a38134ac9a23481ae49df6cded35bfeb0cc06dd1a91d52aa57014de08b48b
MATLAB
315
14
function display(t) disp(' '); if isempty(t.matrix) disp('[]'); else d=[]; n=size(t.matrix,1); for k=1:length(t.names) d=[d repmat(' ',n+1,1) strvcat(t.names{k},num2str(t.matrix(:,k)))]; end d=[d(1,:); repmat('-',1,size(d,2)); d((1:n)+1,:)]; disp(d); end disp(' ');
bff99f722f0de80d4e4d4717e301c96778b56915e7fde1ebab0c9755a953e734
MATLAB
320
12
function loc_list_change_colormap_limits() ax = gca; c_lim = ax.CLim; input_values = inputdlg({'c-min:','c-max:'},'',1,{num2str(c_lim(1)),num2str(c_lim(2))}); if isempty(input_values)==1 return else clim(1)=str2double(input_values{1}); clim(2)=str2double(input_values{2}); caxis(clim); end end
a7801f1ddcb9864ad096a60212ae8a442edc67769990d1cd545a6735eff82fc9
MATLAB
321
11
classdef HistBin % Logarithmic histogram bins for probabilities. properties (Constant) BIN_COUNT = 10000 EDGE_COUNT = nla.HistBin.BIN_COUNT + 1 EDGES = [0; logspace(-200, 0, nla.HistBin.BIN_COUNT)'] SIZE = [nla.HistBin.BIN_COUNT, 1] SMALLEST_POS_EDGE = 1e-200 end end ...