sha256
stringlengths
64
64
language
stringclasses
27 values
size
int32
1
491k
lines
int32
1
21.8k
content
stringlengths
1
200k
2f8c1fc6cbe852ff384f7447bc0e223133c30128cb06defee06e1bc7f15eeeae
MATLAB
484
19
function imwritestack(stack, filename) im = Tiff(filename, 'w'); infostruct.ImageLength = size(stack, 1); infostruct.ImageWidth = size(stack, 2); infostruct.Photometric = Tiff.Photometric.MinIsBlack; infostruct.BitsPerSample =16; infostruct.SampleFormat = Tiff.SampleFormat.UInt; infostruct.PlanarConfiguration = Tiff....
6c09e147cba574be9cdfbc149f0575e9f0ad1c0a1c8d4e7d1702e7a5b063e87a
MATLAB
492
17
function [p_value, jack_se1,jack_se2] = compareHeritability(h2_1, se_1, h2_2, se_2) n_fam = length(se_1); A = (n_fam-1)/n_fam; B1 = sum((se_1 - sum(se_1/n_fam)).^2); h2_var1 = A*B1; jack_se1 = sqrt(h2_var1); B2 = sum((se_2 - sum(se_2/n_fam)).^2); h2_var2 = A*B2; jack_se2 = sqrt(h2_var2); % Cal...
38e67d170cf7aef85aed199168df602608472e15f1a6e704d05f666ef5b00837
MATLAB
498
11
function binPixInd = mat2binInd(obj, matPixInd) % mat2binInd(acq, ind) converts a Matlab-conventional index (into a movie % frame) into an index that can be used with the column-major binary movie % file. % Assume all slices and Channels have same image size movRows = obj.correctedMovies.slice(1).channel(1).size(1,1);...
319d0237e1d2cd147cfa8fd374bbe5925ef2e2335a3ed92acc9d006edea96a37
MATLAB
501
13
function window = getWindow(signal, center, window_size) half_window = floor(window_size / 2); start_idx = max(1, center - half_window); end_idx = min(length(signal), center + half_window); window = signal(start_idx:end_idx); % Zero-pad if near edges if length(window) < window_size ...
762729f6692d6a30b005969012fe26fc19dea8370d914ca4996d33c7d42fe61b
MATLAB
505
22
function mov = translateAcq(mov, xShift, yShift, fillval) if nargin < 4 fillval = nan; end [h, w, z] = size(mov); referenceFrame = imref2d([h, w]); parfor f = 1:z % if mod(f,250)==0 % display(sprintf('Applying frame shift %d of %d',f,z)), % end tformMat = eye(3); tformMat(3, 1) = xShift(...
15d97ba8293e937540e5389ca878750535e636ac76571f2cc8ca0f7c67867bd6
MATLAB
519
18
function grid = vector_to_symmetric_grid(vec,num_net) % Initialize a matrix of zeros grid = zeros(num_net, num_net); % Index to keep track of the position in the vector idx = 1; % Fill in the upper triangle of the matrix, including the diagonal for i = 1:num_net for j = i:num_net ...
e6014211e4a674f69878e8def8f679e3b32579cd15d0d542bc57ee48e5bd5e92
MATLAB
535
18
folder = '\\harvey-rotScope-scanimage\C\data\Matthias\MM102\MM102_160730'; oldStr = 'MM102_160730_depthstart_00002'; newStr = 'MM102_160730_main_00001'; lst = dir(fullfile(folder, '*.tif')); for f = lst(:)' if isempty(strfind(f.name, oldStr)) continue end newName = strrep(f.name, oldStr, newStr);...
c2567c57b20bb1d400152b47765ed11e5bc5e667ce7b76bb4f0a67493cef5361
MATLAB
536
16
function cbKeypressTraceWin(sel, ~, evt) %Allows for keypresses from the traces figures switch evt.Key case {'1', '2', '3', '4', '5', '6', '7', '8', '9'} % cRoi is the unique number that the current ROI will get. It is % not stored globally but always determined locally from the % roiInfo s...
e2ad72b9d9cac19bd9ab556aa8b6e6c2ab6b14afe371206a74558dac43d2410d
MATLAB
547
13
function y=generate_psf(gama,kernelRadius_user) gama=gama/(2.335); % gama is fwhm, new gama is sigma kernelRadius_default = ceil(gama* sqrt(-2* log(0.0002)))+1; % if the kernel radius is not defined instead of fwhm, use fw at 0.0002 of the maximum if nargin == 1 kernelRadius = kernelRadius_default; else k...
a0aee08ae67b8037d4b821dc46aa6cd6008f7944861300df96a1111c266c1ab6
MATLAB
554
13
cd('Z:\Laura\code_workspace\LD187') mouseDir = pwd; sessionList = dir('LD*'); destDir = ['C:\DATA\Laura\code_workspace\' sessionList(1).name(1:5)]; for session = 7:9%:size(sessionList) cd(fullfile(mouseDir,sessionList(session).name)) load(['selected_rois_' sessionList(session).name(1:12)],'acq') if ~exist(f...
4b9a7a7a8ea546c24b1a6fee4dda60949400db6be1fb4a61583b2ff76133a611
MATLAB
558
15
function A = runningPrctile(A, winSize, prctile) % runningPrctile(A, winSize, prctile) assert(isvector(A), 'A must be a vector') assert(winSize>=1 && winSize<=numel(A) && round(winSize)==winSize, ... 'winSize must be an integer between 1 and numel(A)'); assert(prctile>=0 && prctile <=100, 'prctile must be between ...
815e7f14742af36666932f8912ecd98b4c43e85c4eea258d432e77722f2e40d0
MATLAB
566
16
clearvars mainpath = '/home/tud1006235/Documents/Simulated_Data/PxSize_100nm/10_Dens1000_sbr15vs5_nonst_otf2000_on20/Test/Noisy/'; [TifPaths, fileNames] = getTifFilePaths(mainpath, '*.tif'); Imax = 5000; outpath = [fileparts(mainpath) 'N_max' num2str(Imax) '/']; mkdir(outpath); for nf = 1: numel(TifPaths) imref = d...
2f384a73824d49ec387045ae86ce888aec4a6d296519b910f07c046f0b3f50c8
MATLAB
591
21
%% Pipeline for Concentric Circles % nina fultz - february 24th cd concentricCircles/ %% using inflow effect at 7T to make vessel mask makingVesselfromT1.m %% dilating vessels so that it hits the CSF signal scan VesselDilatingwithBoundaries.m %% manually correct those vessels %% make concentric circles on all p...
736be7292b69a41482dec5c8900f74e5a1f75bcb487c2b7fbfa86871576d8043
MATLAB
611
26
function int = calculate_int(subj_data) % Get the size of subj_data [trs, vertices] = size(subj_data); % Initialize INT array int = zeros(vertices, 1); % Calculate INT for each vertex and each subject parfor v = 1:vertices % Extract the BOLD time series for the kth vertex bold_ts = squeeze(subj_data(:, v));...
230aa44d663acfb129743fdcbb6c4ec7cd175089c8332d2697fe62b5b567e723
MATLAB
615
23
%% segmenting t1s clear; %% GENERALDIR = 'R:\- Gorter\- Personal folders\Fultz, N\csfdonuts_lydiane\' addpath(genpath('R:\- Gorter\- Personal folders\Fultz, N\scripts\csfdonuts_lydiane\functions')); allSubjects = dir([GENERALDIR '*20201014_Reconstruction']); subjectNb = 1; subject = allSubjects(subjectN...
027b6f4f9bc7c072b7318fb57d5666e648d7b913ee5fa912b5e2a3d5a5cd055f
MATLAB
626
23
function anchor_starts = find_speed_crossings(speed, reset, threshold) anchor_starts = []; num_laps = length(reset) - 1; for i = 1:num_laps % Get current lap boundaries start_idx = reset(i); end_idx = reset(i+1) - 1; % Extract lap speed data lap_speed = speed(start_idx:end_idx); %...
3f95c11946a09a2d1048bf403cae9baa253ed262d4432a3519af7ab927402e48
MATLAB
655
35
%% csf donuts plots fig_crosssec_and_barplots.m fig_violinplots.m fig_violinplots_aca_m1_postm1.m fig_violinplots_aca_m1_postm1_FA.m fig_violinplots_b0.m fig_violinplots_FA.m doubledonuts_crosssec.m %fig 2k %% creating the vectors rgb_maps.m just_vectors_not_rgb.m %% physio retrospectiv...
f6c882d4a9bac4d8f9aaf750aa5bf5c3f0047fb9e24f58247b9935efca464216
MATLAB
687
14
function plotSubScatterFit(sel) % Delete old line if applicable if isfield(sel.disp,'subFitLine') && isvalid(sel.disp.subFitLine) delete(sel.disp.subFitLine), end % Plot fit line %xRange = [min(sel.disp.fNeuropil), max(sel.disp.fNeuropil)] - median(sel.disp.fNeuropil); xRange = [min(sel.disp.fNeuropil), max(sel.d...
c624f1b453a353286402c91ac980bf809c0c46bfe0992b4e36d76e71940ba6de
MATLAB
697
19
function addMovie(obj, pathToTiff) %Function to add a file to the acquisition object, checking for errors try Tiff(pathToTiff); if sum(strcmp(pathToTiff,obj.Movies)) > 0 error('Duplicate'), end obj.Movies{end+1} = pathToTiff; catch err if strcmp(err.message,'Dupl...
7d80890c32215af60adf38aa30908c4950f39c98da2d82fdf72a006c1d15ba12
MATLAB
719
28
function run(ajp, isExitAfterOneJob) % Runs a loop that loads acquisition objects and processes them. if ~exist('isExitAfterOneJob', 'var') || isempty(isExitAfterOneJob) isExitAfterOneJob = true; end nJobsDone = 0; while ~ajp.flagStop success = ajp.loadNextAcq; if ~success && ~isExitAfterOneJob ...
228226c4963ebb33d2405cfcf180e11c7512249c4c29ba44060fc8ecdb5a1026
MATLAB
800
31
function subCoefScrollWheel(sel, ~, evt) %Allows interactive adjustment of neuropil subtractive coefficient if strcmpi(evt.Source.CurrentModifier,'control') gain = 0.05; elseif strcmpi(evt.Source.CurrentModifier,'shift') gain = .5; else gain = 0.005; end switch sign(evt.VerticalScrollCount) case -1 %...
ed6ef20ba005cfaa026850295a2cfb30b1061d2301357d38d89552bdbd638815
MATLAB
837
26
function saveCurrentAcq(ajp) % Saves the current acq both in its default dir and in the inProgress dir. try % Rename acq object before saving: if verLessThan('matlab', 'R2014a') acqVarName = genvarname(ajp.currentAcq.acqName); else acqVarName = matlab.lang.makeValidName(ajp.currentAcq.acqNa...
3d7fa9fd27c324b9c6a9ff9b465901b2623e4d7aba26ac4f644526610ef69b11
MATLAB
842
28
cd('Z:\Laura\code_workspace\LD185') mouseDir = pwd; sessionList = dir('LD*'); for session = [36 8:34 37:size(sessionList,1)] output_dir = fullfile('Z:\Laura\code_workspace\',... sessionList(session).name(1:5),sessionList(session).name); if ~exist(output_dir,'dir') mkdir(output_dir) end cd(fullfile(mouseDir,ses...
bf8053fd6f30c855f0333daed528ad3cdf185ccfee2f7e46bb54e1b2857df039
MATLAB
845
25
function [plateau_starts, plateau_durations] = filterPlateausBySpeed(plateau_starts, plateau_durations, speed, speed_threshold) % Filter plateaus by speed condition valid = true(size(plateau_starts)); abs_threshold = abs(speed_threshold); for i = 1:length(plateau_starts) start_sample = plateau_starts(i); end_...
631a3ab28aa42a1354761e7b909fbda17ed9016156657a608294ae9ce9716a4d
MATLAB
854
22
function removeRoiList(acq) % removeRoiList(acq) updates the way that ROI information is stored. if isfield(acq.roiInfo.slice(1), 'roiList') for sl = 1:numel(acq.roiInfo.slice) roiInfoOld = acq.roiInfo.slice(sl); for r = 1:numel(roiInfoOld.roi) roiId = acq.roiInfo.slice(sl).roiL...
129e59a51b652dfb92f98c44bd24b1e9e5b6512e105608f9623259210fdf99d5
MATLAB
855
22
%% elastix registration clear; % goal: to register t1s to b0 % register t2 maps to the b0 %% Define project directory and subject code project_directory = '/exports/gorter-hpc/users/ninafultz/'; project_name = 'csf_donut'; subject_code = 'csfdonut02_20191022'; %% Paths t2maps_path = fullfile(project_d...
2f2f3a58897e12430c805c76f689456f55dfab3312a036d5736b9cf1750f7d11
MATLAB
869
26
cd('Z:\Laura\DATA\imaging\Current Imaging\LD169') mouseDir = pwd; sessionList = dir('LD*'); % for session = 4:56%size(sessionList,1) cd(fullfile(mouseDir,sessionList(session).name)) % acq = Acquisition2P([],@lnd_init); % acq.motionCorrect; output_dir = fullfile('Z:\Laura\code_workspace\',mouseDir(end-4:end),... se...
42e73f504a1dc9125d48664714c51801af9b6decc3b16a443f212c83cea33912
MATLAB
876
28
function resultArray = runningPrctileMat(dataArray, winLength, nth) runningWindow = sort(dataArray(1:winLength)); dataArrayLength = numel(dataArray); resultArray = dataArray; iWinInsert = floor(winLength/2); for iWinStart = 1:(dataArrayLength-winLength) iNextDataPoint = iWinStart + winLength; resultArray(iWin...
0380fb00048c3d0fffa45fc7cc63e164b3cda24eda089de51289234a0a65213e
MATLAB
900
33
function par2nifti(subjPath, parDir); %% loading par file cd(parDir) [img_data, ~ ] = import_parrec_special_WT2_LH(1, '*'); % loads the raw data of all echoes (NOT YET MASKED!) FA_map_avg = flipud(img_data); img_data_flipped = permute(FA_map_avg,[3 1 2]); % Flips the first dimension (top-to-bottom) %...
d6161a5978091d9d2643e439afbc663c20003ab791c63ada833a5e38b3a5d614
MATLAB
900
25
function r = detectFullframeRecursive(mov, idx) % Recursive full-frame alignment code from: % https://scanbox.wordpress.com/2014/03/20/recursive-image-alignment-and-statistics/ if(length(idx)==1) A = mov(:, :, idx(1)); r.m = A; % mean r.T = [0 0]; % no translation (identity) r.n = 1; % # of frames...
899431e5c1c8ceb742b2fd6a5a6febb55859508cf6852853b0117493dc5ec739
MATLAB
901
37
A= xlsread('1.xls'); Fs=2000; peak=[]; k=1;mm=1; figure for i=1:size(A,2) subplot(5,6,k) temp=A(:,i); time=(1:length(temp))/Fs; % ÕÒѰ10s-15sÖ®¼äµÄpeakÖµ onset=10; % 10s endset=15; % 15s [peak(i,1),ind]=max(temp(onset*Fs:endset*Fs)); plot(time,temp) hold on ...
1ac02d12bedc2abfd0e8df92d64b5e70d439842a600c57a03e6b908a59833017
MATLAB
905
33
function save(obj,writeDir,writeName,varName) % Saves the acquisition object. By default uses defaultDir as writeDir and % acqName as both writeName and varName % % save(obj,writeDir,writeName,varName) % % writeDir is the directory to save the acq in % writeName is the filename to save the acq as % varName is the var...
ae3b664f2fb7c595357d158da5589a44874e6f9aeb2745966dc3473b7d8045e1
MATLAB
917
35
function img = getOverviewImg(acq, altImg) % Merges the anatomical and activity images into a nice overview image for % selectRois if nargin<2 altImg = []; end %% Get mean img: mode = 'standard'; switch mode case 'standard' meanImg = acq.meanRef; meanImg(meanImg<0) = 0; meanImg(is...
1e0a101a24b3cdcca6134e537a9034f677fd0b658ee5a6d43d56e4e5b662a6ce
MATLAB
921
30
function movInd = nh2movInd(sel, nhInd, nhCenter, nhSize) % movInd = nh2movInd(sel, nhInd, nhCenter, nhSize) coverts linear indices % into the covariance neighborhood region into linear indices into the % whole movie frame. if ~exist('nhCenter', 'var') || isempty(nhCenter) nhCenter = sel.disp.currentPos; end if ~...
2ffcd9754bcc1f4ae3bd82a05f2d188b2c2b37e2af1b0d0921fe0917d90d8f75
MATLAB
924
27
cd('Z:\Laura\DATA\imaging\Current Imaging\LD169') mouseDir = pwd; sessionList = dir('LD*'); % for session = [3:4 58:size(sessionList,1)-1] cd(fullfile(mouseDir,sessionList(session).name)) % acq = Acquisition2P([],@lnd_init); % acq.motionCorrect; output_dir = fullfile('Z:\Laura\code_workspace\',mouseDir(end-4:end),... ...
4e05db7cbe777497b27fc1a01e7d21307d7b3484c57234cd43e52283dea6834c
MATLAB
926
28
function [netIds, parcelColors] = processNetworkData(filePath, numParcels, networkNames) % Function to process network data from a given file fileID = fopen(filePath, 'r'); netIds = zeros(numParcels, 1); parcelColors = zeros(numParcels, 4); for i = 1:numParcels % Read the netwo...
8f30d4c70c3317da3de074076c674245426637aec101a8afc87cb6255544691d
MATLAB
936
22
function mergeCurrentROI(sel) isMerging = strcmp('Select cluster to merge with', ... get(get(sel.h.ax.cluster, 'Title'), 'string')); if ~isMerging sel.disp.clus2merge = sel.disp.currentClustInd; title(sel.h.ax.cluster,'Select cluster to merge with'), elseif isMerging ind2merge = sel.disp.currentCluste...
2685423cd67bba76b5d7d0c4a518caa3f8b2f372817f0567d27ac88f73c7bfe6
MATLAB
959
29
%{ Initialize a batch of sessions for processing using Acq2p. %} %% Get session list: dirRaw = '\\research.files.med.harvard.edu\Neurobio\HarveyLab\Matthias\data\imaging\raw'; mouse = 'MM112'; snList = dir(fullfile(dirRaw, mouse, 'MM*')); snList = snList([snList.isdir]==1); %% Initialize: for i = 1:numel(snList) ...
8a9545e5db3fd96914d5279c723c8b78da3559032103f36a0f3009f187bc5dbd
MATLAB
970
31
function mov = getRoiMovie(acq, roiNum) % mov = getRoiMovie(acq, roiNum) returns a 3D mov stack of the image data % in acq surrounding the roi roiNum. h = acq.derivedData(1).size(1); w = acq.derivedData(1).size(2); nFramesTotal = cat(1, acq.derivedData.size); nFramesTotal = sum(nFramesTotal(:, 3)); roiInd = acq.roiIn...
2306bae69387e275bbc5a46d9028f48b7cdd213857525b5ed5ad07839a60b2ab
MATLAB
973
54
% matlabpool('open',4); %% tic load modeldata_12.mat % load behMod.mat % q_list=[1]'; parm_results=[]; % for qq=q_list; % for qq=2 parfor qq=1:12 % parfor(qq=1:8,8) ResModData=modeldata{qq,1}; results=[]; for parm1=[0.005 0.01 0.05 0.1 0.5]*10e7;% delta1 for parm2=[0....
4d2a5d9552ab714d6239ad9c8341e050ac26691663fe577f071e05cd7c4bb867
MATLAB
975
34
function reorienting_t1(subjPath); anatFolder = fullfile(subjPath, 'anat'); %% loading file img_data = fullfile(anatFolder, '3dt1_0.9mm.nii'); img_data = niftiread(img_data); ADC_map_avg = flipud(img_data); ADC_map_avg = permute(ADC_map_avg,[3 2 1]); % Flips the first dimension (top-to-bott...
8d1990e3282a0ee87a33cb792635a429e2bbfcafd6543dc533c8cf6ed63d0f64
MATLAB
996
28
function trEdge = getEdgeTrace(acq) % trEdge = getEdgeTrace(acq) returns the pixel values at the edge of the % frame for each line independently. h = acq.derivedData(1).size(1); w = acq.derivedData(1).size(2); nFramesTotal = cat(1, acq.derivedData.size); nFramesTotal = sum(nFramesTotal(:, 3)); % Find edges: colBright...
613681c1b3b3b8eb63d59ee0c02b404cd7b000aba375b6dc115916bb3ae78bee
MATLAB
1,002
35
function ICC_2_k = ICC2K(T) % T should be a table of the long format of the ratings with variables: % T.rating : numeric rating % T.soundID : categorical or numeric id for each sound (1..291) % T.raterID : categorical or numeric id for each participant % % Example: % T = table(ratingsVec, soundVec, rat...
d1dfdd6ca7ef98437cdb8a3932a767632c2460f45203b8327e12e9216ff8c865
MATLAB
1,016
43
function [loss,gradients,mseF1,mseF2,mseF3,mseF4,mseF5,f1,f2,f3,f4]=modelLoss(parameters,net1,CP,CB,CBIC,U0,dataInfer,w1,w2,w3,w4,w5) net1.Learnables=parameters(1:6,:); alpha=parameters(end,:).Value{1}; % make predictions U=forward(net1,CP); gradientsU=dlgradient(sum(U,"all"),CP,EnableHigherDerivatives=true...
cb4b2c2ba11a221febd0bc0953cae46016cf2d7bace5853f8d687f881c857549
MATLAB
1,018
24
function calcRoi(sel) %Helper function that performs clustering using n simultaneous normcuts and %updates cluster/ROI display accordingly nCuts = sel.disp.clusterNum; clusterMod = sel.disp.clusterMod; [clusterIndex, clusterCentroid] = getClusters(sel, nCuts, nCuts+1+clusterMod); clusterQual = mean(silhouette(sel.di...
520e944e0fd722f62050be2f3a23a652d7fd84324baa3d1c0447bfb4ce331ab3
MATLAB
1,038
46
function mask = computeicmask_v2(mag,phi,Parenchyma_Only) % function mask = ComputeICMask(mag,phi,Parenchyma_Only) % Changes % 29/09/09: Initial release (JM) % 30/09/09: Added Parenchyma_Only swith in order to include the skull % when needed (JM) if nargin==2 Parenchyma_Only = 1; end mask =...
16fec541405e44d620351271cbe38ff8be3491443ee9ad63d4f3b582535a0f17
MATLAB
1,047
38
function out = hanning3d( n_x, n_y, n_z, pad_array ) % Create 3d Hanning filter: % out = hanning3d( n_x, [n_y, n_z]) % if only n_x is specified [n_x, n_y, n_z] is assumed if (nargin == 1) n_y = n_x; n_z = n_x; end a = .25; %default hanning is 2 xx = linspace(-1,1,n_x).*(a/2); yy = linspace(-1,...
563d5843c62b7f183bdbed8cd9f3158b0ddd87dd1dd0ce96d57c8580f57ce6ff
MATLAB
1,048
45
% spid=[]; % for j=1:1000 % a=(1:11)'; % spid=[spid;a]; % end % % simPostCNOAnimID=cell(1000,1); % for i=1:1000 % x=spid(randperm(length(spid))); % x=x(1:11); % simPostCNOAnimID{i}=x; % end % save('simPostCNOAnimID','simPostCNOAnimID'); %% load postlearnmodeldata.mat load para...
e352cc73a827b998652aea788e03d168278086e1f9ce4c2ba6eadaea88d045fc
MATLAB
1,056
36
%% csf mobility all subjects %% purpose % 1) plot average of ADC as it moves from 0 for different cross sectionals % 2) bar plots for ratings % 3) statistical comparison clear; % Define project parameters project_directory = '/exports/gorter-hpc/users/ninafultz/'; project_name = 'csfdonuts_lydiane'; %fig = 'donut0...
a7fd35e4bcd743ce2a42f3d5ac02d11080b6b47fb874e8a53097d92b2e6c36c5
MATLAB
1,066
34
function [stimMov, dFmov] = getStimEvokedMovie(stimExpt, nROI, nTarg, winSize) if nargin < 4 winSize = 30; end % % if nargin < 3 % nTarg = nROI; % end % tV = stimExpt.tV; mov = getRoiMovie(stimExpt.acq, stimExpt.cIds(nROI), winSize); stimTimes = []; for nBlock = 1:stimExpt.numStimBlocks blockOffsetFrame ...
079b8b18576a6cd54345d8969d255c7d46d4eb53e417d125dc8642f85d72e7a8
MATLAB
1,071
31
function addCorrMovies(obj,nSlice,nChannel) %Example of an Acq2P Initialization Function. Allows user selection of %movies to form acquisition, sorts alphabetically, assigns an acquisition %name and default directory, and assigns the object to a workspace variable %named after the acquisition name if ~exist('nSlice','...
7a53916df5e8f334beaa6b5672e0eb29b71ef78a8f7af919cd86466289b0fc4a
MATLAB
1,078
45
function anchor_starts = find_speed_crossings_down(speed, reset, threshold) if nargin < 3 threshold = 0.05; end % Handle reset vector if nargin < 2 || isempty(reset) reset = [1, length(speed)+1]; else reset = unique(reset(:))'; if reset(1) ~= 1 reset = [1, reset]; end if reset(end) <=...
a36fc3d4b4bef491eb6052ee8de4933f0752f08afcb3734a9e7eb29d3ffae32a
MATLAB
1,083
28
function plotTwoDistributions(all1, short1, long1, all2, short2, long2, bin_size, bin_units, titles, main_title) max_range = 1.2; edges = -max_range:bin_size:max_range; centers = (edges(1:end-1) + edges(2:end))/2; xlabel_str = ['Distance from anchor (' bin_units ')']; figure('Name', main_title,...
5a8b24162a35235edf80e6b969d69d2fd1d6fe8d674c724680446c74794c49c5
MATLAB
1,097
26
function addOverlayTrace(sel) thisROIind = sel.nh2movInd(find(sel.disp.roiMask)); mov = sel.movMap.Data.mov; thisROItrace = mean(mov(:, sel.acq.mat2binInd(thisROIind)), 2)'; smoothWin = gausswin(sel.disp.smoothWindow)/sum(gausswin(sel.disp.smoothWindow)); thisROItrace = conv(thisROItrace,smoothWin, 'valid'); xFrames =...
4a0546afde2b0699ca9af4b177ae090ef923a22ca2760068ed05540ac97991f6
MATLAB
1,099
37
function plotDonutBarPlots(filename, col_right, col_left, categories) % Read the Excel file data = readtable(filename, 'FileType', 'spreadsheet'); % Reads .xlsx file % Extract columns A1_right = data.(col_right); A1_left = data.(col_left); % Initialize counts category_counts = zeros(1...
29ed32ab14c2a3b60def1f121ae2e1fa6cd4a41a02f1271d9c01de1f57df64ef
MATLAB
1,116
32
function mov = getRoiMovie(acq, roiNum, winSize) % mov = getRoiMovie(acq, roiNum) returns a 3D mov stack of the image data % in acq surrounding the roi roiNum. h = acq.correctedMovies.slice(1).channel(1).size(1,1); w = acq.correctedMovies.slice(1).channel(1).size(1,2); nFramesTotal = sum(acq.correctedMovies.slice(1).c...
290f605c340ab9af4d625e88a8593fa953fd5c0e9b487f45f1e6a456f7ece98f
MATLAB
1,129
30
function deconvNmf(acq) % Wrapper function for NMF-source deconvolution. % Matthias-specific: Some acqs from MM102 and MM104 have fake SI metadata % because the code hadn't been updated for SI2016. Detect that here and get % real metadata: if isfield(acq.metaDataSI, 'SI4') || isempty(acq.metaDataSI) fPath = acq.Mo...
63243e27677d46a78f37f72d63d5e2580fba493c0225f38f13be777b10220d94
MATLAB
1,155
35
function splitCurrentROI(sel) % Get Covariance Data for normCuts [covMat, pxNeighbors] = sel.getCovData; corrMat = corrcov(covMat, 1); m = size(corrMat, 1); offDiags = diag2full(ones(m, 4), [-sqrt(m) -1 1 sqrt(m)], m, m); % 4-connected nhWeight = 0; W = corrMat + nhWeight*offDiags; % Select subset of W matrix corresp...
b319095548e1d5358e5e8201629623b832c5b54b0f6f6fc1e2a179ebb207aac3
MATLAB
1,160
36
function par2nifti(subjPath, parDir); %% loading par file cd(parDir) [img_data, ~ ] = import_parrec_special_WT2_LH(1, '*'); % loads the raw data of all echoes (NOT YET MASKED!) FA_map_avg = flipud(img_data); img_data_flipped = permute(FA_map_avg,[3 1 2]); % Flips the first dimension (top-to-bottom) %...
09a11fcd6bc9bb543ccb04b3d345ff1891c3ed0ec76076eef0bf19efe4181b09
MATLAB
1,168
42
function [loss,gradients,mseF1,mseF2,mseF3,mseF4,mseF5]=modelLoss(parameters,net1,CP,CB1,CB2,xpin,w1,w2,w3,w4,w5) net1.Learnables=parameters(1:end-1,:); Gi=parameters(end,:).Value{1}; % make predictions U=forward(net1,CP); Ux=dlgradient(sum(U,"all"),CP,EnableHigherDerivatives=true); Uxx=dlgradient(sum(Ux...
90b0f00b937bd6466b5ba903b429b3c3961c1859a229de3c3ac97111659dac16
MATLAB
1,181
40
%% loading mhd file and thresholding GENERALDIR = 'R:\- Gorter\- Personal folders\Fultz, N\csfdonuts_lydiane\' allSubjects = dir([GENERALDIR '*20201019_Reconstruction']); subjectNb = 1; subject = allSubjects(subjectNb); disp(subject.name) refScanTemp = dir([subject.folder '\' subject.name '\mhd\Scan*.mhd...
03b675256172e90c1256079b94a607a9df9ea3e1d901db4670b5073a60b3e0c2
MATLAB
1,189
42
classdef acq2pJobProcessor < handle properties debug = false; dir logFileName currentAcq currentAcqFileName nameFunc end properties (Hidden = true, Access = protected) flagStop = false; end methods % Constructor: ...
52816e14e8abc93525ce6700429889686a9c8c929fa5d914966257052fd1a28c
MATLAB
1,205
40
%% loading mhd file and thresholding GENERALDIR = 'R:\- Gorter\- Personal folders\Fultz, N\csfdonuts_lydiane\' allSubjects = dir([GENERALDIR '*20191022_Reconstruction']); subjectNb = 1; subject = allSubjects(subjectNb); disp(subject.name) refScanTemp = dir([subject.folder '\' subject.name '\mhd\Scan*.mhd...
198a6f4dab4c82ba2234b474fe98d26b9ebf85caa307339326c24f02c61197f1
MATLAB
1,227
30
function [plateau_starts, plateau_durations] = getPlateauInfo(plateaus, widPlat, min_plateau_duration_samples, plateau_grouping, group_num) % Extract plateau starts and durations with optional group filtering plateau_starts = find(diff(plateaus) == 1) + 1; plateau_durations = widPlat; % Filter by minimum duration vali...
aadbf16c29bc4b439b520d05f5ebd3b563b53c374b81dc0689f22591178d9cee
MATLAB
1,262
44
function anat_par2nifti(subjPath); regDir = fullfile(subjPath , 'reg'); anat_dir = fullfile(subjPath, 'anat'); par_path = fullfile(subjPath, 'par'); %% saving T2* map % Define the directory and file pattern filePattern = fullfile(anat_dir, '*_3dt1_0.9mm*.nii.gz'); % Find matching files matching...
a5fa919a5e5eb80b6577ce4e41572ada5ce36b2cfb699f108019a28394bfe132
MATLAB
1,270
54
function log(ajp, msg) % Writes log message to the command line and to disk. % Log if we're in debug mode: if ajp.debug msg = ['DEBUG MODE: ', msg]; end % Log which computer we're on: [~, host] = system('hostname'); host = strtrim(host); % Combine information into tabular form: msgFull = sprintf('%s\t%s\t%s\t%s\...
8dc13d32ae20729a9043665d54e4df0ac6e7256a119f3a593eac75b78bfd156a
MATLAB
1,277
38
function doSubTracePlot(sel,~,~) if ~isfield(sel.disp,'fBody') return; end % Calculate corrected dF and plot dF = sel.disp.fBody-sel.disp.fNeuropil*sel.disp.neuropilCoef(2); dF = dF/sel.disp.f0Body; dF = dF - median(dF); movSizes = [sel.acq.correctedMovies.slice.channel.size]; nFramesComplete = sum(movSizes(:, 3...
19c0a909aa36ed87cff5dca9cf6a0fbbdc48c2a3736f238c3c00daa95e31301b
MATLAB
1,289
38
function segmented_region = regiongrowing_v2(image, seed_point, seed_value, tolerance) % Create a binary mask for the segmented region [rows, cols] = size(image); segmented_region = false(rows, cols); region_pixels = false(rows, cols); region_pixels(seed_point(1), seed_point(2)) = true; segmente...
3a87df23020e62df2ffe4979d5808804cdff8362c2ced380c4e33785b4d1fab5
MATLAB
1,299
32
function [clusterIndex, clusterCentroid] = getClusters(sel, nCuts, nClusters) % getClusters(sel, nCuts, nClusters) performs k-means clustering on the % normcuts data. This function should be used wherever clustering is done, % rather than using kmeans() separately in different places. cutVecs = sel.disp.cutVecs(:,(1+s...
2ca7341f75b3a45779c2c66a4149ecf82685003fe88d34b8f55d1cebd588d670
MATLAB
1,303
36
function AJlk(obj) %Example of an Acq2P Initialization Function. Allows user selection of %movies to form acquisition, sorts alphabetically, assigns an acquisition %name and default directory, and assigns the object to a workspace variable %named after the acquisition name %Initialize user selection of multiple tif fi...
380e742b5b49e707163b151e4d30cc14f065667388bee9112a0efca1e823cec6
MATLAB
1,312
36
function cbMousemove(sel, ~, ~) % Give the figure focus when the mouse moves onto it: if ~isequal(gcf, sel.h.fig.main) figure(sel.h.fig.main) end % Do not change clusters based on mouse movement when a cell/neuropil pair % has been selected (to prevent that the loaded pair is unloaded by % accidentally moving acr...
f87be0350ddfffc09e38ecd93a18b2448f36bcf9151051a983df91f6fcefd149
MATLAB
1,315
41
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 %% %% ...
ed7e915d360dc09b32d0469b376129ca0f2dc8d218bf16c94b83a72ee16d8900
MATLAB
1,330
35
function [p_values, actual_diffs,actual_diffs_perc] = computeNetworkHeritabilityPValues(movieNetHerit, restNetHerit, numPermutations) numNetworks = 17; numDays = 2; p_values = zeros(numNetworks, numDays); actual_diffs = zeros(numNetworks, numDays); for day = 1:numDays actual_diff = mean(movieNetHerit(:,:,day), 2)...
5068015dec1c2a85383e2f1e2f2d223282eb7a61ebd17e2b519c69e7b17a1f01
MATLAB
1,356
41
function pixCov = mmPixCov(mov, nh) temporalBin = 8; mov = mov(:,:,1:end-rem(end, temporalBin)); % Deal with movies that are not evenly divisible. movSize = size(mov); [h, w, z] = size(mov); z = z/temporalBin; mov = squeeze(sum(reshape(mov,movSize(1)*movSize(2),temporalBin,movSize(3)/temporalBin),2)); mov = bsxfun(@m...
7a9308e65854383dbd88d60812923f410a46d299395126f52498999e283638bb
MATLAB
1,361
43
function lnd_init(acq) movPath = pwd; fileList = dir('LD*tif'); movNames = cell(1,10*floor(size(fileList,1)/10));%cell(1,size(fileList,1));% for file = 1:10*floor(size(fileList,1)/10)%size(fileList,1)% movNames{file} = fileList(file).name; end %Set default directory to folder location, acq...
e768f8d87059eca0fa51264aeec5be978d9892a96da5612b92072a762fd9e27b
MATLAB
1,366
42
function lnd_init_green(acq) movPath = pwd; fileList = dir('LD*tif'); movNames = cell(1,10*floor(size(fileList,1)/10));%cell(1,size(fileList,1));% for file = 1:10*floor(size(fileList,1)/10)%size(fileList,1)% movNames{file} = fileList(file).name; end %Set default directory to folder location...
edb7dd224891e93bb56886f1418177d0d8ed437515a51df084f0d85970ee4525
MATLAB
1,366
40
function echo_times = extract_echo_times(directory_path, common_prefix) %% % Find all NIfTI files matching the pattern nifti_files = dir(fullfile(directory_path, [common_prefix '_e*_ph.nii'])); nifti_files = {nifti_files.name}; % Extract file names into a cell array % Initialize array to store ech...
70d3659f5c465f12b4aad62861562ed173494dcf636acbc8a9c63fa78452c4f5
MATLAB
1,368
50
% From the paper of DBlink, a mithocondria simulator, dynamic part is % integrated in blinkPSF function % https://github.com/alonsaguy/DBlink/blob/main/demo/DataHandlers.py % TU Delft % Grussmayer Lab % % Miyase Tekpinar %function mito_mask = mithocondria(pxnum, pxsize, num_of_mito, R_range, P_range) pxnum = 500 pxsiz...
e2e020eb91d0024e657ada9c9deed4577f2080ff19f6a96a5f67c626ae91b0d1
MATLAB
1,376
45
function u=nagumo_implicit(u,xpt,dt,alpha,template,templatex); dx=xpt(2)-xpt(1); np=length(u)-1; dudt=zeros(np+1,1); u0=u; while 1 ajac=sparse(np+1,np+1); res=zeros(np+1,1); % node 1 i=1; res(i)=(u(i+1)-u(i))/dx^2+u(i).*(1-u(i)).*(u(i)-alpha)-(u(i)-u0(i))/dt; ajac=ajac+spa...
32c1ddc595d0532f52774ec7dd4a9a476aae2a239bbad82db91d154666708208
MATLAB
1,385
48
function extractSources(acq,nSlice,data,initImages) % Wrapper function for NMF-based source extraction. if ~exist('nSlice','var') || isempty(nSlice) nSlice = 1; end if ~exist('data','var') data = []; end if ~exist('initImages','var') initImages = []; end % NMF code requires syncInfo. Create minimal...
e5e3577d6963221bc016a9e93b73ca0a1abf0be561d1ef2e69268a5a3bdc39db
MATLAB
1,396
45
function plotDonutM2onwardsrating(filename, col_right, col_left, categories); %% % Read the Excel file data = readtable(filename, 'FileType', 'spreadsheet'); % Reads .xlsx file % Initialize counts for each category category_counts = zeros(1, length(categories)); % Process each subject for i ...
c67a1a35e274307d785fefd17a9bf0246769554d7fcc6134697b42847e520b79
MATLAB
1,401
58
% SRHIST Generate a 2D histogram image from a set of x,y coordinates % % SYNOPSIS: % histim=SRhist(xsz,ysz,xco,yco) % % INPUTS: % xsz % x dimension of the histogram image, in pixels % ysz % y dimension of the histogram image, in pixels % xco % x coordinates, in pixels % yco % ...
e317ef75f6fa85ac8bda2aa0d632f94e65ed7e18421025afabb2c122be4b0bda
MATLAB
1,413
41
function success = loadNextAcq(ajp) % Checks if there are new unprocessed acq2ps in the to-be-processed folder. acqFileList = dir(fullfile(ajp.dir.jobs, '*.mat')); % Go to next un-done job: if isempty(acqFileList) success = false; return end ajp.currentAcqFileName = acqFileList(1).name; nextFilePath = fullfil...
4a41100ebeb9444287534cdd06d9daa3619a6ddaac9d0441b916981ae2700c68
MATLAB
1,414
43
function fieldsPxCov(obj, movNums, radiusPxCov, temporalBin, sliceNum, channelNum, writeDir) % Function to fill in acq2p object fields for a pixCov file % Function mimics setup of calcPxCov and fields in fields as if function % were called ordinarily %% Input handling / Error Checking if ~exist('sliceNum','var') || i...
2f8ebfd871b7495cd5d40a4823cbd231a7206d0ce3a5e67efecb07ebdd78b99e
MATLAB
1,427
46
function setupGurobi() % SETUPGUROBI - Automatically find and add Gurobi to MATLAB path % Check if Gurobi is already in path if ~isempty(which('gurobi')) fprintf('Gurobi is already in MATLAB path.\n'); return; end % Common Gurobi installation locations possible_paths = ...
f2f36347773c8e6a34d8708d4e5e8f9e7ae830f787cf77e11882d77bfb0d493f
MATLAB
1,428
53
function success = acq2server(obj,fileDest,rawTransfer) %Example auxilliary function to transfer all files in an acq's default %directory to the server, perform motion correction, then transfer the %acquisition and motion corrected data to the server % % acq2server(obj,fileDest,rawTransfer) % %obj is the acquisition ob...
85de2bab0e0dbcd9488477250e681cabb015decde6508f66893fac405529398e
MATLAB
1,430
43
function addMovieSizes(acq) % Function to find and store movie size information in old acquisition % objects that did not calculate this info during motion correction. if isfield(acq.correctedMovies.slice(1).channel(1), 'size') warning('This acquisition already has size information. Will not change anything.'); en...
6344984fd222d26a37f49e63bb2d63c28dc453192a2499ad306835acd5b2f4ac
MATLAB
1,433
73
numLayers = 3; numNeurons=40; layers=featureInputLayer(1); for i=1:numLayers-1 layers = [layers fullyConnectedLayer(numNeurons) tanhLayer]; end layers = [layers fullyConnectedLayer(1)]; net1=dlnetwork(layers); net1 = dlupdate(@double,net1); % Collocation points xpt=l...
08e59be7a1fe5f9ae85469ac350265ab99d74bbdef8c04ac8944d5aea540d177
MATLAB
1,453
35
function view_voxel_data(masked_par_data, T2_map, S0, goodnessFit) % Display the 3D image using imshow3Dfull figure; imshow3Dfull(masked_par_data(:,:,:,2)); % Show data from the 2nd echo % Set up the callback function for mouse click set(gcf, 'WindowButtonDownFcn', @voxel_callback); % ...
ea652244810298d81dc2932a4fa787f4bd96823449833f9c0be3955191c1dc7d
MATLAB
1,453
41
function SCsc(obj) %Example of an Acq2P Initialization Function. Allows user selection of %movies to form acquisition, sorts alphabetically, assigns an acquisition %name and default directory, and assigns the object to a workspace variable %named after the acquisition name %Initialize user selection of multiple tif fi...
6187fcc628abad0af98525c8cdf845cb41c571c97177bdb797b65b0706af73f3
MATLAB
1,455
41
function SC2Pinit(obj) %Example of an Acq2P Initialization Function. Allows user selection of %movies to form acquisition, sorts alphabetically, assigns an acquisition %name and default directory, and assigns the object to a workspace variable %named after the acquisition name %Initialize user selection of multiple ti...
4079124bab895be255db86264c27d2b7d01b1fe5090fc6ea9cbfc898cfe345fc
MATLAB
1,460
55
addpath('/exports/gorter-hpc/users/ninafultz/scripts/spm12') %% % Define project path and subject project_path = '/exports/gorter-hpc/users/ninafultz/highres_pvs/'; subject = '20240307_PVS3'; % Construct the full path to the functional directory func_dir = fullfile(project_path, subject, 'func'); anat_dir = full...
fc298e59c84286853b54fd4575a8ab718f3bdad3ebecd769c8f13ad7823fc26f
MATLAB
1,466
60
moving = [1 2; 0 0]; Dx = [1 -1; 0 0]; Dy = [0 0; 0 0]; D = cat(3, Dx, Dy); disp(imwarp(moving, D)) %% Test it img = double(imread('cameraman.tif')); [x_orig, y_orig] = meshgrid((0:255)-255/2); C_orig = cat(3, x_orig, y_orig); figure(1) imagesc(img) title('Original') % Create affine tform: theta = 15; tform = affin...
f7b47c11a72e56287be6e1e763b6ed1d12dc508ef7ed78c85f72d76e04a8d09f
MATLAB
1,467
39
function outFile = ft_GlobalSurrogateAnalysis(subjList, freqLabel, varargin) p = inputParser; p.addParameter('BaseDir', pwd, @(x)ischar(x)||isstring(x)); p.addParameter('OutDir', '', @(x)ischar(x)||isstring(x)); p.addParameter('NPerm', 5000, @(x)isnumeric(x)&&isscalar(x)&&x>0); p.parse(varargin{:}); opt = p.Results; ...
3c397a1909cf8da2804b855f8511b1a6d230ace75e60466fe306b5155898a0bd
MATLAB
1,477
39
function acq2tempDir(acq, dirTemp) % Switch the paths pointing to the pixcov and bin files to the local temp % dir. acq.defaultDir = dirTemp; if isfield(acq.roiInfo.slice, 'covFile') [~, filename, ext] = fileparts(acq.roiInfo.slice.covFile.fileName); acq.roiInfo.slice.covFile.fileName = fullfile(dirTemp, [fil...
9c5667a7b3c47c6129eebf06964e139740e4730d02a59b457c31ca8b5419e83b
MATLAB
1,505
51
function [out, swi_image] = my_unwrap2( in, x_f, y_f, z_f, twoD, create_SWI, swi_factor ) % Unwrap 3-D complex data using FFT approach % function out = my_unwrap( in, x_f, y_f, z_f, twoD ) % A 3-D hanning filter is constructed and is used to highpass filter % the complex data % get rid of possible NaN's and repl...
914030adc1e9bb39f77065743a50e854efbe443eb75abc329b1ab8d20c35b3fb
MATLAB
1,518
42
function SClk(obj) %Example of an Acq2P Initialization Function. Allows user selection of %movies to form acquisition, sorts alphabetically, assigns an acquisition %name and default directory, and assigns the object to a workspace variable %named after the acquisition name %Initialize user selection of multiple tif fi...
186da57b81e360aa714cbf789312ff406f78170d68cd62fa38bdfe6f45d823f6
MATLAB
1,526
57
%{ This script creates a test environment to quickly test new or changed motion correction functions. %} %% Load raw data: a = MM102_160825_main; acq = a.acq; [mov, si] = tiffRead('\\research.files.med.harvard.edu\Neurobio\HarveyLab\Matthias\data\imaging\raw\MM102\MM102_160825\MM102_160825_MAIN_00001_00008.tif'); mov...
174247199f2127aadc21ef9a3e54fd923bbb7256ec88347bda2ac7a05ba98f83
MATLAB
1,535
43
function CAR2Pinit(obj) %Example of an Acq2P Initialization Function. Allows user selection of %movies to form acquisition, sorts alphabetically, assigns an acquisition %name and default directory, and assigns the object to a workspace variable %named after the acquisition name %Initialize user selection of multiple t...
dc3099d72b547e118fba794a77a2162538d8889a1c06f8bb0df27fd02153655c
MATLAB
1,548
52
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,Y,Temp,dx) 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"),C...