Cross session cell alignment - bahanonu/ciatah GitHub Wiki
https://bahanonu.github.io/ciatah/
Please use the online documentation website going forward:Cross-day or -session cell alignment alignment
Find the main function at https://github.com/bahanonu/calciumImagingAnalysis/blob/master/classification/matchObjBtwnTrials.m
Algorithm overview
For details, see Cross-day analysis of BLA neuronal activity methods section in the associated Science paper: http://science.sciencemag.org/content/sci/suppl/2019/01/16/363.6424.276.DC1/aap8586_Corder_SM.pdf#page=10.
- Example output on several mPFC animals across multiple sessions. Color is used to indicate a global ID cell (e.g. the same cell matched across multiple days).
Usage
The below commands in MATLAB can be used to align sessions across days.
% Create input images, cell array of [x y nCells] matrices
inputImages = {day1Images,day2Images,day3Images};
% options to change
opts.maxDistance = 5; % distance in pixels between centroids for them to be grouped
opts.trialToAlign = 1; % which session to start alignment on
opts.nCorrections = 1; %number of rounds to register session cell maps.
opts.RegisTypeFinal = 2 % 3 = rotation/translation and iso scaling; 2 = rotation/translation, no iso scaling
% Run alignment code
[alignmentStruct] = matchObjBtwnTrials(inputImages,'options',opts);
% Global IDs is a matrix of [globalID sessionID]
% Each (globalID, sessionID) pair gives the within session ID for that particular global ID
globalIDs = alignmentStruct.globalIDs;
% View the cross-session matched cells, saved to `private\_tmpFiles` sub-folder.
[success] = createMatchObjBtwnTrialsMaps(inputImages,alignmentStruct);
In certain cases, you want to run analysis on the registered images, see below.
% Get registered images, cell array of [x y nCells] matrices
registeredImagesCell = alignmentStruct.inputImages;
% Get registered cell maps, cell array of [x y] matrices
registeredCellmaps = alignmentStruct.objectMapTurboreg;
% OR another method below.
% Get the registration coordinates
globalRegCoords = alignmentStruct.registrationCoords;
globalRegCoords = globalRegCoords{folderNo};
% Re-register input images for particular imaging session for later analysis.
for iterationNo = 1:length(globalRegCoords)
fn=fieldnames(globalRegCoords{iterationNo});
for i=1:length(fn)
localCoords = globalRegCoords{iterationNo}.(fn{i});
[inputImages, localCoords] = turboregMovie(inputImages,'precomputedRegistrationCooords',localCoords);
end
end
Algorithm results
Cross-session metrics and results on cross-session amygdala response to pain
PFC cross-session alignment.
Dorsal striatum cross-session algorithm comparison
- Original dorsal striatum cell maps from ICA with no motion correction applied.
calciumImagingAnalysis
(Biafra's) registration algorithm- Color is used to indicate a global ID cell (e.g. the same cell matched across multiple days). Thus, same color cell = same cell across sessions under the quick iteration parameters used in the below run.
CellReg
registration algorithm Using older code at https://github.com/zivlab/CellReg.