sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
53406505e677ba9fc9d04d3953f5ec0b6d43905d842657811c8e24717100de0f
MATLAB
1,570
43
function actImg = calcActivityOverviewImg(pixCov, diags, h, w) % actImg = calcActivityOverviewImg(pixCov, diags, h, w) calculates an image % displaying the variance of the correlation of a pixel with its neighbors, % which gives a visual impression of where active cells are. C = corrcovDiag(pixCov, diags); actStd = st...
cc9dc188b1580654c9a57c4ba4b8756395d3f6f983048974f0fe1c04baa0d51f
MATLAB
1,575
53
function [loss,gradients,mseF1,mseF2,mseF3,mseF4,mseF5]=modelLoss(parameters,net1,net2,CP,CB1,CB2,CBIC,CBt,U0,Ux0,w1,w2,w3,w4,w5) net1.Learnables=parameters(1:6,:); net2.Learnables=parameters(7:end,:); % make predictions U=forward(net1,CP); vel=forward(net2,CBt); gradientsU=dlgradient(sum(U,"all"),CP,EnableHigher...
06eb75b3663e179ddb2cf653c9be778fb41d1672a3b8972995dfc373b176d40e
MATLAB
1,609
65
function Ahat = nearestSPD(A) % nearestSPD - the nearest (in Frobenius norm) Symmetric Positive Definite matrix to A % usage: Ahat = nearestSPD(A) % % From Higham: "The nearest symmetric positive semidefinite matrix in the % Frobenius norm to an arbitrary real matrix A is shown to be (B + H)/2, % where H is the symmetr...
be750086bd37357f3a817d0947bc02fb25e90e232d6218c2f842cb0d5b391efc
MATLAB
1,612
51
function [u,flag]=pme2d_rhs(dt,u0,xpt,template) np=length(xpt); dx=xpt(2)-xpt(1); u=u0; flag=0; while 1 res=zeros(np+2,1); ajac=sparse(np+2,np+2); i=1; res(i)=u(i); ajac=ajac+sparse(i,i,1,np+2,np+2); i=2:np-1; res(i)=(u(i+1).^2+u(i-1).^2-2.*u(i).^2)./dx.^2.*...
8759dcb088b0ea9800089b42464a152581a94f508e5ca66bb1d453acd10337e8
MATLAB
1,618
44
function centers = randomly_distribute_centerpoints(numberofpatterns, GridSizeN, PatternLength) % Generated by LLM %RANDOMLY_DISTRIBUTE_CENTERPOINTS Randomly place segment centers in an NxN area. % % centers = randomly_distribute_centerpoints(numberofpatterns, GridSizeN, PatternLength) % % Inputs: % numberofpatterns ...
fdf2d90150a8ae3ca821c56bb7992b34dbdd1f6fabd7797c590da9c92c1bdcec
MATLAB
1,633
39
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % function assignParams(opts,params) % % Assigns all of the fields of the struct params to variables in the % caller's workspace. Used for overwriting defaults with parameter inputs. % Note that it expects 'opts', which is a list of poss...
d22e32b403998ea510fe805ee9e22d8a3e1e5a32c2dbef28a0b1b85d0897577f
MATLAB
1,639
71
function [perf_s awhist spwhist choice_s audp]=model_CNO(delta1,delta2,aw,spw,side,cnoeffect); perf_s=[]; choice_s=[]; awhist=aw; spwhist=spw; audp=[]; for i=1:length(side); percept_rate=binornd(1,cnoeffect); p=aw/(aw+spw); audp=[audp;p]; awspw=binornd(1,p); if awspw==1; ...
361cfdcaf37e60862586e2a429df5682bdc2e739c02383f0b92582a85e231690
MATLAB
1,697
41
function [T2_map, S0_map] = T2_fit(x_dim, y_dim, z_dim, sub_boli_number, echotimes, average, gmmask) T2_map = NaN(x_dim, y_dim, z_dim, sub_boli_number); S0_map = NaN(x_dim, y_dim, z_dim, sub_boli_number); % Define the function for fitting func = @(TE, S0, T2) S0 .* exp(-TE ./ T2); for z = 1:z_dim...
54d07f8bdc314531170433790fa3bc0084943dc88d0e264fe9b807868b8fa6df
MATLAB
1,697
53
function populateMovieList(obj,firstMov) %Function to add all movies with same base name to the Movies field, %using the addMovie method for error checking [movDir, movName movExt] = fileparts(firstMov); movName = [movName,movExt]; trueCounters = []; potentialCounters = find(movName == '1'); ...
74beb02a11fd09c1d0140605cbf4f303ac2fe02ddf4d495cff8b547193a9c1f9
MATLAB
1,714
50
function ref = meanRef(obj, movNums, sliceNum, channelNum, isAvg, isNormalize) % Constructs a mean reference image of an acquisition after motion % correction using the derived data structure, without requiring % loading movie files % % ref = meanRef(obj,movNums,sliceNum,channelNum) % % mov...
0ae12ef640f06adae89f7ac993402f9a6d940e3778f57c65ed133c3204cc1072
MATLAB
1,749
58
function cbScrollwheel(sel, ~, evt) %Allows interactive adjustment of the number of clusters / cuts to perform % No region has been selected yet: if isempty(sel.disp.cutVecs) return end %Determine scrolling direction and update cluster count accordingly nEigs = size(sel.disp.cutVecs, 2); if strcmpi(evt.Source.Cu...
19f0dbc2550ff5f4a80d826ed2211559afcfdcc6424a3d0e9e5641025507e4a3
MATLAB
1,766
62
function outFile = ft_Orthogonalized_wPLI(roiFile, freqLabel, freqRange, varargin) % Recompute debiased wPLI after symmetric orthogonalization of ROI time series. p = inputParser; p.addParameter('FTPath','',@(x)ischar(x)||isstring(x)); p.addParameter('Fs',600,@(x)isnumeric(x)&&isscalar(x)); p.addParameter('OutFile',''...
742131c77a631e88ed8194e60ffcc85ffec5f74fbd8c6778f3d5b8358aee1d69
MATLAB
1,770
42
function doManualROI(sel) %Turn off figure click callback while drawing ROI set(sel.h.fig.main, 'WindowButtonDownFcn', []), title(sel.h.ax.roi, 'Drawing Manual ROI'); %If a poly somehow wasn't deleted, do it now if isfield(sel.disp,'manualPoly') && isvalid(sel.disp.manualPoly) delete(sel.disp.manualPoly) end %Dra...
56d70acd6e2dd41aa5fe1fb768af84eccd5af7aa05c1431d7d7435b944ccf5fc
MATLAB
1,790
79
numLayers = 3; numNeurons=20; layers=featureInputLayer(2); for i=1:numLayers-1 layers = [layers fullyConnectedLayer(numNeurons) tanhLayer]; end layers = [layers fullyConnectedLayer(1)]; net1=dlnetwork(layers); net1 = dlupdate(@double,net1); % Collocation points ti=li...
1182b1ca456cf9db6e80fe45f7fe06bc1ada0dc89e39b0c36bdc792f45376fd9
MATLAB
1,797
65
function [covMat, qNhInd] = mmCovMat(pixCov, h, w, nh, qRow, qCol) persistent mem queryCols indBlock2Diag covMatDiagsInd if isempty(mem) mem.h = h; mem.w = w; mem.nh = nh; else if ~(h==mem.h && w==mem.w && nh==mem.nh) % If any of these have changed, we need to re-calculate persistent %...
d285b510da1f5d55bdc19b8093cfda0672f6a5f0a230a63df9ae023ceeb5a7c9
MATLAB
1,797
59
function [loss,gradients,mseF1,mseF2,mseF3,mseF4,mseF5,mseF6]=modelLoss(parameters,net1,net2,CP,CB1,CB2,CBIC,CBt,U0,w1,w2,w3,w4,w5,w6) net1.Learnables=parameters(1:6,:); net2.Learnables=parameters(7:end,:); % make predictions U=forward(net1,CP); AB=forward(net2,CBt); gradientsU=dlgradient(sum(U,"all"),CP,EnableHi...
57d93e83d9b6249b44006ece94473af735aabe2fe2deaad4be8ee7dd58f6be11
MATLAB
1,799
59
function [loss,gradients,mseF1,mseF2,mseF3,mseF4,mseF5,mseF6]=modelLoss(parameters,net1,net2,CP,CB1,CB2,CBIC,CBt,U0,w1,w2,w3,w4,w5,w6) net1.Learnables=parameters(1:8,:); net2.Learnables=parameters(9:end,:); % make predictions U=forward(net1,CP); AB=forward(net2,CBt); gradientsU=dlgradient(sum(U,"all"),CP,EnableHi...
382c5fd79c4c2f92f9a6ad6bfe0c3ff083d4f9e3f9e7f540ff3eb278ba7d5789
MATLAB
1,801
51
function u=burgers_rhs(dt,u0,xpt,template,dtemplate) np=length(xpt); dx=xpt(2)-xpt(1); u=u0; while 1 res=zeros(np+2,1); ajac=sparse(np+2,np+2); i=1; res(i)=0.01.*(2.*u(i+1)-2.*u(i))./dx.^2+u(np+1).*u(i)-(u(i)-u0(i))/dt; ajac=ajac+sparse(i,i,-1/dt+u(np+1) - 1./(20.*dx.^2),np+2...
3d08fbccbb97e4d6dcc3b163030bbd1234d7aa93224fa70c19d54bd85e743eae
MATLAB
1,806
47
function subjData = loadData(numSubjects, baseDir, alignType,taskType,dataType,curr_parc,scanIds,numTRs) % Function to load data for either 'rest' or 'movie' condition for scanId = scanIds if strcmp(taskType,'rest') numTR = 1800; else numTR = numTRs(scanId); end if strcmp(dataType,'gra...
22fd86511baabb86de6fd38d2d5a11b78317eeef3d60eafc1d259d8657e2f6da
MATLAB
1,807
49
function global_se = get_mag_se(directory,task_type, align_type,curr_parc,scan_id) % Get a list of files matching the pattern filePattern = strcat('fc_herit_net_',task_type,'_',align_type,'_parc_',curr_parc,'_scan_',num2str(scan_id),'_jackknife_*.csv'); files = dir(fullfile(directory, filePattern)); % Count the ...
63fa8fc5abb32071cf95bc774ac089ebdae8e7bad0542f6e5e3f0b8c93c38f9b
MATLAB
1,808
76
a=xlsread('m2 30s60s zong.xlsx','yali'); b=xlsread('m2 30s60s zong.xlsx','Caxinhao'); fs1=800; fs2=2000; movement=a(:,1); calcium=b(:,1); % Â˲¨ ÖØ²ÉÑù b=fir1(fs1*2,0.1/fs1*2,'high'); calcium_f=filtfilt(b,1,calcium); b=fir1(fs2*5,0.1/fs2*2,'high'); movement_f=filtfilt(b,1,movement); k=1;calcium_r...
c660e75750f2abfbdbf355f2f21f7ae4988cf76bc0d24744f348a8c932069631
MATLAB
1,811
55
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % example script to generate simulated interacting brain regions and % perform Current-Based Decomposition (CURBD). Ref: % % Perich MG et al. Inferring brain-wide interactions using data-constrained % recurrent neural network models. bioRxiv. D...
89d37c4dea51d50c3191ee4e08b693146b9053eb84585bc3dfc4b00f884f454c
MATLAB
1,833
59
function changeAcqPathToLocal(path) %changePathToLocal.m Looks in path for acq objects necessary for roi %selection, and changes path in object to allow for proper local %processing. % %INPUTS %path - path to local folder containing acq objects. If empty, opens % uigetdir % %ASM 12/14 %check if path exists if nargin...
e460fc3cf3ce543c095c36680c40b8a0ff573b7d575b685e3d8175eb12303033
MATLAB
1,848
71
function [loss,gradients,mseF1,mseF2,mseF3,mseF4,mseF5,f1,f2,f3,f4]=modelLoss(parameters,net1,net2,CP,CB,CBIC,CBt,U0,Ux0,dataVel,A,w1,w2,w3,w4,w5) net1.Learnables=parameters(1:6,:); net2.Learnables=parameters(7:end,:); alpha=parameters(end,:).Value{1}; % make predictions U=forward(net1,CP); vel=forward(net2,CB...
a2593ea110dc1b58ccba9c7de7fabd6c62f3a051de4a1f74989e7949f7e9bf3f
MATLAB
1,859
42
function [T2_map_CSF, S0, goodnessFit] = calculate_T2_map_CSF(img_data, echo_times, t2maps_path, wm_average) % Initialize the dimensions [x_dim, y_dim, z_dim, num_echoes] = size(img_data); % Preallocate the T2_map matrix for each echo T2_map_CSF = zeros(x_dim, y_dim, z_dim); S0 = zeros(x_dim, y_dim...
1604936b62140c7929223cb9561bbffc8be9cad6c0c7461b9b6d5c08c059962c
MATLAB
1,866
46
function [T2_map, S0, goodnessFit] = calculate_T2_map(img_data, echo_times, t2maps_path) % Initialize the dimensions [x_dim, y_dim, z_dim, num_echoes] = size(img_data); % Preallocate the T2_map matrix for each echo T2_map = zeros(x_dim, y_dim, z_dim); S0 = zeros(x_dim, y_dim, z_dim); goodnessFi...
16b7f476328de131c26b020750fee77501b2012791dae0aba804ddd5cde305c5
MATLAB
1,890
47
function plot_voxel_t2_fit(echo_times, T2_map, goodnessFit, x, y, z) %% % Extract voxel data voxel_data = squeeze(T2_map(x, y, z, :)); % Check if the voxel data is all zeros if all(voxel_data == 0) disp('The selected voxel data is all zeros.'); return; end %% ...
755d7c8c6c41bafb75cd5b399bcd2e19b9e15878a0382d78536bcb1aae4e0660
MATLAB
1,898
48
function saveNewROI(sel,evt) %saves new roi if isempty([sel.roiInfo.roi.id]) newRoiNum = 1; else newRoiNum = max([sel.roiInfo.roi.id])+1; end % Save current ROI: newInd = numel([sel.roiInfo.roi.id])+1; % Attention: newRoiIndex is no necessarily the same as the roiNumber of the current ROI! sel.roiInfo.roi(ne...
2534c832d0e78c36008a3a8b877756d8245b5372ad66c2f416c0159aca572d42
MATLAB
1,925
80
function [finalParms , finDiscrepancy]=wrap_2lp_rand(startParms,ResModData); % options = optimset('Display','iter') options = optimset('MaxFunEvals',500*length(startParms),'MaxIter',500*length(startParms)); [finalParms , finDiscrepancy] = fminsearchbnd(@fitModBY,startParms,[0 0 0],[10e7 10e7 10e7],options) ;...
5818bb0ecd259740e85b43348efd108cca66400c302d0af750c3b416532bfb12
MATLAB
1,928
81
function [finalParms , finDiscrepancy]=wraponeloop(startParms,ResModData); % options = optimset('Display','iter') options = optimset('MaxFunEvals',500*length(startParms),'MaxIter',500*length(startParms)); [finalParms , finDiscrepancy] = fminsearchbnd(@fitModBY,startParms,[0 0 0],[10e7 10e7 10e7],options) ; ...
182d69e9bc2103629b38f4f24cbbcc83263cb9c157da9abf885594c37c1cb39a
MATLAB
1,930
55
function [u,flag]=burgers_rhs_forward(dt,u0,xpt,template,dtemplate) np=length(xpt); dx=xpt(2)-xpt(1); flag=0; u=u0; nu=0.001; while 1 res=zeros(np+2,1); ajac=sparse(np+2,np+2); i=1; res(i)=u(np+1).*u(i) - (nu.*(2.*u(i) - 2.*u(i+1)))./dx.^2-(u(i)-u0(i))/dt; ajac=ajac+sparse(i,i,-1...
557320a0d21507b9e5cd3d55a63b28f23968bae3ec66e2fca43534b2034bda30
MATLAB
1,948
60
% [im,path] = loadData(path) % --------------------------------------- % % Generic function to load arbitrary image stacks in the workspace % % Inputs: % path Full path of the file, if not provided the function will call uigetfile % % Outputs: % im Loaded image % path Image full path % % ----------...
aee54e39eaa4620ac438b2f27e5ad6db6e6e7e96b5f796bf40b2bb6934207ca5
MATLAB
1,951
57
function outFile = ft_LateralityAnalysis(subjList, method, freqLabel, varargin) % Compute paired hemispheric laterality indices for ROI-based connectivity. p = inputParser; p.addParameter('BaseDir', pwd, @(x)ischar(x)||isstring(x)); p.addParameter('Condition', 'marker', @(x)ischar(x)||isstring(x)); p.addParameter('Pai...
b8ce55fe34b1a807efe05c25eec6313ec9fe94175a11e918a36235a8a0beeba6
MATLAB
1,968
44
function varargout = withinFile_fullFrame_fft(obj,movStruct, metaMov, movNum, opMode) %Example of a motion correction function compatable with Acquisition2P class, %calculates full frame translations within each file independently, then adds %these to shifts calculated between each file % % nSlices = metaMov.stackNumSl...
3de2295b7db06e921033103fc94237df165bb0a202c24b3b5b7f57138d310368
MATLAB
1,986
61
function mMov = avgMov(obj, keyFrames, frameWin) %% Input handling sliceNum = 1; channelNum = 1; %% Make memory map movSizes = obj.correctedMovies.slice(sliceNum).channel(channelNum).size; movLengths = movSizes(:, 3); % if ~exist(obj.indexedMovie.slice(sliceNum).channel(channelNum).fileName, 'file') % error('Can...
815e96f18f1a6be96846767e924a26b66d249705fe5a5d8c171e735440022fba
MATLAB
2,012
85
function [finalParms , finDiscrepancy]=wrap_onlyaud(startParms,ResModData); % options = optimset('Display','iter') options = optimset('MaxFunEvals',500*length(startParms),'MaxIter',500*length(startParms)); [finalParms , finDiscrepancy] = fminsearchbnd(@fitModBY,startParms,[0 0 0],[10e7 10e7 10e7],options) ; ...
1413b220f7bfd7ec9867038278f6b07d20e1c3cd43a7f8c7ead072faf6fc1218
MATLAB
2,024
65
function [covMat, pxNeighbors] = getCovData(sel, queryNhRad) % [covMat, pixNeighbors] = getCovData(hFig) extracts the covariance data % for one "seed" pixel from the covFile. This function deals with the % different covFile formats. persistent mem queryCols nElInRow % Simplify variable names: h = sel.disp.movSize(1); ...
963f7a9ed6693f7530cf77c19291f6afa3c7b959739db6918dd51c88e50c0711
MATLAB
2,025
77
%% Make avg movie %tV = vecTrials(stimExpt); movNeur = unique(tV.nTarg); targOn = []; for iNeur = 1:length(movNeur) nNeur = movNeur(iNeur); repF = find(tV.nTarg == nNeur); for f = 1:length(repF) targOn(iNeur,f) = tV.stimFrames{repF(f)}(1); end end frameWin = -15:84; %frameWin = -6:43; mMov = na...
2d8e551f417a207457d2ba6241692687702acaf655eeeeec47a8b03d97414612
MATLAB
2,051
55
function [avgMov, dFmov] = eventTriggeredMovie(obj,avgMovFrames) % avgMovFrames should be a 1xf cell array, where f is the number of frames % in the average movie, and each cell contains the (data) frame numbers to % be averaged together for each triggered movie frame % Note that the code will not allow 'double count...
e91fac87ace168a7ace8f3eacef08b77b92c3295bb95820389e20e13020c4631
MATLAB
2,062
84
function [finalParms , finDiscrepancy]=wrap_onlyaud_aversion(startParms,ResModData); % options = optimset('Display','iter') options = optimset('MaxFunEvals',500*length(startParms),'MaxIter',500*length(startParms)); [finalParms , finDiscrepancy] = fminsearchbnd(@fitModBY,startParms,[0 0 0 0],[10e7 10e7 10e7 1...
d8b90708e756171bbbeddf49db9fbd768b03f2b0658dbd90bb70d4c9c84eff38
MATLAB
2,067
84
% %% % spid=[]; % for j=1:1000 % a=(1:39)'; % spid=[spid;a]; % end % % simLearnAnimID=cell(1000,1); % for i=1:1000 % x=spid(randperm(length(spid))); % x=x(1:39); % simLearnAnimID{i}=x; % end % save('simLearnAnimID','simLearnAnimID'); %% %Simulate experimental derived CNO effect l...
cd6b8dd99ce9a6dde51d3c211c9333427101a077d3ce558d819c1569a8eba8f3
MATLAB
2,083
60
function adc_and_fa_masking_threshold(subjPath, subject_code, ADC_map_avg, FA_map_avg); % goal: convert adc and fa maps to niftis, create frangi filter on inverted % image % register t2 maps to the b0 %% Paths regDir = fullfile(subjPath, 'reg'); fa = fullfile(subjPath, 'fa'); adc = ful...
11213b7c213e31590dbf274bc9e7438f754a832f15432c79503b71bce152ada6
MATLAB
2,087
60
function adc_and_fa_masking_reorientating(subjPath, subject_code, ADC_map_avg, FA_map_avg); % goal: convert adc and fa maps to niftis, create frangi filter on inverted % image % register t2 maps to the b0 %% Paths regDir = fullfile(subjPath, 'reg'); fa = fullfile(subjPath, 'fa'); adc =...
8003b5b73c7730ca0b26bed2ffd53aff0e1e2c93a70bff7f18834f9bc0dc7475
MATLAB
2,100
94
numLayers = 3; numNeurons=40; layers=featureInputLayer(2); for i=1:numLayers-1 layers = [layers fullyConnectedLayer(numNeurons) tanhLayer]; end layers = [layers fullyConnectedLayer(1)]; net1=dlnetwork(layers); net1 = dlupdate(@double,net1); numLayers = 2; numNeurons=5; ...
349ba590fbd20ca21e1df47b86d214283e178a3891339a77e683f6a13615613b
MATLAB
2,106
84
function [finalParms , finDiscrepancy]=wrap_2lp_rand_v2(startParms,ResModData); % options = optimset('Display','iter') options = optimset('MaxFunEvals',500*length(startParms),'MaxIter',500*length(startParms)); [finalParms , finDiscrepancy] = fminsearchbnd(@fitModBY,startParms,[0 0 0],[10e7 10e7 10e7],options...
6836f9be2dfe6af25c0f35b65b36588373bcbb811f494cd0898302b82194d8df
MATLAB
2,113
65
function anchor_starts = computeExactAccelEvents(reward, distance, reset, speed, reward_starts, speed_threshold) % Parameters window_size = 2000; % 100ms window min_distance_cm = 50; % 50 cm minimum smooth_speed = smooth(speed, 100); acceleration = [0; diff(smooth_speed)]; global_accel_tolerance = (max(acceleration) -...
03e9eb3c9cd4ecec09fccb2d562568a94f9f8336212d092c3a5ee85bcc14c76b
MATLAB
2,150
59
function [u,flag]=burgers_rhs_forward_2(dt,u0,xpt,template,dtemplate) np=length(xpt); dx=xpt(2)-xpt(1); flag=0; u=u0; nu=0.001; while 1 res=zeros(np+2,1); ajac=sparse(np+2,np+2); i=1; res(i)=nu.*(2.*u(i+1)-2.*u(i))./dx.^2-u(i).*(u(i+1)-u(i))./(dx)+u(np+1).*(u(i)+xpt(i).*(u(i+1)-u(i))....
b4039c8e01e82c8b4695c2a8586c2fdbde97e04e5471a8b619f5f1e7aaac7494
MATLAB
2,158
79
function outFile = ft_GraphMetrics(groupFile, varargin) % Compute basic weighted graph metrics from a group connectivity matrix. p = inputParser; p.addParameter('OutDir', '', @(x)ischar(x)||isstring(x)); p.addParameter('ThresholdDensity', [], @(x)isnumeric(x)); p.parse(varargin{:}); opt = p.Results; S = load(groupFil...
55c5bd7a72e6d67890ed8c73e72827bfa1c929b01c3e4574e648d2d26e665879
MATLAB
2,176
91
function [perf_s awhist choice_s]=model_act_onlyaud_aversion(delta1,delta2,aw,aversion,side); % thre=1; delta1=delta1/10e7; delta2=delta2/10e7; aw=aw/10e7; aversion=aversion/10e7; rng("default") % rng(9,"threefry") perf_s=[]; choice_s=[]; awhist=aw; fo...
22ac28d2c80a96d311f0c86ed36bec56a9aefb5b9954e85ca048cee8056d27af
MATLAB
2,191
96
numLayers = 4; numNeurons=20; layers=featureInputLayer(2); for i=1:numLayers-1 layers = [layers fullyConnectedLayer(numNeurons) tanhLayer]; end layers = [layers fullyConnectedLayer(1)]; net1=dlnetwork(layers); net1 = dlupdate(@double,net1); numLayers = 2; numNeurons=4; ...
69c482ad4f4788e33f7cd54afbc4d29e6b8f4cb7edef479788ff7d4d54f97172
MATLAB
2,192
69
function points = generate_polygon(center, avg_radius, irregularity, spikiness, num_vertices) % Start with the center of the polygon at center, then create the % polygen by sampling points on a circle around the center. % Random noise is added by varying the angular spacing between % sequential points, ...
6f6f579eb9646fe28e024529b49a5fcb6c05a82304818a19e8258f7443f913bc
MATLAB
2,193
53
function opposite_starts = computeOppositeRewardEvents(reward, distance, reset) % COMPUTEOPPOSITEREWARDEVENTS Anchor points on the opposite half of the track. % % For each reward, returns the sample index on the opposite half of the 2 m % track, at the mirrored position (reward position +/- 1 m). Used as a % behaviour...
b84f85ae61fec4e25a73fa2fb1a16a4b3cfc0fcadf662e964e0bb5312f27c81a
MATLAB
2,193
67
function location_groups = group_reward_locations(reward, distance, reset) % Circular mean helper function function m = circularMean(positions, L) theta = positions * (2*pi/L); s = sum(sin(theta)); c = sum(cos(theta)); mean_angle = atan2(s, c); m = mod(mean_angle * L/(2*p...
5aa6163e51589121a3fd6d796e4c6123bc5d149e96bc70af2671c790a0366e2a
MATLAB
2,201
66
function anchor_starts = computeExactSpeedEvents(reward, distance, reset, speed, reward_starts, speed_threshold) % Parameters window_size = 20000; % 20000 samples = 1000ms min_distance_cm = 50; % 50 cm minimum distance global_speed_tolerance = (max(speed) - min(speed)) / 20; % Dynamic tolerance % Handle optional inpu...
f76165647f5786900d4c394063210f8e4fccec492b91677619a0d3bc111acc97
MATLAB
2,203
92
function [perf_s awhist spwhist choice_s]=model_act_2lp_rand(delta1,delta2,aw,spw,side); % thre=1; delta1=delta1/10e7; delta2=delta2/10e7; spw=spw/10e7; rng("default") % rng(9,"threefry") perf_s=[]; choice_s=[]; awhist=aw; spwhist=spw; for i=1:length(side);...
e867cf6cb83d5bc1f8bb63fc029dfe7be5e736b46bbecb95217b86dc17a024fe
MATLAB
2,219
56
function [shuffled_rest_fc, shuffled_movie_fc, shuffled_rest_covari, shuffled_movie_covari, swap_indices] = shuffleFCData(rest_fc_square, movie_fc_square, rest_covari, movie_covari,iter) rng(iter) % Check if FC data is provided if exist('rest_fc_square', 'var') && exist('movie_fc_square', 'var') [nROIs, nROIs, num_...
554d78070aa10991d95601daabe080e7125b39cb4869d4430d3b965545961fa1
MATLAB
2,235
96
function [perf_s awhist choice_s phist]=model_act_onlyaud(delta1,delta2,aw,side); % thre=1; delta1=delta1/10e7; delta2=delta2/10e7; aw=aw/10e7; rng("default") % rng(9,"threefry") perf_s=[]; choice_s=[]; awhist=aw; phist=[]; for i=1:length(side); % ma...
692fd9d5e17bd385fd15360d34bdc2dfabeeea611027b3d097025189ec7a364c
MATLAB
2,242
64
function B0_to_niftis(subjPath, imageData); % goal: convert adc and fa maps to niftis % register t2 maps to the b0 %% Paths regDir = fullfile(subjPath, 'reg'); anatFolder = fullfile(subjPath, 'anat'); % anat folder path mhd = fullfile(subjPath, 'mhd'); % Target file path echo1File = fullfil...
a0a96190c106a8609c9f5a2a8e58a3c99c4b89f5d41132688d5765f30ba6400f
MATLAB
2,250
95
function [perf_s awhist spwhist choice_s]=model_act_2lp_rand_v2(delta1,delta2,aw,spw,side); % thre=1; delta1=delta1/10e7; delta2=delta2/10e7; spw=spw/10e7; rng("default") % rng(9,"threefry") perf_s=[]; choice_s=[]; awhist=aw; spwhist=spw; for i=1:length(sid...
33a2904e239e7c9b68dccd23c0e69f11c64f28cc4042ab6308b8fac2d99ecefd
MATLAB
2,254
101
numLayers = 4; numNeurons=40; layers=featureInputLayer(2); for i=1:numLayers-1 layers = [layers fullyConnectedLayer(numNeurons) tanhLayer]; end layers = [layers fullyConnectedLayer(1)]; net1=dlnetwork(layers); net1 = dlupdate(@double,net1); numLayers = 2; numNeurons=4; ...
2e155be1c682c2d38408adb96e5d45e70f82df237c62b7126c84c466f7acf984
MATLAB
2,269
93
function [perf_s awhist spwhist choice_s aw]=model_act_CNO_2lp_rand(delta1,delta2,aw,spw,side,cnoeffect); % thre=1; delta1=delta1/10e7; delta2=delta2/10e7; spw=spw/10e7; spw=spw*cnoeffect; rng("default") % rng(9,"threefry") perf_s=[]; choice_s=[]; awhist=aw...
3a4d4969c69285c8f4a182adac94b7c27031a8541f82d12662f040e7769efdde
MATLAB
2,278
76
function copyLocalAcqToServer(path,serverPath) %copyLocalAcqToServer.m Copies local acquisition back to server and fixes %paths % %INPUTS %path - local path % %ASM 12/14 if nargin < 2 || isempty(serverPath) serverPath = 'Z:\HarveyLab\Ari\2P Data\ResScan'; end %check if path exists if nargin < 1 || isempty(path)...
a26839430a91f3b626d17b1ad2f1799a0d0fc53382c45bbd721483fc0d41f143
MATLAB
2,293
71
function T2star_venogram_thresholded(project_directory, project_name, subject_code); reoriented = fullfile(project_directory, project_name, subject_code, 'reoriented'); veno_dir = fullfile(project_directory, project_name, subject_code, 'veno'); toolbox = fullfile(project_directory, 'scripts', 'toolbox...
7bfed3ffb6a78411ca62dba7143b058e9c1da47586d7a82d4f74c6dd7526cfc0
MATLAB
2,298
50
function [fc_herit, fc_herit_perm,fc_herit_jack,fc_similarity] = computeNetworkHeritability(fc_square, net_ids, subjects,kinship,covari,num_perm,fam_ids) num_nets = max(net_ids); n2 = num_nets + ((num_nets * (num_nets - 1)) / 2); numsubjects = length(subjects); fc_similarity =...
577a91644893e71536d19f08d4ad96846383eea5a9f3404d1ae4b9025229a8f0
MATLAB
2,341
103
numLayers = 3; numNeurons=40; layers=featureInputLayer(2); for i=1:numLayers-1 layers = [layers fullyConnectedLayer(numNeurons) tanhLayer]; end layers = [layers fullyConnectedLayer(1)]; net1=dlnetwork(layers); net1 = dlupdate(@double,net1); numLayers = 2; numNeurons=5; ...
207079dc047a4e2878a7f689cd73737711f50786999573998e09bbf7fffe207c
MATLAB
2,342
71
function [loss,gradients,mseF1,mseF2,mseF3,mseF4,mseF5,mseF6,mseF7,mseF8]=modelLoss(parameters,net1,net2,CP,CB1,CB2,CB3,CB4,CBIC,CBt,CPin,U0,drdth,w1,w2,w3,w4,w5,w6,w7,w8) net1.Learnables=parameters(1:8,:); net2.Learnables=parameters(9:end,:); % make predictions U=forward(net1,CP); AB=forward(net2,CBt); gradU = d...
83d9346c852ac5420ef549fe2778b1ffaff2fcc56f551d04c7e2d6de0d64376f
MATLAB
2,343
85
function addSIMetaData(folder) %addSIMetaData.m Looks through folder and adds metadata to all objects % %INPUTS %folder - folder to look through % %ASM 12/14 if nargin < 1 || isempty(folder) folder = '\\research.files.med.harvard.edu\Neurobio\HarveyLab\Ari\2P Data\ResScan'; end %get subdirectories which match mo...
0b596d82c9c7ca2589873eb5217694476777b759a74cbd16c1370e05d0be4b99
MATLAB
2,353
63
%% Define project paths project_directory = '/exports/gorter-hpc/users/ninafultz/'; project_name = 'csfdonuts_lydiane'; scripts = fullfile(project_directory, 'scripts'); addpath(genpath(fullfile(scripts, project_name))); addpath(genpath(fullfile(scripts, 'toolbox', 'nifti_tools-master'))); addpath(genpa...
d0ac5255c069587f933d3fbb6baaba16c293b5ccd2546e4a4b65ed36a22637db
MATLAB
2,360
69
function plotConcentricCircles(project_directory, project_name, subject_list, roi_patterns, voxel_size) % Initialize structure to store data roi_data = struct(); for roi_name = roi_patterns roi_data.(roi_name{1}).ADC = {}; % Cell array for variable-length ADC data end % Process each subject for subj = 1:length(su...
009aa3a384b30b4392a46bce8446ba0be44e41d586044f8a479a5796584c4939
MATLAB
2,384
87
function venogram_combiningimages(project_directory, project_name, subject_code); % Define the switch block for subject-specific operations switch subject_code case 'csfdonut01' subject_code = ''; case 'test' subject_code = 'test01_angiogramvenogram'; otherwise ...
7f89b73be772fae7a7c01613e37cc80e6646f320ed2f6576da858b87f34c8de8
MATLAB
2,385
66
function selectROIs(acq, img, sliceNum, channelNum, smoothWindow, excludeFrames) % selectROIs(acq, img, sliceNum, channelNum, smoothWindow, excludeFrames) % All inputs except acquisition object are optional. % % GUI for sorting through pixel-pixel correlation matrices to select % appropriate ROIs for an acquisition. Re...
b42cbbdbb16801a9a3889ab21d1f914597f5b03b327ad62633a932c3fb4e5f4a
MATLAB
2,458
51
function doAllClusterTraces(sel) % Tell user that we're loading the traces: title(sel.h.ax.roi, 'Loading Trace for Current ROI'); drawnow % Get matrix of fluorescence traces for all clusters: mov = sel.movMap.Data.mov; F = zeros(sel.disp.clusterNum+1, size(mov, 1)); ...
0e34176f0e7e0c04d5d0f5956221a387f22207972d32b1446f8bb09216abc6d0
MATLAB
2,470
87
function calcClusterProps(sel) doCuts = get(sel.h.ui.autoCalcCuts,'Value'); doClusters = get(sel.h.ui.autoCalcClusters,'Value'); if doCuts cutVals = sel.disp.cutVals; X = 1:length(cutVals); warnState = warning('off', 'stats:statrobustfit:IterationLimit'); [B,stats] = robustfit(X,cutVals,'bisquare',2);...
70ca8a9f686d722564b971da30ae1157b637fa396cd4bb410bdae8e85e228695
MATLAB
2,481
74
function [loss,gradients,mseF1,mseF2,mseF3,mseF4,mseF5,mseF6,mseF7,mseF8]=modelLoss(parameters,net1,net2,CP,CB1,CB2,CB3,CB4,CBIC,CBt,U0,w1,w2,w3,w4,w5,w6,w7,w8) net1.Learnables=parameters(1:8,:); net2.Learnables=parameters(9:end,:); % make predictions U=forward(net1,CP); AB=forward(net2,CBt); gradU = dlgradient(s...
facae415725f6c266f213239ae16a4712ad888a6e24e359bd576f7d43130dbf2
MATLAB
2,488
112
numLayers = 3; numNeurons=20; layers=featureInputLayer(2); for i=1:numLayers-1 layers = [layers fullyConnectedLayer(numNeurons) tanhLayer]; end layers = [layers fullyConnectedLayer(1)]; net1=dlnetwork(layers); net1 = dlupdate(@double,net1); numLayers = 2; numNeurons=5; ...
e5c7507defc1d55cb5e0462e718732d976afb77d0d47670f5d8326fe483d647b
MATLAB
2,535
117
function [h2, p_perm, jack_se,h2_jack] = h2_mat(P, K, X, n_perm, F) %% % % Heritability estimation from phenotypic and genetic similary mattrices % % Input: % P: an Nsubj x Nsubj phenotypic similarity matrix % K: an Nsubj x Nsubj genetic similarity matrix % X: an Nsubj x Ncov matrix of covariates % n_perm: number of pe...
de06048bbfa041d3b1b6fcd893b5c601f4290c9df87e3f0079586717fa0b2eb9
MATLAB
2,540
77
function plotSixDistributions(all_counts_cell, short_counts_cell, long_counts_cell, ... bin_size, bin_units, titles, main_title) % Plot six distributions in 2x3 grid with consistent y-axis max_range = 1.2; % ±1.2 meters xlabel_str = ['Distance from anchor (' bin_units ')']; edges = -max_range:bin_size:m...
00e50e2c40a374aa4bd720345f0ea92ef8cc432f5eddee88d2637825ae6477c1
MATLAB
2,584
78
function varargout = correctLineShift(mov, manualShift) % [movCorrected, shifts] = correctLineShift(mov) corrects the offset % between odd and even image lines caused by bidirectional laser scanning. % Apply this correction before any other processing. if ~exist('manualShift', 'var') || isempty(manualShift) manual...
6ad6b87f07295df842a1db170d139da3b501878dbf163c2b9e706c61312b733b
MATLAB
2,626
121
numLayers = 4; numNeurons=40; layers=featureInputLayer(3); for i=1:numLayers-1 layers = [layers fullyConnectedLayer(numNeurons) tanhLayer]; end layers = [layers fullyConnectedLayer(1)]; net1=dlnetwork(layers); net1 = dlupdate(@double,net1); numLayers = 2; numNeurons=5; ...
770c4a208386ee64319556f911bd8f40e7cb4bebd8ef65865336d125bbcc8684
MATLAB
2,628
60
function displayRoi(sel) %Helper function which updates display of currently selected ROI in overlay %panel %Check current status, reflected in title of ROI overlay axes. If trace has %recently been loaded, reset title to ROI selection, or if currently %searching for neuropil, do not enforce ROI continuity constraint ...
165c7e71466bd9adaa9667f9321540519ba376d7bb3aee810a941540d82cd693
MATLAB
2,630
95
clear GENERALDIR = 'R:\- Gorter\CSF_STREAM\Data\'; allSubjects = dir([GENERALDIR '*20201019_Reconstruction']); subjectNb = 1; subject = allSubjects(subjectNb); disp(subject.name) physioFolder = '\Cardiac\T2prep'; physio = 'cardiac'; threshold = 150; newFolder = 'R:\- Gorter\- Personal folders\Fultz, N...
1182f4f5e8ca4c6bb828e993c7bcefd440cd8e925520d2fb59f85f38e7ad1269
MATLAB
2,636
74
function mhd_to_niftis(subjPath, referenceScan); % goal: convert adc and fa maps to niftis % register t2 maps to the b0 %% Paths regDir = fullfile(subjPath, 'reg'); fa = fullfile(subjPath, 'fa'); adc = fullfile(subjPath, 'adc'); anatFolder = fullfile(subjPath, 'anat'); % anat fol...
4a788f93b8e3c87cfb71963595e00c08383e25c7aab43ee0bb4ca74c44259062
MATLAB
2,663
62
function [movStruct, nSlices, nChannels] = parseScanimageTiff(mov, siStruct) % Check for scanimage version before extracting metainformation if isfield(siStruct, 'VERSION_MAJOR') % SI2016 or later tiff that was loaded using the new SI tiff reader: fZ = siStruct.hFastZ.enable; nChannels =...
fb1fbb535279aa15346e731b1fa606f87c2e26fff49f04371c6c95112736af5c
MATLAB
2,684
82
function [dF, traces, rawF, roi, traceNeuropil] = ... extractROIsBin(obj,roiGroups,sliceNum,channelNum, isGetDF) % Function for extracting ROIs from movies using grouping assigned by % selectROIs. This function uses a memorymapped binary file of the entire % movie, as output by indexMovie. See extractROIsTIFF to ex...
57b2502829f4967ff27f64fcd3abdb9fcf54cd9f6ec402868e53ede6795873ab
MATLAB
2,694
57
function [all_counts, short_counts, long_counts, all_plateau_times, ... short_plateau_times, long_plateau_times, dwell_times] = ... analyze_anchor_set(anchor_starts, analysis_name, distance, reset, plateaus, widPlat, ... bin_size, short_thresh_samples, min_plateau_duration_samples, speed, ... ...
cc5f3d26edb88891ea9b1ef2be0a3bca6519ca46564206f9facf35553f67cf5a
MATLAB
2,713
76
function [CURBD,CURBDLabels] = computeCURBD(varargin) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Performs Current-Based Decomposition (CURBD) of multi-region data. Ref: % % Perich MG et al. Inferring brain-wide interactions using data-constrained % recurrent neural network models. b...
a915edd5152677722464f2854fa312da879b241639fe3b9623997f84992beecc
MATLAB
2,716
123
numLayers = 4; numNeurons=40; layers=featureInputLayer(3); for i=1:numLayers-1 layers = [layers fullyConnectedLayer(numNeurons) tanhLayer]; end layers = [layers fullyConnectedLayer(1)]; net1=dlnetwork(layers); net1 = dlupdate(@double,net1); numLayers = 2; numNeurons=5; ...
b3e3f547e09f123c91adc632c4307cdced1948df1c22e5b4d94ca00e90b0c276
MATLAB
2,719
112
function [perf_s awhist spwhist choice_s]=model_act_oneloop(delta1,delta2,aw,spw,side); % thre=1; delta1=delta1/10e7; delta2=delta2/10e7; spw=spw/10e7; rng("default") % rng(2,"threefry") perf_s=[]; choice_s=[]; awhist=aw; spwhist=spw; for i=1:length(side); ...
55736f9ffc792f7a6facfd22503e630b22e2d19aed43462245459310aa86d9d3
MATLAB
2,736
63
function anchor_starts = findCrossingsNearRewards(reward, distance, reset, reward_starts, all_crossings) track_length = 2; % meters min_dist_before = 0.2; % meters (20 cm) min_dist_after = 0.8; % meters (80 cm) anchor_starts = NaN(size(reward_starts)); for i = 1:length(reward_starts) R ...
e30a3c7ee92841a1e0cf12f11055d427b6d0b40c72680790d3d3e919b8116f8c
MATLAB
2,747
83
function anchor_starts = computeSimilarAccelEvents(reward, distance, reset, speed, reward_starts) % Parameters for trend matching bin_duration = 0.1; % 100 ms bins trend_window = 5; % ±5 bins (±500ms) min_distance_cm = 50; % 50 cm minimum distance % Get reward starts if not provided if nargin < 5 || isempty(reward_sta...
6e10c2a61e3560cb620cf48d1daef7415571dabb30aee17d525d6ee865ee99c7
MATLAB
2,772
132
%% %Do simulation load mod2lp_control_result load model_chem_control.mat parm_results2=parm_results; parm_results2(:,2:4)=parm_results2(:,2:4)/10e7; % figure; % hold on; cnoeffect=0.559; % cnoeffect=0.54; perfday=zeros(39,5,2); for qq=1:size(parm_results,1) qq=parm_results(qq,1); param=parm_resu...
fa5ee13cdfcea2dc7c4b0232db588e6a06b8099c42b950853950473301efcb85
MATLAB
2,773
68
function movStruct = withinFile_segmentConsensus(obj,movStruct, metaMov, movNum, opMode) %Example of a motion correction function compatable with Acquisition2P class, %calculates full frame translations within each file independently, then adds %these to shifts calculated between each file % Clips off pockels-blanked ...
14d68bc980484c7546f3502cbec8168b13ed7837937f97ae96126adc9da5b877
MATLAB
2,801
73
function [dF, traces, rawF, roi] = extractROIsTIFF(obj,roiGroups,movNums,sliceNum,channelNum) % Function for extracting ROIs from movies using grouping assigned by % selectROIs. This function motion corrected tiff files. See extractROI for a % sometimes faster method using a memory mapped 'indexed' binary file instead...
5d1c64b24f969d23994fd39dad3a1704e975ac2cfe99eb33955a94a0ddb87f20
MATLAB
2,860
73
function plotConcentricCircles(project_directory, project_name, subject_list, roi_patterns, voxel_size) %% Parameters num_layers = 20; % Number of concentric circles layer_thickness = 0.45; % Thickness of each layer in voxel units % Process each subject for subj = 1:length(subject_list) sub...
e10b4ffa6620e8b2451352e8136cc096286b24609fcba503c50d6051d1fa40e3
MATLAB
2,883
83
function anchor_starts = computeSimilarSpeedEvents(reward, distance, reset, speed, reward_starts) % Parameters for trend matching bin_duration = 1; % 1000 ms bins (in seconds) trend_window = 5; % ±5 bins (i.e., ±500ms around reward) min_distance_cm = 50; % Minimum 50 cm away from reward % Get reward starts if not prov...
cd8391a40bfba7585a440c927c0e8fa1fcd1fc04565dcffa72eaf1033687506e
MATLAB
2,997
188
%model A--use cum all perf -independent 2 loops, with random noise clear all tic load model_chem_control.mat parm_results=[]; parfor qq=1:39 ResModData=modeldata{qq,1}; results=[]; for parm1=[0.005 0.01 0.05 0.1 0.5]*10e7;% delta1 for parm2=[0.3 0.4 0.5...
a159a1dbab99a5464561c3c044798bbec3814cfcdc2105bd4497e0b92892df54
MATLAB
3,074
79
function plotADCandB0Values(project_directory, project_name, subject_list, roi_patterns, voxel_size) %% Process the first subject only subject_code = subject_list(1).name; subjPath = fullfile(project_directory, project_name, subject_code); ROIs_dir = fullfile(subjPath, 'ROIs'); reoriented_dir = full...
5451a9e7db54be27dfad2ecee4cb569f3ad0139997064a7a00d574e8ad7132c2
MATLAB
3,092
93
%% CONVERTPARREC Convert a Philips PARREC image file to a different version % % [SUCCESS] = CONVERTPARREC(SRCFILENAME,DSTFILENAME,VERSION) % % SRCFILENAME is a string containing a file prefix or name of the PAR header % file or REC data file, e.g. SURVEY_1 or SURVEY_1.PAR or SURVEY_1.REC % % DSTFILENAM...
a800ff4e2e0d48e9ef5cfcb215fef0d6ab9c50d52e7738dfd95299315e3b9a69
MATLAB
3,124
83
function result = XMLRECwritexml(xmlrec_struct,filename) %% Assumes the following structure format % xmlrec_struct.Series_Info % xmlrec_struct.Image_Array(:) % % xmlrec_struct.Series_Info.ATTRIBUTE_NAME.subattribute_1 % xmlrec_struct.Series_Info.ATTRIBUTE_NAME.subattribute_2 % ... % xmlrec_struct.Series_Info....
d0dc5857d3780dc5459fdb2377376b31c980f44399b6eb80426fc9d2562b7aa5
MATLAB
3,143
81
function plotADCandB0Values(project_directory, project_name, subject_list, roi_patterns, voxel_size) %% Process the first subject only subject_code = subject_list(1).name; subjPath = fullfile(project_directory, project_name, subject_code); ROIs_dir = fullfile(subjPath, 'ROIs'); reoriented_dir = ful...